/* KilotonWatch dashboard. Calm, factual, no external assets. */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  --r1: 6px; --r2: 10px; --r3: 14px;
  --wrap: 1320px;
  --topbar-h: 56px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1015;
  --bg-glow: #111a24;
  --surface: #131a22;
  --surface-2: #18212b;
  --surface-3: #1e2833;
  --border: #242f3b;
  --border-strong: #33404e;
  --text: #e5eaf0;
  --text-2: #b7c1cc;
  --muted: #8e9aa8;
  --accent: #72b7d8;
  --accent-2: #9fcfe6;
  --accent-bg: rgba(114, 183, 216, .12);
  --focus: #9fcfe6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px -12px rgba(0, 0, 0, .55);
  --band-0: #5d9ea3; --band-1: #79aa69; --band-2: #cfa64b; --band-3: #cf8550; --band-4: #a95c4b;
  --ok: #6db58b; --warn: #cfa64b; --bad: #c9715f; --idle: #7f8b98; --info: #72a6d8;
  --ok-bg: rgba(109, 181, 139, .14); --warn-bg: rgba(207, 166, 75, .14); --bad-bg: rgba(201, 113, 95, .15);
  --idle-bg: rgba(127, 139, 152, .16); --info-bg: rgba(114, 166, 216, .14);
  --chart-grid: #222c37;
  --track: #222c37;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-glow: #e9eef4;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #edf1f5;
  --border: #dde3ea;
  --border-strong: #c9d2dc;
  --text: #16202b;
  --text-2: #374454;
  --muted: #5b6878;
  --accent: #1d6a8f;
  --accent-2: #155674;
  --accent-bg: rgba(29, 106, 143, .09);
  --focus: #1d6a8f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .14);
  --band-0: #3f8589; --band-1: #5a8c49; --band-2: #a98225; --band-3: #b2652f; --band-4: #8c4738;
  --ok: #2f8a58; --warn: #9a7518; --bad: #ad4b39; --idle: #697684; --info: #2b6fae;
  --ok-bg: rgba(47, 138, 88, .1); --warn-bg: rgba(169, 130, 37, .12); --bad-bg: rgba(173, 75, 57, .1);
  --idle-bg: rgba(105, 118, 132, .12); --info-bg: rgba(43, 111, 174, .1);
  --chart-grid: #e6ebf0;
  --track: #e3e8ee;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 44px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: radial-gradient(1200px 500px at 10% -10%, var(--bg-glow), transparent 70%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-2); }
button, input, select { font: inherit; color: inherit; }
.num, .t-num, .mono, table { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--s6); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: var(--s4); top: -100px; z-index: 100; background: var(--surface); padding: var(--s2) var(--s4); border-radius: var(--r1); border: 1px solid var(--border-strong); }
.skip-link:focus { top: var(--s2); }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: var(--s5); height: var(--topbar-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -.01em; flex: none; }
.brand:hover { color: var(--text); }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.brand-name { font-size: 16px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; mask-image: linear-gradient(90deg, #000 92%, transparent); }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: var(--r1); font-size: 14px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--accent-bg); }
.top-actions { display: flex; align-items: center; gap: var(--s2); flex: none; }
.updated { color: var(--muted); font-size: 13px; white-space: nowrap; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r1);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }
html[data-theme="dark"] .i-moon, html[data-theme="light"] .i-sun { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.disclaimer { margin: 0; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: 12.5px; }
.disclaimer .wrap { display: block; padding-top: 5px; padding-bottom: 5px; }
.disclaimer .wrap::before { content: "i"; display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 8px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font: 600 10px/1 var(--font); vertical-align: 1px; }

/* ------------------------------------------------------------ layout */
main.wrap { padding-top: var(--s7); padding-bottom: var(--s8); outline: none; }
.section { margin-bottom: var(--s6); }
.section > .card + .card { margin-top: var(--s5); }
.system-card .kv-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s7); }
.system-card .kv-list > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s5); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head h1 { font-size: 28px; }
.lede { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3);
  box-shadow: var(--shadow); padding: var(--s6);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); margin-bottom: var(--s4); }
.card-head.wrap-head { align-items: flex-start; flex-wrap: wrap; }
.card-title { font-size: 17px; }
.card-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 78ch; }
.fine { color: var(--muted); font-size: 13px; }
.count-pill:empty { display: none; }
.count-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
h3 .count-pill { vertical-align: 2px; margin-left: 6px; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s5); }
.hero-grid > .card { display: flex; flex-direction: column; }

/* ------------------------------------------------------------ chips & badges */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.chip.skeleton { width: 120px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: var(--info); }
.dot.ok { box-shadow: 0 0 0 3px var(--ok-bg); } .dot.warn { box-shadow: 0 0 0 3px var(--warn-bg); } .dot.bad { box-shadow: 0 0 0 3px var(--bad-bg); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--idle-bg); color: var(--text-2); border: 1px solid transparent;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.idle { background: var(--idle-bg); color: var(--muted); }
.badge.lg { font-size: 14px; padding: 5px 14px; }
.badge.outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); font-weight: 500; }

.cat { display: inline-block; padding: 1px 8px; border-radius: var(--r1); font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.cat::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; background: var(--cat, var(--idle)); }
.cat-test { --cat: #b58aa8; } .cat-posture { --cat: #c98d6a; } .cat-deploy { --cat: #c2a35a; } .cat-threat { --cat: #c77a6a; }
.cat-policy { --cat: #7c9cc9; } .cat-arms { --cat: #6aa5a0; } .cat-conflict { --cat: #b08a6b; } .cat-missile { --cat: #a98bc4; }
.cat-prolif { --cat: #8aa86a; } .cat-incident { --cat: #c9a35a; } .cat-rhetoric { --cat: #8c9aab; } .cat-civil { --cat: #6aa58a; }
.cat-hist { --cat: #9a8f80; } .cat-other { --cat: #7f8b98; }

.term { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 11.5px; line-height: 1.7; background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.dom { display: inline-block; padding: 0 8px; border-radius: 4px; font-size: 12px; line-height: 1.8; background: var(--surface-3); color: var(--text-2); }

/* ------------------------------------------------------------ hero / gauge */
.hero-card { padding-bottom: var(--s5); }
.gauge-wrap { position: relative; width: 100%; max-width: 380px; margin: 0 auto; }
.gauge-note { text-align: center; margin-top: 2px; }
.gauge-legend { text-align: center; margin-top: 6px; }
.gauge-legend .lg-tick { color: var(--text-2); font-weight: 700; margin-left: 10px; }
.gauge { display: block; width: 100%; height: auto; overflow: visible; }
.gauge .g-track { fill: none; stroke: var(--track); stroke-width: 18; stroke-linecap: butt; }
.gauge .g-band { fill: none; stroke-width: 18; opacity: .38; }
.gauge .g-fill { fill: none; stroke-width: 18; stroke-linecap: round; }
.gauge .g-tick { stroke: var(--border-strong); stroke-width: 1.5; }
.gauge .g-label { fill: var(--muted); font-size: 11px; font-family: var(--font); text-anchor: middle; font-variant-numeric: tabular-nums; }
.gauge .g-marker { stroke: var(--surface); stroke-width: 3; }
.gauge .g-base { stroke: var(--text-2); stroke-width: 2.5; stroke-linecap: round; }
.gauge .g-base-label { fill: var(--text-2); font-size: 11px; font-weight: 600; text-anchor: middle; font-family: var(--font); font-variant-numeric: tabular-nums; }
.band-0 { stroke: var(--band-0); fill: var(--band-0); color: var(--band-0); }
.band-1 { stroke: var(--band-1); fill: var(--band-1); color: var(--band-1); }
.band-2 { stroke: var(--band-2); fill: var(--band-2); color: var(--band-2); }
.band-3 { stroke: var(--band-3); fill: var(--band-3); color: var(--band-3); }
.band-4 { stroke: var(--band-4); fill: var(--band-4); color: var(--band-4); }
.gauge-readout { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; pointer-events: none; }
.idx-value { font-size: 54px; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--text); }
.idx-band { margin-top: 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.idx-band.band-0, .idx-band.band-1, .idx-band.band-2, .idx-band.band-3, .idx-band.band-4 { fill: none; stroke: none; }

.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin: var(--s5) 0 var(--s3); }
.kv-grid > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r2); padding: 10px 12px; min-width: 0; }
.kv-grid dt { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv-grid dd { margin: 2px 0 0; font-size: 18px; font-weight: 650; }
.kv-grid dd small { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--band-3); } .down { color: var(--band-1); } .flat { color: var(--text-2); }
.na { color: var(--muted); font-weight: 500; font-size: 15px; }

.state-badge-wrap { margin-bottom: var(--s3); }
.state-text { color: var(--text); font-size: 15px; line-height: 1.55; }
.state-reason { color: var(--muted); font-size: 12.5px; margin-top: var(--s2); word-break: break-word; }
.rule-list { list-style: none; margin: var(--s4) 0 0; padding: 0; display: grid; gap: 6px; }
.rule-list li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: var(--s3); font-size: 13px; color: var(--text-2); }
.rule-list li > span:first-child { color: var(--muted); }
.rule-list b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.warmup { margin-top: auto; padding-top: var(--s5); }
.warmup-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.meter { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease; }
.warmup .fine { margin-top: 6px; }
#last-alert { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); }

.kv-list { margin: 0; display: grid; gap: 0; }
.kv-list > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding: 9px 0; border-bottom: 1px dashed var(--border); min-width: 0; }
.kv-list > div:last-child { border-bottom: 0; }
.kv-list dt { color: var(--muted); font-size: 13px; flex: none; }
.kv-list dd { margin: 0; text-align: right; font-size: 13.5px; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.kv-list dd small { display: block; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ segmented / tabs / filters / buttons */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r2); }
.seg-btn { border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }

.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--border); margin-bottom: var(--s4); }
.tab { border: 0; background: none; padding: 8px 2px 10px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-count { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 500; }

.filters { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; margin-bottom: var(--s4); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); min-width: 150px; }
.field > span { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; }
.field output { color: var(--text); font-weight: 600; }
.field-grow { flex: 1; min-width: 220px; }
.field-range { min-width: 180px; }
select, input[type="search"] {
  height: 36px; padding: 0 12px; border-radius: var(--r1); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 14px; width: 100%;
}
select { padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type="search"]::placeholder { color: var(--muted); opacity: .8; }
select:hover, input[type="search"]:hover { border-color: var(--muted); }
input[type="range"] { width: 100%; height: 36px; accent-color: var(--accent); margin: 0; cursor: pointer; }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 18px; border-radius: var(--r1); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .6; cursor: progress; }
.linkish { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: left; font-weight: 600; font-size: inherit; line-height: inherit; }
.linkish:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.more-row { display: flex; justify-content: center; margin-top: var(--s4); }
.more-row:empty { display: none; }

/* ------------------------------------------------------------ chart */
.chart { position: relative; width: 100%; min-height: 300px; border-radius: var(--r2); }
.chart svg { display: block; width: 100%; height: 300px; overflow: visible; }
.chart .c-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .c-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .c-bandbg { opacity: .07; stroke: none; }
.chart .c-line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .c-area { fill: var(--accent); opacity: .08; stroke: none; }
.chart .c-base { fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .8; }
.chart .c-alertidx { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; opacity: .75; }
.chart .c-pt { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.chart .c-gap { fill: var(--muted); opacity: .07; }
.chart .c-norun { fill: var(--idle); }
.chart .c-norun.degraded { fill: var(--warn); } .chart .c-norun.error { fill: var(--bad); }
.chart .c-alert { fill: var(--band-4); stroke: var(--surface); stroke-width: 1.5; }
.chart .c-guide { stroke: var(--border-strong); stroke-width: 1; }
.chart .c-hl { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .c-overlay { fill: transparent; cursor: crosshair; }
.chart-empty {
  position: absolute; inset: 0 0 24px 44px; display: grid; place-items: center; text-align: center; pointer-events: none;
}
.chart-empty > div { background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border); border-radius: var(--r2); padding: var(--s4) var(--s5); max-width: 440px; }
.chart-empty b { display: block; font-size: 15px; margin-bottom: 4px; }
.chart-empty span { color: var(--muted); font-size: 13.5px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s5); margin: var(--s3) 0 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { display: inline-block; width: 18px; height: 0; }
.sw-index { border-top: 2.5px solid var(--accent); }
.sw-base { border-top: 2px dashed var(--text-2); }
.sw-alertidx { border-top: 1px dotted var(--accent); }
.sw-gap { height: 10px; width: 14px; background: var(--muted); opacity: .25; border-radius: 2px; }
.sw-norun { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.sw-alert { width: 9px; height: 9px; background: var(--band-4); transform: rotate(45deg); border-radius: 1px; }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 180px; max-width: 300px;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r2);
  box-shadow: var(--shadow); padding: 10px 12px; font-size: 12.5px; color: var(--text-2);
}
.tooltip .tt-time { color: var(--text); font-weight: 600; margin-bottom: 6px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: var(--s4); }
.tooltip .tt-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.tooltip .tt-story { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--text-2); }

/* ------------------------------------------------------------ drivers */
.explanation { margin-bottom: var(--s4); }
.explanation ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.explanation li { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; color: var(--text-2); }
.explanation .badge { flex: none; min-width: 70px; justify-content: center; }
.contribs { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.contrib { display: grid; grid-template-columns: 34px minmax(0, 1fr) 210px; gap: var(--s4); padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface-2); }
.rank { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-weight: 700; font-size: 13px; }
.contrib-head { font-size: 15px; margin-bottom: 6px; }
.contrib-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.contrib-reason { color: var(--text-2); font-size: 13.5px; }
.contrib-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12.5px; }
.signal { align-self: center; }
.signal-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.signal-top b { color: var(--text); font-size: 15px; }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: currentColor; }
.minibar { display: inline-block; width: 46px; height: 5px; border-radius: 99px; background: var(--track); vertical-align: middle; margin-left: 8px; overflow: hidden; }
.minibar > span { display: block; height: 100%; background: currentColor; border-radius: 99px; }

/* ------------------------------------------------------------ empty / skeleton / banner */
.empty {
  display: flex; gap: var(--s4); align-items: flex-start; padding: var(--s5); border: 1px dashed var(--border-strong);
  border-radius: var(--r2); color: var(--text-2); background: var(--surface-2);
}
.empty svg { width: 28px; height: 28px; color: var(--muted); flex: none; margin-top: 2px; }
.empty b { display: block; color: var(--text); margin-bottom: 3px; font-size: 14.5px; }
.empty span { font-size: 13.5px; color: var(--muted); }
.empty.error svg { color: var(--bad); }
.skeleton { position: relative; overflow: hidden; color: transparent !important; background: var(--surface-3) !important; border-color: transparent !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); animation: shimmer 1.4s infinite; transform: translateX(-100%); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { display: block; height: 14px; border-radius: 4px; margin: 6px 0; }
.banner { margin-bottom: var(--s5); padding: var(--s3) var(--s4); border-radius: var(--r2); background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text); font-size: 14px; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r2); }
.table-wrap.scroll-y { max-height: 640px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stories-table th, .stories-table td { padding-left: 10px; padding-right: 10px; }
.stories-table .minibar { width: 36px; margin-left: 6px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; letter-spacing: .01em; }
.table tbody tr:last-child > td { border-bottom: 0; }
.table tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table .t-num { text-align: right; white-space: nowrap; }
.table .t-time { white-space: nowrap; color: var(--text-2); }
.table .t-time small { display: block; color: var(--muted); font-size: 11.5px; }
.table .t-muted { color: var(--muted); }
th[data-sort] { padding: 0; }
.sort-btn { display: inline-flex; align-items: center; gap: 4px; width: 100%; padding: 10px 12px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; justify-content: inherit; }
th.t-num .sort-btn { justify-content: flex-end; }
.sort-btn:hover { color: var(--text); }
.sort-btn::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .25; }
th[aria-sort="ascending"] .sort-btn, th[aria-sort="descending"] .sort-btn { color: var(--text); }
th[aria-sort="ascending"] .sort-btn::after { border-top: 0; border-bottom: 5px solid currentColor; opacity: .9; }
th[aria-sort="descending"] .sort-btn::after { opacity: .9; }
.story-cell { min-width: 220px; max-width: 420px; }
.story-cell .linkish { font-size: 14px; }
.story-cell .sub { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.story-cell .also-reported { font-style: italic; }
.score { font-weight: 650; white-space: nowrap; }
.score small { color: var(--muted); font-weight: 400; }
.pending { color: var(--muted); font-style: italic; }
.row-toggle { width: 28px; height: 28px; border-radius: var(--r1); border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.row-toggle:hover { color: var(--text); }
.row-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.row-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
tr.details > td { background: var(--surface-2); padding: var(--s4) var(--s5); }
tr.details:hover > td { background: var(--surface-2) !important; }
.run-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s5); }
.run-details h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.run-details ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.run-details li { margin: 2px 0; word-break: break-word; }
.stat-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 12.5px; margin: 0; }
.stat-grid dt { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.stat-grid dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; word-break: break-word; }
.sources-table td { padding-top: 8px; padding-bottom: 8px; }
.err-text { color: var(--text-2); font-size: 12.5px; max-width: 340px; word-break: break-word; }
.src-name { font-weight: 600; color: var(--text); }
.src-name a { color: var(--text); text-decoration: none; }
.src-name a:hover { color: var(--accent); text-decoration: underline; }
.table td > .badge:first-child { margin-top: -2px; }
.status-cell { white-space: nowrap; }
.status-cell small { display: block; margin-top: 3px; }
.src-name small { display: block; font-weight: 400; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.src-cell { display: flex; gap: 10px; align-items: flex-start; min-width: 220px; }
.src-cell .dot { margin-top: 7px; }

/* ------------------------------------------------------------ news */
.news-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r2); }
.news-list:empty { display: none; }
.news-item { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: var(--s4); padding: 12px var(--s4); border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: 0; }
.news-time { color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.news-time small { display: block; color: var(--muted); font-size: 11.5px; }
.news-title { font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.news-title a { color: var(--text); text-decoration: none; }
.news-title a:hover { color: var(--accent); text-decoration: underline; }
.news-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.news-meta .sep { opacity: .5; }
.news-snippet { margin-top: 6px; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cluster-link { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 0 9px; font-size: 11.5px; line-height: 1.8; cursor: pointer; font-weight: 600; }
.cluster-link:hover { color: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------ alerts */
.alerts-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.alerts-list:empty { display: none; }
.alert-item { border: 1px solid var(--border); border-left: 3px solid var(--band-4); border-radius: var(--r2); padding: var(--s4); background: var(--surface-2); }
.alert-top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.alert-top .when { font-weight: 600; }
.alert-top .figs { color: var(--text-2); font-size: 13.5px; }
.alert-item details { margin-top: 10px; }
.alert-item summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
.alert-item pre { margin: 10px 0 0; padding: var(--s3); border-radius: var(--r1); background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 var(--mono); color: var(--text-2); max-height: 420px; overflow: auto; }

/* ------------------------------------------------------------ about */
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s7); }
.prose { color: var(--text-2); font-size: 14.5px; }
.prose h3 { color: var(--text); font-size: 15px; margin: var(--s5) 0 var(--s2); }
.prose h3:first-child { margin-top: 0; }
.prose p { margin: 0 0 var(--s2); }
.prose ul, .prose ol { margin: 0 0 var(--s2); padding-left: 20px; }
.prose li { margin: 4px 0; }
.prose b, .prose strong { color: var(--text); font-weight: 600; }
.prose [data-meta] { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.prose .ua { font-weight: 400; font-size: 12px; word-break: break-word; }
.formula { padding: 10px 14px; border-radius: var(--r1); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 13px; margin: var(--s2) 0 var(--s3) !important; }
.steps li::marker { color: var(--muted); font-weight: 600; }
.about-sources { list-style: none; padding: 0 !important; display: grid; grid-template-columns: 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--r2); }
.about-sources li { display: flex; justify-content: space-between; gap: var(--s3); padding: 7px 12px; margin: 0 !important; border-bottom: 1px solid var(--border); font-size: 13px; }
.about-sources li:last-child { border-bottom: 0; }
.about-sources .src-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.about-sources .off { opacity: .6; }
/* AI search terms: one line per term (market · story · searches · items; the query text is not served) */
.about-terms { list-style: none; padding: 0 !important; border: 1px solid var(--border); border-radius: var(--r2); }
.about-terms li { padding: 7px 12px; margin: 0 !important; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.about-terms li:last-child { border-bottom: 0; }
.about-terms .term-market { color: var(--text); }
.about-terms .off { color: var(--muted); }

/* ------------------------------------------------------------ drawer */
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; max-height: 100%; width: min(760px, 100%);
  max-width: 100%; padding: 0; border: 0; border-left: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); box-shadow: -20px 0 50px rgba(0, 0, 0, .35); overflow: hidden;
}
.drawer[open] { display: flex; flex-direction: column; animation: slide-in .22s ease-out; }
.drawer::backdrop { background: rgba(5, 8, 12, .55); backdrop-filter: blur(2px); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; gap: var(--s4); align-items: flex-start; padding: var(--s5) var(--s6); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin-bottom: 4px; }
.drawer-title { font-size: 19px; line-height: 1.35; }
.drawer-body { overflow-y: auto; padding: var(--s5) var(--s6) var(--s7); flex: 1; }
.drawer-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: var(--s6) 0 var(--s3); }
.drawer-body h3:first-child { margin-top: 0; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin: 0 0 var(--s3); }
.facts > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r2); padding: 9px 12px; }
.facts dt { color: var(--muted); font-size: 11.5px; }
.facts dd { margin: 2px 0 0; font-weight: 650; font-size: 15px; }
.facts dd small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.spark-cap { display: flex; justify-content: space-between; margin-top: var(--s3); color: var(--muted); font-size: 12px; }
.assess-latest { margin-top: var(--s3); padding: var(--s4); border-radius: var(--r2); border: 1px solid var(--border); background: var(--surface-2); }
.assess-latest p { color: var(--text-2); margin-top: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li { position: relative; padding: 0 0 var(--s4) var(--s5); }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .tl-top { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; }
.timeline .tl-top .when { font-weight: 600; color: var(--text); }
.timeline .tl-reason { margin-top: 4px; color: var(--text-2); font-size: 13px; }
.timeline .tl-model { color: var(--muted); font-size: 11.5px; }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.member { padding: 12px 14px; border-radius: var(--r2); border: 1px solid var(--border); background: var(--surface-2); }
.member .news-title { font-size: 14px; }
.member .news-snippet { -webkit-line-clamp: 4; }
.spark { display: block; width: 100%; height: 64px; margin-top: var(--s2); }
.spark .sp-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark .sp-pt { fill: var(--accent); }
.spark .sp-axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }

/* ------------------------------------------------------------ footer */
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between; padding-top: var(--s5); padding-bottom: var(--s6); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) and (min-width: 721px) {
  .kv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .hero-card .gauge-wrap { max-width: 360px; }
  .updated { display: none; }
}
@media (max-width: 860px) {
  .wrap { padding: 0 var(--s4); }
  .about-grid { grid-template-columns: 1fr; gap: 0; }
  .system-card .kv-list { grid-template-columns: 1fr; }
  .system-card .kv-list > div:nth-last-child(2):nth-child(odd) { border-bottom: 1px dashed var(--border); }
  .hero-grid { grid-template-columns: 1fr; }
  .contrib { grid-template-columns: 30px minmax(0, 1fr); }
  .contrib .signal { grid-column: 2; }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root { --topbar-h: 52px; }
  body { font-size: 14.5px; }
  main.wrap { padding-top: var(--s5); }
  .topbar-inner { gap: var(--s3); }
  .brand-name { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .card { padding: var(--s4); border-radius: var(--r2); }
  .page-head h1 { font-size: 23px; }
  .idx-value { font-size: 46px; }
  .field, .field-grow, .field-range { min-width: calc(50% - var(--s3)); flex: 1 1 calc(50% - var(--s3)); }
  .field-grow { flex-basis: 100%; }
  .news-item { grid-template-columns: 1fr; gap: 4px; padding: 12px; }
  .news-time small { display: inline; margin-left: 6px; }
  .drawer-head, .drawer-body { padding-left: var(--s4); padding-right: var(--s4); }
  .chart svg { height: 260px; }
  .chart { min-height: 260px; }
  .chart-empty { inset: 0 0 24px 36px; }
  /* stories table becomes cards */
  .stories-table thead { display: none; }
  .stories-table, .stories-table tbody, .stories-table tr, .stories-table td { display: block; width: 100%; }
  .stories-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
  .stories-table tbody tr:last-child { border-bottom: 0; }
  .stories-table td { padding: 0; border: 0; text-align: left !important; }
  .stories-table td.story-cell { grid-column: 1 / -1; min-width: 0; max-width: none; margin-bottom: 4px; }
  .stories-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
  .stories-table td.t-time small { display: none; }
  .stories-table td[data-label="Category"] { grid-column: span 2; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stories-table tbody tr:hover > td { background: none; }
  .table-wrap.stack { border-radius: var(--r2); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .skeleton::after { display: none; }
}
@media print {
  .topbar, .footer, .more-row, .filters, .seg, .tabs { display: none; }
  .card { box-shadow: none; }
}
