/* Tokens from the validated reference palette (dataviz skill). Light + dark both selected. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --lane-1: #2a78d6;           /* second_leg: categorical slot 1 */
  --lane-2: #eb6834;           /* fresh_grad: slot 2 */
  --c-vol: #1baf7a;            /* score components: slots 3-7 */
  --c-brk: #eda100;
  --c-turn: #e87ba4;
  --c-trend: #008300;
  --c-liq: #4a3aa7;
  --bar: #86b6ef;              /* single-series bars: blue step 250 */
  --up: #006300;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --glow: rgba(42, 120, 214, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --lane-1: #3987e5;
    --lane-2: #d95926;
    --c-vol: #199e70;
    --c-brk: #c98500;
    --c-turn: #d55181;
    --c-trend: #008300;
    --c-liq: #9085e9;
    --bar: #256abf;
    --up: #0ca30c;
    --glow: rgba(57, 135, 229, 0.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --lane-1: #3987e5;
  --lane-2: #d95926;
  --c-vol: #199e70;
  --c-brk: #c98500;
  --c-turn: #d55181;
  --c-trend: #008300;
  --c-liq: #9085e9;
  --bar: #256abf;
  --up: #0ca30c;
  --glow: rgba(57, 135, 229, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  background-image: radial-gradient(1200px 400px at 10% -10%, var(--glow), transparent 70%);
  background-attachment: fixed;
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; text-underline-offset: 2px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.sub { color: var(--text-secondary); margin: 2px 0 12px; font-size: 12.5px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lane-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lane-2) 25%, transparent); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); white-space: nowrap; }
.pill-mode { font-weight: 600; color: var(--text-primary); }
.pill .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.pill-good .dot { background: var(--good); animation: pulse 2s ease-in-out infinite; }
.pill-warning .dot { background: var(--warning); }
.pill-critical { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.pill-critical .dot { background: var(--critical); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }
@media (prefers-reduced-motion: reduce) { .pill-good .dot { animation: none; } }
.spacer { flex: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
.ghost { background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 10px; color: var(--text-secondary); }
.ghost:hover { background: var(--surface-2); }
.topbar form { margin: 0; }

/* layout */
.app { max-width: 1320px; margin: 0 auto; padding: 16px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
.filters { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.filters button { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; color: var(--text-secondary); }
.filters button[aria-pressed="true"] { color: var(--text-primary); font-weight: 600; border-color: var(--axis); }
.filters .muted { margin-left: 10px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hero-row { display: grid; grid-template-columns: minmax(240px, 1fr) 2.2fr; gap: 16px; }
.app.loading .chart, .app.loading table { opacity: 0.6; transition: opacity .2s; }
@media (max-width: 900px) {
  .grid2, .hero-row { grid-template-columns: 1fr; }
  .topbar, .app { padding-left: 16px; padding-right: 16px; }
}

/* hero + lane tiles */
.label { color: var(--text-secondary); font-size: 12.5px; }
.hero { display: flex; flex-direction: column; justify-content: center; }
.hero-value { font-size: 52px; font-weight: 650; letter-spacing: -1px; line-height: 1.1; margin: 4px 0; }
.lanes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .lanes { grid-template-columns: 1fr; } }
.lane-head { display: flex; align-items: center; gap: 8px; }
.lane-key { width: 14px; height: 3px; border-radius: 2px; }
.lane-name { font-weight: 600; }
.lane-desc { color: var(--text-muted); font-size: 12px; margin: 2px 0 12px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat .v { font-size: 20px; font-weight: 600; }
.stat .l { color: var(--text-muted); font-size: 11.5px; }
.meter { margin-top: 12px; }
.meter-track { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--bar) 22%, var(--surface-1)); overflow: hidden; }
.meter-fill[data-w="0"] { display: none; }
.meter-fill { height: 100%; border-radius: 3px; background: var(--bar); }
.meter-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.up { color: var(--up); }
.down { color: var(--critical); }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart .ink { fill: var(--text-secondary); }
.chart .ink-strong { fill: var(--text-primary); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 8px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.key-rect { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.empty { color: var(--text-muted); padding: 28px 0; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }
details.data { margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
details.data summary { cursor: pointer; color: var(--text-muted); }
.hit { fill: transparent; cursor: default; }
.hit:hover + .seg, .seg.hover { filter: brightness(1.15); }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); padding: 8px 10px; font-size: 12px; min-width: 120px;
}
.tooltip .t-head { color: var(--text-muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-val { font-weight: 650; color: var(--text-primary); }
.tooltip .t-name { color: var(--text-secondary); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-weight: 500; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); color: var(--text-secondary); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.sym { color: var(--text-primary); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 12.5px; }
.feed li:last-child { border-bottom: none; }
.feed .when { color: var(--text-muted); min-width: 64px; }
footer { text-align: center; padding-top: 8px; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.login-sub { color: var(--text-secondary); margin: 4px 0 20px; }
.login-card label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--axis); background: var(--page); color: var(--text-primary); font: inherit; }
.login-card button { width: 100%; margin-top: 6px; padding: 10px; border-radius: 9px; border: none; background: var(--lane-1); color: #fff; font-weight: 600; }
.login-err { color: var(--critical); font-size: 13px; margin: 0 0 12px; }
