/*
 * Lead Ops console. Self-contained on purpose: no CDN, no webfont, no framework. An operations page
 * has to render when something else is already broken.
 *
 * Palette: warm paper and ink by day, graphite by night, one signal accent. Data colours (call
 * outcomes) were validated for colour-blind separation in both modes; text never wears them.
 */
:root {
  color-scheme: light;
  --paper: #f3f1eb;
  --surface: #fbfaf7;
  --surface-2: #f0ede5;
  --surface-3: #e7e3d8;
  --ink: #1b1a17;
  --ink-2: #57544c;
  --ink-3: #8a867b;
  --rule: #e2ded3;
  --rule-strong: #cdc8b9;
  --rail: #1b1a17;
  --rail-2: #26241f;
  --rail-ink: #e9e5da;
  --rail-ink-2: #a39e91;
  --rail-rule: #33312b;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9df;
  --focus: rgba(194, 65, 12, 0.28);
  --good: #1f7a4d;
  --good-soft: #e3f1e8;
  --bad: #b42318;
  --bad-soft: #fbe8e6;
  --warn: #9a5b00;
  --warn-soft: #faf0dc;

  /* call outcomes (validated: light surface #fbfaf7) */
  --o-connected: #1f8a5b;
  --o-short: #e6a219;
  --o-no_answer: #4a78c9;
  --o-busy_failed: #d0473e;
  --o-voicemail: #9a5fc7;
  --o-other: #c9c3b6;

  /* journey phases (identity dots beside text labels) */
  --p-new: #7a8aa6;
  --p-working: #3f78c4;
  --p-nurture: #8a73c9;
  --p-closer: #0f8b8d;
  --p-negotiating: #c98a12;
  --p-contract: #d4683a;
  --p-dispo: #b5487a;
  --p-won: #1f8a5b;
  --p-lost: #8c877c;
  --p-disq: #b9b3a6;
  --p-unmapped: #d6336c;
  --p-none: #cfc9bc;

  --radius: 10px;
  --radius-sm: 6px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --shadow-pop: 0 18px 50px -18px rgba(27, 26, 23, 0.35), 0 2px 6px rgba(27, 26, 23, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121210;
    --surface: #1a1917;
    --surface-2: #211f1c;
    --surface-3: #2a2824;
    --ink: #ece8df;
    --ink-2: #aba69a;
    --ink-3: #7f7b71;
    --rule: #2c2a26;
    --rule-strong: #3b3934;
    --rail: #0c0c0b;
    --rail-2: #1b1a18;
    --rail-ink: #e9e5da;
    --rail-ink-2: #8f8a7e;
    --rail-rule: #24231f;
    --accent: #f07a45;
    --accent-ink: #1b1a17;
    --accent-soft: #3a2519;
    --focus: rgba(240, 122, 69, 0.32);
    --good: #4cc38a;
    --good-soft: #17301f;
    --bad: #f07167;
    --bad-soft: #3a1b18;
    --warn: #e0a53a;
    --warn-soft: #36290f;
    --o-connected: #2fa570;
    --o-short: #c28000;
    --o-no_answer: #5b8ee0;
    --o-busy_failed: #e0574d;
    --o-voicemail: #9676d6;
    --o-other: #4d4a43;
    --p-new: #8b9ab5;
    --p-working: #5b8ee0;
    --p-nurture: #9a85d8;
    --p-closer: #2ba6a8;
    --p-negotiating: #d49b2a;
    --p-contract: #e07a4c;
    --p-dispo: #c96592;
    --p-won: #2fa570;
    --p-lost: #7d796f;
    --p-disq: #5a5750;
    --p-unmapped: #ef5a8c;
    --p-none: #4a4741;
    --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121210;
  --surface: #1a1917;
  --surface-2: #211f1c;
  --surface-3: #2a2824;
  --ink: #ece8df;
  --ink-2: #aba69a;
  --ink-3: #7f7b71;
  --rule: #2c2a26;
  --rule-strong: #3b3934;
  --rail: #0c0c0b;
  --rail-2: #1b1a18;
  --rail-ink: #e9e5da;
  --rail-ink-2: #8f8a7e;
  --rail-rule: #24231f;
  --accent: #f07a45;
  --accent-ink: #1b1a17;
  --accent-soft: #3a2519;
  --focus: rgba(240, 122, 69, 0.32);
  --good: #4cc38a;
  --good-soft: #17301f;
  --bad: #f07167;
  --bad-soft: #3a1b18;
  --warn: #e0a53a;
  --warn-soft: #36290f;
  --o-connected: #2fa570;
  --o-short: #c28000;
  --o-no_answer: #5b8ee0;
  --o-busy_failed: #e0574d;
  --o-voicemail: #9676d6;
  --o-other: #4d4a43;
  --p-new: #8b9ab5;
  --p-working: #5b8ee0;
  --p-nurture: #9a85d8;
  --p-closer: #2ba6a8;
  --p-negotiating: #d49b2a;
  --p-contract: #e07a4c;
  --p-dispo: #c96592;
  --p-won: #2fa570;
  --p-lost: #7d796f;
  --p-disq: #5a5750;
  --p-unmapped: #ef5a8c;
  --p-none: #4a4741;
  --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--rail-rule);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 16px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--rail-ink-2); letter-spacing: 0.02em; }
.nav { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; }
.nav-label {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--rail-ink-2); padding: 16px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px; text-decoration: none;
  color: var(--rail-ink-2); font-weight: 520; position: relative;
}
.nav a:hover { background: var(--rail-2); color: var(--rail-ink); }
.nav a[aria-current="page"] { background: var(--rail-2); color: var(--rail-ink); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav svg { flex: none; opacity: 0.9; }
.nav-count { margin-left: auto; font-size: 11px; color: var(--rail-ink-2); font-variant-numeric: tabular-nums; }
.rail-foot { margin-top: auto; padding: 12px 10px 14px; border-top: 1px solid var(--rail-rule); display: grid; gap: 8px; }
.health-btn {
  display: grid; gap: 4px; width: 100%; text-align: left;
  background: none; border: 1px solid var(--rail-rule); border-radius: 8px; padding: 9px 10px;
  color: var(--rail-ink-2); font-size: 12px;
}
.health-btn:hover { border-color: var(--rail-ink-2); color: var(--rail-ink); }
.health-row { display: flex; align-items: center; gap: 7px; }
.health-row strong { color: var(--rail-ink); font-weight: 600; }
.health-row .when { margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--rail-ink-2); }
.dot.ok { background: #3bb273; box-shadow: 0 0 0 3px rgba(59, 178, 115, 0.18); }
.dot.warn { background: #e0a53a; box-shadow: 0 0 0 3px rgba(224, 165, 58, 0.2); }
.dot.bad { background: #f07167; box-shadow: 0 0 0 3px rgba(240, 113, 103, 0.22); }
.rail-tools { display: flex; gap: 6px; }
.rail-tools button {
  flex: 1; background: none; border: 1px solid var(--rail-rule); border-radius: 7px;
  color: var(--rail-ink-2); padding: 6px 8px; font-size: 12px;
}
.rail-tools button:hover { color: var(--rail-ink); border-color: var(--rail-ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule);
}
.crumbs { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.page-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin: 0; white-space: nowrap; }
.page-sub { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.filters { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content { padding: 22px 28px 64px; display: flex; flex-direction: column; gap: 18px; max-width: 1480px; width: 100%; }

/* ---------- controls ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 9px; padding: 2px; }
.seg button {
  border: 0; background: none; border-radius: 7px; padding: 5px 11px;
  font-size: 12.5px; font-weight: 560; color: var(--ink-2);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--rule); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--rule-strong); background: var(--surface);
  font-size: 13px; font-weight: 560; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12px; }
select, input[type="search"], input[type="text"], input[type="password"], input[type="date"] {
  height: 32px; padding: 0 10px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
}
select { padding-right: 24px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[type="search"] { min-width: 240px; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; }
.custom-range input { width: 142px; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.panel-title { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin: 0; color: var(--ink); }
.panel-note { font-size: 12px; color: var(--ink-3); }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 16px; }
.grid { display: grid; gap: 18px; }
.cols-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- scoreboard (KPI strip) ---------- */
.scoreboard { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.score {
  display: block; padding: 16px 16px 14px; text-decoration: none; min-width: 0;
  border-right: 1px solid var(--rule); position: relative;
}
.score:last-child { border-right: 0; }
a.score:hover { background: var(--surface-2); }
.score-label { font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.score-value { font-size: 34px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.score-value small { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); margin-left: 1px; }
.score-foot { margin-top: 6px; font-size: 12px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--ink-3); }

/* ---------- lead journey track ---------- */
.journey { padding: 18px 16px 16px; }
.track { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); position: relative; }
.track::before {
  content: ""; position: absolute; left: calc(100% / 14); right: calc(100% / 14); top: 56px;
  height: 3px; background: var(--rule-strong); border-radius: 3px;
}
.station {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-decoration: none; padding: 4px 4px 8px; border-radius: 10px; position: relative; min-width: 0;
}
.station:hover { background: var(--surface-2); }
.station-count { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; height: 30px; }
.station.zero .station-count { color: var(--ink-3); font-weight: 500; }
.station-stop {
  width: 18px; height: 18px; border-radius: 50%; background: var(--surface);
  border: 4px solid var(--c, var(--ink-3)); position: relative; z-index: 1; margin: 5px 0 2px;
}
.station.hasleads .station-stop { background: var(--c); }
.station-name { font-size: 12.5px; font-weight: 600; text-align: center; color: var(--ink); }
.station-share { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sidings { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--rule-strong); }
.siding {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--rule); text-decoration: none; font-size: 13px; background: var(--surface);
}
.siding:hover { border-color: var(--ink-3); }
.siding strong { font-variant-numeric: tabular-nums; font-size: 15px; }
.siding.alert { border-color: var(--p-unmapped); background: color-mix(in srgb, var(--p-unmapped) 8%, var(--surface)); }
.swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c, var(--ink-3)); }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px 8px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 560;
  background: var(--surface-2); border: 1px solid var(--rule); color: var(--ink);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-3)); flex: none; }
.chip.plain::before { display: none; }
.chip.flag { border-color: var(--p-unmapped); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--rule); border-radius: 5px; padding: 0 6px; }
.tag.good { color: var(--good); background: var(--good-soft); border-color: transparent; }
.tag.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.tag.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.tag.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.dir { font-size: 13px; color: var(--ink-3); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-2); padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
th.r, td.r { text-align: right; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[aria-sort]::after { content: " ↓"; color: var(--accent); }
th[aria-sort="ascending"]::after { content: " ↑"; }
td { padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover td, tbody tr.hover td { background: var(--surface-2); }
td .sub { display: block; font-size: 11.5px; color: var(--ink-3); }
td a.cell-link { text-decoration: none; font-weight: 600; }
td a.cell-link:hover { text-decoration: underline; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--ink-3); }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.bar-track { display: block; flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 3px; background: var(--o-connected); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chart .col-hit { fill: transparent; cursor: pointer; }
.chart .col-hit:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--c); }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; max-width: 300px;
  background: var(--ink); color: var(--paper); border-radius: 8px; padding: 9px 11px;
  font-size: 12px; line-height: 1.45; box-shadow: var(--shadow-pop);
}
.tooltip .t-head { font-weight: 700; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.tooltip .t-row b { margin-left: auto; padding-left: 16px; font-variant-numeric: tabular-nums; }
.help {
  display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--rule-strong); color: var(--ink-3); font-size: 10px; font-weight: 700;
  cursor: help; background: none; padding: 0; line-height: 1; text-transform: none; letter-spacing: 0;
}
.help:hover, .help:focus-visible { color: var(--ink); border-color: var(--ink-3); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  padding: 9px 16px; border-bottom: 1px solid var(--rule); text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .l-title { font-weight: 600; }
.list-row .l-sub { font-size: 12px; color: var(--ink-3); grid-column: 1; }
.list-row .l-side { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-size: 12px; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding: 12px 16px 6px; display: flex; gap: 8px; align-items: center; }
.section-label .count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); overflow-x: auto; overflow-y: hidden; }
.tabs a {
  padding: 10px 14px; text-decoration: none; font-weight: 600; font-size: 13px; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- board (pipelines) ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.board-col {
  padding: 14px 14px 12px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  box-shadow: inset -1px 0 0 var(--rule), inset 0 -1px 0 var(--rule);
}
.board-col:hover { background: var(--surface-2); }
.board-name { font-size: 12.5px; font-weight: 600; display: flex; gap: 6px; align-items: flex-start; min-height: 38px; }
.board-name .swatch { margin-top: 5px; }
.board-count { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.board-col.zero .board-count { color: var(--ink-3); font-weight: 500; }
.board-meta { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.board-bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.board-bar span { display: block; height: 100%; background: var(--c); border-radius: 2px; }

/* ---------- lead page ---------- */
.lead-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; padding: 18px 18px 16px; }
.lead-name { font-size: 24px; font-weight: 750; letter-spacing: -0.025em; margin: 0; }
.lead-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.lead-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--rule); }
.fact { padding: 12px 18px; border-right: 1px solid var(--rule); min-width: 0; }
.fact:last-child { border-right: 0; }
.fact-label { font-size: 10.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.fact-value { font-size: 17px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.timeline { padding: 6px 16px 12px; }
.tl { display: grid; grid-template-columns: 92px 22px minmax(0, 1fr); gap: 0 10px; }
.tl-time { font-size: 12px; color: var(--ink-3); text-align: right; padding-top: 11px; font-variant-numeric: tabular-nums; }
.tl-time b { display: block; color: var(--ink-2); font-weight: 600; }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--rule); }
.tl:first-child .tl-rail::before { top: 14px; }
.tl:last-child .tl-rail::before { bottom: calc(100% - 14px); }
.tl-node { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--c, var(--ink-3)); margin-top: 13px; position: relative; z-index: 1; }
.tl-node.square { border-radius: 3px; }
.tl-body { padding: 8px 0 10px; border-bottom: 1px solid var(--rule); min-width: 0; }
.tl:last-child .tl-body { border-bottom: 0; }
.tl-title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.tl-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
audio { height: 30px; max-width: 100%; margin-top: 6px; display: block; }
.kv { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 7px 12px; margin: 0; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.verdict { padding: 12px 14px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--c, var(--ink-3)); margin-bottom: 14px; }
.verdict b { display: block; margin-bottom: 2px; }

/* ---------- states ---------- */
.empty { padding: 28px 18px; text-align: center; color: var(--ink-2); font-size: 13px; }
.empty strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }
.error-box { padding: 16px; display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); font-size: 13px; }
.error-box strong { color: var(--bad); display: block; margin-bottom: 2px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; font-size: 13px; background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.alert { background: color-mix(in srgb, var(--p-unmapped) 10%, var(--surface)); border-color: color-mix(in srgb, var(--p-unmapped) 45%, transparent); }
.banner b { font-weight: 650; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(12, 12, 11, 0.4); opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 60; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 70;
  background: var(--surface); border-left: 1px solid var(--rule); box-shadow: var(--shadow-pop);
  transform: translateX(102%); transition: transform 0.18s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; gap: 10px; align-items: flex-start; padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.drawer-body { overflow-y: auto; padding: 16px 18px 40px; display: flex; flex-direction: column; gap: 18px; }
.icon-btn { border: 1px solid var(--rule); background: var(--surface); border-radius: 7px; width: 30px; height: 30px; display: grid; place-items: center; margin-left: auto; }
.icon-btn:hover { border-color: var(--ink-3); }
pre.raw { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 12px; font-size: 11.5px; overflow: auto; max-height: 360px; }

/* ---------- gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; padding: 26px; display: grid; gap: 14px; }
.gate-card h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.gate-card p { margin: 0; color: var(--ink-2); font-size: 13px; }
.gate-card input { width: 100%; }
.gate-error { color: var(--bad); font-size: 12.5px; min-height: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .scoreboard { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .score:nth-child(4) { border-right: 0; }
  .score:nth-child(-n + 4) { border-bottom: 1px solid var(--rule); }
  .cols-main { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; min-width: 0; }
  .brand { padding: 12px 16px 6px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px 10px 10px; }
  .nav-label { display: none; }
  .nav a { white-space: nowrap; }
  .nav a[aria-current="page"]::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 2px; }
  .rail-foot { padding: 0 10px 10px; border-top: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
  .rail-tools { flex-direction: column; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .topbar { position: static; }
  .filters { margin-left: 0; }
  input[type="search"] { min-width: 0; width: 100%; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score { border-bottom: 1px solid var(--rule); }
  .score:nth-child(odd) { border-right: 1px solid var(--rule); }
  .score:nth-child(even) { border-right: 0; }
  .score-value { font-size: 28px; }
  .track { grid-template-columns: 1fr; gap: 2px; }
  .track::before { left: 21px; right: auto; top: 16px; bottom: 16px; width: 3px; height: auto; }
  .station { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 6px 8px; }
  .station-stop { order: -1; margin: 0; }
  .station-count { order: 2; margin-left: auto; font-size: 22px; height: auto; }
  .station-share { order: 3; min-width: 34px; text-align: right; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tl { grid-template-columns: 64px 18px minmax(0, 1fr); }
  .kv { grid-template-columns: 100px minmax(0, 1fr); }
}
