/* MindMetric funnel dashboard. Tokens first, then shell, then components. */

/* ---------- Tokens ---------- */
:root,
:root[data-theme="light"] {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #EBEFF4;
  --rail: #16233A;
  --rail-hover: #1D2C46;
  --rail-active: #22324D;
  --rail-ink: #E6EBF2;
  --rail-muted: #9DAAC0;
  --rail-accent: #8FB0FF;
  --ink: #121A26;
  --ink-2: #4A5566;
  --accent: #2453D6;
  --accent-ink: #FFFFFF;
  --accent-tint: #E6ECFB;
  --mark: #7D899B;
  --mark-weak: #C3CAD5;
  --bad: #B3361F;
  --bad-tint: #FBEAE6;
  --good: #18744A;
  --good-tint: #E4F3EB;
  --warn: #86580A;
  --shadow-pop: 0 1px 2px color-mix(in oklab, var(--ink) 8%, transparent),
                0 8px 24px color-mix(in oklab, var(--ink) 12%, transparent);
  --accent-hover: color-mix(in oklab, var(--accent) 92%, #000000);
  --scrim: color-mix(in oklab, var(--ink) 40%, transparent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E131A;
    --surface: #151B24;
    --surface-2: #1C2430;
    --rail: #090D13;
    --rail-hover: #10161F;
    --rail-active: #151E2B;
    --rail-ink: #E6EBF2;
    --rail-muted: #8E9AAD;
    --rail-accent: #8FB0FF;
    --ink: #E6EBF2;
    --ink-2: #A1ABBA;
    --accent: #7FA3F5;
    --accent-ink: #0E131A;
    --accent-tint: #1B2740;
    --mark: #6E7B8F;
    --mark-weak: #3A4554;
    --bad: #F2836B;
    --bad-tint: #2D1B19;
    --good: #52C48D;
    --good-tint: #14271F;
    --warn: #E3B04B;
    --shadow-pop: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .45);
    --accent-hover: color-mix(in oklab, var(--accent) 90%, #FFFFFF);
    --scrim: rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0E131A;
  --surface: #151B24;
  --surface-2: #1C2430;
  --rail: #090D13;
  --rail-hover: #10161F;
  --rail-active: #151E2B;
  --rail-ink: #E6EBF2;
  --rail-muted: #8E9AAD;
  --rail-accent: #8FB0FF;
  --ink: #E6EBF2;
  --ink-2: #A1ABBA;
  --accent: #7FA3F5;
  --accent-ink: #0E131A;
  --accent-tint: #1B2740;
  --mark: #6E7B8F;
  --mark-weak: #3A4554;
  --bad: #F2836B;
  --bad-tint: #2D1B19;
  --good: #52C48D;
  --good-tint: #14271F;
  --warn: #E3B04B;
  --shadow-pop: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .45);
  --accent-hover: color-mix(in oklab, var(--accent) 90%, #FFFFFF);
  --scrim: rgb(0 0 0 / .6);
  color-scheme: dark;
}

:root {
  --line: color-mix(in oklab, var(--ink) 11%, var(--surface));
  --line-strong: color-mix(in oklab, var(--ink) 20%, var(--surface));
  --ctl-border: color-mix(in oklab, var(--ink) 45%, var(--surface)); /* input/select outline, 3:1 on surface (WCAG 1.4.11) */
  --focus: var(--accent);
  --hatch: repeating-linear-gradient(135deg, var(--mark-weak) 0 1px, transparent 1px 6px);
  --hatch-bad: repeating-linear-gradient(135deg, color-mix(in oklab, var(--bad) 25%, transparent) 0 1px, transparent 1px 6px);

  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --r-1: 4px; --r-2: 6px; --r-3: 8px;
  --rail-w: 232px; --bar-h: 56px; --tabbar-h: 64px;
  --z-base: 0; --z-sticky: 10; --z-chrome: 20; --z-panel: 40; --z-sheet: 100; --z-tooltip: 1000;

  --ease-in: cubic-bezier(.16, 1, .3, 1);
  --ease-out: cubic-bezier(.4, 0, 1, 1);
  --t-hover-in: 150ms; --t-hover-out: 120ms; --t-press: 90ms;
  --t-panel-in: 200ms; --t-panel-out: 140ms; --t-indicator: 200ms;

  --gut: 16px; --gap: 12px; --pad: 16px; --ctl-h: 40px;
}
@media (min-width: 640px) { :root { --gut: 24px; --gap: 16px; } }
@media (min-width: 1024px) { :root { --gut: 32px; --gap: 24px; --pad: 24px; } }
@media (pointer: coarse) { :root { --ctl-h: 44px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar-h) + 8px); -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; accent-color: var(--accent); }
html.lock { overflow: hidden; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 16px/24px var(--font-sans);
  font-variant-numeric: tabular-nums;
  caret-color: var(--accent);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-tint); color: var(--ink); }
h1, h2, h3 { font-weight: 500; margin: 32px 0 12px; text-wrap: balance; }
h1 { font-size: 28px; line-height: 34px; letter-spacing: -0.015em; }
h2 { font-size: 20px; line-height: 26px; }
h3 { font-size: 16px; line-height: 24px; }
p { margin: 0; text-wrap: pretty; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
b, strong { font-weight: 500; }
ul, ol { margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nw { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-weight: 400; overflow-wrap: anywhere; }
.muted { color: var(--ink-2); }
.wrapany { overflow-wrap: anywhere; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-14 { width: 14px; height: 14px; }
.i-16 { width: 16px; height: 16px; }
.i-20 { width: 20px; height: 20px; }
@media (max-width: 639.98px) {
  h1 { font-size: 24px; line-height: 30px; }
  h2 { font-size: 18px; line-height: 24px; }
}

.skip {
  position: fixed; left: 8px; top: 8px; z-index: var(--z-tooltip);
  padding: 8px 12px; background: var(--surface); color: var(--ink);
  border-radius: var(--r-2); outline: 2px solid var(--focus); outline-offset: 2px;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ---------- Shell ---------- */
.mark { width: 16px; height: 16px; fill: var(--rail-accent); flex: none; }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w); z-index: var(--z-chrome);
  background: var(--rail); color: var(--rail-muted);
  display: flex; flex-direction: column;
}
.brand {
  height: var(--bar-h); padding: 0 20px; display: flex; align-items: center; gap: 10px; flex: none;
  border-bottom: 1px solid color-mix(in oklab, var(--rail-ink) 10%, var(--rail));
}
.wordmark { font-size: 17px; line-height: 24px; white-space: nowrap; }
.wm-a { font-weight: 500; color: var(--rail-ink); letter-spacing: -0.01em; }
.wm-b { color: var(--rail-muted); }
.rail nav { padding: 12px; flex: 1; }
.nav { list-style: none; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px;
  border-radius: var(--r-2); color: var(--rail-muted); text-decoration: none;
  font-size: 15px; font-weight: 500; line-height: 20px;
  transition: background-color var(--t-hover-out) var(--ease-out), color var(--t-hover-out) var(--ease-out);
}
.nav .lbl { position: relative; }
.nav a:focus-visible { outline-color: var(--rail-accent); }
.nav a[aria-current="page"] { background: var(--rail-active); color: var(--rail-ink); }
.nav a[aria-current="page"] .i { color: var(--rail-accent); }
.nav a[aria-current="page"] .lbl::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px; background: var(--rail-accent); border-radius: 1px;
}
@media (hover: hover) and (pointer: fine) {
  .nav a:not([aria-current="page"]):hover { background: var(--rail-hover); color: var(--rail-ink); transition-duration: var(--t-hover-in); transition-timing-function: var(--ease-in); }
}
.rail-foot { padding: 16px 24px 20px; }
.rail-foot a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px;
  color: var(--rail-muted); font-size: 13px; line-height: 18px; text-decoration: none;
}
.rail-foot a:hover { color: var(--rail-ink); text-decoration: underline; }
.rail-foot a:focus-visible { outline-color: var(--rail-accent); }
.rail-foot .i { width: 14px; height: 14px; }

.topbar {
  position: fixed; top: 0; left: var(--rail-w); right: 0; height: var(--bar-h); z-index: var(--z-chrome);
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 32px;
}
.tb-brand { display: none; align-items: center; gap: 10px; font-size: 17px; line-height: 24px; }
.tb-brand .mark { fill: var(--accent); }
.tb-brand .wm-a { color: var(--ink); }
.scope { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.tb-scope { flex: 1; min-width: 0; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.live { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13px; line-height: 18px; color: var(--ink-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mark-weak); flex: none; }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.live .stale { color: var(--warn); }
.live .failed { color: var(--bad); }

main { display: block; padding: calc(var(--bar-h) + 32px) 0 64px var(--rail-w); outline: none; }
.wrap { width: min(100% - 2 * var(--gut), 1280px); margin-inline: auto; }
.view-head { margin-bottom: 24px; }
.view-head h1 { margin: 0; }
.view-head .meta { margin-top: 4px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.view-head .scope { display: none; }
.view-head.has-ctl { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
h1:focus { outline: none; }
h1:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 2px; }

@media (max-width: 1023.98px) {
  .rail {
    inset: auto 0 0 0; width: auto; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line); color: var(--ink-2);
  }
  .brand, .rail-foot { display: none; }
  .rail nav { padding: 0; }
  .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; height: var(--tabbar-h); }
  .nav li { display: flex; }
  .nav a {
    position: relative; flex: 1; flex-direction: column; justify-content: center; gap: 4px;
    height: auto; min-height: 44px; padding: 6px 2px; border-radius: 0;
    font-size: 13px; line-height: 18px; color: var(--ink-2);
  }
  .nav a .i { width: 20px; height: 20px; }
  .nav a:focus-visible { outline-color: var(--focus); outline-offset: -2px; }
  .nav a[aria-current="page"] { background: transparent; color: var(--accent); }
  .nav a[aria-current="page"] .i { color: var(--accent); }
  .nav a[aria-current="page"] .lbl::after { display: none; }
  .nav a[aria-current="page"]::before {
    content: ""; position: absolute; top: 0; left: 50%; width: 24px; margin-left: -12px; height: 2px; background: var(--accent); border-radius: 0 0 1px 1px;
  }
  @media (hover: hover) and (pointer: fine) {
    .nav a:not([aria-current="page"]):hover { background: var(--surface-2); color: var(--ink); }
  }
  .topbar { left: 0; padding: 0 var(--gut); }
  .tb-brand { display: flex; }
  .tb-scope { display: none; }
  .tb-right { gap: 8px; }
  main { padding: calc(var(--bar-h) + 16px) 0 calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)) 0; }
  html { scroll-padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
  .view-head .scope { display: block; }
}
@media (max-width: 639.98px) {
  .live .lp { display: none; }
  .btn-refresh .rf-lbl { display: none; }
  .btn-refresh { width: var(--ctl-h); padding: 0; }
}

/* ---------- Grid & panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.grid > * { grid-column: span 12; min-width: 0; }
@media (min-width: 1024px) {
  .grid > .c6 { grid-column: span 6; align-self: start; }
  html:has(#v-leads:not([hidden])) { scroll-padding-top: calc(var(--bar-h) + 48px); }
  .grid > .c7 { grid-column: span 7; }
  .grid > .c5 { grid-column: span 5; }
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3);
  padding: var(--pad); min-width: 0;
}
.panel-flush { padding: 0; }
.phead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.phead h2 { margin: 0; }
.pctl { display: flex; flex-wrap: wrap; gap: 8px; }
.takeaway { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--ink-2); }
.pbody { margin-top: 24px; position: relative; }
.pbody > .takeaway:first-child { margin-top: -20px; margin-bottom: 24px; }
.qtbl .qv { width: 40%; }
.foot { margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.range-row { display: flex; justify-content: flex-end; }
@media (max-width: 639.98px) { .range-row { width: 100%; } }
.how { list-style: none; margin-top: 16px; display: grid; gap: 8px; font-size: 14px; line-height: 20px; color: var(--ink-2); max-width: 72ch; }
.panel-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; font-size: 14px; line-height: 20px; min-height: 24px; }
.panel-link .i { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { a:hover { text-decoration-thickness: 2px; } }
@media (max-width: 639.98px) {
  .pctl { width: 100%; }
  .range-row .seg { width: 100%; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--ctl-h); padding: 0 24px; border-radius: var(--r-2);
  font-size: 16px; font-weight: 500; line-height: 24px; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform var(--t-hover-out) var(--ease-out), background-color var(--t-hover-out) var(--ease-out), border-color var(--t-hover-out) var(--ease-out);
}
.btn .i { width: 18px; height: 18px; }
.btn-1 { background: var(--accent); color: var(--accent-ink); }
.btn-2 { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-icon { width: var(--ctl-h); padding: 0; background: var(--surface); color: var(--ink); }
.btn-sm { padding: 0 16px; }
@media (hover: hover) and (pointer: fine) {
  .btn:not([aria-disabled="true"]):not(:disabled):hover { transform: translateY(-1px); transition-duration: var(--t-hover-in); transition-timing-function: var(--ease-in); }
  .btn-1:not([aria-disabled="true"]):not(:disabled):hover { background: var(--accent-hover); }
  .btn-2:not([aria-disabled="true"]):not(:disabled):hover { background: var(--surface-2); }
  .btn-icon:not([aria-disabled="true"]):not(:disabled):hover { background: var(--surface-2); border-color: var(--line-strong); }
}
.btn:not([aria-disabled="true"]):not(:disabled):active { transform: translateY(0) scale(.985); transition-duration: var(--t-press); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.ico-slot { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; }
.spin { width: 14px; height: 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-refresh .rf-busy { display: none; }

/* ---------- Segmented ---------- */
.seg {
  position: relative; display: inline-flex; height: var(--ctl-h); padding: 3px;
  background: var(--surface-2); border-radius: var(--r-2); isolation: isolate; max-width: 100%;
}
.seg-pill {
  position: absolute; top: 3px; bottom: 3px; left: 0; z-index: 0;
  width: var(--pw, 0px); transform: translateX(var(--px, 0px));
  background: var(--ink); border-radius: var(--r-1);
  transition: transform var(--t-indicator) var(--ease-in);
}
.seg.accent .seg-pill { background: var(--accent); }
.seg.no-anim .seg-pill { transition: none; }
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; cursor: pointer;
  padding: 0 14px; border-radius: var(--r-1); color: var(--ink-2);
  font-size: 14px; font-weight: 500; line-height: 20px; white-space: nowrap;
  transition: color var(--t-hover-out) var(--ease-out);
}
.seg button[aria-checked="true"] { color: var(--surface); }
.seg.accent button[aria-checked="true"] { color: var(--accent-ink); }
.seg button:focus-visible { outline-offset: 0; }
@media (hover: hover) and (pointer: fine) {
  .seg button[aria-checked="false"]:hover { color: var(--ink); }
}
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1 1 0; padding: 0 6px; min-width: 0; }
.seg .cnt { font-weight: 500; }

/* ---------- Chips ---------- */
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: var(--r-1); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 13px; font-weight: 500; line-height: 18px; white-space: nowrap;
}
.chip .i { width: 14px; height: 14px; }
.chip.paid { background: var(--good-tint); border-color: color-mix(in oklab, var(--good) 35%, var(--surface)); color: var(--good); }
.chip.test { background: transparent; border: 1px dashed var(--line-strong); color: var(--ink-2); }
.chip.nt { background: var(--hatch), var(--surface); border-color: var(--line-strong); color: var(--ink-2); }

/* ---------- Inputs ---------- */
.search { position: relative; flex: 1 1 260px; max-width: 380px; min-width: 0; }
.search .i { position: absolute; left: 11px; top: 50%; margin-top: -9px; color: var(--ink-2); pointer-events: none; }
.search input {
  width: 100%; height: var(--ctl-h); padding: 0 40px 0 36px; font-size: 16px;
  background: var(--surface); border: 1px solid var(--ctl-border); border-radius: var(--r-2);
  transition: border-color var(--t-hover-out) var(--ease-out);
}
.search input::placeholder { color: var(--ink-2); opacity: 1; }
.search input:placeholder-shown { padding-right: 12px; }
.search input::-webkit-search-cancel-button { display: none; }
@media (hover: hover) and (pointer: fine) { .search input:hover { border-color: var(--ink-2); } }
.search input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.search .clear {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; padding: 0; border: 0; background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-1); cursor: pointer;
}
.search .clear:hover { color: var(--ink); }
.select { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.select select {
  height: var(--ctl-h); padding: 0 12px; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--ctl-border); border-radius: var(--r-2);
}

/* ---------- Skeletons ---------- */
.sk { display: block; width: var(--sw, 100%); height: var(--sh, 14px); background: var(--surface-2); border-radius: var(--r-1); max-width: 100%; }
.sk-row { display: flex; align-items: center; gap: 16px; min-height: 44px; border-bottom: 1px solid var(--line); }
.sk-row .sk:last-child { margin-left: auto; }

/* ---------- KPI band ---------- */
.kpis { padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 20px 24px; border-right: 1px solid var(--line); min-width: 0; display: grid; gap: 4px; align-content: start; }
.kpi:last-child { border-right: 0; }
.kpi-l { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); }
.kpi-v { justify-self: start; font-size: 34px; line-height: 38px; font-weight: 500; letter-spacing: -0.02em; margin: 2px -4px; padding: 0 4px; border-radius: var(--r-1); white-space: nowrap; }
.kpi-c { display: flex; align-items: flex-start; gap: 6px; font-size: 14px; line-height: 20px; color: var(--ink); }
.kpi-c .i { width: 16px; height: 16px; margin-top: 2px; color: var(--ink-2); }
.kpi-c.muted { color: var(--ink-2); }
.kpi-v.flash { animation: tint 1600ms var(--ease-out) both; }
@keyframes tint { from { background-color: var(--accent-tint); } to { background-color: transparent; } }
@media (max-width: 1023.98px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 639.98px) {
  .kpi { padding: 16px; }
  .kpi-v { font-size: 28px; line-height: 32px; }
}

/* ---------- Chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font-sans); font-size: 13px; fill: var(--ink-2); }
.chart .grid-l { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base-l { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .col { fill: var(--accent); }
.chart .col.today { fill: var(--accent-tint); stroke: var(--accent); stroke-width: 1; }
.chart .col.sel { fill: var(--ink); stroke: none; }
.chart .stub { fill: var(--mark-weak); }
.chart .stub.sel { fill: var(--ink); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .ring { fill: none; stroke: var(--focus); stroke-width: 2; }
.chart g.inter:focus { outline: none; }
.chart .sk-col { fill: var(--surface-2); }
.tip {
  position: absolute; z-index: var(--z-tooltip); pointer-events: none; min-width: 168px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-2); box-shadow: var(--shadow-pop);
  padding: 8px 12px; font-size: 14px; line-height: 20px; opacity: 0;
  transition: opacity 120ms var(--ease-in);
}
.tip.on { opacity: 1; }
.tip .t1 { font-weight: 500; }
.tip .tr { display: flex; justify-content: space-between; gap: 16px; }
.tip .tr span:first-child, .tip .tm { color: var(--ink-2); }

/* ---------- Ranked rows ---------- */
.rows { list-style: none; }
.rows > li { border-bottom: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 0; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; row-gap: 6px;
  align-items: center; min-height: 44px; padding: 10px 0; width: 100%;
}
.row .lab { min-width: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 20px; }
.row .val { text-align: right; font-size: 14px; line-height: 20px; white-space: nowrap; }
.row .sub { display: block; font-size: 13px; line-height: 18px; color: var(--ink-2); white-space: normal; }
.row .bar { grid-column: 1 / -1; }
.bar { display: block; height: 6px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: calc(var(--w, 0) * 100%); background: var(--mark); border-radius: 2px; }
.bar.top > i { background: var(--ink); }
button.row { border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: var(--r-1); color: inherit; }
@media (hover: hover) and (pointer: fine) { button.row:hover { background: var(--surface-2); } }
.ss { font-size: 13px; line-height: 18px; color: var(--ink-2); margin-left: 8px; white-space: nowrap; }
#v-audience .grid { align-items: start; }
.val .pc { color: var(--ink-2); margin-left: 8px; display: inline-block; min-width: 5ch; }
.more { margin-top: 16px; }
.rows .disc { grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: 8px; }
.rows .disc .i { color: var(--ink-2); }
.rows .disc .bar { grid-column: 2 / -1; }
.raw { list-style: none; padding-left: 26px; margin-bottom: 8px; }
.raw li { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 13px; line-height: 18px; border-top: 1px solid var(--line); }
.raw li span:last-child { white-space: nowrap; color: var(--ink-2); }
.group-h { margin: 24px 0 4px; }
.group-h:first-child { margin-top: 0; }
.group-note { font-size: 13px; line-height: 18px; color: var(--ink-2); margin-bottom: 4px; }
.code { font-size: 13px; color: var(--ink-2); margin-left: 6px; }

/* Newest leads rows */
.nl { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; min-height: 44px; padding: 10px 8px; margin: 0 -8px; width: calc(100% + 16px); }
.nl .em { font-size: 14px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; }
.nl .tm { font-size: 13px; line-height: 18px; color: var(--ink-2); white-space: nowrap; text-align: right; }
@media (max-width: 639.98px) {
  .nl { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .nl .chips { grid-row: span 2; align-self: center; }
  .nl .tm { grid-column: 1; grid-row: 2; text-align: left; }
}

/* ---------- Leak panel ---------- */
.leak-text { font-size: 16px; line-height: 24px; }
.leak-text b { color: var(--bad); }
.mini { margin-top: 20px; display: grid; gap: 10px; }
.mini-row { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; line-height: 18px; }
.mini-row .ml { color: var(--ink-2); overflow-wrap: anywhere; }
.mini-row .mv { font-size: 14px; font-weight: 500; white-space: nowrap; text-align: right; min-width: 3ch; }

/* ---------- Funnel pipe ---------- */
.pipe { list-style: none; position: relative; isolation: isolate; }
.pipe > li {
  display: grid; grid-template-columns: 200px minmax(0, 1fr) 96px 168px; column-gap: 12px;
  align-items: center; min-height: 48px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.pipe > li:last-of-type { border-bottom: 0; }
.st-l { min-width: 0; }
.st-name { display: block; font-size: 15px; line-height: 20px; font-weight: 500; }
.st-ev { display: block; font-family: var(--font-mono); font-size: 13px; line-height: 18px; color: var(--ink-2); overflow-wrap: anywhere; }
.track { position: relative; height: 20px; background: var(--surface-2); border-radius: var(--r-1); }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--w) * 100%); background: var(--mark); border-radius: var(--r-1); }
.track .lost {
  position: absolute; top: 0; bottom: 0; left: calc(var(--w) * 100%); width: calc((var(--r) - var(--w)) * 100%);
  border: 1px solid var(--bad); background: var(--hatch-bad), var(--bad-tint); border-radius: 0 var(--r-1) var(--r-1) 0;
}
.track .extra {
  position: absolute; top: 0; bottom: 0; left: calc(var(--r) * 100%); width: calc((var(--w) - var(--r)) * 100%);
  border: 1px dotted var(--ink-2); border-radius: 0 var(--r-1) var(--r-1) 0;
}
.track.nt { background: var(--hatch), var(--surface); border: 1px dashed var(--line-strong); display: flex; align-items: center; justify-content: center; }
.track.nt .chip { height: 20px; background: var(--surface); }
.st-c { text-align: right; }
.st-n { display: block; font-size: 16px; line-height: 22px; font-weight: 500; white-space: nowrap; }
.st-p { display: block; font-size: 13px; line-height: 18px; color: var(--ink-2); white-space: nowrap; }
.st-s { font-size: 14px; line-height: 20px; min-width: 0; }
.st-s .s2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.st-s.leak { color: var(--bad); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.st-s.leak .i { width: 16px; height: 16px; margin-top: 2px; }
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink-2); cursor: pointer; }
@media (pointer: coarse) { .info-btn { width: 44px; height: 44px; margin: -10px -10px -10px -8px; } }
.info-btn:hover { color: var(--ink); background: var(--surface-2); }
.info-btn .i { width: 16px; height: 16px; }
.pipe .expl { grid-column: 1 / -1; margin-top: 8px; font-size: 14px; line-height: 20px; color: var(--ink-2); }
.pipe-svg { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pipe-svg path { fill: none; stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.pipe-svg path.dash { stroke-dasharray: 3 3; }
.pipe-take { margin-top: 16px; font-size: 14px; line-height: 20px; color: var(--ink-2); }
.pipe .sk-row { border-bottom: 0; }
@media (max-width: 1023.98px) and (min-width: 640px) {
  .pipe > li { grid-template-columns: 160px minmax(0, 1fr) 88px 148px; }
}
@media (max-width: 639.98px) {
  .pipe > li {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l c" "t t" "s s";
    row-gap: 8px; padding: 12px 0;
  }
  .pipe .st-l { grid-area: l; }
  .pipe .st-c { grid-area: c; }
  .pipe .track { grid-area: t; }
  .pipe .st-s { grid-area: s; }
  .pipe-svg { display: none; }
  .st-s .s1 { display: inline; }
  .st-s .s2 { display: inline-flex; }
  .st-s .s1::after { content: "·"; margin: 0 6px; color: var(--ink-2); }
  .st-s .s1:last-child::after { content: none; }
}

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.tbl th { text-align: left; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); padding: 8px 12px; border-bottom: 1px solid var(--line-strong); vertical-align: bottom; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .bad { color: var(--bad); font-weight: 500; }
.tbl .bad .i { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.vbar { display: flex; align-items: center; gap: 12px; }
.vbar .bar { flex: 1; }
.vbar .n { min-width: 3ch; text-align: right; }
@media (max-width: 639.98px) {
  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack, .stack tbody, .stack tr, .stack td { display: block; }
  .stack tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .stack tr:last-child { border-bottom: 0; }
  .stack td { padding: 2px 0; border: 0; display: flex; justify-content: space-between; gap: 16px; }
  .stack td:first-child { font-weight: 500; }
  .stack td[data-label]::before { content: attr(data-label); color: var(--ink-2); font-size: 13px; }
  .stack .r { text-align: right; }
}

/* Question rows (phone) */
.qrow { padding: 12px 0; display: grid; gap: 6px; }
.qrow .q1 { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; line-height: 20px; }
.qrow .q3 { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.qrow .q3 .bad { color: var(--bad); font-weight: 500; }

/* ---------- Leads ---------- */
.leads-grid { align-items: start; }
.leads-grid > .leads-panel { grid-column: span 12; }
@media (min-width: 1024px) {
  .leads-grid.has-detail { grid-template-columns: minmax(0, 1fr) minmax(360px, 34%); }
  .leads-grid.has-detail > .leads-panel { grid-column: 1; }
  .leads-grid.has-detail > .detail { grid-column: 2; }
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.toolbar .sort { display: none; }
.leads-body { container-type: inline-size; }
.ltbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.ltbl th {
  position: sticky; top: var(--bar-h); z-index: var(--z-sticky);
  background: var(--surface); border-bottom: 1px solid var(--line-strong);
  padding: 0; text-align: left; font-weight: 500;
}
.ltbl th button {
  display: inline-flex; align-items: center; gap: 4px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; background: transparent; cursor: pointer; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2);
}
.ltbl th button .i { width: 14px; height: 14px; }
.ltbl th[aria-sort] button { color: var(--ink); }
.ltbl th.r button { justify-content: flex-end; }
.ltbl th:first-child button { padding-left: 24px; }
.ltbl th:last-child button { padding-right: 24px; }
.ltbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ltbl td:first-child { padding-left: 24px; }
.ltbl td:last-child { padding-right: 24px; }
.ltbl tbody tr:last-child td { border-bottom: 0; }
.ltbl tbody tr { cursor: pointer; }
.ltbl tr.is-open td { background: var(--accent-tint); }
@media (hover: hover) and (pointer: fine) { .ltbl tbody tr:not(.is-open):hover td { background: var(--surface-2); } }
.ltbl .r { text-align: right; white-space: nowrap; }
.ltbl .c-email { width: 28%; }
.row-open { border: 0; background: transparent; padding: 0; text-align: left; font-size: 14px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; cursor: pointer; color: var(--ink); }
.ltbl tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-3); }
.ltbl tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-3); }
@container (max-width: 900px) {
  .ltbl .c-campaign, .ltbl .c-submits { display: none; }
}
.llist { list-style: none; }
.llist li { border-bottom: 1px solid var(--line); }
.llist li:last-child { border-bottom: 0; }
.lrow {
  display: grid; gap: 4px; width: 100%; min-height: 64px; padding: 12px var(--pad);
  border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--ink);
}
.lrow[aria-current="true"] { background: var(--accent-tint); }
.lrow .l1 { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 6px 12px; }
.lrow .em { font-size: 14px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.lrow .l2 { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.lrow:focus-visible { outline-offset: -2px; }
.empty { padding: 24px 0; display: grid; gap: 12px; justify-items: start; font-size: 14px; line-height: 20px; max-width: 60ch; }
.leads-body .empty { padding: 24px; }
.leads-body .skl { padding: 0 24px; }
@media (max-width: 1023.98px) {
  .toolbar { padding: 16px; }
  .toolbar .search { flex: 1 1 100%; max-width: none; }
  .toolbar .seg { width: 100%; }
  .toolbar .grow { display: none; }
  .toolbar .sort { display: flex; flex: 1 1 100%; }
  .toolbar .sort select { flex: 1; }
  .toolbar .export { flex: 1 1 100%; }
  .leads-body .empty { padding: 16px; }
  .leads-body .skl { padding: 0 16px; }
}

/* Detail panel */
.detail {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3);
  opacity: 0; transform: translateX(16px);
  transition: opacity var(--t-panel-out) var(--ease-out), transform var(--t-panel-out) var(--ease-out);
}
.detail.in { opacity: 1; transform: none; transition-duration: var(--t-panel-in); transition-timing-function: var(--ease-in); }
@media (min-width: 1024px) {
  .detail { position: sticky; top: calc(var(--bar-h) + 24px); max-height: calc(100dvh - var(--bar-h) - 48px); overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 1023.98px) {
  .detail {
    position: fixed; inset: var(--bar-h) 0 0 0; z-index: var(--z-sheet); overflow-y: auto; overscroll-behavior: contain;
    border-radius: var(--r-3) var(--r-3) 0 0; box-shadow: var(--shadow-pop); border-bottom: 0;
    transform: translateY(24px); padding-bottom: env(safe-area-inset-bottom);
  }
  .scrim { position: fixed; inset: 0; z-index: calc(var(--z-sheet) - 1); background: var(--scrim); opacity: 0; transition: opacity var(--t-panel-out) var(--ease-out); }
  .scrim.in { opacity: 1; transition-duration: var(--t-panel-in); }
}
@media (min-width: 1024px) { .scrim { display: none !important; } }
.d-sec { padding: var(--pad); border-bottom: 1px solid var(--line); }
.d-sec:last-child { border-bottom: 0; }
.d-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: start; }
.d-head h2 { margin: 6px 0 0; font-size: 20px; line-height: 26px; overflow-wrap: anywhere; }
.d-head h2:focus { outline: none; }
.d-head h2:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.d-acts { display: flex; gap: 4px; }
.d-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.d-nav { display: flex; gap: 8px; }
.d-nav .btn { flex: 1; padding: 0 12px; font-size: 14px; }
.d-sec h3 { margin: 0 0 8px; }
.dl { display: grid; grid-template-columns: 40% minmax(0, 1fr); margin: 0; font-size: 14px; line-height: 20px; }
.dl dt, .dl dd { padding: 8px 0; border-top: 1px solid var(--line); margin: 0; }
.dl dt:first-of-type, .dl dd:first-of-type { border-top: 0; }
.dl dt { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-2); padding-right: 12px; }
.dl dd { min-width: 0; overflow-wrap: anywhere; }
.dl dd .sub { display: block; font-size: 13px; color: var(--ink-2); }
.dd-copy { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.dd-copy .btn-icon { width: 32px; height: 32px; margin: -6px 0; }
@media (pointer: coarse) { .dd-copy .btn-icon { width: 44px; height: 44px; margin: -12px -6px -12px 0; } }
.none { color: var(--ink-2); }

/* ---------- Notices & errors ---------- */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 24px;
  padding: 12px 16px; border-radius: var(--r-2); font-size: 14px; line-height: 20px;
  background: var(--bad-tint); border: 1px solid color-mix(in oklab, var(--bad) 35%, var(--surface));
}
.notice > .i { color: var(--bad); }
.notice p { flex: 1 1 220px; }
.notice.neutral { background: var(--surface); border-color: var(--line-strong); }
.notice.neutral > .i { color: var(--ink-2); }
.notice .btn { height: 36px; padding: 0 16px; font-size: 14px; }
@media (pointer: coarse) { .notice .btn { height: 44px; } }
.err-panel { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin-bottom: var(--gap); }
.err-panel > .i { width: 24px; height: 24px; color: var(--bad); grid-row: span 3; margin-top: 2px; }
.err-panel h2 { margin: 0; }
.err-panel p { font-size: 16px; line-height: 24px; }
.err-panel .det { font-family: var(--font-mono); font-size: 13px; line-height: 18px; color: var(--ink-2); overflow-wrap: anywhere; }
.err-panel .btn { grid-column: 2; justify-self: start; margin-top: 12px; }
main.is-failed .grid, main.is-failed .foot, main.is-failed .range-row { display: none; }
.skl-leak { display: grid; gap: 12px; }
.skl-leak .mini { margin-top: 8px; }
.perr { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 14px; line-height: 20px; }
.perr .i { color: var(--bad); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-property: opacity, color, background-color, border-color !important; transition-duration: 120ms !important; }
  .btn, .btn:hover, .btn:active { transform: none !important; }
  .seg-pill { transition: none !important; }
  .detail, .detail.in { transform: none !important; }
  .skip { transform: none; left: -9999px; }
  .skip:focus { left: 8px; }
  .spin { animation: none; opacity: .5; }
  .kpi-v.flash { animation: none; background-color: var(--accent-tint); }
}
