/*
 * Operator dashboard styling — 2026-09-12 redesign, v2 (sidebar console).
 *
 * Hand-written, no framework — the tier ships no third-party CSS and loads nothing
 * cross-origin, matching the `default-src 'self'` CSP in apps/web/nginx.conf. Every class the
 * views emit (apps/web/src) is preserved. The layout is a left navigation rail with the
 * session pinned to its foot, a content column with a page header, sub-tabs for views that
 * used to stack several sections down one page, a quick filter and a summary strip above
 * long lists, and tables built for scanning: zebra rows, hover shading, sticky headers.
 */

:root {
  --bg: #0a0e15;
  --bg-2: #0d121b;
  --surface: #111725;
  --surface-2: #171f30;
  --surface-3: #1e283d;
  --surface-4: #26324b;
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.26);
  --ink: #e9edf4;
  --ink-2: #b4bfcf;
  --ink-3: #7e8a9c;
  --ink-dim: var(--ink-2);
  --accent: #5b8def;
  --accent-2: #38bdf8;
  --accent-ink: #06121f;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px -16px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --rail: 248px;
  --content-max: 1440px;
  --pad: clamp(18px, 2.4vw, 36px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); }
::selection { background: color-mix(in oklab, var(--accent) 35%, transparent); }
.booting { padding: 2rem; color: var(--ink-3); }

/* ---------------------------------------------------------------- shell / rail ---- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 1.1rem 0.9rem 0.9rem;
  background: linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.2rem 0.5rem 1.1rem; }
.brandMark {
  flex: none; display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.02em;
  box-shadow: 0 8px 20px -10px color-mix(in oklab, var(--accent) 85%, transparent);
}
.brandText { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brandName { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.01em; white-space: nowrap; }
.brandTag { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); margin-top: 0.15rem; }

.nav { display: contents; }
.navviews { display: flex; flex-direction: column; gap: 1rem; }
.navGroup { display: flex; flex-direction: column; gap: 0.1rem; }
.navGroupLabel {
  color: var(--ink-3); font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  padding: 0.4rem 0.6rem 0.35rem;
}
.navbtn {
  appearance: none; display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--ink-2); font: inherit; font-size: 0.875rem; font-weight: 500;
  padding: 0.5rem 0.65rem; cursor: pointer; position: relative;
  transition: color 120ms ease, background-color 120ms ease;
}
.navbtn::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}
.navbtn:hover { color: var(--ink); background: color-mix(in oklab, var(--surface-3) 70%, transparent); }
.navbtn.active { color: var(--ink); background: color-mix(in oklab, var(--accent) 16%, var(--surface-2)); font-weight: 600; }
.navbtn.active::before { background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.navbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.navuser {
  margin-top: auto; padding-top: 0.9rem; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.6rem;
}
.who { display: flex; align-items: center; gap: 0.6rem; min-width: 0; padding: 0 0.3rem; }
.avatar {
  flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-4); color: var(--ink); font-size: 0.8rem; font-weight: 700; border: 1px solid var(--line-strong);
}
.whoText { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.whoName { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whoSep { display: none; }
.whoRole { font-size: 0.72rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navuserActions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* -------------------------------------------------------------------- content ---- */
.content { min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: var(--content-max); padding: calc(var(--pad) * 0.8) var(--pad) 4rem; }
.view h1, .detailTitle { margin: 0 0 0.9rem; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.detailMeta { color: var(--ink-3); margin-bottom: 0.9rem; }
.view, .viewbody, .tabPanel { min-width: 0; }
.viewbody, .tabPanel { overflow-x: auto; }

/* Sub-tabs: one section on screen at a time (v2). */
.subnav {
  display: inline-flex; gap: 0.2rem; flex-wrap: wrap; align-items: center;
  padding: 0.25rem; margin: -0.2rem 0 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-1);
}
.subtab {
  appearance: none; background: transparent; border: 0; border-radius: 999px;
  color: var(--ink-2); font: inherit; font-size: 0.84rem; font-weight: 500;
  padding: 0.42rem 0.95rem; cursor: pointer; white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}
.subtab:hover { color: var(--ink); background: var(--surface-3); }
.subtab.active { color: var(--ink); background: var(--surface-4); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-strong); }
.subtab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sectionNote { margin: -0.4rem 0 0.9rem; }
.sectionNote > summary { cursor: pointer; font-size: 0.78rem; color: var(--ink-3); }
.sectionNote .note { padding: 0.3rem 0 0; font-size: 0.85rem; max-width: 80ch; }

/* Summary strip (v2). */
.kpis { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: stretch; margin: 0.2rem 0 1rem; }
.kpi {
  min-width: 9.5rem; padding: 0.7rem 0.95rem; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  border-left: 3px solid var(--line-strong);
}
.kpi.ok { border-left-color: var(--ok); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.bad { border-left-color: var(--bad); }
.kpi.live { border-left-color: var(--accent-2); }
.kpiValue { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpiLabel { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 0.25rem; }
.kpiCaption { align-self: center; color: var(--ink-3); font-size: 0.8rem; padding-left: 0.3rem; }

/* Quick filter (v2). */
.tableBlock { min-width: 0; }
.tableTools { display: flex; gap: 0.75rem; align-items: center; margin: 0.2rem 0 0.6rem; }
.quickFilter {
  width: min(28rem, 100%); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.5rem 0.95rem; font: inherit; font-size: 0.85rem;
}
.quickFilter::placeholder { color: var(--ink-3); }
.quickFilter:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.tableCount { color: var(--ink-3); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------------------- buttons ---- */
.btn, .tabbtn, .groupbtn {
  appearance: none;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 0.38rem 0.75rem; cursor: pointer; font: inherit; font-size: 0.85rem; font-weight: 500;
  line-height: 1.3; transition: border-color 120ms ease, background-color 120ms ease, transform 60ms ease;
}
.btn.small { padding: 0.28rem 0.6rem; font-size: 0.78rem; }
.btn:hover, .tabbtn:hover, .groupbtn:hover { border-color: color-mix(in oklab, var(--accent) 60%, var(--line-strong)); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.tabbtn.active, .groupbtn.active { background: color-mix(in oklab, var(--accent) 18%, var(--surface-2)); border-color: color-mix(in oklab, var(--accent) 55%, var(--line-strong)); color: var(--ink); font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { background: color-mix(in oklab, var(--accent) 88%, white); }
.btn:focus-visible, .tabbtn:focus-visible, .groupbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------------------------------------------------------------- banners ---- */
.banner-slot:empty { display: none; }
.banner {
  margin: calc(var(--pad) * 0.8) var(--pad) 0; max-width: var(--content-max);
  padding: 0.65rem 0.9rem 0.65rem 1rem; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); border-left-width: 4px; background: var(--surface-2); box-shadow: var(--shadow-1);
}
.banner.ok { border-left-color: var(--ok); }
.banner.warn { border-left-color: var(--warn); }
.banner.bad { border-left-color: var(--bad); background: color-mix(in oklab, var(--bad) 14%, var(--surface-2)); }
.card .banner, .mutationForm .banner, .viewbody .banner { margin: 0 0 0.7rem; box-shadow: none; max-width: none; }
.loading, .empty, .note { color: var(--ink-3); padding: 0.5rem 0; }
.note.warn { color: var(--warn); }

/* ---------------------------------------------------------------- tables ---- */
table.grid {
  width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 0.2rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
  box-shadow: var(--shadow-1);
}
table.grid th, table.grid td { text-align: left; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 36rem; overflow-wrap: break-word; word-break: normal; }
table.grid td.nowrap, table.grid td.ticker { white-space: nowrap; }
table.grid thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--ink-3);
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; white-space: nowrap;
}
table.grid tbody tr:nth-child(even) td { background: color-mix(in oklab, var(--surface-2) 55%, var(--surface)); }
table.grid tbody tr:hover td { background: color-mix(in oklab, var(--accent) 12%, var(--surface-2)); }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.grid tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.ticker, table.grid td:first-child { font-weight: 600; }
table.grid td.muted, .muted { color: var(--ink-3); font-weight: 400; }
table.grid tbody tr[hidden] { display: none; }
.entityTable td:first-child { color: var(--ink); }

.pager { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.9rem; flex-wrap: wrap; }
.tabGroups, .tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.tabGroups { padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.tabPanel { margin-top: 0.9rem; }

/* ----------------------------------------------------------------- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem 1.1rem; margin-bottom: 0.9rem; box-shadow: var(--shadow-1); }
.card h3 { margin: 0 0 0.6rem; font-size: 0.72rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.kv { display: grid; grid-template-columns: minmax(9rem, 18rem) 1fr; gap: 0.25rem 1rem; }
.kvkey { color: var(--ink-3); }
.kvval { overflow-wrap: anywhere; }

/* --------------------------------------------------------------- badges ---- */
.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.1rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-3); color: var(--ink-2);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.01em; line-height: 1.5; white-space: nowrap;
}
.pill.ok, .pill.published, .pill.publish, .pill.success { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, transparent); background: color-mix(in oklab, var(--ok) 13%, var(--surface)); }
.pill.warn, .pill.held, .pill.hold, .pill.publish_with_shortfall, .pill.partial { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 40%, transparent); background: color-mix(in oklab, var(--warn) 13%, var(--surface)); }
.pill.bad, .pill.failed { color: var(--bad); border-color: color-mix(in oklab, var(--bad) 40%, transparent); background: color-mix(in oklab, var(--bad) 13%, var(--surface)); }
.pill.live, .pill.running, .pill.dossier { color: var(--accent-2); border-color: color-mix(in oklab, var(--accent-2) 40%, transparent); background: color-mix(in oklab, var(--accent-2) 12%, var(--surface)); }
.pill.legacy, .pill.na { color: var(--ink-3); border-color: var(--line-strong); background: transparent; }
.pill.running::before, .pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ----------------------------------------------------------------- login ---- */
.shell:has(> .content > .main > .login) { grid-template-columns: 1fr; }
.shell:has(> .content > .main > .login) .sidebar { display: none; }
.login { max-width: 25rem; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 0.45rem; padding: 1.5rem 1.6rem 1.6rem; box-shadow: var(--shadow-2); }
.login h1 { margin: 0 0 0.9rem; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; }
.login label { color: var(--ink-3); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-top: 0.4rem; }
.login input { background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0.6rem 0.75rem; font: inherit; }
.login input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login .btn { margin-top: 0.9rem; padding: 0.6rem 0.75rem; }

.back { margin-bottom: 0.9rem; }

/* ---- Sections within a view ---- */
.sectionHead { margin: 1.4rem 0 0.3rem; font-size: 1.05rem; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; }
.viewbody + .sectionHead { border-top: 1px solid var(--line); padding-top: 1.1rem; }
.group { margin-bottom: 1.3rem; }
.groupHead { margin: 0.9rem 0 0.25rem; font-size: 0.72rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.kvscalar { color: var(--ink-3); }

/* ---- Report / entity detail head ---- */
.detailHead { margin-bottom: 1rem; }
.titleRow { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.titleRow h2 { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.015em; }
.metaGrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.6rem 1.2rem; margin-top: 0.7rem; padding: 0.85rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.metaGrid .k { color: var(--ink-3); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.metaGrid .v { overflow-wrap: anywhere; margin-top: 0.1rem; }
.assetFacts { color: var(--ink-2); margin: 0.5rem 0; }
/* Entity detail: the long body becomes a two-column layout above 1100px (v2). */
.entityDetail .detailHead { display: grid; grid-template-columns: 1fr; gap: 0.4rem; }
@media (min-width: 1100px) {
  .entityDetail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 1.5rem; align-items: start; }
  .entityDetail > .detailHead { grid-column: 1 / -1; }
  .entityDetail > h3, .entityDetail > .sectionHead, .entityDetail > .groupHead { grid-column: 1 / -1; }
}

/* ---- Overview tab: composer markdown ---- */
.overviewGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 0.9rem; margin-top: 0.9rem; }
.mdCard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow-1); }
.mdFootnote { margin-top: 1rem; padding-top: 0.7rem; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 0.9em; }
.content-md h1 { font-size: 1.2rem; margin: 0 0 0.4rem; letter-spacing: -0.01em; }
.content-md h2 { font-size: 1.02rem; margin: 0 0 0.4rem; }
.content-md h4 { font-size: 0.94rem; margin: 0.7rem 0 0.3rem; color: var(--ink-2); }
.content-md h5 { font-size: 0.88rem; margin: 0.6rem 0 0.25rem; color: var(--ink-2); }
.content-md p { margin: 0 0 0.6rem; }
.content-md ul { margin: 0 0 0.6rem; padding-left: 1.2rem; }
.content-md a { color: var(--accent); }
.content-md { overflow-x: auto; }
table.mdTable { border-collapse: collapse; margin: 0.4rem 0 0.7rem; }
table.mdTable th, table.mdTable td { text-align: left; padding: 0.3rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mdTable th { color: var(--ink-3); font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }

/* ================================================================================
 * Report detail: the bespoke tab renderers (lane W4). Served rules kept, tokens updated.
 * ================================================================================ */
.branchCard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 13px 15px; margin-bottom: 10px; box-shadow: var(--shadow-1); }
.branchCard .bTitle { font-weight: 650; font-size: 13.5px; margin-bottom: 4px; }
.branchCard .bTitle.link { cursor: pointer; color: var(--accent); }
.branchCard .bMeta { font-size: 11px; color: var(--ink-3); margin-bottom: 8px; }
.branchCard .bField { font-size: 12.5px; margin-bottom: 4px; line-height: 1.55; }
.branchCard .bField b { color: var(--ink-3); font-weight: 600; }
.branchCard a { color: var(--accent); }
.branchCard p { margin: 4px 0 0; line-height: 1.55; }
.bCols { display: grid; grid-template-columns: minmax(0, 76ch) minmax(260px, 1fr); gap: 2px 36px; align-items: start; margin-top: 4px; }
.bCols .bMain p { margin-top: 0; }
.bCols .bSide { font-size: 12.5px; border-left: 1px solid var(--line); padding-left: 20px; }
.bCols .bSide .bField { margin-bottom: 9px; }
@media (max-width: 900px) { .bCols { grid-template-columns: 1fr; } .bCols .bSide { border-left: none; padding-left: 0; } }
.overviewGrid .branchCard { margin-bottom: 0; }
.overviewGrid .bCols { grid-template-columns: 1fr; }
.overviewGrid .bCols .bSide { border-left: none; padding-left: 0; }
.overviewGrid .mdBody { overflow: hidden; min-width: 0; }
.reviewCard.reviewHighlight { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent); }

.scenarioGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-bottom: 6px; }
.scenarioCard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--shadow-1); }
.scenarioCard .sHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.scenarioCard .sScenario { font-weight: 650; text-transform: capitalize; }
.scenarioCard .sProb { font-family: var(--mono); color: var(--accent); font-size: 12px; font-weight: 600; }
.scenarioCard .sRange { font-family: var(--mono); font-size: 13px; margin-bottom: 2px; }
.scenarioCard .sRangeDollar { font-family: var(--mono); font-size: 12px; margin-bottom: 6px; }
.scenarioCard.scenario-positive { border-color: color-mix(in oklab, var(--ok) 35%, var(--line)); background: color-mix(in oklab, var(--ok) 7%, var(--surface)); }
.scenarioCard.scenario-negative { border-color: color-mix(in oklab, var(--bad) 35%, var(--line)); background: color-mix(in oklab, var(--bad) 7%, var(--surface)); }
.scenarioCard.scenario-neutral { border-color: var(--line); }
.scenarioCard p { font-size: 12px; color: var(--ink-2); margin: 4px 0 0; line-height: 1.55; }
.scenarioCard .bMeta { font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.scenarioCard .bField { font-size: 12px; margin-top: 4px; }
.delta-positive { color: var(--ok); }
.delta-negative { color: var(--bad); }
.delta-neutral { color: var(--ink); }
.windowLabel { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; margin: 18px 0 8px; }
.forecastNote { color: var(--ink-3); font-size: 11px; margin-top: 12px; font-style: italic; }
.chartNote { color: var(--ink-3); font-size: 11.5px; line-height: 1.6; margin-top: 10px; }
.evLink { color: var(--accent); cursor: pointer; text-decoration: underline; }
.filters { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.filters .count { color: var(--ink-3); font-size: 12px; }
.filters .sortLabel { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.filters select, .viewbody select { background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0.3rem 0.5rem; font: inherit; font-size: 12px; }
.filters select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tabPanel h4 { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--ink); }

/* ============================ Lane W7 — mutation forms and grouped operator surfaces ===== */
.mutationForm { margin: 10px 0; padding: 12px 14px; }
.mutationForm h3 { margin: 0 0 6px; font-size: 0.95rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.mutationForm .formBanner:empty { display: none; }
.mutationForm .formBanner .banner { margin: 0 0 10px; }
.field { margin: 8px 0; }
.field label { display: block; font-size: 12px; color: var(--ink-3); }
.fieldLabel { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.fieldHelp { font-size: 11px; margin-top: 3px; }
.field input[type="text"], .field input[type="password"], .field textarea, .field select {
  display: block; width: 100%; max-width: 40rem; margin-top: 3px;
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 0.35rem 0.5rem; font: inherit; font-size: 13px;
}
.field input[type="checkbox"] { display: inline-block; width: auto; margin-right: 6px; }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.formActions { display: flex; gap: 8px; margin-top: 10px; }
.btn.danger { border-color: color-mix(in oklab, var(--bad) 45%, var(--line-strong)); color: var(--bad); }
.btn[data-armed="1"] { border-color: var(--bad); color: var(--bad); font-weight: 650; background: color-mix(in oklab, var(--bad) 12%, var(--surface-2)); }
.subtabGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 2px 12px; margin-top: 4px; }
.subtabOption { font-size: 12px; color: var(--ink); }
.rowForms { padding-left: 8px; border-left: 2px solid var(--line-strong); }
.collapsedSection { margin: 10px 0; }
.collapsedSection > summary { cursor: pointer; font-size: 12px; color: var(--ink-3); padding: 4px 0; }
.queueCard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-1); }
.queueCard .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.cardMore > summary { cursor: pointer; font-size: 11.5px; color: var(--ink-3); }
.count { color: var(--ink-3); font-size: 12.5px; margin: 4px 0 8px; }
.muted { color: var(--ink-3); font-size: 12px; }
.empty { color: var(--ink-3); font-size: 12.5px; padding: 8px 0; }
.pmStat { display: inline-block; margin-right: 12px; min-width: 200px; vertical-align: top; }
.ltsControls { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 12px; }
.ltsControls label { display: flex; gap: 6px; align-items: center; }
.citation { padding: 6px 0; border-bottom: 1px solid var(--line); }
.citation:last-child { border-bottom: none; }
.cTitle { font-size: 13px; }
.cMeta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.lifetimeSources .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 12px; margin: 8px 0; }
.lifetimeSources .kv .k { color: var(--ink-3); }
.lifetimeSources .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }

/* ------------------------------------------------- Runs tab: nightly progress ---- */
.runs-progress-line { color: var(--ink); font-size: 0.95rem; font-weight: 500; margin: 0.2rem 0 0.5rem; }
.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 4px 0 10px; max-width: 720px; border: 1px solid var(--line); }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 60%, transparent); transition: width 0.4s ease; }
.runs-status-line { margin-bottom: 10px; display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ------------------------------------------------------------ small screens ---- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0.8rem var(--pad); }
  .navviews { flex-direction: row; flex-wrap: wrap; gap: 0.6rem 1.2rem; }
  .navGroup { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .navbtn { width: auto; }
  .navuser { margin-top: 0.6rem; flex-direction: row; align-items: center; justify-content: space-between; }
  .kv { grid-template-columns: 1fr; }
}

/* ===================================================================== v3 additions ===== */
/* Filterable tables: sortable headers and the per-column filter row. */
table.grid.compact th, table.grid.compact td { padding: 0.45rem 0.7rem; font-size: 0.86rem; }
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--ink); }
table.grid th.sortable .sortMark::after { content: ↕; opacity: 0.35; margin-left: 0.35rem; font-size: 0.75rem; }
table.grid th.sortable.sorted .sortMark::after { content: ↑; opacity: 1; color: var(--accent-2); }
table.grid th.sortable.sorted.desc .sortMark::after { content: ↓; }
table.grid thead tr.filterRow th { top: 2.35rem; padding: 0.3rem 0.5rem; background: var(--surface-2); }
.colFilter {
  width: 100%; min-width: 4.5rem; background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0.25rem 0.5rem; font: inherit; font-size: 0.78rem; font-weight: 400; text-transform: none; letter-spacing: 0;
}
.colFilter::placeholder { color: var(--ink-3); }
.colFilter:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.tableCaption { color: var(--ink-3); font-size: 0.8rem; }

/* Dossier detail v3: chapter buttons, a sticky section rail, and the chapter as a flow of sections. */
.detail .back { margin-bottom: 0.9rem; }
.tabGroups { display: inline-flex; gap: 0.2rem; flex-wrap: wrap; align-items: center; padding: 0.25rem; margin: 0.2rem 0 1.1rem; border: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-1); }
.groupbtn { border: 0; border-radius: 999px; background: transparent; padding: 0.42rem 0.95rem; font-size: 0.84rem; }
.groupbtn:hover { background: var(--surface-3); border-color: transparent; }
.groupbtn.active { background: var(--surface-4); border-color: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.detailBody { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.sectionRail { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 0.1rem; padding: 0.4rem 0; border-left: 1px solid var(--line); }
.railHead { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); padding: 0.2rem 0.9rem 0.5rem; }
.railItem { display: block; width: 100%; text-align: left; appearance: none; background: transparent; border: 0; cursor: pointer; font: inherit; color: var(--ink-2); font-size: 0.85rem; padding: 0.38rem 0.9rem; margin-left: -1px; border-left: 2px solid transparent; }
.dossierSection:focus { outline: none; box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 45%, transparent); }
.railItem:hover { color: var(--ink); border-left-color: var(--line-strong); }
.railItem:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dossierFlow { margin-top: 0; }
.dossierSection { padding: 1.1rem 1.25rem 1.25rem; margin-bottom: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); scroll-margin-top: 1rem; }
.dossierSectionTitle { margin: 0 0 0.8rem; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
.dossierSection h4 { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 1rem 0 0.4rem; }
.dossierSection .card, .dossierSection .branchCard, .dossierSection .mdCard, .dossierSection .scenarioCard { box-shadow: none; background: var(--surface-2); }
.dossierSection .kpis.reconcile { margin: 0.2rem 0 0.9rem; }
@media (max-width: 1000px) {
  .detailBody { grid-template-columns: 1fr; }
  .sectionRail { position: static; flex-direction: row; flex-wrap: wrap; border-left: 0; border-bottom: 1px solid var(--line); padding-bottom: 0.5rem; margin-bottom: 0.8rem; }
  .railHead { width: 100%; }
  .railItem { border-left: 0; border-bottom: 2px solid transparent; padding: 0.3rem 0.6rem; }
}

/* ===================================================================== v4 additions ===== */
/* Financial Data & Macro read as the rest of the dossier: label/value rows with hairlines,
   grouped into uniform metric cards; long values stack under their label. */
.dossierSection .kv:not(.lifetimeSources *) { display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 0; }
.dossierSection .kv:not(.lifetimeSources *) > .k, .dossierSection .kv:not(.lifetimeSources *) > .v { padding: 0.45rem 0; border-bottom: 1px solid var(--line); min-width: 0; }
.dossierSection .kv:not(.lifetimeSources *) > .k { color: var(--ink-3); font-size: 0.82rem; }
.dossierSection .kv:not(.lifetimeSources *) > .v { color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dossierSection .kv:not(.lifetimeSources *) > :nth-last-child(-n + 2) { border-bottom: 0; }
.metricGroupGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 0.8rem; margin: 0.3rem 0 0.4rem; }
.metricCard { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 0.75rem 1rem 0.5rem; min-width: 0; }
.metricCard h5 { margin: 0 0 0.3rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); }
.dossierSection .metricCard .kv { grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; }
.dossierSection .metricCard .kv > .k { font-size: 0.8rem; }
.dossierSection .metricCard .kv > .v { text-align: right; font-size: 0.88rem; font-weight: 500; }
.dossierSection .metricCard .kv > .v.long { grid-column: 1 / -1; text-align: left; font-weight: 400; color: var(--ink-2); font-size: 0.84rem; line-height: 1.5; padding-top: 0; }
.dossierSection .metricCard .kv > .k:has(+ .v.long) { border-bottom: 0; padding-bottom: 0.15rem; }
.macroNote { margin-top: 0.7rem; max-width: 72ch; font-size: 0.82rem; line-height: 1.55; color: var(--ink-3); }
.dossierSection h4.teHead { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.teLabel { margin: 0.9rem 0 0.35rem; font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
@media (max-width: 860px) {
  .dossierSection .kv:not(.lifetimeSources *) { grid-template-columns: 1fr; }
  .dossierSection .kv:not(.lifetimeSources *) > .k { border-bottom: 0; padding-bottom: 0; }
}

/* Standard accounts: the Reports page opens on the most recent research day. */
.scopeBar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.65rem 0.9rem; margin-bottom: 0.8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.scopeText { color: var(--ink-2); font-size: 0.9rem; }
.scopeText strong { color: var(--ink); font-weight: 650; }
