/* ==========================================================================
   PE Risk Engine — shared design system
   One stylesheet for every page (/, /replay, /portfolio, /analyze, /login).
   Do not fork this file per page — add page-specific rules in the page's
   own <style> block, scoped to that page's own classes, and reuse the
   tokens/components defined here.
   ========================================================================== */

:root {
  /* --- color --- */
  --ink: #14213D;
  --paper: #FAFAF8;
  --slate: #5B6472;
  --line: #E3E1DC;

  --status-pass-text: #2F6B4F;
  --status-pass-bg: #E7F2EC;
  --status-fail-text: #A13D2E;
  --status-fail-bg: #FBEAE6;
  --status-warn-text: #835A1A;
  --status-warn-bg: #FBF1DE;

  --accent: #1F3A5F;
  --accent-hover: #16293F;
  --accent-tint: #E8EDF3;
  --accent-contrast: #FFFFFF;

  --surface: #FFFFFF;

  /* --- type --- */
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* --- 8px spacing scale --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 40px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 33, 61, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 33, 61, 0.08);

  color-scheme: light;
}

/* --- reset --- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 var(--space-2);
}
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 var(--space-3); }
h3 { font-size: 14px; margin: 0 0 var(--space-2); }

p { margin: 0 0 var(--space-3); }
p.subtitle { color: var(--slate); margin: 0 0 var(--space-4); line-height: 1.55; }
p.subtitle a { color: var(--accent); }

a { color: var(--accent); }

/* --- numeric figures: tabular, monospace --- */
.num, td.num, .tabular,
input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ==========================================================================
   Top nav — identical chrome on every page
   ========================================================================== */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-wrap: wrap;
}
.topnav-brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.topnav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.topnav-link {
  font-size: 13px;
  color: var(--slate);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.topnav-link:hover { color: var(--ink); background: var(--line); }
.topnav-link.is-active { color: var(--accent); background: var(--accent-tint); font-weight: 600; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-5);
}
.page-narrow { max-width: 760px; }

/* ==========================================================================
   App shell — sidebar navigation for the institutional pages (/, /company,
   /review, /audit). The four older single-purpose pages (/, /replay,
   /portfolio, /analyze pre-Cycle-18) kept .topnav above instead; that
   stays as-is for whichever of them still use it (see .app-legacy-note
   below) — this is additive, not a replacement of that component.
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}
.app-sidebar {
  flex: 0 0 220px;
  width: 220px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.app-sidebar-brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  padding: 0 var(--space-2);
  margin-bottom: var(--space-4);
  display: block;
}
.app-nav-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  padding: var(--space-3) var(--space-2) var(--space-1);
}
.app-nav-label:first-of-type { padding-top: 0; }
.app-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  padding: 7px var(--space-2);
  border-radius: var(--radius-sm);
}
.app-nav-link:hover { background: var(--line); }
.app-nav-link.is-active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.app-nav-link.is-disabled {
  color: var(--slate);
  cursor: default;
  pointer-events: none;
}
.app-nav-soon {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--slate);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  flex-shrink: 0;
}
.app-sidebar-footer {
  margin-top: auto;
  padding: var(--space-2);
  font-size: 12px;
}
.app-sidebar-footer a { color: var(--slate); text-decoration: none; }
.app-sidebar-footer a:hover { color: var(--ink); }

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: hidden;
}
.app-main .page { max-width: 1180px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    flex: 0 0 auto;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .app-sidebar-brand { width: 100%; }
  .app-nav-label { display: none; }
  .app-sidebar-footer { display: none; }
}

/* ==========================================================================
   Dashboard tiles — Overview's summary row
   ========================================================================== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}
.tile.tile-warn { border-color: color-mix(in srgb, var(--status-warn-text) 30%, var(--line)); background: var(--status-warn-bg); }
.tile.tile-fail { border-color: color-mix(in srgb, var(--status-fail-text) 30%, var(--line)); background: var(--status-fail-bg); }
.tile-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--slate);
  margin-bottom: var(--space-1);
}
.tile.tile-warn .tile-label { color: var(--status-warn-text); }
.tile.tile-fail .tile-label { color: var(--status-fail-text); }
.tile-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
}
.tile-sub { font-size: 11.5px; color: var(--slate); margin-top: 4px; }
.tile-link { display: block; margin-top: var(--space-2); font-size: 12px; font-weight: 600; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.section-head h2 { margin: 0; }
.section-head a { font-size: 12px; font-weight: 600; }

.empty-state {
  color: var(--slate);
  font-size: 12.5px;
  font-style: italic;
  padding: var(--space-3) 0;
}
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-item {
  padding: var(--space-2) 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
.feed-item:first-child { border-top: none; }
.feed-item .feed-when { color: var(--slate); font-size: 11px; }

/* ==========================================================================
   Coming-later capability notice — an honest "not built yet" state, never
   a fabricated empty table.
   ========================================================================== */
.not-built {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  color: var(--slate);
  font-size: 12.5px;
}
.not-built strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 4px; }

/* ==========================================================================
   Panels / cards
   ========================================================================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: var(--space-4); }

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: var(--space-4);
  align-items: start;
}
/* Grid items default to min-width: auto, which refuses to shrink a track
   below its content's intrinsic width -- without this, a wide results
   table blows out the 1fr column (and the whole page scrolls
   horizontally) instead of confining itself to .table-scroll's own
   overflow-x: auto, which is what lets that div's sticky-left columns
   (see .sticky-col) actually have a scroll container to stick within. */
.layout > .panel { min-width: 0; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.section-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--slate);
  margin: 0 0 var(--space-3);
}
.section-label:not(:first-child) { margin-top: var(--space-5); }

/* ==========================================================================
   Forms — identical across every page
   ========================================================================== */
.field { margin-bottom: var(--space-3); }
.field label,
label.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: var(--space-1);
}
.field input,
.field select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="url"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: border-color 0.1s ease;
}
input[type="number"] { font-family: var(--font-mono); }
.field input:focus,
.field select:focus,
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
input[type="file"] { font-size: 13px; font-family: var(--font-sans); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

table.rows { width: 100%; border-collapse: collapse; margin-bottom: var(--space-2); }
table.rows th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--slate);
  padding: 0 var(--space-1) var(--space-1);
}
table.rows td { padding: 0 var(--space-1) var(--space-2) 0; vertical-align: top; }
table.rows input, table.rows select { padding: 6px 8px; font-size: 12px; }

.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--slate); cursor: pointer; font-size: 15px; line-height: 1;
  padding: 4px 9px;
}
.icon-btn:hover { background: var(--line); color: var(--ink); }

.link-btn {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: none; border: none; cursor: pointer; padding: var(--space-1) 0;
}
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }

.slider-block { margin-bottom: var(--space-4); }
.slider-block .slider-head {
  display: flex; justify-content: space-between; font-size: 12px; margin-bottom: var(--space-1);
}
.slider-block .slider-head label { color: var(--slate); font-weight: 500; }
.slider-block .slider-head span.val {
  color: var(--accent); font-weight: 600; font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
button, .btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  border: none;
}
button.btn-primary, button#run-btn, button#submit-btn, button#ingest-btn {
  width: auto;
  background: var(--accent);
  color: var(--accent-contrast);
}
button.btn-primary:hover:not(:disabled),
button#run-btn:hover:not(:disabled),
button#submit-btn:hover:not(:disabled),
button#ingest-btn:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.55; cursor: default; }

button.secondary, .btn-secondary {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
}
button.secondary:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { background: var(--line); }
/* D7.14: a link styled as a secondary button is a bordered control, never colour-only text (axe `link-in-text-block`). */
a.button.secondary { background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); padding: 4px 12px; }
a.button.secondary:hover { background: var(--line); }

.error {
  color: var(--status-fail-text);
  font-size: 12px;
  margin-top: var(--space-2);
  white-space: pre-wrap;
}

/* ==========================================================================
   Tables — shared data-table conventions
   ========================================================================== */
table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
table.data-table th, table.data-table td {
  border-bottom: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  text-align: right;
  white-space: nowrap;
}
table.data-table th {
  background: var(--paper);
  color: var(--slate);
  font-weight: 600;
  font-size: 11px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}
table.data-table td:first-child, table.data-table th:first-child {
  text-align: left;
}
table.data-table tbody tr:hover td { background: var(--accent-tint); }

/* Sticky leading columns (Quarter, Status) so they stay visible while a
   wide covenant table scrolls horizontally. Once scrolled, a normal
   column's content can sit partly underneath the opaque sticky columns
   -- that's expected/correct (it's the whole point of an opaque sticky
   overlay) and not corrected for. What must never happen is the sticky
   columns themselves misaligning at rest (scrollLeft 0): see #results'
   own CSS in index.html for how column 2's left offset is kept in sync
   with column 1's actual rendered width instead of a hardcoded guess. */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.table-scroll table.data-table { border: none; }
.table-scroll table.data-table th, .table-scroll table.data-table td { border-left: none; border-right: none; }

.sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}
th.sticky-col { z-index: 3; background: var(--paper); }
table.data-table tbody tr:hover td.sticky-col { background: var(--accent-tint); }
tr.breach-row td.sticky-col { background: var(--status-fail-bg); }

.quarter-cell { font-weight: 600; color: var(--ink); }
tr.breach-row td.quarter-cell { color: var(--status-fail-text); }

/* ==========================================================================
   Status chips — compact pass/fail/warn indicator for table cells
   ========================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  line-height: 1.4;
  white-space: nowrap;
}
.chip-pass { background: var(--status-pass-bg); color: var(--status-pass-text); }
.chip-fail { background: var(--status-fail-bg); color: var(--status-fail-text); }
.chip-warn { background: var(--status-warn-bg); color: var(--status-warn-text); }
.chip-neutral { background: var(--line); color: var(--slate); }
.chip-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: currentColor;
}

td.covenant-cell { padding: var(--space-1) var(--space-2); text-align: center; }

/* ==========================================================================
   Banners — pass/fail/warn callouts
   ========================================================================== */
.banner {
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: var(--space-3);
  border: 1px solid transparent;
}
.banner-title {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: var(--space-1);
}
.banner-pass { background: var(--status-pass-bg); color: var(--status-pass-text); border-color: color-mix(in srgb, var(--status-pass-text) 20%, transparent); }
.banner-warn { background: var(--status-warn-bg); color: var(--status-warn-text); border-color: color-mix(in srgb, var(--status-warn-text) 20%, transparent); }
.banner-fail { background: var(--status-fail-bg); color: var(--status-fail-text); border-color: color-mix(in srgb, var(--status-fail-text) 20%, transparent); }
.banner ul { margin: var(--space-1) 0 0; padding-left: 18px; }
.banner a { color: inherit; text-decoration: underline; }

.badge-pill {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  margin: var(--space-1) 0 var(--space-3);
}
.badge-pill.pass { background: var(--status-pass-bg); color: var(--status-pass-text); }
.badge-pill.warn { background: var(--status-warn-bg); color: var(--status-warn-text); }

/* ==========================================================================
   Dropzone — styled drag-and-drop wrapper around a native <input type=file>
   (see /static/dropzone.js). The native input stays functionally identical
   (same id, same .files), this just replaces its default browser chrome.
   ========================================================================== */
.dropzone {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  padding: var(--space-5) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--slate); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-tint); }
.dropzone input[type="file"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.dropzone-icon { font-size: 26px; color: var(--slate); margin-bottom: var(--space-2); line-height: 1; }
.dropzone.is-dragover .dropzone-icon,
.dropzone.is-dragover .dropzone-browse { color: var(--accent); }
.dropzone-text { font-size: 14px; color: var(--ink); font-weight: 500; margin-bottom: var(--space-1); }
.dropzone-browse { color: var(--accent); font-weight: 600; text-decoration: underline; }
.dropzone-hint { font-size: 12px; color: var(--slate); }

.dropzone-files { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); text-align: left; }
.dropzone-file {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 12.5px;
}
.dropzone-file .file-icon { color: var(--slate); flex-shrink: 0; }
.dropzone-file .file-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-weight: 500;
}
.dropzone-file .file-size {
  color: var(--slate); font-family: var(--font-mono);
  font-variant-numeric: tabular-nums; font-size: 11px; flex-shrink: 0;
}
.dropzone-file .file-remove {
  background: none; border: none; cursor: pointer; color: var(--slate);
  font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: var(--radius-sm); flex-shrink: 0;
}
.dropzone-file .file-remove:hover { color: var(--status-fail-text); background: var(--status-fail-bg); }
.dropzone-clear-all {
  align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--accent);
  background: none; border: none; cursor: pointer; padding: var(--space-1) 0;
}
.dropzone-clear-all:hover { color: var(--accent-hover); text-decoration: underline; }

/* Divider between the dropzone and the "paste a link" alternative --
   upload OR link, not both; see the url-field rule below and each page's
   own script for the mutual-exclusivity behavior. */
.url-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  color: var(--slate);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.url-divider::before, .url-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.url-field { text-align: left; }

/* Upfront "what to upload for a complete analysis" guidance -- concise,
   scannable, doesn't imply every item is always required (see the
   "optional" modifier). */
.doc-guidance {
  margin: 0 0 var(--space-4);
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--slate);
  line-height: 1.6;
  text-align: left;
}
.doc-guidance strong { color: var(--ink); font-weight: 600; }
.doc-guidance li.optional { font-style: italic; }

/* ==========================================================================
   Manual "gap-filling" inputs -- when extraction couldn't find a
   required figure but the analysis can proceed once the user supplies
   it (see api.portfolio._apply_manual_financial_inputs). Visually
   distinct from an extracted value throughout: pale accent-tinted
   background, dashed border (echoes .dropzone's "we need something from
   you" language), and every downstream mention of the value carries the
   .manual-value-badge.
   ========================================================================== */
.gap-fill {
  border: 1px dashed var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-tint);
  padding: var(--space-3);
  text-align: left;
  margin: var(--space-3) 0;
}
.gap-fill .gap-fill-found {
  font-size: 12.5px;
  color: var(--ink);
  margin: 0 0 var(--space-2);
}
.gap-fill .gap-fill-found strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.gap-fill-row { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.gap-fill-row .field { flex: 1 1 200px; margin-bottom: 0; }
.gap-fill-row button { flex-shrink: 0; }

.manual-value-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  vertical-align: middle;
}

/* ==========================================================================
   Evidence status -- api.portfolio.EvidenceStatus surfaced per extracted
   field (VERIFIED/DERIVED/INSUFFICIENT get a badge here; USER_PROVIDED
   reuses .manual-value-badge above -- same "not silently rendered as
   extracted" purpose, already distinct, no need for a second class).
   Deliberately reuses existing status tokens rather than adding colors:
   VERIFIED = pass green (confirmed), DERIVED = warn amber (computed, not
   stated -- worth a second look, not wrong), INSUFFICIENT = slate/line
   (the same neutral-gray "not a risk level" treatment
   tr.sev-insufficient already uses elsewhere for the identical concept).
   ========================================================================== */
.evidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  vertical-align: middle;
}
.evidence-verified { color: var(--status-pass-text); background: var(--status-pass-bg); }
.evidence-derived, .evidence-requires_review { color: var(--status-warn-text); background: var(--status-warn-bg); }
.evidence-insufficient { color: var(--slate); background: var(--line); }
/* The wider vocabulary pe_platform.domain.enums.EvidenceStatus adds on top
   of the five above (see docs/incompleteness-register.md row 21): ESTIMATED
   and USER_PROVIDED are real, human-sourced values -- not a problem state --
   so they get the same neutral pass-adjacent treatment as VERIFIED's family
   without claiming document-backed verification; CONFLICTING/INVALID are
   real problems, fail-red. */
.evidence-estimated, .evidence-user_provided { color: var(--accent); background: var(--accent-tint); }
.evidence-conflicting, .evidence-invalid { color: var(--status-fail-text); background: var(--status-fail-bg); }

/* review_status (pe_platform.domain.enums.ReviewStatus): whether a
   human-entered value has been confirmed authoritative, distinct from
   evidence_status above (how well the value itself is sourced). Same badge
   shape, its own modifier namespace so the two never collide. */
.review-approved, .review-not_required { color: var(--status-pass-text); background: var(--status-pass-bg); }
.review-pending { color: var(--status-warn-text); background: var(--status-warn-bg); }
.review-rejected { color: var(--status-fail-text); background: var(--status-fail-bg); }

/* A DERIVED value's "inspect on demand" disclosure -- the formula, each
   component with its own value/source/quote, and (if this value replaced
   an earlier one) that superseded entry. Plain <details>/<summary>: free
   keyboard/click toggle, no JS state to manage. */
.derivation-details { margin-top: var(--space-2); font-size: 11.5px; }
.derivation-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}
.derivation-details summary::-webkit-details-marker { display: none; }
.derivation-details summary::before { content: '▸ '; }
.derivation-details[open] summary::before { content: '▾ '; }
.derivation-formula {
  margin: var(--space-2) 0;
  padding: var(--space-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.derivation-inputs { margin: 0; padding: 0; list-style: none; }
.derivation-inputs li { padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.derivation-inputs li:first-child { border-top: none; }
.derivation-input-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.derivation-quote { display: block; margin-top: 2px; color: var(--slate); font-style: italic; }

/* The entry a DERIVED value replaced -- see
   api.portfolio._merge_extractions' "superseded" provenance key. Same
   warn-amber family as .evidence-derived (this is about the derived
   value that superseded it, not a problem in its own right), set apart
   with a left border rather than a full banner treatment so it reads as
   "attached to the value above," not a separate alert. */
.superseded-block {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--status-warn-text);
  background: var(--status-warn-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.superseded-block .evidence-badge { margin-bottom: 4px; }

/* ==========================================================================
   Enterprise shell + Portfolio Command Centre (Product Surface Slice 1)
   Trust and severity chips always carry text; colour only reinforces it.
   ========================================================================== */
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--space-3); top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-contrast); padding: 8px 14px;
  border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
main:focus { outline: none; }

.app-shell:has(> .pe-nav) { background: linear-gradient(to right, var(--surface) 220px, transparent 220px); }
.pe-nav { position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto; }
.pe-nav-brand {
  font-family: var(--font-serif); font-weight: 600; font-size: 15px; color: var(--ink);
  text-decoration: none; padding: 0 var(--space-2); margin-bottom: var(--space-4); display: block;
}
.pe-nav-list, .pe-nav-sub { list-style: none; margin: 0; padding: 0; }
.pe-nav-sub { margin-left: var(--space-3); }
.pe-nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  min-height: 32px; font-size: 13px; font-weight: 500; color: var(--ink); text-decoration: none;
  padding: 6px var(--space-2); border-radius: var(--radius-sm);
}
.pe-nav-link:hover { background: var(--line); }
.pe-nav-link[aria-current="page"] { background: var(--accent-tint); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.pe-nav-sublink { font-size: 12.5px; font-weight: 400; }
.pe-nav-link.is-disabled { color: var(--slate); cursor: default; }
.pe-nav-link.is-disabled:hover { background: none; }
.pe-nav-note { font-size: 10.5px; color: var(--slate); font-weight: 500; }
.pe-nav-labs { margin-top: var(--space-4); font-size: 12.5px; }
.pe-nav-labs summary { cursor: pointer; padding: 6px var(--space-2); color: var(--slate); font-weight: 600; min-height: 24px; }
.pe-nav-note-block { font-size: 11.5px; color: var(--slate); margin: 0 var(--space-2) var(--space-2); line-height: 1.4; }
.pe-nav-identity { margin-top: auto; padding: var(--space-3) var(--space-2) var(--space-1); display: flex; flex-direction: column; gap: 2px; font-size: 12px; border-top: 1px solid var(--line); }
.pe-nav-user { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.pe-nav-org, .pe-nav-role { color: var(--slate); overflow-wrap: anywhere; }
.pe-nav-logout { color: var(--slate); }

.app-main .page.page-wide { max-width: 1320px; }
.page-head { margin-bottom: var(--space-4); }
.page-head h1 { margin-bottom: var(--space-1); }
.pe-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-4); min-width: 0; }
.pe-section .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin: 0 0 var(--space-3); }
.pe-section .section-head h2 { margin: 0; font-size: 17px; }
.section-meta { margin: 0; color: var(--slate); font-size: 12.5px; }
.section-note { color: var(--slate); font-size: 12.5px; margin: var(--space-3) 0 0; }
.pe-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-4); align-items: start; }
.pe-columns .pe-section { margin-bottom: var(--space-4); }
.subhead { font-size: 13px; margin: var(--space-3) 0 var(--space-2); font-family: var(--font-sans); }
.subhead:first-child { margin-top: 0; }

.state-message { margin: 0; padding: var(--space-2) 0; color: var(--ink); }
.state-loading { color: var(--slate); }
.state-empty, .state-no-action { color: var(--ink); }
.state-forbidden, .state-not-found { color: var(--ink); border-left: 3px solid var(--slate); padding-left: var(--space-3); }
.state-network-error, .state-server-error, .state-validation-error, .state-conflict {
  color: var(--status-fail-text); border-left: 3px solid var(--status-fail-text); padding-left: var(--space-3);
}
.state-retry { margin-top: var(--space-2); }

table.data-table.pe-table th, table.data-table.pe-table td { text-align: left; vertical-align: top; white-space: normal; }
table.data-table.pe-table tbody th { background: none; color: var(--ink); font-size: 12.5px; font-weight: 600; }
table.data-table.pe-table tbody tr:hover th { background: var(--accent-tint); }
.cell-sub { display: block; color: var(--slate); font-size: 11.5px; font-weight: 400; margin-top: 2px; }
.muted { color: var(--slate); }
.chip-cell { min-width: 12rem; }
.chip-cell .trust { margin: 0 4px 4px 0; }
.attention-table td:first-child, .attention-table td:last-child { white-space: nowrap; }
.pager { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); color: var(--slate); font-size: 12.5px; }
.pager button { min-height: 32px; }

.trust, .severity {
  display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1.3;
  padding: 2px 8px; border-radius: var(--radius-pill); border: 1px solid transparent; white-space: nowrap;
}
.trust-current { color: var(--ink); background: var(--paper); border-color: var(--line); font-weight: 500; }
.trust-pending_review { color: var(--status-warn-text); background: var(--surface); border-color: var(--status-warn-text); }
.trust-stale { color: var(--status-warn-text); background: var(--status-warn-bg); }
.trust-incomplete { color: var(--ink); background: var(--surface); border: 1px dashed var(--ink); }
.trust-unsupported { color: var(--slate); background: var(--line); }
.trust-assumption { color: var(--ink); background: var(--surface); border-color: var(--slate); font-style: italic; }
.trust-conflict { color: var(--status-fail-text); background: var(--status-fail-bg); }
.severity-critical { color: #FFFFFF; background: var(--status-fail-text); }
.severity-high { color: var(--status-fail-text); background: var(--status-fail-bg); border-color: var(--status-fail-text); }
.severity-medium { color: var(--status-warn-text); background: var(--status-warn-bg); }
.severity-low { color: var(--slate); background: var(--line); }

.work-list { list-style: none; margin: 0; padding: 0; }
.work-item { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.work-item:last-child { border-bottom: none; }
.readiness-list { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-4); margin: 0; }
.readiness-list dt { font-weight: 600; }
.readiness-list dd { margin: 0; font-family: var(--font-mono); font-size: 15px; text-align: right; }
.search-form { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.search-form input { min-width: 240px; }
.company-meta { color: var(--slate); margin: 0; }
a.button { display: inline-flex; align-items: center; text-decoration: none; }

@media (max-width: 1100px) {
  .pe-columns { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 860px) {
  .app-shell:has(> .pe-nav) { background: none; }
  .pe-nav { position: static; height: auto; overflow: visible; width: auto; }
  .pe-nav-list { display: flex; flex-wrap: wrap; gap: 2px var(--space-1); }
  .pe-nav-sub { display: none; }
  .pe-nav-list > li > .pe-nav-sub { display: none; }
  .pe-nav-identity { display: none; }
  .pe-nav-labs { margin-top: 0; }
  .search-form input { min-width: 0; flex: 1 1 160px; }
}
a.btn { background: var(--accent); color: var(--accent-contrast); }
a.btn.btn-secondary { background: none; color: var(--ink); }
table.data-table.pe-table[data-testid="portfolio-table"] { min-width: 60rem; }
table.data-table.attention-table { min-width: 52rem; }
.nowrap { white-space: nowrap; }

/* ==========================================================================
   Company Decision Room (Product Surface Slice 2)
   ========================================================================== */
.company-head { margin-bottom: var(--space-3); }
.company-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-2) var(--space-4); margin: var(--space-3) 0 0; }
.company-facts dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); }
.company-facts dd { margin: 2px 0 0; }
.room-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); margin: var(--space-4) 0 var(--space-4); }
.room-tabs [role="tab"] {
  background: none; border: none; border-bottom: 3px solid transparent; border-radius: 0; color: var(--slate);
  font-weight: 600; padding: 10px 14px; min-height: 40px; cursor: pointer;
}
.room-tabs [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.room-tabs [role="tab"]:hover { color: var(--ink); }
.room-panel:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
/* D7.12 valuation workspace: grouped surface navigation, shell facts and primary action */
.val-nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); border-bottom: 1px solid var(--line); margin: var(--space-4) 0; }
.val-nav-group { display: flex; align-items: flex-end; gap: var(--space-1); min-width: 0; }
.val-nav-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); padding: 0 2px 12px 0; }
.val-nav-tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.val-nav [role="tab"] {
  background: none; border: none; border-bottom: 3px solid transparent; border-radius: 0; color: var(--slate);
  font-weight: 600; padding: 8px 10px; min-height: 40px; cursor: pointer;
}
.val-nav [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.val-nav [role="tab"]:hover { color: var(--ink); }
.val-nav [role="tab"]:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.val-shell-facts { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.val-action { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-3) 0 0; }
.val-primary-action { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.val-primary-action .form-status:empty { display: none; }
.val-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-5); }
.val-overview-block { min-width: 0; }
.val-overview-block[data-overview="methodology"] { grid-column: 1 / -1; }
.val-overview a { display: inline-block; min-height: 24px; line-height: 24px; }
#valuation-room .auth-fieldset input[type="radio"], #valuation-room input[type="checkbox"] { width: 24px; height: 24px; margin: 0 6px 0 0; vertical-align: middle; }
.val-placeholder { border-left: 3px solid var(--line); padding-left: var(--space-3); color: var(--slate); }
.val-binding h3 .cell-sub { display: block; font-weight: 400; }
[data-revealed="true"] { outline: 3px solid var(--accent); outline-offset: 2px; }
#valuation-room select { max-width: min(100%, 24rem); text-overflow: ellipsis; }
#valuation-room .actions a.button, #valuation-room .actions .why-button { min-height: 28px; }
@media (max-width: 860px) {
  .val-nav { flex-direction: column; gap: var(--space-1); }
  .val-nav-group { flex-wrap: wrap; align-items: center; }
  .val-nav-label { padding: 0; min-width: 4.5rem; }
  .val-nav [role="tab"] { padding: 6px 8px; min-height: 36px; }
  .val-overview { grid-template-columns: minmax(0, 1fr); }
}
.panel-heading { font-size: 17px; margin: 0 0 var(--space-3); }
.pe-section h2 { font-size: 17px; margin: 0 0 var(--space-3); }
.comparison-line { margin: 0 0 var(--space-3); }
.more-changes { margin-top: var(--space-3); }
.more-changes summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-entry { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.attention-entry:last-child { border-bottom: none; }
.row-actions { display: inline-flex; gap: var(--space-2); margin-left: var(--space-2); }
.why-button { padding: 4px 10px; min-height: 28px; font-size: 12px; }
table.data-table.pe-table tbody tr.is-highlighted th, table.data-table.pe-table tbody tr.is-highlighted td { background: var(--status-warn-bg); }
.valuation-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.valuation-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); background: var(--surface); }
.valuation-card h3 { margin: 0 0 var(--space-2); font-size: 15px; }
.drawer-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--space-4); margin: 0; }
.drawer-facts dt { color: var(--slate); font-weight: 600; }
.drawer-facts dd { margin: 0; overflow-wrap: anywhere; }
.inline-form { margin-top: var(--space-4); border-top: 1px solid var(--line); padding-top: var(--space-3); }
.inline-form summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.field-grid { display: grid; grid-template-columns: max-content minmax(0, 22rem); gap: var(--space-2) var(--space-3); align-items: center; margin-top: var(--space-3); }
.field-grid button, .field-grid .form-status { grid-column: 2; justify-self: start; }
.period-picker { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20, 33, 61, 0.35); z-index: 90; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(36rem, 100vw); z-index: 91; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(20, 33, 61, 0.15); padding: var(--space-4);
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-section { margin-top: var(--space-4); }
.drawer-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); margin: 0 0 var(--space-2); }
.source-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); margin-bottom: var(--space-2); }
.source-title { margin: 0 0 4px; font-weight: 600; }
.source-card blockquote { margin: var(--space-2) 0 0; padding-left: var(--space-3); border-left: 3px solid var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; }
.chip-line { display: flex; flex-wrap: wrap; gap: 4px; margin: var(--space-2) 0 0; }
@media (max-width: 860px) {
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .field-grid button, .field-grid .form-status { grid-column: 1; }
}
.action-link { display: inline-block; min-height: 24px; line-height: 24px; }
.period-picker select { width: auto; max-width: 100%; }

/* Forward Risk workspace (Product Surface Slice 3). Completeness is carried by text;
   amber marks incomplete coverage, never the size or direction of an outcome. */
.fr-not-forecast { margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3); border-left: 3px solid var(--accent); background: var(--accent-tint); font-weight: 600; }
.fr-not-forecast .cell-sub { font-weight: 400; }
.fr-status { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.4; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.fr-status-complete { color: var(--ink); background: var(--paper); }
.fr-status-partial, .fr-status-incomplete { color: var(--status-warn-text); background: var(--status-warn-bg); border-color: var(--status-warn-text); }
.fr-status-not_computable { color: var(--status-warn-text); background: var(--surface); border: 1px dashed var(--status-warn-text); }
.fr-status-not_recorded, .fr-status-not_available { color: var(--slate); background: var(--line); }
.fr-headline dd { font-size: 15px; }
.fr-total { font-variant-numeric: tabular-nums; display: block; }
.fr-total-none { color: var(--status-warn-text); font-weight: 600; }
.fr-grade { font-weight: 600; }
.fr-grade-no { color: var(--slate); }
.fr-legacy, .fr-warning { margin: 0; padding: var(--space-2) var(--space-3); border-left: 3px solid var(--status-warn-text); background: var(--status-warn-bg); color: var(--ink); }
.fr-limitations { margin-top: var(--space-3); }
.fr-limitations summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.fr-limitations li { margin: var(--space-2) 0; }
.fr-exclusions { margin: var(--space-1) 0 0; padding-left: 1.1rem; }
.fr-exclusions li { margin-bottom: var(--space-1); }
.fr-horizon-button { background: none; border: 1px solid var(--line); color: var(--accent); font-weight: 600; padding: 2px 10px; min-height: 28px; border-radius: var(--radius-sm); cursor: pointer; }
.fr-horizon-button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.fr-horizon-table td, .fr-horizon-table th { vertical-align: top; }
.fr-path { margin: 0; padding-left: 1.4rem; }
.fr-path li { margin-bottom: var(--space-2); }
.fr-path-nodes { display: block; font-weight: 600; }
.fr-path-value { display: block; font-variant-numeric: tabular-nums; }
.fr-detail-total { font-size: 15px; margin: 0 0 var(--space-3); }
.fr-detail-total .fr-total { display: inline; }
.fr-compare-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.fr-compare-run { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); min-width: 0; }
.fr-not-comparable { font-weight: 600; color: var(--slate); }
.fr-baseline-company { border-top: 1px solid var(--line); padding: var(--space-2) 0; }
.fr-baseline-company summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.fr-baseline-company h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); margin: var(--space-3) 0 var(--space-1); }
.fr-company-path { border-top: 1px solid var(--line); padding: var(--space-2) 0; }
.fr-company-path summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.fr-identity { margin-top: var(--space-2); }
.fr-identity summary { cursor: pointer; min-height: 24px; }
.fr-identity code, .fr-header-facts code { overflow-wrap: anywhere; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { margin-bottom: 2px; }
.link-button { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; min-height: 24px; }
.button-link { display: inline-block; min-height: 28px; line-height: 28px; padding: 0 12px; border: 1px solid var(--accent); border-radius: var(--radius-sm); color: var(--accent); font-weight: 600; text-decoration: none; }
.button-link[aria-disabled="true"] { color: var(--slate); border-color: var(--line); cursor: not-allowed; }
tr[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Valuation and capital-structure workspaces (Product Surface Slice 4). Every state is carried by text;
   amber marks something a reviewer should look at, never a value judgement. */
.auth-form { display: grid; gap: var(--space-3); margin-top: var(--space-3); max-width: 60rem; }
.auth-field { display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 4px var(--space-3); align-items: start; }
.auth-field > label { font-weight: 600; padding-top: 6px; }
.auth-field > .cell-sub, .auth-field > .auth-error { grid-column: 2; }
.auth-control { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.auth-control input, .auth-control select, .auth-control textarea { width: 100%; min-width: 0; max-width: 32rem; }
.auth-control textarea { min-height: 4.5rem; resize: vertical; }
.auth-unit { color: var(--slate); font-size: 12.5px; white-space: nowrap; }
.auth-error { color: var(--status-fail-text); font-size: 12.5px; font-weight: 600; }
.auth-error:empty { display: none; }
[aria-invalid="true"] { border-color: var(--status-fail-text); outline: 1px solid var(--status-fail-text); }
.auth-fieldset { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); display: grid; gap: var(--space-2); min-width: 0; }
.auth-fieldset legend { font-weight: 600; padding: 0 4px; }
.auth-row { border-top: 1px dashed var(--line); padding-top: var(--space-2); display: grid; gap: var(--space-2); }
.auth-save-state { font-size: 12.5px; margin: var(--space-2) 0 0; color: var(--slate); }
.auth-save-state[data-state="unsaved"], .auth-save-state[data-state="conflict"] { color: var(--status-warn-text); font-weight: 600; }
.form-status[data-state="error"] { color: var(--status-fail-text); font-weight: 600; }
.inline-action { display: inline-flex; align-items: center; gap: var(--space-2); }
.auth-dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); max-width: min(40rem, calc(100vw - 2rem)); width: 100%; }
.auth-dialog::backdrop { background: rgba(20, 33, 61, 0.35); }
.auth-dialog h2 { font-size: 18px; margin: 0 0 var(--space-3); }
.auth-dialog-body { max-height: 60vh; overflow-y: auto; }
.dims { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.dim { display: inline-block; font-size: 11.5px; line-height: 1.4; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); white-space: nowrap; }
.dim-attention { color: var(--status-warn-text); background: var(--status-warn-bg); border-color: var(--status-warn-text); font-weight: 600; }
.val-status { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); }
.val-status-ready_for_review, .val-status-validated { color: var(--status-warn-text); background: var(--status-warn-bg); border-color: var(--status-warn-text); }
.val-status-rejected { color: var(--status-fail-text); background: var(--status-fail-bg); }
.val-status-superseded, .val-status-cancelled { color: var(--slate); background: var(--line); }
.val-method .section-head h3 { margin: 0; font-size: 16px; }
.val-total th, .val-total td { font-weight: 700; border-top: 2px solid var(--ink); }
/* D7.12.3 Comps / Transactions: the stored trace, explained in order */
.val-market { display: grid; gap: var(--space-3); margin: var(--space-3) 0; }
.val-market-part { border-top: 1px solid var(--line); padding-top: var(--space-2); overflow-wrap: anywhere; }
.val-market-part:focus, .val-method:focus, .val-market-findings > li:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.val-market-part[data-revealed], .val-market-findings > li[data-revealed] { background: var(--accent-tint); }
.val-market-facts { margin-top: var(--space-2); }
.val-market-facts dd { margin: 0; overflow-wrap: anywhere; }
.val-market-findings { margin: 0; padding-left: 1.2rem; display: grid; gap: var(--space-1); }
/* D7.12.4 DCF authoring: one fieldset per decision */
.val-fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); min-width: 0; }
.val-fieldset > legend { font-weight: 600; padding: 0 var(--space-1); }
.val-changes { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-2); }
.val-changes > li { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); background: var(--surface); overflow-wrap: anywhere; }
.val-changes > li[data-kind="method"], .val-changes > li[data-kind="judgement"] { border-left-color: var(--status-warn-text); }
.val-changes > li > .cell-sub { margin-top: 4px; }
.val-change { display: inline-flex; flex-wrap: wrap; gap: 4px var(--space-3); font-variant-numeric: tabular-nums; }
.val-comments { list-style: none; padding: 0; margin: 0 0 var(--space-3); display: grid; gap: var(--space-2); }
.val-comments > li { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); overflow-wrap: anywhere; }
.val-comments > li[data-author-role="reviewer"] { border-left: 3px solid var(--accent); }
.val-comments p { margin: 4px 0 0; white-space: pre-wrap; }
[data-section="validation"][data-status="fail"] [data-testid="validation-status"] { color: var(--status-fail-text); font-weight: 600; }
@media (max-width: 860px) {
  .auth-field { grid-template-columns: minmax(0, 1fr); }
  .auth-field > .cell-sub, .auth-field > .auth-error { grid-column: 1; }
}

/* Entity structure workspace (D1). Status is carried by text; chips only add emphasis. */
.es-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin-bottom: var(--space-3); }
.es-controls .auth-field { margin: 0; }
.es-control-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.es-control-actions button, .es-control-actions .button-link { min-height: 32px; }
.es-date-banner { padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); margin-bottom: var(--space-3); }
.es-date-banner:empty { display: none; }
.es-date-banner[data-relative="future"] { border-left-style: dashed; }
.es-workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr); gap: var(--space-4); align-items: start; }
.es-filters { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-2); }
.es-filters .auth-field { margin: 0; }
.es-tree, .es-tree ul { list-style: none; margin: 0; padding: 0; }
.es-tree ul { padding-left: 1.5rem; border-left: 1px dotted var(--line); margin-left: 0.5rem; }
.es-tree-item > .es-tree-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--space-2); padding: 4px var(--space-2); min-height: 28px; border-radius: var(--radius-sm); cursor: pointer; }
.es-tree-item[aria-expanded]::before { content: none; }
.es-tree-item[aria-expanded="false"] > .es-tree-row .es-tree-name::before { content: "▸ "; }
.es-tree-item[aria-expanded="true"] > .es-tree-row .es-tree-name::before { content: "▾ "; }
.es-tree-item[aria-selected="true"] > .es-tree-row { background: var(--accent-tint); outline: 1px solid var(--accent); }
.es-tree-item:focus { outline: none; }
.es-tree-item:focus > .es-tree-row { outline: 3px solid var(--accent); outline-offset: 1px; }
.es-tree-item[data-match="true"] > .es-tree-row .es-tree-name { text-decoration: underline; }
.es-tree-name { font-weight: 600; }
.es-tree-roles { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.es-inspector { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); position: sticky; top: var(--space-3); max-height: calc(100vh - 2 * var(--space-3)); overflow-y: auto; }
.es-inspector h3:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.es-table-details { margin-top: var(--space-4); }
.es-table-details summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.oc-matrix-section { margin-top: var(--space-5); }
table.data-table.oc-matrix-table { min-width: 76rem; }
table.data-table.oc-matrix-table th button.link-button { font-weight: 600; font-size: inherit; white-space: nowrap; }
table.data-table.oc-matrix-table th[aria-sort="ascending"] button.link-button::after { content: " ▲"; }
table.data-table.oc-matrix-table th[aria-sort="descending"] button.link-button::after { content: " ▼"; }
table.data-table.oc-matrix-table tbody tr[aria-selected="true"] th, table.data-table.oc-matrix-table tbody tr[aria-selected="true"] td { background: var(--accent-tint); }
table.data-table.oc-matrix-table tbody tr th button.link-button { text-align: left; white-space: normal; }
.es-path-steps { margin: var(--space-2) 0; padding-left: 1.5rem; }
.es-path-steps li { margin: 4px 0; }
.es-lower { margin-top: var(--space-4); }
.es-operations li { margin: 6px 0; }
/* Operation forms: each field is a label-above-control cell, several per row. Nesting `.auth-field` (label column up to 16rem) inside the 2-track
   `.field-grid` left a second-column control ~80px (>=1366px) or ~22px (900-1280px) wide. */
.field-grid.es-op-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); align-items: start; }
.es-op-form > .auth-field { grid-template-columns: minmax(0, 1fr); }
.es-op-form > .auth-field > label { padding-top: 0; }
.es-op-form > .auth-field > .cell-sub, .es-op-form > .auth-field > .auth-error { grid-column: 1; }
.es-op-form .auth-control input, .es-op-form .auth-control select, .es-op-form .auth-control textarea { max-width: none; }
.es-op-form > .auth-field:has(textarea), .es-op-form > .auth-fieldset, .es-op-form > button, .es-op-form > .form-status { grid-column: 1 / -1; }
.es-diff { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); margin: var(--space-2) 0; }
.es-diff[data-changed="false"] { border-style: dashed; }
.es-diff-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.es-frozen { border-left: 4px solid var(--slate); padding: var(--space-2) var(--space-3); background: var(--surface); }
.es-fingerprint { font-family: "IBM Plex Mono", ui-monospace, monospace; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .es-workspace { grid-template-columns: minmax(0, 1fr); }
  .es-inspector { position: static; max-height: none; }
  .es-diff-columns { grid-template-columns: minmax(0, 1fr); }
}
.es-check { display: inline-flex; align-items: center; gap: 4px; margin: 2px var(--space-3) 2px 0; min-height: 24px; }
.es-check input { width: auto; min-width: 18px; min-height: 18px; }
.es-controls .auth-field, .es-filters .auth-field { display: flex; flex-direction: column; gap: 4px; }
.es-filters input[type="search"] { min-width: 14rem; min-height: 32px; }

.es-timeline { list-style: none; margin: var(--space-2) 0; padding: 0; border-left: 2px solid var(--line); }
.es-timeline-entry { padding: var(--space-2) 0 var(--space-2) var(--space-3); margin-left: -1px; border-left: 2px solid var(--line); }
.es-timeline-entry[data-kind="correction"] { border-left-color: var(--status-warn-text); }
.es-timeline-entry[data-kind="amendment"] { border-left-color: var(--status-pass-text); }
.es-timeline-entry[data-kind="void"] { border-left-color: var(--status-fail-text); }
.es-timeline-when { margin: 0 0 2px; }

.es-correction-review { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); margin: var(--space-3) 0; }
.es-classification { border-bottom: 1px solid var(--line); padding: var(--space-2) 0; }
.es-classification:last-child { border-bottom: none; }

.es-compare-tool { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); margin-top: var(--space-3); }
.es-compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin: var(--space-2) 0; }
.es-compare-grid fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2); }
.es-compare-labels { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin: var(--space-2) 0; }
@media (max-width: 700px) {
  .es-compare-grid { grid-template-columns: minmax(0, 1fr); }
}

/* D4.11 ownership & control workbench */
html:has(.oc-page) { scroll-padding-top: 5rem; }
.oc-context { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3); background: var(--surface, #fff); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: var(--space-2); }
.oc-context-company { font-weight: 700; }
.oc-context-state { color: var(--muted, #555); }
.oc-attention { min-height: 28px; }
.oc-shortcut-toggle { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; font-size: 0.875rem; }
.oc-shortcut-toggle input { width: auto; min-width: 16px; min-height: 16px; }
.oc-skip { display: flex; gap: var(--space-3); font-size: 0.8125rem; margin-bottom: var(--space-2); }
.oc-modes { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: var(--space-3); }
.oc-modes [role="tab"] { background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 6px var(--space-3); min-height: 36px; font-weight: 600; cursor: pointer; color: inherit; }
.oc-modes [role="tab"][aria-selected="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--ink); }
.oc-modes [role="tab"]:focus-visible, .oc-grid [tabindex="0"]:focus, .oc-detail:focus, .oc-context button:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.oc-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin-bottom: var(--space-3); }
.oc-toolbar .section-note { margin: 0; flex: 1 1 18rem; }
.oc-radio-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px var(--space-3) 4px; display: inline-flex; gap: var(--space-3); align-items: center; }
.oc-radio-group legend { padding: 0 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.oc-radio-group label { display: inline-flex; gap: 4px; align-items: center; min-height: 28px; }
.oc-radio-group input { width: auto; min-width: 16px; min-height: 16px; }
.oc-measure-section, .oc-capital-section, .oc-control-section, .oc-governance-section, .oc-review-section { margin-top: var(--space-4); }
.oc-grid { width: 100%; font-size: 0.875rem; }
.oc-grid th, .oc-grid td { padding: 3px var(--space-2); white-space: nowrap; }
.oc-grid tbody tr[aria-selected="true"] th, .oc-grid tbody tr[aria-selected="true"] td { background: var(--accent-tint); }
.oc-grid td.num, .oc-grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.oc-grid .link-button { text-align: left; white-space: normal; }
.oc-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr); gap: var(--space-4); align-items: start; }
.oc-detail { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); position: sticky; top: 4.5rem; max-height: calc(100vh - 6rem); overflow: auto; }
.oc-detail h3:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.oc-detail h4 { margin: var(--space-3) 0 var(--space-1); }
.evidence-quote { border-left: 4px solid var(--accent); margin: var(--space-2) 0; padding: var(--space-1) var(--space-3); background: var(--surface, #fafafa); }
.oc-help { max-width: 34rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
@media (max-width: 1100px) { .oc-split { grid-template-columns: minmax(0, 1fr); } .oc-detail { position: static; max-height: none; } }
.company-links { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0; }

/* FX Data Operations (/fx-data) */
.kv-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-3) var(--space-5); margin: var(--space-3) 0; }
.kv-list dt { font-size: 0.8125rem; color: var(--slate); }
.kv-list dd { margin: 0; overflow-wrap: anywhere; }
.form-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-4); margin: var(--space-3) 0; }
.form-row label { display: block; font-size: 0.8125rem; color: var(--slate); margin-bottom: 2px; }
.form-row input[type="text"] { min-width: 300px; }
.replay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); margin-top: var(--space-3); }
.replay-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); }
.replay-rate { font-size: 1.125rem; font-weight: 600; margin: var(--space-2) 0; }

/* --- D0 shell: workspace switcher, sample banner, first-run checklist -------------------------------------------- */
.pe-sample-banner { background: var(--status-warn-bg, #fff4d6); color: var(--status-warn-text, #6b4700); border-bottom: 1px solid currentColor; padding: 8px 16px; font-size: 13px; font-weight: 600; }
.pe-workspace-select { max-width: 100%; margin-top: 4px; }
.pe-onboarding { margin-bottom: var(--space-5, 24px); }
.pe-onboarding .pe-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-3, 12px); margin: var(--space-3, 12px) 0; }
.pe-onboarding .pe-choice > div { border: 1px solid var(--line, #d6dae0); border-radius: 6px; padding: var(--space-3, 12px); }
.pe-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pe-step { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line, #e6e9ee); }
.pe-step[data-done="true"] .pe-step-title { text-decoration: line-through; opacity: .7; }
.pe-step-note { font-size: 12px; opacity: .8; margin: 2px 0 0; }
.pe-form-grid { display: grid; gap: 10px; min-width: min(420px, 90vw); }
.pe-form-grid label { display: block; font-weight: 600; font-size: 13px; }
.pe-form-grid input, .pe-form-grid select { width: 100%; }
.pe-copy-row { display: flex; gap: 8px; }
.pe-copy-row input { flex: 1; }
.pe-cta-row { margin-top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
