/* Frontal Insights. Ink on white: one spacing scale, one radius scale, hairline rules, tabular numerals. */

:root {
  color-scheme: light;
  /* Colour. The ink, track, band and series values are also used by the charts and are validated
     for colour-blind safety: do not change them here. */
  --bg: #ffffff;
  --surface: #f6f6f8;
  --surface-2: #ffffff;
  --border: #eaeaee;
  --rule: #d3d3da;
  --ink: #111118;
  --ink-2: #62626e;
  --ink-3: #9e9ea9;
  --label: #6f6f7b;
  --grid: #ececf0;
  --track: #ededf1;
  --band: rgba(17, 17, 24, 0.16);
  --up: #0ca30c;
  --down: #d03b3b;
  --warn-bg: #fff6df;
  --warn-ink: #6b4b00;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;

  /* Spacing scale */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  /* Radius scale: marks, controls, cards */
  --r-1: 2px; --r-2: 4px; --r-3: 6px;
  --radius: var(--r-3);
  /* Type scale */
  --fs-micro: 11px; --fs-small: 12px; --fs-body: 14px; --fs-title: 15px; --fs-page: 22px; --fs-value: 24px;
  --pad-card: 20px;
  --gutter: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111114; --surface: #1a1a1e; --surface-2: #1f1f24; --border: #2c2c33; --rule: #3d3d46;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8b8a85; --label: #a3a29b; --grid: #2a2a30; --track: #2a2a30;
    --band: rgba(240, 239, 236, 0.22); --warn-bg: #3a2e10; --warn-ink: #f5d68a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111114; --surface: #1a1a1e; --surface-2: #1f1f24; --border: #2c2c33; --rule: #3d3d46;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8b8a85; --label: #a3a29b; --grid: #2a2a30; --track: #2a2a30;
  --band: rgba(240, 239, 236, 0.22); --warn-bg: #3a2e10; --warn-ink: #f5d68a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
html { -webkit-text-size-adjust: 100%; }
body { font-size: var(--fs-body); line-height: 1.5; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-value); line-height: 1.25; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-page); line-height: 1.25; letter-spacing: -0.02em; }
h3 { font-size: var(--fs-body); line-height: 1.4; margin-bottom: var(--sp-3); }
p { margin: var(--sp-3) 0 0; }
b { font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-small); }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.error { color: var(--down); min-height: 1.5em; margin: 0; font-size: var(--fs-small); }

button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { height: 36px; padding: 0 var(--sp-4); background: var(--ink); color: var(--bg); border: 1px solid var(--ink); border-radius: var(--r-2); font-size: 13px; font-weight: 600; }
button.ghost { height: 32px; padding: 0 var(--sp-3); background: transparent; border: 1px solid var(--rule); border-radius: var(--r-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
button.ghost.small { height: 28px; padding: 0 10px; font-size: var(--fs-small); }
button.ghost:hover:not(:disabled) { border-color: var(--ink); }
button.link { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
button.link:hover { color: var(--ink); text-decoration-color: currentColor; }
input, select { height: 36px; min-width: 0; padding: 0 var(--sp-3); font: inherit; font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: var(--r-2); }
input::placeholder { color: var(--ink-3); }
input:hover, select:hover { border-color: var(--ink-3); }
input:focus, select:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- Brand ---------- */
/* Lowercase wordmark, as in the app; the product name sits beside it, lighter. */
.brand { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-title); line-height: 1; white-space: nowrap; }
.mark { width: 20px; height: 20px; border-radius: var(--r-2); background: var(--ink); position: relative; flex: none; }
.mark::after { content: ""; position: absolute; left: 5px; right: 5px; top: 6px; height: 2px; background: var(--bg); border-radius: 1px; box-shadow: 0 5px 0 -0.5px var(--bg); }
.brand .wordmark { font-weight: 650; letter-spacing: -0.03em; font-size: 17px; }
.brand .product { font-weight: 400; color: var(--ink-2); }

/* ---------- Gate ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-5) var(--sp-4) 12vh; }
.gate-card { width: min(400px, 100%); display: grid; }
.gate-card h1 { text-wrap: balance; }
.gate-card .brand { margin-bottom: var(--sp-7); }
.gate-card > p { margin: var(--sp-2) 0 0; }
.gate-card form { display: grid; gap: var(--sp-2); margin-top: var(--sp-6); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.gate-card label { font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.gate-card input { height: 40px; }
.gate-card button.primary { height: 40px; margin-top: var(--sp-1); }
.gate-card .link { justify-self: start; margin-top: var(--sp-4); font-size: 13px; }

/* ---------- Layout ---------- */
#app { max-width: calc(1240px + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter) 64px; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border); }
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); height: 56px; }
.top-actions { display: flex; align-items: center; gap: var(--sp-2); }
#updated { margin-right: var(--sp-2); white-space: nowrap; }
.tabs { display: flex; gap: 28px; margin-bottom: -1px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; height: 40px; padding: 0; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-2); font-size: var(--fs-body); font-weight: 500; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:focus-visible { outline-offset: -2px; }

.sim-banner { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); margin-top: var(--sp-4); padding: var(--sp-2) var(--sp-3); background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r-2); font-size: var(--fs-small); font-weight: 500; }
.sim-banner > span { flex: 1 1 280px; }
.sim-banner b { font-weight: 700; letter-spacing: 0.04em; }
.sim-banner .link { color: inherit; text-decoration-color: currentColor; white-space: nowrap; }

/* Totals: one strip of figures divided by hairlines, not tiles. */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: var(--sp-5); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.kpi { min-width: 0; padding: var(--sp-4); border-left: 1px solid var(--border); }
.kpi:first-child { padding-left: 0; border-left: 0; }
.kpi .label { font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.kpi .value { margin-top: var(--sp-1); font-size: var(--fs-value); line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { margin-top: 2px; font-size: var(--fs-small); color: var(--ink-2); }
.kpis > .empty { grid-column: 1 / -1; }

.panel { display: grid; gap: var(--sp-4); margin-top: var(--sp-6); }
.panel > * { min-width: 0; }
.panel > p { margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-3) var(--sp-5); flex-wrap: wrap; margin-bottom: var(--sp-1); }
.panel-head p { margin: var(--sp-1) 0 0; max-width: 76ch; }
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.filters input[type="search"] { width: 220px; }

.card { min-width: 0; padding: var(--pad-card); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.card > h3 + p { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); }
.card > p.small, .card p.muted.small, .detail p.muted.small { max-width: 110ch; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--sp-4); }
#segments, #dependencies { display: grid; gap: var(--sp-4); }
#segments { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
#segments > p, #segments > .empty { grid-column: 1 / -1; margin: 0; }
#segments:empty, #dependencies:empty { display: none; }
#segments > .card > h3 { margin: 2px 0 var(--sp-3); }
details { margin-top: var(--sp-3); }
summary { width: max-content; cursor: pointer; color: var(--ink-2); font-size: var(--fs-small); }
summary:hover { color: var(--ink); }
details[open] > summary { margin-bottom: var(--sp-2); }
.empty { padding: var(--sp-3) 0; color: var(--ink-2); font-size: 13px; }
.empty b { color: var(--ink); }
.empty.card { padding: var(--pad-card); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.simple, .opt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple th, .opt-table th { padding: var(--sp-2) var(--sp-3); text-align: left; vertical-align: bottom; font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); border-bottom: 1px solid var(--rule); white-space: nowrap; }
.simple td, .opt-table td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.simple td { white-space: nowrap; }
/* The first column may wrap; in the widest tables (7+ columns, which scroll on a phone) it keeps a readable width. */
.simple td:first-child { min-width: 88px; white-space: normal; }
.simple td:first-child:nth-last-child(n + 7) { min-width: 168px; }
.simple th:first-child, .simple td:first-child, .opt-table th:first-child, .opt-table td:first-child { padding-left: 0; }
.simple th:last-child, .simple td:last-child, .opt-table th:last-child, .opt-table td:last-child { padding-right: 0; }
.simple tbody tr:last-child td, .opt-table tbody tr:last-child td { border-bottom: 0; }
.simple td.r, .simple th.r, .opt-table td.r, .opt-table th.r { text-align: right; }
.opt-table td.r { white-space: nowrap; }
.opt-table td .small { margin-top: 2px; }
.opt-name { display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; }
.swatch { width: 8px; height: 8px; border-radius: var(--r-1); flex: none; }
.range { position: relative; height: 8px; min-width: 120px; background: var(--track); border-radius: var(--r-1); }
.range .band { position: absolute; top: 0; bottom: 0; background: var(--band); border-radius: var(--r-1); }
.range .mean { position: absolute; top: -3px; bottom: -3px; width: 3px; border-radius: 1px; background: var(--ink); }
.range + .small { margin-top: var(--sp-1); }
.table-wrap + p, p + .table-wrap { margin-top: var(--sp-3); }

/* ---------- Markets ---------- */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--sp-4); }
.market-grid > .empty { grid-column: 1 / -1; }
.market { display: grid; gap: var(--sp-2); align-content: start; min-width: 0; padding: var(--sp-4); text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.market:hover { border-color: var(--ink-3); }
.market[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.market .meta { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-micro); color: var(--label); }
.market .meta > span:first-child { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.market .title { font-size: var(--fs-body); font-weight: 600; line-height: 1.35; }
.market .lead { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
.market .lead .pct { font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.market .lead .opt { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market > .small { margin-top: -4px; }
.market .foot-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-top: var(--sp-1); padding-top: var(--sp-3); border-top: 1px solid var(--border); font-size: var(--fs-small); color: var(--ink-2); white-space: nowrap; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); }
.spark { width: 64px; height: 22px; flex: none; }
.spark path { stroke-width: 1.5; }

/* Detail */
.detail { scroll-margin-top: 112px; padding: var(--sp-5); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.detail-head h3 { margin: 2px 0 var(--sp-1); font-size: 20px; line-height: 1.25; letter-spacing: -0.02em; }
.detail-head .small + .small { margin-top: var(--sp-1); }
.detail-head .ghost { flex: none; }
.detail > h3 { margin-top: var(--sp-5); }
ul.tests { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; }

/* ---------- Charts ---------- */
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin: 0 0 var(--sp-2); font-size: var(--fs-small); color: var(--ink-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-1); margin-right: 6px; vertical-align: 0; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
svg text { font-variant-numeric: tabular-nums; }
.axis text { fill: var(--ink-3); font-size: 11px; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; max-width: 260px; padding: var(--sp-2) 10px; background: var(--ink); color: var(--bg); border-radius: var(--r-2); font-size: var(--fs-small); line-height: 1.45; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14); }
.tooltip b { font-weight: 600; }
#calibration svg { max-width: 420px; margin: 0 auto; }

/* Label, bar, value rows */
.brier-row { display: grid; grid-template-columns: minmax(96px, 168px) minmax(0, 1fr) 56px; gap: var(--sp-3); align-items: center; max-width: 760px; padding: 6px 0; font-size: 13px; }
.brier-row .r { text-align: right; }
.brier-row .range { min-width: 0; }
.brier-bar { height: 6px; background: var(--track); border-radius: var(--r-1); overflow: hidden; }
.brier-bar span { display: block; height: 100%; background: var(--ink); border-radius: 0 var(--r-1) var(--r-1) 0; }
.term-row { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.term-row:last-child { border-bottom: 0; }
.measure-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-1) var(--sp-4); margin-top: var(--sp-2); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.measure-grid + .table-wrap { margin-top: var(--sp-4); }

/* ---------- Segments and predictor ---------- */
.predict-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); margin: 0 0 var(--sp-4); }
#predict-decision { grid-column: 1 / -1; }
#predict-form input[name="forecast"] { width: 100%; }
.predict-form button { justify-self: start; }

/* ---------- Model ---------- */
.method { margin: 0; padding-left: 18px; display: grid; gap: var(--sp-2); color: var(--ink-2); font-size: 13px; }
.method b { color: var(--ink); margin-right: var(--sp-1); }
.params { display: grid; grid-template-columns: 1fr auto; margin: 0; font-size: 13px; }
.params dt, .params dd { padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.params dt { color: var(--ink-2); }
.params dd { margin: 0; padding-left: var(--sp-4); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.params dt:nth-last-child(2), .params dd:last-child { border-bottom: 0; }
.model-card { border-top: 1px solid var(--border); padding: var(--sp-4) 0 var(--sp-2); }
.model-card:first-child { border-top: 0; padding-top: 0; }
.model-card:last-child { padding-bottom: 0; }
.model-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-1) var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.pd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.pd { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-2); }
.pd svg { width: 100%; height: auto; display: block; }

/* ---------- Dependencies ---------- */
.dep-head { margin: var(--sp-1) 0 var(--sp-2); font-size: var(--fs-title); line-height: 1.35; }

/* ---------- 3D ---------- */
.viz3d-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr); gap: var(--sp-5); align-items: start; }
.viz3d { position: relative; background: var(--surface); border-radius: var(--r-2); aspect-ratio: 4 / 3; overflow: hidden; }
.viz3d canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.viz3d canvas:active { cursor: grabbing; }
.viz3d canvas:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.viz3d-side { min-width: 0; }
.viz3d-side > .strong { margin-bottom: var(--sp-2); }

/* ---------- Methods ---------- */
.method-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: var(--sp-4); }
.method-card { position: relative; margin: 0; }
.method-card h3 { margin-bottom: var(--sp-1); padding-right: 40px; font-size: var(--fs-title); }
.method-card > .muted { margin: 0 0 var(--sp-3); font-size: 13px; }
.method-num { position: absolute; top: var(--pad-card); right: var(--pad-card); font-size: var(--fs-small); font-weight: 500; line-height: 21px; color: var(--label); font-variant-numeric: tabular-nums; }
.eq { margin: var(--sp-2) 0; padding: var(--sp-3) var(--sp-4); overflow-x: auto; background: var(--surface); border-radius: var(--r-2); font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Times New Roman", serif; font-size: 16px; font-variant-numeric: normal; line-height: 2; text-align: center; white-space: nowrap; }
.eq i { font-style: italic; }
.eq sub, .eq sup { font-size: 0.68em; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; line-height: 1.25; }
.frac > span:first-child { padding: 0 3px 2px; border-bottom: 1px solid currentColor; }
.frac > span:last-child { padding: 2px 3px 0; }
.syms { margin: var(--sp-3) 0 0; padding-left: 18px; display: grid; gap: var(--sp-1); color: var(--ink-2); font-size: 13px; }
.syms i { font-family: "STIX Two Math", "Cambria Math", "Times New Roman", serif; font-size: 1.05em; }
.check { margin: var(--sp-3) 0 0; padding-top: var(--sp-3); border-top: 1px solid var(--border); font-size: var(--fs-small); color: var(--ink-2); }
.check b { color: var(--ink); }

/* ---------- Progression ---------- */
.scroll-x { overflow-x: auto; margin-bottom: var(--sp-3); }
.scroll-x svg { min-width: 640px; }
.flow-label { font-size: 11.5px; font-weight: 600; letter-spacing: -0.01em; fill: var(--ink); paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
.flow-sub { font-size: 11px; fill: var(--ink-3); paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
.group-block + .group-block { margin-top: var(--sp-5); }
.group-block h4 { margin: 0 0 var(--sp-1); font-size: 13px; }

/* ---------- Findings ---------- */
.finding { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sp-4); row-gap: 2px; align-items: center; padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.finding > * { grid-column: 1; }
.finding > button { grid-column: 2; grid-row: 1 / span 3; }
.finding:first-child { border-top: 0; padding-top: 0; }
.finding-family { margin: var(--sp-5) 0 0; padding-bottom: var(--sp-2); border-bottom: 1px solid var(--rule); font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.finding-family:first-child { margin-top: 0; }
.finding-family + .finding { border-top: 0; }
#findings-list > p { max-width: none; margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--border); }

.foot { margin-top: var(--sp-7); padding-top: var(--sp-4); border-top: 1px solid var(--border); color: var(--label); }

/* ---------- Narrower screens ---------- */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(n + 4) { border-top: 1px solid var(--border); }
  .kpi:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
}
@media (max-width: 760px) {
  .viz3d-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --pad-card: 16px; --fs-page: 20px; --fs-value: 22px; }
  #app { padding-bottom: var(--sp-7); }
  /* Only the tab bar stays pinned on a phone; the brand row scrolls away. */
  .top { display: contents; }
  .top-bar { flex-wrap: wrap; height: auto; gap: 0 var(--sp-4); padding-top: var(--sp-3); }
  .top-bar .brand { height: 32px; }
  .top-actions { width: 100%; gap: 0; }
  #updated { margin-right: auto; }
  .top-actions button.ghost { padding: 0 var(--sp-2); border-color: transparent; }
  .top-actions button.ghost:last-child { margin-right: calc(-1 * var(--sp-2)); }
  .tabs { position: sticky; top: 0; z-index: 5; gap: var(--sp-5); margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); background: var(--bg); border-bottom: 1px solid var(--border); }
  .tabs button { height: 44px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: var(--sp-4); }
  .kpi { padding: var(--sp-3) var(--sp-4); }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .kpi:nth-child(3n + 1) { padding-left: var(--sp-4); border-left: 1px solid var(--border); }
  .kpi:nth-child(odd) { padding-left: 0; border-left: 0; }
  .panel { margin-top: var(--sp-5); }
  .filters { width: 100%; }
  .filters > * { flex: 1 1 140px; }
  .filters input[type="search"] { width: auto; }
  .detail { scroll-margin-top: 56px; padding: var(--sp-4); }
  .detail-head h3 { font-size: 18px; }
  .opt-table .hide-sm { display: none; }
  /* Headers may wrap in the option table and in small tables (up to 4 columns), so those fit without scrolling. */
  .opt-table th, .simple th:first-child:nth-last-child(-n + 4) ~ th { white-space: normal; }
  .simple th, .simple td, .opt-table th, .opt-table td { padding-left: var(--sp-2); padding-right: var(--sp-2); }
  .simple th:first-child, .simple td:first-child, .opt-table th:first-child, .opt-table td:first-child { padding-left: 0; }
  .simple th:last-child, .simple td:last-child, .opt-table th:last-child, .opt-table td:last-child { padding-right: 0; }
  .range { min-width: 96px; }
  .brier-row { grid-template-columns: minmax(84px, 112px) minmax(0, 1fr) 52px; gap: var(--sp-2); }
  .finding { grid-template-columns: minmax(0, 1fr); }
  .finding > button { grid-column: 1; grid-row: auto; justify-self: start; margin-top: var(--sp-1); }
  .predict-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eq { font-size: 15px; }
}
@media (min-width: 641px) {
  /* Keep the headline figures on one line across a row of cards. */
  .market .title { min-height: 2.7em; }
}

/* Official statistics */
.official { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: var(--sp-5) var(--sp-5); }
.official:empty, .official-pop:empty { display: none; }
.official-group { grid-column: 1 / -1; padding-top: var(--sp-3); border-top: 1px solid var(--border); font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.official-group:first-child { border-top: 0; padding-top: 0; }
.stat { min-width: 0; }
.stat-name { font-size: 13px; font-weight: 600; }
.stat-value { margin-top: var(--sp-1); font-size: var(--fs-value); line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub, .stat-src, .mini-range { font-size: var(--fs-micro); }
.stat-src { margin-top: var(--sp-1); }
.stat-src a { color: inherit; }
.mini-wrap { margin-top: var(--sp-2); }
.mini { display: block; width: 100%; height: auto; overflow: visible; }
.mini-range { display: flex; justify-content: space-between; gap: var(--sp-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.official-pop { margin-top: 0; }
.official-pop h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.pop-row { display: grid; grid-template-columns: minmax(96px, 11em) 1fr 3.5em; align-items: center; gap: var(--sp-3); padding: 6px 0; font-size: 13px; }
.pop-note { grid-column: 1 / -1; margin: 0; }

/* Official statistics: forecast */
.stat-detail { font-size: var(--fs-micro); }
.stat-forecast { margin-top: var(--sp-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.stat-forecast b { font-weight: 600; }
#official > .card + .card, #official > p { margin-top: var(--sp-4); }

/* Control */
.ops-banner { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); padding: var(--sp-4) var(--pad-card); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--surface-2); font-size: 15px; }
.ops-banner.ok { border-left-color: var(--up); }
.ops-banner.bad { border-left-color: var(--down); }
.check-row { display: grid; grid-template-columns: minmax(120px, 12em) 9em 1fr; gap: var(--sp-3); align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.check-row:last-child { border-bottom: 0; }
.check-name { font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--up); }
.status.bad i { background: var(--down); border-radius: 2px; }
.ops-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4); }
.detail-cell { display: inline-block; max-width: 46ch; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 640px) { .check-row { grid-template-columns: 1fr auto; } .check-row > .muted { grid-column: 1 / -1; } }

.ops-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--sp-3); }
.ops-links a { display: flex; flex-direction: column; gap: 3px; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.ops-links a:hover { border-color: var(--ink-3); }
.ops-links b { font-size: 14px; font-weight: 600; }
.ops-links span { font-size: var(--fs-small); color: var(--ink-2); }

.mark-img { display: block; width: 24px; height: 24px; }

/* Outlook */
.outlook-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 0; margin-bottom: var(--sp-4); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--sp-3) var(--sp-5); margin-bottom: var(--sp-3); }
.card-head h3 { margin-bottom: 4px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--track); border-radius: 999px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.signal-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 120px 112px; align-items: center; gap: var(--sp-3); padding: 10px 0; border-bottom: 1px solid var(--border); }
.signal-row:last-child { border-bottom: 0; }
.signal-name, .signal-num { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.signal-name b { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-num { align-items: flex-end; font-variant-numeric: tabular-nums; }
.arrow { font-size: 11px; } .arrow.up { color: var(--up); } .arrow.down { color: var(--down); }
.spark-row { display: block; width: 120px; height: 30px; }
.attention-table td { vertical-align: middle; }
.attention-table td.pos { color: var(--up); font-weight: 600; } .attention-table td.neg { color: var(--down); font-weight: 600; }
a.plain { color: inherit; text-decoration: none; } a.plain:hover b { text-decoration: underline; }
.hbar { position: relative; height: 8px; background: var(--track); border-radius: 4px; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--s1); border-radius: 0 4px 4px 0; }
.hbar .tick { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); border-radius: 1px; }
.quits-row { grid-template-columns: minmax(120px, 15em) 1fr 3.5em; }
@media (max-width: 900px) { .outlook-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .signal-row { grid-template-columns: 18px minmax(0, 1fr) 96px; } .signal-row .spark-row { display: none; } }
.sig-note { margin: var(--sp-3) 0 0; }
#outlook-signals { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--sp-4) var(--sp-6, 32px); }
