/* Corporate Brain — Quant Workbench (UI proposal)
   Dense, keyboard-first analytics terminal. Near-black, hairline borders,
   radius <=2px, monospace numerals, 10-11px dense type, small-caps labels.
   Density is a feature: form-fit content, no dead space, no visible scrollbars. */

:root {
  --bg:        #0b0d0f;   /* near-black page */
  --panel:     #0e1114;   /* card surface */
  --panel-2:   #121619;   /* nested surface */
  --head:      #101417;   /* card header */
  --line:      #1e2429;   /* 1px hairline */
  --line-2:    #262d34;   /* stronger hairline */
  --grid:      #191f24;   /* chart gridlines */
  --text:      #d7dee4;   /* primary text */
  --text-2:    #aeb8c0;   /* secondary */
  --muted:     #6b7680;   /* muted / axis */
  --faint:     #454e56;   /* faintest */
  --accent:    #6b93c4;   /* selection-blue (sparingly) */
  --green:     #5ea585;
  --red:       #c67f85;
  --amber:     #c4a35f;
  --violet:    #ac86bd;

  --c-found: #5ea585;
  --c-calc:  #6b93c4;
  --c-est:   #ac86bd;
  --c-scen:  #c4a35f;
  --c-lead:  #5e9aa2;
  --c-abst:  #838d95;

  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --masonry-row: 4px;    /* masonry row unit (JS sets grid-row span in these units) */
  --gap: 6px;
}

* { box-sizing: border-box; }
/* no visible scrollbars anywhere (scrolling still works) */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 13px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
::selection { background: rgba(107,147,196, 0.28); }
button { font-family: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ============================================================ layout shell */
.wb { display: flex; flex-direction: column; height: 100vh; }

/* ---- top context strip (one thin line) ---- */
.ctx {
  display: flex; align-items: center; gap: 10px;
  height: 30px; min-height: 30px; padding: 0 10px;
  background: var(--head); border-bottom: 1px solid var(--line);
  font-size: 10px; white-space: nowrap; overflow: hidden;
}
.cb-mark {
  font-family: var(--mono); font-weight: 700; font-size: 10px; letter-spacing: 1px;
  color: var(--bg); background: var(--text-2); padding: 2px 5px; border-radius: 2px;
}
.ctx-entities { display: inline-flex; gap: 4px; }
.ent-chip {
  font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 2px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
}
.ent-chip.fix { color: var(--amber); border-color: rgba(196,163,95,0.4); }
.ctx-sep { width: 1px; height: 16px; background: var(--line-2); }
.ctx-asof { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 9px; }
.ctx-asof input, .ctx-asof select {
  font-family: var(--mono); font-size: 10px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px;
  padding: 1px 4px; color-scheme: dark;
}
.ctx-asof select { cursor: pointer; }
/* period-focused: tint the picker when a specific reporting year is active */
.ctx-asof select.on { color: var(--amber); border-color: rgba(196,163,95,0.45); }
.ctx-meta { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 9px; }
.ctx-meta b { font-family: var(--mono); color: var(--text-2); font-weight: 600; text-transform: none; letter-spacing: 0; }
.ctx-meta b.snow { color: var(--accent); cursor: pointer; }
.bemode::before { content: "●"; margin-right: 3px; font-size: 8px; color: var(--muted); }
.bemode.live::before { color: var(--green); }
.bemode.running::before { color: var(--amber); }
.bemode.offline::before { color: var(--red); }
.ctx-meta b.snow:hover { text-decoration: underline; }
.ctx-spacer { flex: 1; }
.ctx-filters { display: inline-flex; gap: 3px; }
.cls-tog {
  font-family: var(--mono); font-size: 9px; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 2px; background: var(--panel-2);
  border: 1px solid var(--line-2); color: var(--text-2);
}
.cls-tog::before { content: "●"; margin-right: 4px; font-size: 8px; }
.ct-found::before { color: var(--c-found); }
.ct-calc::before  { color: var(--c-calc); }
.ct-est::before   { color: var(--c-est); }
.ct-scen::before  { color: var(--c-scen); }
.ct-lead::before  { color: var(--c-lead); }
.ct-abst::before  { color: var(--c-abst); }
.cls-tog.off { opacity: 0.4; text-decoration: line-through; }
.ctx-btn {
  font-family: var(--mono); font-size: 9px; letter-spacing: .04em; color: var(--text-2);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 2px 6px;
}
.ctx-btn:hover { color: var(--text); border-color: var(--accent); }
.warn-badge {
  font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 2px;
  background: rgba(196,163,95,0.1); border: 1px solid rgba(196,163,95,0.35); color: var(--amber);
}
.warn-badge[data-n="0"] { color: var(--muted); background: var(--panel-2); border-color: var(--line-2); }

/* ---- center card grid: row-packed 12-col snap grid ----
   JS (layoutMasonry) packs cards into full-width rows and equalizes each row's
   height, so bottoms line up and no page-background shows through between cards.
   Cards flex to fill their row cell; charts grow, short cards top-align. */
.grid {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: var(--masonry-row); grid-auto-flow: row; gap: var(--gap); padding: var(--gap);
  align-content: start;
}
/* collapsed (single-column) layout: a plain flex stack so each card is its own natural
   content height — no masonry row-spans to balloon a short card into a tall empty region. */
.grid.grid--stack { display: flex; flex-direction: column; }
/* cards keep their NATURAL height and the grid scrolls — flex:0 0 auto stops the
   scrolling flex column from shrinking every card to fit (which collapsed them). */
.grid.grid--stack .card { width: 100%; align-self: stretch; flex: 0 0 auto; }
/* and the chart box uses its intrinsic min-height instead of flex-filling a 0-height parent. */
.grid.grid--stack .chart-box { flex: 0 0 auto; }

/* section tabs — a reading order (Overview / Fundamentals / …) over the card canvas */
.sections { display: flex; align-items: center; gap: 4px; padding: 5px 10px; background: var(--head); border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.section-tab { font-family: var(--sans); font-size: 12.5px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 5px; padding: 5px 12px; white-space: nowrap; }
.section-tab:hover { color: var(--text-2); background: var(--panel-2); }
.section-tab.on { color: var(--text); background: var(--panel); border-color: var(--line-2); font-weight: 600; }
.section-tab .sec-n { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-left: 4px; }
.section-tab.on .sec-n { color: var(--accent); }
.sec-spacer { flex: 1 1 auto; }
.section-tab.cust { color: var(--text-2); font-size: 11.5px; }
.section-tab.cust.on { color: var(--amber); border-color: rgba(196,163,95,0.45); background: rgba(196,163,95,0.08); }
.card[data-section-hidden] { display: none !important; }
/* drag affordance appears only in Customize mode */
.card .ch-left.click { cursor: default; }
.card.cust-on .ch-left.click { cursor: grab; }
.card.cust-on { outline: 1px dashed var(--line-2); }
.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
  overflow: hidden; align-self: stretch; position: relative; /* JS sets grid-column/row; fills its cell */
}
.card.maxed { outline: 1px solid rgba(107,147,196,0.4); }
/* drag-to-reposition affordances (snap-grid) */
.card.dragging { opacity: .45; }
.card.drop-before { box-shadow: -3px 0 0 0 var(--accent); }
.card.drop-after  { box-shadow:  3px 0 0 0 var(--accent); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 7px; background: var(--head); border-bottom: 1px solid var(--line);
  min-height: 32px; cursor: grab;   /* drag handle */
}
.card.dragging .card-head { cursor: grabbing; }
.ch-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
.ch-left.click { cursor: grab; }
.rank { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.ctype {
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 2px; padding: 1px 5px; text-transform: uppercase;
}
.ctitle { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.csub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.face-badge {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; font-weight: 700;
  color: var(--amber); background: rgba(196,163,95,0.12);
  border: 1px solid rgba(196,163,95,0.4); border-radius: 2px; padding: 1px 5px;
}
.ch-act { display: flex; gap: 4px; flex-shrink: 0; }
.act {
  font-family: var(--mono); font-size: 11px; letter-spacing: .03em; color: var(--text-2);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px; padding: 5px 9px; line-height: 1.3;
}
.act:hover { color: var(--text); border-color: var(--accent); }
.card-body { padding: 5px 7px; min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.card-raw { max-height: 260px; overflow: auto; border-top: 1px dashed var(--line-2); flex: none; }
.card-raw pre { margin: 0; padding: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--text-2); white-space: pre-wrap; }

/* class chips on header + inline value tags */
.chdr, .ctag {
  font-family: var(--mono); font-style: normal; font-size: 9.5px; font-weight: 700;
  letter-spacing: .03em; border-radius: 2px; padding: 0 3px; line-height: 1.5;
}
.chdr-found, .ctag-found { color: var(--c-found); background: rgba(94,165,133,0.12); }
.chdr-calc,  .ctag-calc  { color: var(--c-calc);  background: rgba(107,147,196,0.12); }
.chdr-est,   .ctag-est   { color: var(--c-est);   background: rgba(172,134,189,0.12); }
.chdr-scen,  .ctag-scen  { color: var(--c-scen);  background: rgba(196,163,95,0.12); }
.chdr-lead,  .ctag-lead  { color: var(--c-lead);  background: rgba(94,154,162,0.12); }
.chdr-abst,  .ctag-abst  { color: var(--c-abst);  background: rgba(138,148,156,0.12); }
.ctag { margin-left: 4px; }
.fx {
  font-family: var(--mono); font-style: normal; font-size: 8px; font-weight: 700;
  color: var(--amber); background: rgba(196,163,95,0.12); border-radius: 2px; padding: 0 3px; margin-left: 3px;
}

/* value leaf: any classed value is clickable for a class-appropriate detail view */
.val { font-family: var(--mono); }
.val[data-detail] { cursor: pointer; }
.val[data-detail]:hover { text-decoration: underline dotted; text-underline-offset: 2px; }
[data-class-hidden] { opacity: 0.1 !important; filter: grayscale(1); pointer-events: none; }
[data-class-hidden] .val, [data-class-hidden] .ctag, [data-class-hidden] .fx { text-decoration: line-through; }

/* ---- plan preview row ---- */
.plan {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  background: var(--head); border-top: 1px solid var(--line); min-height: 30px; flex-wrap: wrap;
}
.plan-kick { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; color: var(--faint); }
.plan-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pg { display: inline-flex; align-items: center; gap: 4px; }
.pg-lab { font-family: var(--mono); font-size: 8.5px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.pg-sep { color: var(--faint); }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 10px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 1px 3px 1px 6px;
}
.chip.static { padding: 1px 6px; color: var(--text-2); }
.chip.empty { color: var(--faint); border-style: dashed; }
.chip-x {
  font-family: var(--mono); font-size: 11px; line-height: 1; color: var(--muted);
  background: transparent; border: 0; padding: 0 2px;
}
.chip-x:hover { color: var(--red); }

/* ---- bottom command bar ---- */
.cmd {
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  height: 40px; min-height: 40px; background: #090b0d; border-top: 1px solid var(--line-2);
}
.cmd-prompt { font-family: var(--mono); font-size: 14px; color: var(--green); }
.cmd-input {
  flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text);
  background: transparent; border: 0; outline: none; padding: 6px 0;
}
.cmd-input::placeholder { color: var(--faint); }
.cmd-run {
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--bg);
  background: var(--green); border: 0; border-radius: 2px; padding: 4px 12px; font-weight: 700;
}
.cmd-hint { font-family: var(--mono); font-size: 9px; color: var(--faint); border: 1px solid var(--line-2); border-radius: 2px; padding: 1px 4px; }

/* ============================================================ renderers */
/* chart cards: the box flex-grows to fill the row cell; inline min-height sets its
   natural (measured) height, so a chart in a taller row grows instead of leaving a gap */
.chart-box { position: relative; width: 100%; flex: 1 1 auto; min-height: 160px; }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart-tools { position: absolute; top: 4px; right: 6px; z-index: 2; display: flex; gap: 4px; }
.mini {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-2);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px; padding: 4px 9px;
}
.mini:hover { border-color: var(--accent); }
.chart-foot { display: flex; gap: 10px; align-items: center; padding: 4px 2px 0; font-family: var(--mono); font-size: 9px; flex-wrap: wrap; flex: none; }
.legend span { color: var(--muted); }
.legend { display: flex; gap: 10px; }
/* price-history crosshair readout — its own line under the legend, exact point-in-time closes */
.ph-readout { flex-basis: 100%; color: var(--muted); white-space: normal; line-height: 1.5; margin-top: 2px; }
.ph-readout b { color: var(--text); }
.tabs { display: flex; gap: 3px; }
.tab {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  background: transparent; border: 1px solid var(--line-2); border-radius: 3px; padding: 4px 9px;
}
.tab.on { color: var(--text); border-color: var(--accent); background: rgba(107,147,196,0.08); }

/* kpi strip (entity monitor): a thin, full-width monitor row. layoutMasonry()
   places the #kpi-strip card on its own full-width row; the tiles then fill it
   evenly (auto-fit + 1fr) instead of collapsing to one skinny column — the old
   `align-self:start` shrank the grid to min-content (1 col) in the column-flex
   card body, ballooning the card tall. Compact by construction, no dead height. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.kpi-cell { background: var(--panel); padding: 7px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-val { font-family: var(--mono); font-size: 18px; color: var(--text); white-space: nowrap; }

/* dense tables: fill card width, hug height, never scroll horizontally */
.table-wrap { width: 100%; overflow: hidden; }
table.dense { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 10px; table-layout: auto; }
table.dense th {
  background: var(--head); color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .03em; font-size: 8.5px;
  padding: 3px 6px; border-bottom: 1px solid var(--line-2); cursor: pointer; white-space: nowrap;
}
table.dense th.tleft { text-align: left; }
table.dense th.tright { text-align: right; }
table.dense th:hover { color: var(--text-2); }
table.dense td { padding: 2px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.dense td.tleft { text-align: left; }
table.dense td.tright { text-align: right; }
table.dense tbody tr:hover td { background: rgba(107,147,196,0.04); }
.spark { vertical-align: middle; }

/* tornado — fills its cell: bars distribute through the height instead of
   clumping at the top and leaving the card empty when it's stretched to a tall row */
.tornado { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; justify-content: space-evenly; min-height: 0; }
.tor-row { min-height: 16px; }
.tor-base { font-family: var(--mono); font-size: 9px; color: var(--muted); margin-bottom: 2px; }
.tor-row { display: grid; grid-template-columns: 92px 1fr 78px; align-items: center; gap: 6px; }
.tor-lab { font-family: var(--mono); font-size: 9px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tor-track { position: relative; height: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 2px; }
.tor-bar { position: absolute; top: 1px; bottom: 1px; background: linear-gradient(90deg, rgba(198,127,133,0.7), rgba(107,147,196,0.7)); border-radius: 1px; }
.tor-mid { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--text); }
.tor-val { font-family: var(--mono); font-size: 9px; color: var(--muted); text-align: right; }

/* heatmap */
.heat-grid { display: grid; gap: 1px; }
.hcell { font-family: var(--mono); font-size: 9px; text-align: center; padding: 4px 2px; color: var(--text); border-radius: 1px; }
.hcell.hlab { background: transparent; color: var(--muted); font-size: 8.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* timeline */
.timeline { display: flex; flex-direction: column; }
/* dense-stream guard: cap the list and scroll inside it so a full event feed
   (regulatory/LDA/filing) can't balloon the card and break the masonry row. */
.tl-scroll { max-height: 320px; overflow-y: auto; }
.tl-foot { font-family: var(--mono); font-size: 8.5px; color: var(--faint); text-align: right; padding: 3px 4px 0; margin-top: 2px; border-top: 1px dashed var(--line-2); flex: none; }
/* real empty state (replaces a blank card) */
.tl-empty { display: flex; flex-direction: column; gap: 6px; padding: 12px 8px; }
.tl-empty-h { font-size: 12px; color: var(--text-2); font-weight: 600; }
.tl-empty-s { font-size: 10.5px; color: var(--muted); line-height: 1.5; max-width: 54ch; }
.tl-row {
  display: grid; grid-template-columns: 74px 62px minmax(0,1fr) 44px auto; align-items: center; gap: 6px;
  padding: 2px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.tl-row .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tl-row:hover { background: rgba(107,147,196,0.05); }
.tl-date { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.tl-lab { font-size: 10px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-tkr { font-family: var(--mono); font-size: 9px; color: var(--text-2); }
.tl-val { font-family: var(--mono); font-size: 9px; color: var(--text-2); text-align: right; }
.badge {
  font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .03em;
  padding: 0 4px; border-radius: 2px; text-align: center; white-space: nowrap;
  color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line-2);
}
.b-senate_lda, .b-house_lda { color: var(--c-calc); border-color: rgba(107,147,196,0.35); }
.b-sec_companyfacts, .b-form4 { color: var(--c-found); border-color: rgba(94,165,133,0.35); }
.b-scenario_assumption { color: var(--c-scen); border-color: rgba(196,163,95,0.4); }

/* exposure board */
.exposure { display: flex; flex-direction: column; gap: 2px; }
.ex-row { display: grid; grid-template-columns: 118px 34px 1fr; grid-template-rows: auto auto; gap: 3px 8px; padding: 4px; border-bottom: 1px solid var(--line); }
.ex-type { font-family: var(--mono); font-size: 9.5px; color: var(--text); text-transform: capitalize; grid-row: 1 / 3; align-self: center; }
.ex-count { font-family: var(--mono); font-size: 12px; color: var(--text); grid-row: 1 / 3; align-self: center; text-align: right; }
.ex-bars { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.ex-bar {
  font-family: var(--mono); font-size: 8px; color: var(--bg); background: var(--accent);
  border-radius: 1px; padding: 0 4px; white-space: nowrap; overflow: hidden;
}
.ex-pills { display: flex; gap: 3px; flex-wrap: wrap; grid-column: 3; }
.ex-pill {
  font-family: var(--mono); font-size: 8.5px; color: var(--text-2);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 5px;
}
.ex-pill:hover { color: var(--text); border-color: var(--accent); }

/* shock transmission network */
.shocknet { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-height: 0; }
.sn-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.sn-src { font-family: var(--mono); font-size: 12px; color: var(--amber); font-weight: 700; }
.sn-arrow { color: var(--muted); font-size: 10px; }
.sn-mkt { font-family: var(--mono); font-size: 11px; color: var(--text-2); }
.sn-mkt b { font-size: 13px; }
.sn-metatag { font-family: var(--mono); font-size: 8.5px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.sn-neg { color: var(--red); } .sn-pos { color: var(--green); }
.sn-rows { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; justify-content: center; }
.sn-row { display: grid; grid-template-columns: 44px 22px 1fr 58px auto; align-items: center; gap: 6px; padding: 1px 0; }
.sn-tkr { font-family: var(--mono); font-size: 10px; color: var(--text); }
.sn-hop { font-family: var(--mono); font-size: 8px; color: var(--muted); text-align: center; border: 1px solid var(--line-2); border-radius: 2px; }
.sn-track { position: relative; height: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.sn-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 1px; opacity: .8; }
.sn-bar.sn-neg { background: var(--red); } .sn-bar.sn-pos { background: var(--green); }
.sn-val { font-family: var(--mono); font-size: 10px; text-align: right; }
.sn-path { font-family: var(--mono); font-size: 8.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sn-foot { font-family: var(--mono); font-size: 8.5px; color: var(--faint); border-top: 1px dashed var(--line-2); padding-top: 4px; }

/* source audit */
.audit { display: flex; flex-direction: column; }
.audit-row {
  display: grid; grid-template-columns: 120px 1.4fr 78px 58px 2fr; align-items: center; gap: 8px;
  padding: 3px 4px; border-bottom: 1px solid var(--line); font-size: 10px;
}
.au-prov { font-family: var(--mono); color: var(--text); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.au-ds { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.au-rows { font-family: var(--mono); color: var(--muted); text-align: right; font-size: 9px; }
.au-st { font-family: var(--mono); font-size: 8.5px; text-transform: uppercase; text-align: center; padding: 0 5px; border-radius: 2px; }
.st-ok { color: var(--green); background: rgba(94,165,133,0.12); }
.st-partial { color: var(--amber); background: rgba(196,163,95,0.12); }
.st-gap { color: var(--red); background: rgba(198,127,133,0.12); }
.au-gap { color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* assumption profile — COMPACT: a vertical shock slider (left) + ONE dense grid of
   label|input cells (right) holding BOTH the run parameters and the per-ticker betas.
   The cells pack to fill whatever width the card is given, so there is no right-hand
   dead space; the card hugs its content (layoutMasonry pins it to the top of its row).
   Slider min at bottom → drag up = milder. */
.assume { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; }
.as-shock { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 2px 12px 2px 2px; border-right: 1px solid var(--line); }
.as-vlab { font-size: 8.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; text-align: center; max-width: 74px; line-height: 1.3; }
.as-vrange {
  writing-mode: vertical-lr; direction: rtl;                /* vertical, min at bottom → drag up = milder */
  -webkit-appearance: slider-vertical;                       /* fallback for older engines */
  width: 22px; height: 128px;                                /* fixed, compact — not stretched to the row */
  padding: 0; margin: 3px 0; border: 0; background: transparent;
  accent-color: var(--accent); color-scheme: dark; cursor: ns-resize;
}
.as-shock .as-out { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--text); }
/* right side: a single auto-fill grid of compact cells (run params + betas together) */
.as-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px 8px; align-content: start; align-items: end; min-width: 0; }
.as-cap { grid-column: 1 / -1; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 5px; margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--line); }
.as-fields > .as-cap:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.as-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.as-clab { font-size: 9px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-input {
  font-family: var(--mono); font-size: 11px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 3px 6px; width: 100%;
  color-scheme: dark;
}
.as-out { font-family: var(--mono); font-size: 10px; color: var(--text-2); }
.as-beta { width: 100%; }

/* abstain / unrenderable block */
.abstain { display: flex; flex-direction: column; gap: 6px; }
.ab-reason { font-family: var(--mono); font-size: 12px; color: var(--c-abst); display: flex; align-items: center; gap: 6px; }
.ab-reason b { color: var(--amber); }
.ab-detail { font-size: 10.5px; color: var(--text-2); }
.ab-line { font-size: 10px; color: var(--muted); }
.ab-k { font-family: var(--mono); font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-right: 6px; }
.verb { font-family: var(--mono); font-size: 9px; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 5px; margin: 0 3px 3px 0; display: inline-block; }

/* ============================================================ drawer */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 90vw; z-index: 65;
  background: var(--panel); border-left: 1px solid var(--line-2);
  transform: translateX(100%); transition: transform .16s ease; display: flex; flex-direction: column;
  box-shadow: -12px 0 30px rgba(0,0,0,0.4);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.drawer-kick { font-family: var(--mono); font-size: 8.5px; letter-spacing: .1em; color: var(--faint); }
.drawer-title { margin: 2px 0 0; font-size: 13px; font-weight: 600; color: var(--text); }
.drawer-x { font-size: 18px; line-height: 1; color: var(--muted); background: transparent; border: 0; }
.drawer-x:hover { color: var(--text); }
.drawer-body { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.src-card { border: 1px solid var(--line); border-radius: 2px; padding: 8px; background: var(--panel-2); }
.src-card.meth { border-color: var(--line-2); background: var(--head); }
.src-card.muted { color: var(--muted); }
.src-h { font-family: var(--mono); font-size: 8.5px; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.src-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.src-meta span { font-family: var(--mono); font-size: 8.5px; color: var(--text-2); background: var(--head); border: 1px solid var(--line); border-radius: 2px; padding: 0 4px; }
.src-tag { font-family: var(--mono); font-size: 9px; color: var(--muted); margin: 2px 0; word-break: break-all; }
.src-url { display: block; font-family: var(--mono); font-size: 9px; margin: 3px 0; word-break: break-all; }
.src-quote { margin: 4px 0 0; font-size: 10px; color: var(--text-2); border-left: 2px solid var(--line-2); padding-left: 6px; font-style: italic; }
/* calculation detail (click a CALC value) */
.calc-eq { font-family: var(--mono); font-size: 12px; color: var(--text); background: var(--head); border: 1px solid var(--line-2); border-radius: 2px; padding: 8px; margin-bottom: 6px; }
.calc-eq .res { color: var(--c-calc); font-weight: 700; }
.calc-inputs { display: flex; flex-direction: column; gap: 4px; }
.calc-in { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-family: var(--mono); font-size: 10px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 2px; background: var(--panel-2); }
.calc-in .lab { color: var(--text-2); }
.calc-in .num { color: var(--text); }
.calc-in.src { cursor: pointer; }
.calc-in.src:hover { border-color: var(--accent); }
.calc-in .go { color: var(--muted); font-size: 9px; }

/* ============================================================ detail modal (expand a widget) */
.modal { position: fixed; inset: 0; z-index: 55; background: rgba(3,5,7,0.6); display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-box { width: 1200px; max-width: 94vw; height: 78vh; max-height: 88vh; background: var(--panel); border: 1px solid var(--line-2); border-radius: 3px; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,0.55); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--head); }
.modal-head .mtitle { font-size: 13px; font-weight: 600; color: var(--text); }
.modal-head .msub { font-size: 9.5px; color: var(--muted); margin-left: 8px; }
.modal-x { font-size: 18px; line-height: 1; color: var(--muted); background: transparent; border: 0; }
.modal-x:hover { color: var(--text); }
.modal-body { flex: 1; overflow: auto; padding: 12px; display: grid; grid-template-columns: 1fr 320px; gap: 12px; }
.modal-main { min-width: 0; }
.modal-side { min-width: 0; border-left: 1px solid var(--line); padding-left: 12px; overflow: auto; }
.modal-side .src-h { margin-top: 8px; }
.modal-meth { font-size: 10.5px; color: var(--text-2); line-height: 1.5; }

/* ============================================================ palette / audit list */
.palette { position: fixed; inset: 0; z-index: 60; background: rgba(3,5,7,0.55); display: flex; align-items: flex-start; justify-content: center; }
.palette[hidden] { display: none; }
.pal-box { margin-top: 12vh; width: 640px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line-2); border-radius: 3px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); overflow: hidden; }
.pal-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.pal-kick { font-family: var(--mono); font-size: 8.5px; letter-spacing: .1em; color: var(--faint); }
.pal-input { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 2px; padding: 5px 8px; outline: none; }
.pal-x { font-family: var(--mono); font-size: 9px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 2px; padding: 2px 6px; background: var(--panel-2); }
.pal-list { max-height: 46vh; overflow: auto; padding: 4px; }
.pal-item { font-family: var(--mono); font-size: 11px; color: var(--text-2); padding: 6px 8px; border-radius: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item.sel, .pal-item:hover { background: rgba(107,147,196,0.1); color: var(--text); }
.pal-item.muted { color: var(--faint); cursor: default; }
/* audit rows */
.audit-log { display: flex; flex-direction: column; }
.al-row { display: grid; grid-template-columns: 150px 120px 90px 1fr; gap: 8px; align-items: center; padding: 5px 8px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 9.5px; }
.al-row.head { color: var(--muted); text-transform: uppercase; font-size: 8px; letter-spacing: .05em; position: sticky; top: 0; background: var(--head); }
.al-snow { color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-when { color: var(--text-2); }
.al-asof { color: var(--amber); }
.al-q { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================ tooltip */
.tooltip {
  position: fixed; z-index: 80; display: none; pointer-events: none;
  background: #05070a; border: 1px solid var(--line-2); border-radius: 2px; padding: 5px 8px;
  font-family: var(--mono); font-size: 10px; color: var(--text); max-width: 280px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.tooltip b { color: var(--text); }
.tooltip .muted { color: var(--muted); }
.tooltip .hint { color: var(--faint); }

/* narrow screens: JS (layoutMasonry) stacks every card full-width; keep the modal fix */
@media (max-width: 1100px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-side { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 10px; }
}

/* ============================================================ 2026-07-09 readability + responsive pass
   Appended as OVERRIDES so the dense base terminal view is unchanged where it already
   works. Three safe wins here; the structural items (vertical shock slider, shrunk
   assumption panel, KPI-strip entity monitor, user/admin warning split, mobile card
   stacking) live in app.js and land separately. */

/* (1) Kill the native up/down spinner steppers on every number input
   (horizon / sim-paths / vol-mult / beta). Keyboard + typing still work. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* (2) Progressive disclosure: the collapsed card stays dense, but when a widget is
   EXPANDED into the detail modal the data becomes big enough to read across a room. */
.modal-body { font-size: 12.5px; }
.modal-head .mtitle { font-size: 15px; }
.modal-body .kpi-val { font-size: 20px; }
.modal-body .kpi-label { font-size: 11px; }
.modal-body table.dense { font-size: 13px; }
.modal-body table.dense th { font-size: 10.5px; }
.modal-body .tor-lab, .modal-body .tor-val, .modal-body .tor-base { font-size: 12px; }
.modal-body .tl-lab { font-size: 12.5px; }
.modal-body .tl-date, .modal-body .tl-tkr, .modal-body .tl-val, .modal-body .badge { font-size: 11px; }
.modal-body .ex-type { font-size: 12px; }
.modal-body .ex-count { font-size: 15px; }
.modal-body .ex-pill, .modal-body .ex-bar { font-size: 10.5px; }
.modal-body .modal-meth { font-size: 12px; }

/* (3) Responsive: nudge the base up as the viewport shrinks so a smaller screen
   doesn't force you to lean in — and give controls real touch targets on phones. */
@media (max-width: 1400px) { body { font-size: 12.5px; } }
@media (max-width: 1100px) {
  body { font-size: 12.5px; }
  .kpi-val { font-size: 16px; }
  .ctx { height: auto; flex-wrap: wrap; white-space: normal; padding: 4px 8px; }
}
@media (max-width: 640px) {
  body { font-size: 14px; overflow: auto; }
  .wb { height: auto; min-height: 100vh; }
  .card-head { min-height: 34px; }
  .act, .mini, .tab, .ctx-btn, .cls-tog { padding: 6px 9px; }   /* ~44px tap target */
  .cmd { height: 48px; }
  .cmd-input { font-size: 15px; }
  .as-input { font-size: 15px; padding: 8px; }
  .kpi-val { font-size: 18px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(46%, 1fr)); }
  .drawer { width: 100vw; max-width: 100vw; }
  .modal-box { width: 96vw; height: 88vh; }
  .modal-body { grid-template-columns: 1fr; padding: 10px; }
}

/* ============================================================ 2026-07-10 structural pass
   Warning tiering (U4) + a mobile guard for the vertical shock slider. */

/* (U4) Warnings drawer: user-facing warnings (data gaps / abstentions) render large
   and readable; admin/diagnostic ones (run-state, internal fleet/store/lane names)
   are tucked into a de-emphasized, collapsed "diagnostics" disclosure. */
.warns { display: flex; flex-direction: column; gap: 7px; }
.warn-item {
  font-size: 12px; line-height: 1.5; color: var(--text-2);
  border-left: 2px solid var(--amber); background: rgba(196,163,95,0.06);
  border-radius: 2px; padding: 7px 9px;
}
.warn-item.user { font-size: 12.5px; color: var(--text); }
.warn-diag { margin-top: 4px; border-top: 1px dashed var(--line-2); padding-top: 6px; }
.warn-diag > summary {
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); cursor: pointer; padding: 3px 0; list-style: none;
}
.warn-diag > summary::-webkit-details-marker { display: none; }
.warn-diag > summary:hover { color: var(--muted); }
.warn-diag > summary::before { content: "▸ "; }
.warn-diag[open] > summary::before { content: "▾ "; }
.warn-diag .warns { margin-top: 6px; }
.warn-diag .warn-item.diag {
  font-size: 9.5px; line-height: 1.45; color: var(--muted);
  border-left-color: var(--faint); background: transparent; padding: 4px 8px;
}

/* mobile guard: keep the vertical slider slim (the ≤640 .as-input override above
   would otherwise pad it) and give it a taller touch target */
@media (max-width: 640px) {
  .as-vrange { padding: 0; border: 0; height: 150px; width: 26px; }
  .as-shock .as-out { font-size: 16px; }
  .assume { gap: 14px; }
}

/* RAW panel — provenance-first: show HOW each value was pulled (source locator +
   the literal fetch url/query + the verbatim quote), then the raw data JSON. */
.raw-prov { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.raw-h { font-family: var(--mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.raw-src { border-left: 2px solid var(--line-2); padding: 4px 0 4px 8px; }
.raw-k { font-family: var(--mono); font-size: 10px; color: var(--text-2); word-break: break-all; }
.raw-k b { color: var(--text); }
.raw-k a { color: var(--accent, #6b93c4); }
.raw-q { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.raw-prov.muted, .raw-src .muted { color: var(--muted); font-size: 10px; }
.card-raw pre { margin: 0; }
