/* ---------- tokens: swap --accent* to rebrand ---------- */
:root {
  color-scheme: dark;
  --bg: #000000;
  --card: #07090f;
  --card-hover: #0e1220;
  --border: #1c2338;
  --grid: #141a2c;
  --divider: #1c2338;
  --hover: rgba(154, 164, 192, 0.06);
  --text: #e8ebf4;
  --muted: #9aa4c0;
  --accent: #f5c542;
  --accent-rgb: 245, 197, 66;
  --accent-soft: rgba(var(--accent-rgb), 0.14);
  --accent-glow: rgba(var(--accent-rgb), 0.08);
  --accent-text: #171200;
  --series-2: #5b9cf0;
  --error-bg: rgba(200, 90, 90, 0.12);
  --error-text: #e8a0a0;
  --ok-bg: rgba(110, 170, 130, 0.12);
  --ok-text: #9fd0ae;
  --tooltip-bg: #0e1220;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --gutter: 24px;
  --ease: 150ms ease;
}
@media (max-width: 600px) { :root { --gutter: 16px; } }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--font-display); letter-spacing: -0.01em; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.num, .tile-value, td, th { font-variant-numeric: tabular-nums; }

/* ---------- auth pages ---------- */
main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 32px var(--gutter);
  background: radial-gradient(520px 380px at 50% 45%, var(--accent-glow), transparent 70%);
}
.card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--border); border-radius: 18px; padding: 36px 28px;
}
.card h1 { font-size: 1.9rem; font-weight: 600; margin: 0 0 8px; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 0.95rem; }
label { display: block; font-size: 0.8rem; color: var(--muted); margin: 16px 0 6px; }
input {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px;
  color: var(--text); background: #07090f;
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.25); }
button {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 10px;
  border: 1px solid transparent; padding: 11px 16px; color: var(--text);
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease), opacity var(--ease);
}
button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button.primary { width: 100%; margin-top: 22px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.secondary:hover:not(:disabled) { background: var(--hover); border-color: #2c3659; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.link-row { margin-top: 18px; text-align: center; font-size: 0.9rem; }
.link-button { background: none; border: 0; padding: 4px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.message { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; border: 1px solid var(--border); }
.message.error { background: var(--error-bg); color: var(--error-text); }
.message.ok { background: var(--ok-bg); color: var(--ok-text); }
footer { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 20px var(--gutter); letter-spacing: 0.02em; }

/* ---------- dashboard shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px var(--gutter);
  background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .who { color: var(--muted); font-size: 0.85rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .right { display: flex; gap: 14px; align-items: center; min-width: 0; }
@media (max-width: 600px) { .topbar .who { display: none; } }
.content { flex: 1; padding: 28px var(--gutter) 40px; max-width: 1200px; width: 100%; margin: 0 auto; }
.notice { max-width: 440px; margin: 80px auto; text-align: center; color: var(--muted); padding: 0 var(--gutter); }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 24px; }
.field-label { display: block; margin: 0 0 6px; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
select {
  appearance: none; -webkit-appearance: none; min-width: 190px; padding: 10px 38px 10px 14px;
  font: inherit; font-size: 15px; color: var(--text); background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239a9aa2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  transition: border-color var(--ease);
}
select:hover { border-color: #2c3659; }
select option { background: #0e1220; color: var(--text); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 11px; }
.seg button { padding: 7px 14px; font-size: 0.875rem; background: transparent; color: var(--muted); border-radius: 8px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.icon-btn { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color var(--ease), background var(--ease);
  animation: fade-up 450ms ease both;
}
.tile:hover { border-color: #2c3659; background: var(--card-hover); }
.tile:nth-child(2) { animation-delay: 40ms; } .tile:nth-child(3) { animation-delay: 80ms; }
.tile:nth-child(4) { animation-delay: 120ms; } .tile:nth-child(5) { animation-delay: 160ms; }
.tile:nth-child(6) { animation-delay: 200ms; } .tile:nth-child(7) { animation-delay: 240ms; }
.tile-label { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tile-value { font-family: var(--font-display); font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; }
.tile-note { font-size: 0.78rem; color: var(--muted); }
.tile.accent { border-color: rgba(var(--accent-rgb), 0.28); background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.07), var(--card) 70%); }
.tile.accent .tile-value { color: var(--accent); font-size: 2.3rem; }
.tile.accent .tile-label { color: rgba(var(--accent-rgb), 0.85); }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* panels / charts */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 24px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel h2 { font-size: 1rem; font-weight: 600; margin: 0 0 4px; }
.panel-desc { margin: 0 0 16px; font-size: 0.8rem; color: var(--muted); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-head .panel-desc { margin: 4px 0 0; }
.chart-box { position: relative; height: 240px; }
.empty {
  color: var(--muted); text-align: center; padding: 36px 16px; margin: 0; font-size: 0.9rem;
  border: 1px dashed #2c3659; border-radius: 12px;
}
button.gold-ghost { background: transparent; color: var(--accent); border-color: rgba(var(--accent-rgb), 0.55); }
button.gold-ghost:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }

/* table */
.table-wrap { overflow: auto; max-height: 520px; border-radius: 10px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--card);
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--hover); }
td:nth-child(4) { text-align: right; } th:nth-child(4) { text-align: right; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 500;
  background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.25);
}
.pill.muted { background: rgba(255, 255, 255, 0.06); color: var(--muted); border-color: var(--border); }

/* loading skeletons */
.skeleton {
  border-radius: var(--radius); border: 1px solid var(--border);
  background: linear-gradient(100deg, #07090f 30%, #0e1220 50%, #07090f 70%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton.tile-sk { height: 104px; }
.skeleton.chart-sk { height: 300px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* shop */
.shop { max-width: 760px; }
.shop-head h1 { font-size: 1.9rem; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.02em; }
.product { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.product-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin: 0 0 4px; }
.price { font-variant-numeric: tabular-nums; }
.price s { color: var(--muted); margin-right: 8px; }
.price strong { color: var(--accent); font-weight: 600; }
.qty { min-width: 96px; }
.code-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.code-row > div { flex: 1; min-width: 180px; }
.code-row .secondary { height: 46px; }
.shop button.primary { margin-top: 18px; }

/* tabs + sales */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tabs button {
  background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 10px 16px; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
th.r, td.r { text-align: right; }

/* ---------- editorial dashboard: whitespace, hairlines and type instead of boxes ---------- */
:root { --text-2: #c3cadf; }
#app .content { padding-top: 20px; }
#app .tabs { margin-bottom: 32px; }

.headline {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.025em; line-height: 1.25;
  font-size: clamp(1.8rem, 1.1rem + 2.8vw, 3rem); color: var(--text);
  margin: 8px 0 64px; max-width: 30em;
}
.headline .hl { color: var(--accent); font-variant-numeric: tabular-nums; }

.block { margin-bottom: 64px; }
.eyebrow {
  font-family: var(--font-body); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 20px; padding-bottom: 12px; border-bottom: 1px solid var(--divider);
}

/* funnel */
.funnel { display: flex; flex-direction: column; }
.f-stage, .f-link { display: grid; grid-template-columns: 200px 1fr; column-gap: 24px; align-items: center; }
.f-meta { display: flex; flex-direction: column; gap: 2px; }
.f-label { font-size: 0.8rem; color: var(--muted); }
.f-count { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.f-count.money { color: var(--accent); }
.f-track { height: 44px; display: flex; justify-content: center; }
.f-bar {
  height: 100%; border-radius: 4px; transition: width 300ms ease;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.55), rgba(var(--accent-rgb), 0.95), rgba(var(--accent-rgb), 0.55));
}
.f-bar.money { background: var(--accent); }
.f-link { height: 44px; }
.f-pct { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.f-band { width: 100%; height: 100%; display: block; }
.f-band polygon { fill: rgba(var(--accent-rgb), 0.12); }
.f-note { margin: 16px 0 0; font-size: 0.8rem; color: var(--muted); }
@media (max-width: 640px) {
  .f-stage, .f-link { grid-template-columns: 1fr; row-gap: 6px; }
  .f-meta { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .f-link { height: auto; row-gap: 2px; }
  .f-band { height: 32px; }
  .f-pct { text-align: center; }
}

/* big chart, no frame */
.chart-lg { position: relative; height: 340px; }
@media (max-width: 600px) { .chart-lg { height: 260px; } }

/* ranked lists */
.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-bottom: 24px; }
.list-col { min-width: 0; padding-right: 40px; }
.list-col + .list-col { padding: 0 0 0 40px; border-left: 1px solid var(--divider); }
@media (max-width: 760px) {
  .lists { grid-template-columns: 1fr; }
  .list-col { padding: 0 0 32px; }
  .list-col + .list-col { padding: 32px 0 0; border-left: 0; border-top: 1px solid var(--divider); }
}
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { padding: 12px 0; border-bottom: 1px solid var(--divider); }
.rank li:last-child { border-bottom: 0; }
.rank-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-bar { height: 3px; margin-top: 8px; background: rgba(255, 255, 255, 0.06); border-radius: 2px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.rank .rank-empty { color: var(--muted); font-size: 0.9rem; }

/* dashboard-wide: flatten former cards (scoped so the public shop keeps its own look) */
#app .tiles { gap: 0 40px; margin-bottom: 40px; }
#app .tile { background: none; border: 0; border-top: 1px solid var(--divider); border-radius: 0; padding: 16px 0 24px; }
#app .tile:hover { background: none; }
#app .tile.accent { background: none; border-top-color: rgba(var(--accent-rgb), 0.5); }
#app .tile.accent .tile-value { font-size: 2rem; }
#app .tile.accent { border-left: 3px solid var(--accent); padding-left: 16px; }
#app .panels { gap: 40px; margin-bottom: 48px; }
#app .panel { background: none; border: 0; border-top: 1px solid var(--divider); border-radius: 0; padding: 20px 0 0; }
#app .panel h2, #app .panel-head h2 { font-size: 1.05rem; }
#app .panel-head { padding-top: 0; }
#app #tab-leads .panel-head { padding-bottom: 8px; border-bottom: 1px solid var(--divider); margin-bottom: 8px; }
#app .table-wrap { border-radius: 0; }
#app th { background: var(--bg); }
#app th, #app td { padding: 14px 16px 14px 0; }
#app .empty { border: 0; border-top: 1px solid var(--divider); border-radius: 0; padding: 40px 0; text-align: left; }
#app .skeleton { border: 0; border-radius: 6px; }
.skeleton.sk-line { height: 56px; width: 70%; margin-bottom: 40px; }
.skeleton.sk-block { height: 220px; margin-bottom: 24px; }

/* links tab */
.lb-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
@media (max-width: 800px) { .lb-grid { grid-template-columns: 1fr; gap: 32px; } }
.lb-field { margin-bottom: 22px; }
.lb-field input { margin-top: 0; }
.lb-field select { width: 100%; }
#lb-campaign-other { margin-top: 10px; }
.lb-hint { margin: 8px 0 0; font-size: 0.78rem; color: var(--muted); }
.lb-hint code { color: var(--text-2); }
.lb-url { margin: 6px 0 14px; padding: 12px 14px; font-size: 0.85rem; word-break: break-all; border: 1px solid var(--border); border-radius: 10px; background: #07090f; user-select: all; }
.lb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.lb-qr-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.lb-qr { width: 200px; height: 200px; background: #fff; border-radius: 6px; overflow: hidden; }
.lb-qr svg { display: block; width: 100%; height: 100%; }
.saved { list-style: none; margin: 0; padding: 0; }
.saved li { display: flex; gap: 16px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--divider); }
.saved-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.saved-label { font-weight: 500; }
.saved-url { color: var(--muted); font-size: 0.8rem; word-break: break-all; }
.saved-actions { display: flex; gap: 8px; }

/* lead timeline */
.timeline { list-style: none; margin: 24px 0 0 6px; padding: 0; }
.tl-item { position: relative; padding: 0 0 28px 26px; border-left: 2px solid var(--divider); min-width: 0; }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--bg), 0 0 12px rgba(var(--accent-rgb), 0.45);
}
.tl-when { display: block; font-size: 0.78rem; color: var(--muted); cursor: default; }
.tl-email { margin: 4px 0 10px; font-size: 1.05rem; font-weight: 500; word-break: break-all; }
.tl-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill.strong { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tl-campaign { margin-top: 10px; font-size: 0.78rem; color: var(--muted); }

/* campaign link cards */
.cl-name { margin-left: 10px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
.cl-qr { width: 220px; max-width: 100%; margin: 4px 0 16px; background: #fff; border-radius: 8px; overflow: hidden; line-height: 0; }
.cl-qr img { width: 100%; height: auto; display: block; }
.cl-url { margin: 14px 0 0; font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.cl-copy { cursor: pointer; font-size: 0.85rem; }
.cl-meta { margin: 8px 0 18px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#app #cl-warn { margin: 0 0 16px; }
