/* Wavelength — Creator Analytics
   Direction: warm-signal dark. Deep ink surfaces, a coral→amber sonic accent,
   teal as the cool counterpoint. Bricolage Grotesque display + Hanken Grotesk UI. */

:root {
  --bg: #0c0b10;
  --surface: #141319;
  --surface-2: #191821;
  --surface-3: #201f2a;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f1ee;
  --text-mid: #b6b1c0;
  --text-dim: #837e91;

  --coral: #ff7a45;
  --amber: #ffc24b;
  --teal: #34d3c0;
  --peri: #8f9dff;
  --pink: #ff77b0;
  --mint: #5ad39a;
  --up: #4fd08a;
  --down: #ff6b6b;

  --grad-sonic: linear-gradient(120deg, #ff7a45 0%, #ffc24b 100%);

  /* chart theming */
  --chart-text: #837e91;
  --chart-grid: rgba(255, 255, 255, 0.07);
  --chart-tooltip-bg: #221f2c;
  --chart-tooltip-text: #f4f1ee;
  --chart-center-text: #f4f1ee;
  --chart-c1: #ff7a45;
  --chart-c2: #34d3c0;
  --chart-c3: #ffc24b;
  --chart-c4: #8f9dff;
  --chart-c5: #ff77b0;
  --chart-c6: #5ad39a;

  --r: 14px;
  --r-sm: 10px;
  --sp: 8px;
  --sidebar-w: 244px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -18px rgba(0,0,0,.7);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

body::before {
  /* faint warm glow, top-left, the one signature light source */
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 8% -8%, rgba(255,122,69,.10), transparent 60%),
    radial-gradient(760px 520px at 96% 4%, rgba(52,211,192,.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { font-family: "Bricolage Grotesque", "Hanken Grotesk", sans-serif; margin: 0; letter-spacing: -0.015em; }

a { color: inherit; text-decoration: none; }

.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 30%), var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
}

.brand { padding: 4px 8px 20px; }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; }
.brand-word { font-family: "Bricolage Grotesque"; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.wave { filter: drop-shadow(0 3px 10px rgba(255,122,69,.35)); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text-mid); font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.nav-item.active { color: var(--text); background: var(--surface-3); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: var(--grad-sonic); margin-left: -14px;
}
.nav-item { position: relative; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.plan-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; }
.plan-name { font-weight: 600; font-size: 13px; }
.plan-bar { height: 5px; border-radius: 4px; background: rgba(255,255,255,.08); margin: 10px 0 7px; overflow: hidden; }
.plan-bar span { display: block; height: 100%; background: var(--grad-sonic); border-radius: 4px; }
.plan-note { margin: 0; font-size: 11.5px; color: var(--text-dim); }

.account { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #2a1608; background: var(--grad-sonic); flex: none; }
.account-meta { display: flex; flex-direction: column; line-height: 1.25; }
.account-name { font-weight: 600; font-size: 13px; }
.account-sub { font-size: 11.5px; color: var(--text-dim); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: rgba(12,11,16,.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 21px; font-weight: 700; }
.topbar-title p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--text-dim); font: inherit; font-weight: 600; font-size: 12.5px; padding: 5px 12px; border-radius: 7px; cursor: pointer; transition: all .16s var(--ease); }
.segmented button:hover { color: var(--text-mid); }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }
.segmented button:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 10px; cursor: pointer; border: 1px solid var(--border-strong); transition: all .16s var(--ease); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-ghost { background: var(--surface-2); color: var(--text-mid); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

.icon-btn { display: none; }

.menu-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; width: 38px; height: 38px; cursor: pointer; color: var(--text); place-items: center; }
.menu-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.scroll { padding: 26px 28px 40px; flex: 1; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.kpi-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--coral); flex: none; }
.kpi-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi-value { font-family: "Bricolage Grotesque"; font-weight: 700; font-size: 28px; letter-spacing: -0.02em; margin: 10px 0 6px; line-height: 1; }
.kpi-foot { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; padding: 1px 7px 1px 5px; border-radius: 20px; }
.delta svg { width: 12px; height: 12px; }
.delta-up { color: var(--up); background: rgba(79,208,138,.12); }
.delta-down { color: var(--down); background: rgba(255,107,107,.12); }
.kpi-foot .muted { color: var(--text-dim); }

/* ---------- Grid + cards ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.link { color: var(--text-mid); font-weight: 600; font-size: 12.5px; transition: color .16s; }
.link:hover { color: var(--coral); }
.table-hint { font-size: 11.5px; color: var(--text-dim); }

.chip { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.chip-up { color: var(--up); background: rgba(79,208,138,.12); }
.chip-down { color: var(--down); background: rgba(255,107,107,.12); }

.chart { width: 100%; }
.chart-legend-inline { display: flex; gap: 14px; font-size: 12px; color: var(--text-mid); flex-wrap: wrap; }
.chart-legend-inline .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-inline .dot { width: 8px; height: 8px; border-radius: 3px; }
.chart-legend-inline b { color: var(--text); font-weight: 700; }

/* ---------- Bar list (geo) ---------- */
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 11px; }
.bar-flag { font-size: 16px; line-height: 1; }
.bar-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bar-name { font-size: 13px; font-weight: 500; display: flex; justify-content: space-between; gap: 10px; }
.bar-name span:last-child { color: var(--text-dim); font-size: 12px; }
.bar-track { height: 6px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--grad-sonic); transform-origin: left; animation: grow .7s var(--ease) both; }
.bar-val { font-weight: 700; font-size: 13px; min-width: 44px; text-align: right; }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: -4px -4px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 11px 12px; text-align: left; white-space: nowrap; }
.data-table thead th { font-size: 11.5px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.data-table tbody td { border-bottom: 1px solid rgba(255,255,255,.045); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .14s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table.sortable th { cursor: pointer; user-select: none; }
.data-table.sortable th.num { text-align: right; }
.data-table.sortable th .arrow { opacity: 0; margin-left: 4px; font-size: 10px; }
.data-table.sortable th.sorted .arrow { opacity: 1; color: var(--coral); }
.data-table.sortable th:hover { color: var(--text-mid); }

.ep-cell { display: flex; flex-direction: column; gap: 2px; max-width: 320px; }
.ep-title { font-weight: 600; color: var(--text); white-space: normal; }
.ep-show { font-size: 11.5px; color: var(--text-dim); }
.rank { color: var(--text-dim); font-weight: 700; width: 22px; }
.spark { display: inline-block; vertical-align: middle; }
.tiny-delta { font-weight: 700; font-size: 12px; }
.tiny-delta.up { color: var(--up); }
.tiny-delta.down { color: var(--down); }

.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.pill-live { color: var(--up); background: rgba(79,208,138,.14); }
.pill-new { color: var(--amber); background: rgba(255,194,75,.14); }
.pill-evergreen { color: var(--peri); background: rgba(143,157,255,.14); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

/* ---------- Footer ---------- */
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 28px 26px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 12.5px; }
.foot strong { color: var(--text-mid); font-weight: 600; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(12px); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 18px; border-radius: 12px; font-size: 13px; font-weight: 500; box-shadow: 0 16px 40px -12px rgba(0,0,0,.7); opacity: 0; transition: opacity .22s, transform .22s var(--ease); z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- View transitions ---------- */
.view { animation: viewin .34s var(--ease) both; }
@keyframes viewin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: 260px;
    transform: translateX(-100%); transition: transform .28s var(--ease);
    box-shadow: 0 0 60px rgba(0,0,0,.6);
  }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: grid; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; backdrop-filter: blur(2px); }
  .topbar { padding: 12px 16px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-title p { display: none; }
  .scroll { padding: 18px 16px 32px; }
  .btn span, .btn { }
  .foot { padding: 18px 16px 24px; }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi-value { font-size: 23px; }
  .topbar-actions { gap: 6px; }
  .segmented button { padding: 5px 9px; }
  .btn-ghost span { display: none; }
  .btn-ghost { padding: 8px 10px; }
  .card { padding: 15px 15px; }
  .grid, .kpi-grid { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
