/* ── Self-hosted fonts (CSP font-src 'self'; no CDN) ────────────────────────
   JetBrains Mono is the UI/mono face (chrome, labels, numbers, tables, kbd,
   brand) — terminal soul, far more legible than Courier New. Inter carries the
   long-form prose only (AI report body, landing paragraphs) — the single biggest
   readability win. Both self-hosted woff2 under client/fonts/, split by subset so
   the uk/ru i18n keeps proper Cyrillic instead of falling back to a system font. */

/* JetBrains Mono 400 */
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/jetbrains-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/jetbrains-mono-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/jetbrains-mono-400-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
/* JetBrains Mono 500 */
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/jetbrains-mono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/jetbrains-mono-500-cyrillic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/jetbrains-mono-500-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
/* JetBrains Mono 700 */
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/jetbrains-mono-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/jetbrains-mono-700-cyrillic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/jetbrains-mono-700-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
/* Inter 400 */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/inter-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/inter-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/inter-400-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
/* Inter 600 */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/inter-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/inter-600-cyrillic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/inter-600-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}

* {
    box-sizing: border-box;
}

/* ── Design tokens (UI redesign U1 — "Refined Terminal") ────────────────────
   Warm near-black surface stack, calm warm-grey body text, white-alpha borders.
   The company green (`--brand`, = `--accent`) stays the UI accent (buttons,
   active, links, focus); green/red are the data semantics (`--pnl-*`). Amber
   `--warn` is reserved for MEDIUM-severity DATA only (never chrome). Old names
   (--panel, --panel-2, --border-strong, --danger, --warn, --area-*) are kept so
   every existing selector re-skins without edits. The chart reads --bg / grid /
   area at theme time (js/chart.js); the equity LINE now reads --chart-line
   (green) so it stays PnL-colored independent of --accent. */
:root {
  --bg: #131312;
  --surface-1: #1B1B1A;
  --surface-2: #232322;
  --surface-3: #2B2B29;
  --panel: var(--surface-1);       /* legacy alias */
  --panel-2: var(--surface-2);     /* legacy alias */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);   /* was green — now neutral white-alpha */
  --fg: #D9D6CF;
  --fg-strong: #F0EDE6;
  --accent: #53B57E;               /* refined company green (was neon #37d97a) */
  --accent-hover: #67C791;
  --accent-muted: rgba(83, 181, 126, 0.12);
  --brand: var(--accent);
  --brand-hover: var(--accent-hover);
  --brand-muted: var(--accent-muted);
  --focus: var(--accent);
  --muted: #8D8B85;
  --hint: #A5A29B;
  --pnl-pos: #53B57E;
  --pnl-neg: #E05C5C;
  --danger: #E05C5C;
  --warn: #D08770;                 /* terracotta — MEDIUM-severity data only, not chrome */
  --grid: #20201E;
  --dotted: rgba(255, 255, 255, 0.08);
  --row-hover: #232322;
  --chart-line: #53B57E;           /* equity line — PnL green, decoupled from --accent */
  --area-top: rgba(83, 181, 126, 0.16);
  --area-bottom: rgba(83, 181, 126, 0.02);
  --radius: 8px;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Light "Audit Paper" — warm off-white; the exported report looks like a signed
   audit document. Green darkened to AA on paper; amber warn darkened likewise. */
:root[data-theme="light"] {
  --bg: #FAF7F1;
  --surface-1: #FFFFFF;
  --surface-2: #F3EFE8;
  --surface-3: #ECE7DD;
  --panel: var(--surface-1);
  --panel-2: var(--surface-2);
  --border: #E6E1D7;
  --border-strong: #D2CCBE;
  --fg: #3A3833;
  --fg-strong: #211F1B;
  --accent: #2E7D53;
  --accent-hover: #256B46;
  --accent-muted: rgba(46, 125, 83, 0.10);
  --muted: #6F6B61;
  --hint: #7C776C;
  --pnl-pos: #2E7D53;
  --pnl-neg: #C13B3B;
  --danger: #C13B3B;
  --warn: #A8532F;
  --grid: #E9E4D8;
  --dotted: #E6E1D7;
  --row-hover: #F3EFE8;
  --chart-line: #2E7D53;
  --area-top: rgba(46, 125, 83, 0.20);
  --area-bottom: rgba(46, 125, 83, 0.03);
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-mono);
    min-height: 100vh;
}

/* Visually-hidden but screen-reader-available — used for section headings that the
   visual design conveys through styled labels / context (a11y heading structure). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Subtle, reduced-motion-safe reveal for result panels as they populate. */
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

#dashboard {
    width: 100%;
    padding: 14px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.dashboard-brand {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

#dashboard h1 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 1.5px;
    color: var(--fg-strong);
    font-weight: 700;
}
#dashboard h1 .brand-mark { color: var(--accent); }

.dashboard-status {
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 1px;
}

/* ── U6 — header icon actions (the shortcut strip is gone; shortcuts live in
   tooltips + the "?" overlay). Icons are quiet ghosts; the New-audit CTA appears
   only in the report stage. ── */
.dashboard-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}
.icon-btn:hover { color: var(--fg-strong); border-color: var(--border-strong); background: var(--accent-muted); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#dock-toggle[aria-expanded="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

/* Theme toggle shows the icon of the theme you would switch TO. */
#theme-btn .theme-icon-moon { display: none; }
:root[data-theme="light"] #theme-btn .theme-icon-sun { display: none; }
:root[data-theme="light"] #theme-btn .theme-icon-moon { display: inline; }

/* "New audit" — visible in the report stage only (state C). Light-on-dark
   primary per the monochrome token spec. */
.header-cta {
  display: none;
  background: var(--fg-strong);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  padding: 7px 14px;
  cursor: pointer;
  transition: filter 150ms ease;
}
.header-cta:hover { filter: brightness(1.1); }
.header-cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body[data-stage="report"] .header-cta { display: inline-flex; }

/* ── U6 — three-stage architecture. The stage attribute on <body> gates whole
   layers: the entry card owns states A (empty) and B (loading); the report layer
   exists only in state C. Sections also keep their inline display toggles — the
   stage rules are the structural guarantee that nothing leaks across states. ── */
body[data-stage="report"] #entry-stage { display: none; }
/* The report layer exists ONLY in state C — a structural guarantee over the
   per-section inline display toggles (!important beats a stale inline ''). */
body:not([data-stage="report"]) #chart-wrapper,
body:not([data-stage="report"]) #verdict-panel,
body:not([data-stage="report"]) #behavioral-panel,
body:not([data-stage="report"]) #stats-panel,
body:not([data-stage="report"]) #breakdowns-panel,
body:not([data-stage="report"]) #data-quality-notice,
body:not([data-stage="report"]) #ai-report,
body:not([data-stage="report"]) #sample-banner { display: none !important; }
body[data-stage="loading"] #entry-drop,
body[data-stage="loading"] .entry-row,
body[data-stage="loading"] .entry-guide-link,
body[data-stage="loading"] #entry-error,
body[data-stage="loading"] #entry-demo-link { display: none; }
#entry-progress { display: none; }
body[data-stage="loading"] #entry-progress { display: block; }

/* The A→C reveal: report sections stagger in (one composited transform+opacity
   each). Re-runs only when the stage attribute flips or a section re-shows —
   language re-renders don't retrigger it. Reduced motion zeroes it globally. */
body[data-stage="report"] #app-main > section { animation: panel-in 320ms cubic-bezier(0.16, 1, 0.3, 1) both; }
body[data-stage="report"] #chart-wrapper { animation-delay: 60ms; }
body[data-stage="report"] #behavioral-panel { animation-delay: 120ms; }
body[data-stage="report"] #stats-panel { animation-delay: 180ms; }
body[data-stage="report"] #breakdowns-panel { animation-delay: 240ms; }
body[data-stage="report"] #data-quality-notice { animation-delay: 280ms; }
body[data-stage="report"] #ai-report { animation-delay: 320ms; }

#chart-wrapper {
    position: relative;
    width: 100%;
    /* Compact height so the dashboard fits without heavy scrolling; the chart
       (js/chart.js) tracks this via a ResizeObserver. min-height keeps it usable
       on short viewports. Fullscreen mode overrides this below. */
    height: 52vh;
    min-height: 320px;
    border-bottom: 1px solid var(--border);
}

#chart-container {
    width: 100%;
    height: 100%;
}

.chart-axis-label {
    position: absolute;
    color: var(--hint);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 5;
    display: none;
}

#chart-wrapper[data-ready="true"] .chart-axis-label {
    display: block;
}

#ledger-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    padding: 16px 24px;
    /* The 11-column ledger is wider than a phone (and a narrow desktop window). The
       inline style sets overflow-y; this lets the table scroll horizontally instead
       of clipping its right-hand columns (Fee, Net P&L, R, Setup, Screenshot). */
    overflow-x: auto;
}

.ledger-controls {
    display: flex;
    justify-content: flex-end;
    padding: 0 0 12px;
}
.ledger-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--hint);
}
#ledger-symbol-filter {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
}
#ledger-symbol-filter:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

#ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

#ledger-table thead th {
    position: sticky;
    top: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.7rem;
    color: var(--muted);
    padding: 11px 12px;
    z-index: 1;
}

#ledger-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--dotted);
    white-space: nowrap;
}

#ledger-table tbody tr:hover {
    background: var(--row-hover);
}

/* AI-A2: a ledger row is a keyboard-accessible button that opens the chat focused
   on that trade. Cursor + accent-tinted hover/focus signal the affordance; a muted
   glyph in the time cell keeps it discoverable without hover (touch). */
#ledger-table tbody tr.ledger-row { cursor: pointer; }
#ledger-table tbody tr.ledger-row:hover,
#ledger-table tbody tr.ledger-row:focus-visible { background: var(--accent-muted); }
#ledger-table tbody tr.ledger-row:focus-visible {
    outline: none;
    box-shadow: inset 2px 0 0 var(--accent);
}
.ledger-ask-glyph {
    display: inline-block;
    width: 0.9em;
    margin-right: 6px;
    color: var(--muted);
    opacity: 0.5;
    transition: color 0.12s ease, opacity 0.12s ease;
}
.ledger-ask-glyph::before { content: '◆'; font-size: 0.7em; vertical-align: 1px; }
#ledger-table tbody tr.ledger-row:hover .ledger-ask-glyph,
#ledger-table tbody tr.ledger-row:focus-visible .ledger-ask-glyph {
    color: var(--accent);
    opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
    .ledger-ask-glyph { transition: none; }
}

#ledger-table .ledger-pnl-col,
#ledger-table td.ledger-pnl-cell {
    text-align: right;
    font-weight: 700;
}

.profit-text {
    color: var(--accent);
}

.loss-text {
    color: var(--danger);
}

.chart-axis-title {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--hint);
    font-size: 0.75rem;
    letter-spacing: 2px;
}

.chart-axis-y {
    top: 14px;
    left: 14px;
    color: var(--hint);
}

.chart-axis-x {
    bottom: 26px;
    right: 80px;
    color: var(--hint);
}

#stats-panel {
    margin: 32px 24px 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1px;
    background-color: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

#stats-panel .stat-row {
    flex: 1 1 9rem;
    min-width: 0;
}

.stat-row {
    background: var(--panel);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 92px;
}

.stat-label {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.25px;
}

.stat-value {
    color: var(--fg-strong);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
.stat-value.profit-text { color: var(--accent); }
.stat-value.loss-text { color: var(--danger); }

#ai-report {
    margin: 32px 24px;
    padding: 24px 28px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: panel-in 160ms ease-out;
}

#ai-report .report-label {
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    margin-bottom: 14px;
    border-bottom: 1px dashed var(--dotted);
    padding-bottom: 10px;
}

#ai-report .report-content {
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

body.chart-fullscreen-mode #dashboard,
body.chart-fullscreen-mode #verdict-panel,
body.chart-fullscreen-mode #behavioral-panel,
body.chart-fullscreen-mode #breakdowns-panel,
body.chart-fullscreen-mode #stats-panel,
body.chart-fullscreen-mode #ai-report {
    display: none;
}

body.chart-fullscreen-mode {
    overflow: hidden;
}

body.chart-fullscreen-mode #chart-wrapper {
    height: 100vh;
    border-bottom: none;
}

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}

#settings-dialog {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  min-width: 320px;
  padding: 24px;
}
#settings-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
#settings-dialog h2 { color: var(--fg-strong); font-size: 0.9rem; letter-spacing: 1.5px; margin: 0 0 18px; }
#settings-dialog .settings-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 14px; }
#settings-dialog select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: inherit; padding: 5px 10px;
}
#settings-dialog select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#settings-close {
  margin-top: 10px; background: var(--bg); color: var(--accent);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; padding: 7px 16px; cursor: pointer;
}
#settings-close:hover { border-color: var(--border-strong); }
#settings-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── U6 — STATE A: the empty stage. One centered action card, LLM-app style.
   The viewport minus the header centers a ~640px card; everything else on the
   screen is one quiet meta line and one ghost demo link. ── */
#entry-stage {
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
#entry-card {
  position: relative;
  width: min(640px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}
#entry-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 190px;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 28px 20px;
  transition: border-color 150ms ease, background-color 150ms ease;
}
#entry-drop:hover { border-color: var(--muted); background: var(--accent-muted); }
#entry-drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.entry-drop-icon { color: var(--muted); font-size: 1.6rem; line-height: 1; }
.entry-drop-title { color: var(--fg-strong); font-size: 1.02rem; letter-spacing: 0.3px; text-align: center; }
.entry-drop-sub { color: var(--muted); font-size: 0.78rem; }

/* State B — the card's progress face (styled like the old terminal loader). */
#entry-progress { padding: 46px 20px; min-height: 190px; }
#entry-progress-text {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* Pre-audit error line inside the card. */
#entry-error {
  margin: 12px 2px 0;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
}
#entry-error[hidden] { display: none; }

/* Bottom row of the card — like an LLM input's toolbar: "+" extras on the left,
   the compact model select on the right. */
.entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
#entry-extras-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}
#entry-extras-btn:hover { color: var(--fg-strong); border-color: var(--border-strong); background: var(--accent-muted); }
#entry-extras-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#entry-extras-btn[aria-expanded="true"] { color: var(--fg-strong); background: var(--accent-muted); }
.entry-extras-note { color: var(--muted); font-size: 0.72rem; font-family: var(--font-mono); }
.entry-model { margin-left: auto; }
.entry-model select {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 6px 8px;
  max-width: 15rem;
  cursor: pointer;
}
.entry-model select:hover { color: var(--fg); border-color: var(--border-strong); }
.entry-model select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.entry-model select option:disabled { color: var(--muted); }

/* The "+" popover — the former optional-inputs block, relocated. */
#extras-popover {
  position: absolute;
  left: 14px;
  bottom: 60px;
  z-index: 30;
  width: min(400px, calc(100% - 28px));
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  animation: panel-in 160ms ease-out;
}
#extras-popover[hidden] { display: none; }
.extras-title {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
#extras-popover .option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--hint);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
#extras-popover input[type="number"] {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  padding: 5px 8px;
  width: 9rem;
}
#extras-popover input[type="number"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#extras-popover #opt-tx-btn {
  background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; padding: 5px 12px;
  cursor: pointer; font-size: 0.78rem;
}
#extras-popover #opt-tx-btn:hover { border-color: var(--border-strong); }
#extras-popover #opt-tx-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#extras-popover .option-filename { color: var(--accent); font-size: 0.72rem; word-break: break-all; }
#extras-popover .option-hint { color: var(--muted); font-size: 0.7rem; line-height: 1.5; margin-top: 4px; }
#extras-popover .option-warn {
  color: var(--warn);
  font-size: 0.72rem;
  margin: 6px 0 0;
  flex-basis: 100%;
}

/* Quiet guide link in the card's corner. */
.entry-guide-link {
  position: absolute;
  right: 16px;
  bottom: -28px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 2px;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.entry-guide-link:hover { color: var(--fg); }
.entry-guide-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ONE meta line under the card (replaces the five scattered remarks). */
#entry-meta {
  margin: 44px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.3px;
  text-align: center;
  max-width: 640px;
  line-height: 1.7;
}
.entry-demo-link {
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 150ms ease, background-color 150ms ease;
}
.entry-demo-link:hover { color: var(--fg-strong); background: var(--accent-muted); }
.entry-demo-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#sample-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 24px 0;
  padding: 10px 16px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
#sample-banner .sample-tag {
  color: var(--warn);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#demo-run-own {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 12px;
  cursor: pointer;
}
#demo-run-own:hover { border-color: var(--border-strong); }
#demo-run-own:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#demo-chat-hint {
  margin: 0 24px 24px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ── U6 — slide-over export guide (the former inline <details>) ─────────────
   A fixed right panel; auto-opens on a 422 "wrong export". Scrim + Esc close. */
#guide-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 88;
}
#guide-scrim[hidden] { display: none; }
#guide-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 94vw);
  z-index: 89;
  background: var(--surface-1);
  border-left: 1px solid var(--border-strong);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
  visibility: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#guide-panel[aria-hidden="false"] { transform: translateX(0); visibility: visible; }
:root[data-motion="reduced"] #guide-panel { transition: none; }
.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-strong);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  background: var(--surface-1);
}
#guide-panel .guide-body { padding: 16px 18px; }

/* ── U6 — keyboard shortcuts overlay ("?") ─────────────────────────────────*/
#shortcuts-help {
  padding: 0;
  border: none;
  background: transparent;
  max-width: 420px;
  width: 92vw;
}
#shortcuts-help::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
.shortcuts-box {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  padding: 20px 22px;
}
.shortcuts-title {
  color: var(--fg-strong);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.shortcuts-list { margin: 0 0 16px; }
.shortcuts-list > div {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 8px;
}
.shortcuts-list dt { flex: 0 0 5.5rem; margin: 0; }
.shortcuts-list dd {
  margin: 0;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.shortcuts-list kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-strong);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}
#shortcuts-close {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 6px 16px;
  cursor: pointer;
}
#shortcuts-close:hover { border-color: var(--border-strong); color: var(--fg-strong); }
#shortcuts-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.guide-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.guide-crumb {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg);
}
.guide-crumb--target { border-color: var(--accent); color: var(--accent); }
.guide-arrow { color: var(--muted); font-size: 0.72rem; }
.guide-steps {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.6;
}
.guide-steps li { margin-bottom: 4px; }
.guide-hint {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.5;
}
.prov-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--warn);
  border-radius: 3px;
  color: var(--warn);
  font-size: 0.6rem;
  letter-spacing: 0.5px;
  vertical-align: middle;
  text-transform: uppercase;
  cursor: help;
}

/* ── P4 — metric glossary tooltips ─────────────────────────────────────────
   An ⓘ trigger next to each metric label reveals a plain-language definition.
   Shown on hover, keyboard focus (:focus-within), or click (.tip--open for touch);
   the bubble lives inside .tip so the pointer can move onto it (WCAG 1.4.13). */
.tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 6px;
}
.tip-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  padding: 0;
  cursor: help;
}
.tip-btn:hover { color: var(--accent); }
.tip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 50%; }
.tip-bubble {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.tip:hover .tip-bubble,
.tip:focus-within .tip-bubble,
.tip.tip--open .tip-bubble { display: block; }

/* The model byline closes the report the way .report-label opens it. */
#ai-report .report-model {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px dashed var(--dotted);
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── L5 — Post-audit chat ──────────────────────────────────────────────────
   Mirrors #ai-report's panel chrome. Messages are quiet bubbles: the user's
   tinted with --accent, the assistant on --bg. Theme-native + reduced-motion. */
#chat-panel {
  margin: 32px 24px;
  padding: 24px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: panel-in 160ms ease-out;
}
#chat-panel .report-label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  border-bottom: 1px dashed var(--dotted);
  padding-bottom: 10px;
}
#chat-panel .chat-disclaimer {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 16px;
}
#chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg--user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--fg);
}
.chat-msg--assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
}
.chat-msg--error {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--warn);
  color: var(--warn);
}
.chat-input-row {
  display: flex;
  gap: 10px;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.92rem;
}
.chat-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
/* Light-on-dark primary (monochrome token spec) — green is data, not chrome. */
#chat-send {
  padding: 10px 20px;
  background: var(--fg-strong);
  border: none;
  border-radius: var(--radius);
  color: var(--bg);
  font-family: var(--font-mono, var(--font-sans));
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  cursor: pointer;
}
#chat-send:hover { filter: brightness(1.1); }
#chat-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── U6 — safe mini-markdown rendering (chat replies + the AI report). The
   renderer (js/markdown.js) emits only p/ul/ol/li/strong/em/code nodes with
   textContent — these styles make them read as typography, not raw syntax. ── */
.chat-msg p, .report-content p { margin: 0 0 10px; }
.chat-msg p:last-child, .report-content p:last-child { margin-bottom: 0; }
.chat-msg .md-heading, .report-content .md-heading {
  color: var(--fg-strong);
  font-weight: 600;
  margin: 14px 0 8px;
}
.chat-msg .md-heading:first-child, .report-content .md-heading:first-child { margin-top: 0; }
.chat-msg ul, .chat-msg ol, .report-content ul, .report-content ol {
  margin: 0 0 10px;
  padding-left: 22px;
}
.chat-msg li, .report-content li { margin-bottom: 4px; }
.chat-msg code, .report-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
.chat-msg .md-hr, .report-content .md-hr {
  border-top: 1px dashed var(--dotted);
  margin: 12px 0;
}

/* P9 — chat starter questions (pills above the input). */
.chat-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chat-starter {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 14px;
  cursor: pointer;
}
.chat-starter:hover { border-color: var(--border-strong); }
.chat-starter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* AI-A2: the "discussing trade X" indicator above the chat log, with a reset that
   returns the conversation to the whole audit. */
.chat-focus {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--accent-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--fg);
}
.chat-focus-label { flex: 1 1 auto; min-width: 0; }
.chat-focus-clear {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.chat-focus-clear:hover { color: var(--fg-strong); }
.chat-focus-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* AI-B2: the "Chart" affordance on the focus banner + the per-trade chart panel. */
.chat-focus-chart {
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 10px;
  cursor: pointer;
}
.chat-focus-chart:hover { border-color: var(--accent); color: var(--fg-strong); }
.chat-focus-chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#trade-chart-panel {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.trade-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.trade-chart-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: var(--muted);
}
.trade-chart-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.trade-chart-close:hover { color: var(--fg-strong); }
.trade-chart-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#trade-chart-container { width: 100%; height: 240px; }
.trade-chart-state {
  margin: 0;
  padding: 16px 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  #chat-panel { animation: none; }
}

/* ── Phase 8 — Risk Verdict, Scores, Behavioral Flags ──────────────────────
   The verdict is the hero of the result — given the most weight. Panels lift via
   --panel over --bg with quiet --border; the accent border is reserved for the
   verdict headline by level. */
#verdict-panel,
#behavioral-panel {
  margin: 32px 24px 0;
  padding: 24px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: panel-in 160ms ease-out;
}
#verdict-panel .report-label,
#behavioral-panel .report-label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--dotted);
  padding-bottom: 10px;
}

/* The verdict headline — the single most important takeaway, sized to dominate. */
.verdict-level {
  display: inline-block;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 8px 20px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  margin-bottom: 18px;
}
.verdict-level.risk-low { color: var(--accent); border-color: var(--accent); }
.verdict-level.risk-mid { color: var(--warn); border-color: var(--warn); }
.verdict-level.risk-high,
.verdict-level.risk-critical { color: var(--danger); border-color: var(--danger); }

.verdict-field {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.verdict-field-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.7rem;
  min-width: 11rem;
  flex-shrink: 0;
  padding-top: 2px;
}
.verdict-field-value { color: var(--fg-strong); word-break: break-word; }
.verdict-qualified {
  margin-top: 12px;
  color: var(--warn);
  font-size: 0.75rem;
  font-style: italic;
}

/* Scores — three compact chips below the verdict. Seams are quiet --border. */
#scores-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-top: 20px;
  background-color: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.score-chip {
  flex: 1 1 0;
  min-width: 7rem;
  background: var(--panel);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.score-value { font-size: 2rem; font-weight: 700; letter-spacing: 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.score-value.score-good { color: var(--accent); }
.score-value.score-mid { color: var(--warn); }
.score-value.score-bad { color: var(--danger); }
.score-label {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.25px;
}
.scores-confidence {
  width: 100%;
  background: var(--panel);
  color: var(--hint);
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  padding: 8px 18px;
  text-transform: uppercase;
}

/* Behavioral flags — one card per finding, severity-coded, evidence-grounded. */
.flag-card {
  border-left: 3px solid var(--hint);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--panel-2);
}
.flag-card.sev-high { border-left-color: var(--danger); }
.flag-card.sev-medium { border-left-color: var(--warn); }
.flag-card.sev-low { border-left-color: var(--hint); }
.flag-card:last-child { margin-bottom: 0; }
.flag-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.flag-severity {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 1px 7px;
  border: 1px solid var(--muted);
  border-radius: 3px;
  color: var(--muted);
}
.flag-severity.sev-high { color: var(--danger); border-color: var(--danger); }
.flag-severity.sev-medium { color: var(--warn); border-color: var(--warn); }
.flag-severity.sev-low { color: var(--hint); border-color: var(--hint); }
.flag-type {
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.25px;
}
.flag-desc { color: var(--fg); font-family: var(--font-sans); font-size: 0.9rem; line-height: 1.6; word-break: break-word; }
.flag-evidence {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 6px;
  letter-spacing: 0.25px;
}

/* ── Phase 8 polish — Breakdown slices (mini-bars) ─────────────────────────
   No charting dependency — bars are plain divs, theme-native. */
#breakdowns-panel {
  margin: 32px 24px 0;
  padding: 24px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: panel-in 160ms ease-out;
}
#breakdowns-panel .report-label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--dotted);
  padding-bottom: 10px;
}
#breakdowns-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}
.bd-title {
  color: var(--accent);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
.bd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 0.75rem;
}
.bd-label {
  flex: 0 0 5.5rem;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bd-track {
  flex: 1 1 auto;
  height: 12px;
  background: var(--grid);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.bd-bar { height: 100%; }
.bd-bar.bd-pos { background: var(--accent); }
.bd-bar.bd-neg { background: var(--danger); opacity: 0.6; }
.bd-val {
  flex: 0 0 6.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── U6 — data quality notice: one sentence + an expandable detail. ──────────*/
#data-quality-notice {
  margin: 16px 24px 0;
  padding: 14px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
#data-quality-notice #dq-sentence { margin: 0; color: var(--warn); }
#data-quality-notice #dq-details { margin-top: 8px; }
#data-quality-notice #dq-details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.72rem;
  list-style: none;
}
#data-quality-notice #dq-details > summary::-webkit-details-marker { display: none; }
#data-quality-notice #dq-details > summary::before { content: '▸ '; }
#data-quality-notice #dq-details[open] > summary::before { content: '▾ '; }
#data-quality-notice #dq-details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#data-quality-notice #dq-reasons { margin: 8px 0 0; color: var(--muted); font-size: 0.75rem; line-height: 1.6; }

/* ── U2 — App shell + docked auditor chat ───────────────────────────────────
   The report is the content column; the auditor chat lives in a right-hand dock
   (bottom-sheet on mobile). The chat DOM kept its IDs, so chat.js / app.js are
   untouched — this is layout + a small dock controller (js/dock.js). */
#app-shell {
  --dock-w: 384px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--dock-w);
  align-items: start;
}
#app-shell[data-dock="closed"] { grid-template-columns: minmax(0, 1fr) 0; }
#app-shell[data-dock="closed"] #chat-dock { display: none; }
/* min-width:0 lets the content column shrink so a wide ledger scrolls inside
   itself instead of forcing the whole grid (and the dock) wider. */
#app-main { min-width: 0; }

#chat-dock {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
}
/* Resize handle on the dock's left edge (persisted width in js/dock.js). */
#dock-resize {
  position: absolute;
  left: -3px; top: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 3;
  transition: background-color 150ms ease;
}
#dock-resize:hover,
#dock-resize:focus-visible { background: var(--accent-muted); outline: none; }

.dock-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.dock-title { color: var(--accent); font-size: 0.72rem; letter-spacing: 1.5px; }
.dock-close {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 9px;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.dock-close:hover { color: var(--fg-strong); border-color: var(--border-strong); }
.dock-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The dock body never scrolls itself (overflow hidden) — only the inner message
   log does, with overscroll containment so a chat scroll can never chain into
   scrolling the page behind it. */
.dock-body {
  flex: 1 1 auto;
  overflow: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Empty-state primer (pre-audit). Hidden by dock.js once a chat exists. */
#dock-primer { color: var(--fg); }
.dock-primer-lead { color: var(--fg-strong); font-size: 0.95rem; margin: 0 0 10px; }
.dock-primer-note {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
}

/* The chat panel fills the dock: drop its standalone card chrome + the internal
   heading (the dock header already titles it), and stick the input to the base. */
#chat-dock #chat-panel {
  margin: 0;
  border: none;
  padding: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
#chat-dock #chat-panel > .report-label { display: none; }
/* The message log is the ONLY scroll container in the dock; contain keeps its
   overscroll from chaining into the page (the U6 scroll-chaining fix). */
#chat-dock .chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#chat-dock .chat-input-row {
  flex: 0 0 auto;
  margin: 0 -16px -16px;
  padding: 12px 16px;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
}

/* "Ask about this" ghost buttons on the verdict + each behavioral flag. Clicking
   pre-fills the chat input (js/dock.js) — render-only, no computation. */
.ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  padding: 3px 11px;
  margin-top: 10px;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}
.ask-btn::before { content: "?"; font-weight: 700; opacity: 0.8; }
.ask-btn:hover { color: var(--accent-hover); border-color: var(--accent); background: var(--accent-muted); }
.ask-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── U6 — insight rows inside the verdict panel. The former standalone insight
   cards merge into the verdict as evidence lines: severity dot + one sentence +
   inline ghost actions (Show trades / Ask). ── */
#verdict-insights:not(:empty) {
  margin-top: 18px;
  border-top: 1px dashed var(--dotted);
  padding-top: 6px;
}
.verdict-insight {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--dotted);
}
.verdict-insight:last-child { border-bottom: none; }
.insight-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  align-self: center;
}
.insight-high .insight-dot { background: var(--pnl-neg, var(--danger)); }
.insight-medium .insight-dot { background: var(--warn); }
.insight-low .insight-dot { background: var(--pnl-pos, var(--accent)); }
.insight-info .insight-dot { background: var(--muted); }
.insight-sentence {
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0;
  flex: 1 1 16rem;
}
.insight-key {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 1.25px;
  text-transform: uppercase;
}
.insight-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.insight-action {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}
.insight-action:hover { color: var(--accent-hover); border-color: var(--accent); background: var(--accent-muted); }
.insight-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The Ask action reuses .ask-btn; keep its pill look but drop the ask ? glyph
   here (the label already says "Ask"). */
.insight-action.ask-btn { margin-top: 0; }
.insight-action.ask-btn::before { content: none; }

/* ── U3 — drag-and-drop overlay ─────────────────────────────────────────────── */
#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
#drop-overlay[hidden] { display: none; }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 64px;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: var(--surface-1, var(--panel));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: panel-in 160ms ease-out;
}
.drop-overlay-icon {
  color: var(--accent);
  font-size: 2.4rem;
  line-height: 1;
  animation: drop-bounce 1s ease-in-out infinite;
}
.drop-overlay-text {
  color: var(--fg-strong);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}
@keyframes drop-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}
:root[data-motion="reduced"] .drop-overlay-icon { animation: none; }

/* Floating action button + scrim — mobile only (hidden on desktop). */
#dock-fab, #dock-scrim { display: none; }

@media (max-width: 1024px) {
  /* Single content column; the dock becomes a fixed bottom-sheet. */
  #app-shell,
  #app-shell[data-dock="closed"] { display: block; grid-template-columns: none; }

  #chat-dock {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    height: 82vh;
    max-height: 82vh;
    border-left: none;
    border-top: 1px solid var(--border-strong);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 60;
    box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.42);
  }
  /* Base rule hides the dock when closed; on mobile keep it mounted so it can
     slide, and drive visibility with the transform instead. */
  #app-shell[data-dock="closed"] #chat-dock { display: flex; }
  #app-shell[data-dock="open"] #chat-dock { transform: translateY(0); }
  #dock-resize { display: none; }

  #dock-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--fg-strong);
    color: var(--bg);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 58;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  }
  #dock-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  #app-shell[data-dock="open"] ~ #dock-fab { display: none; }

  #dock-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 59;
  }
  #dock-scrim[hidden] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #chat-dock { transition: none; }
}

/* ── U4 — command palette (Ctrl/Cmd+K) ──────────────────────────────────────── */
#command-palette {
  padding: 0;
  border: none;
  background: transparent;
  max-width: 560px;
  width: 92vw;
  margin-top: 12vh;
}
#command-palette::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
.palette-box {
  background: var(--surface-1, var(--panel));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.palette-input {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  color: var(--fg-strong);
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 16px 18px;
}
.palette-input:focus { outline: none; }
.palette-input::placeholder { color: var(--muted); }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.palette-item {
  padding: 9px 12px;
  border-radius: var(--radius-btn, 6px);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
}
.palette-item.palette-active,
.palette-item:hover { background: var(--accent-muted); color: var(--fg-strong); }
.palette-list:empty::after {
  content: "—";
  display: block;
  padding: 14px 12px;
  color: var(--muted);
  text-align: center;
}

/* ── U4 — collapsible report sections ───────────────────────────────────────── */
[data-collapsible="1"] {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
[data-collapsible="1"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Chevron as ::after (not a child node) so a language change — which re-sets the
   heading's textContent via localizeDOM — can never wipe it. */
[data-collapsible="1"]::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  font-size: 0.7rem;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.is-collapsed > [data-collapsible="1"]::after { transform: rotate(-90deg); }
/* Collapsed = hide everything in the panel except its heading. No height
   animation → zero layout-shift jank; honors reduced-motion by construction. */
.is-collapsed > :not(.report-label) { display: none !important; }
:root[data-motion="reduced"] [data-collapsible="1"]::after { transition: none; }

/* ── Print / PDF export (Phase 9) ───────────────────────────────────────────
   A shareable one-document artifact. The on-screen theme prints faithfully
   (print-color-adjust: exact) so the PDF looks like the product; interactive
   chrome (uploads, chat, ledger, the live canvas) is dropped, and a print-only
   header/footer frame the report with branding + a P4 disclaimer. The live chart
   canvas does not rasterize on print, so print.js swaps in a PNG screenshot held
   in #print-chart, gated by data-has so a chartless audit prints no empty figure. */
.print-only { display: none; }
#print-chart-section { display: none; }

/* On-screen app footer (Phase 9 legal): short P4 disclaimer + links to /legal.
   Carries .no-print so it never doubles the PDF's #print-footer disclaimer. */
.app-foot {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 20px 24px 28px;
  text-align: center;
}
.app-foot-note {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  line-height: 1.55;
  max-width: 70ch;
  margin: 0 auto 10px;
}
.app-foot-legal { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; }
.app-foot-legal a {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  text-decoration: none;
}
.app-foot-legal a:hover { color: var(--fg-strong); }
.app-foot-legal a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Small screens (phones / narrow windows). The app is desktop-first; this reflows the
   chrome so a casually-shared link is usable on a phone instead of cramped + clipped.
   Layout/spacing only — the quant-terminal palette and type are unchanged. The viewport
   meta (app.html) already renders at device width; the ledger gets horizontal scroll via
   #ledger-container above. */
@media (max-width: 640px) {
  #dashboard { padding: 12px 16px; gap: 10px 14px; }
  #dashboard h1 { font-size: 0.85rem; }
  .dashboard-brand { gap: 10px; flex-wrap: wrap; }

  /* The entry card breathes less on a phone; the popover inputs flex down so a
     ~320px row never overflows next to its label. */
  #entry-stage { min-height: calc(100vh - 120px); padding: 20px 12px; }
  #entry-drop { min-height: 160px; padding: 22px 14px; }
  #extras-popover input[type="number"] { width: auto; flex: 1 1 7rem; min-width: 0; }
  .entry-guide-link { position: static; display: block; margin: 10px auto 0; }

  /* Give the chart/ledger a touch more room and a lower floor on short phones. */
  #chart-wrapper { height: 60vh; min-height: 260px; }
  #ledger-container { padding: 12px; }
}

@media print {
  @page { margin: 14mm; }

  *, *::before, *::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Drop interactive / non-essential chrome. The verdict-insight rows print
     (they are report content); their action buttons don't. */
  #dashboard,
  #chat-panel,
  #chat-dock,
  #dock-fab,
  #dock-scrim,
  #entry-stage,
  #guide-panel,
  #guide-scrim,
  #shortcuts-help,
  #ledger-container,
  #chart-wrapper,
  #demo-chat-hint,
  .insight-actions,
  .no-print {
    display: none !important;
  }

  /* Collapse the shell grid so the report column prints full-width. */
  #app-shell { display: block !important; }

  /* A section the reader collapsed on screen still prints in full. */
  .is-collapsed > :not(.report-label) { display: revert !important; }
  [data-collapsible="1"]::after { content: none !important; }

  /* Reveal the print-only frame. */
  #print-header,
  #print-footer { display: block !important; }
  #print-chart-section[data-has="true"] { display: block !important; }

  body { background: var(--bg); color: var(--fg); }

  /* Use the page margin instead of the on-screen side gutters, and keep each
     result block intact across page breaks. */
  #verdict-panel,
  #behavioral-panel,
  #stats-panel,
  #breakdowns-panel,
  #data-quality-notice,
  #ai-report,
  #print-chart-section {
    margin: 0 0 14px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .flag-card,
  .score-chip { page-break-inside: avoid; break-inside: avoid; }

  #print-header {
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  #print-header .print-brand { color: var(--accent); font-size: 1.1rem; letter-spacing: 1.5px; font-weight: 700; }
  #print-header .print-title { color: var(--fg-strong); font-size: 0.8rem; letter-spacing: 2px; margin-top: 6px; text-transform: uppercase; }
  #print-header .print-generated { color: var(--muted); font-size: 0.7rem; letter-spacing: 1px; margin-top: 6px; }

  #print-chart-section .print-chart-title {
    color: var(--accent);
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
  }
  #print-chart {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  #print-footer {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  #print-footer .print-disclaimer {
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    line-height: 1.5;
  }
}
