/* Market-Brain dashboard — teal accent (D33 family with strfinance,
   distinguished by the ⬡ wordmark and a brighter teal so the two tabs don't
   blur together).

   Theme follows the OS via prefers-color-scheme (D71): dark is the default
   :root (GitHub-dark family, unchanged); a @media (light) block below swaps
   the palette to "warm paper". Two rules keep the two modes honest:
   (1) every surface/text/accent reads a CSS var, never a literal — so the
   light block re-themes the whole app by overriding ~25 vars; and (2) tints
   over a base colour use color-mix(var) not a baked rgba(), so they shift
   with the base var instead of staying a dark-mode wash on cream. The handful
   of colours that genuinely differ by mode (text sitting ON a tint, chart
   ink) are their own vars (--on-* / --chart-*). */

:root {
    --bg: #0d1117;
    --bg-elev: #161b22;
    --bg-elev-2: #1c2430;
    --border: #2a3441;
    --text: #e6edf3;
    --text-light: #9aa7b4;
    --teal: #2dd4bf;
    --teal-dim: #14b8a6;
    --amber: #f0b429;
    --red: #f85149;
    --green: #3fb950;

    /* Text sitting ON a low-alpha tint of the same hue. In dark these equal
       the bright accent (or its hand-tuned soft variant) so dark renders
       pixel-identical to pre-D71; the light block deepens them for cream. */
    --on-teal: var(--teal);
    --on-amber: var(--amber);
    --on-red: #ff9d97;
    --on-green: var(--green);
    --tint-error-text: #ffb3ae;
    --tint-warning-text: #f5d488;
    --tint-success-text: #8fe39a;
    --tint-pending-text: #f5c451;

    /* Chart.js ink — read by ticker.js via getComputedStyle so the canvas
       re-themes on an OS switch (no Chart colour is baked into the JS). */
    --chart-line: #2dd4bf;
    --chart-flag: #f0b429;
    --chart-flag-border: #0d1117;
    --chart-grid: #1c2430;
    --chart-tick: #9aa7b4;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #faf8f3;
        --bg-elev: #f3efe6;
        --bg-elev-2: #e9e3d6;
        --border: #e0d9c8;
        --text: #1f2933;
        --text-light: #5c6670;
        --teal: #14b8a6;
        --teal-dim: #0f9488;
        --amber: #c2820a;
        --red: #d13b32;
        --green: #2c8a3d;

        --on-teal: #0f7d70;
        --on-amber: #8a5d00;
        --on-red: #b3271e;
        --on-green: #237032;
        --tint-error-text: #b3271e;
        --tint-warning-text: #8a5d00;
        --tint-success-text: #237032;
        --tint-pending-text: #8a5d00;

        --chart-line: #0f9488;
        --chart-flag: #c2820a;
        --chart-flag-border: #faf8f3;
        --chart-grid: #e0d9c8;
        --chart-tick: #5c6670;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ── Top nav ─────────────────────────────────────────────────────────── */
.topnav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.brand-mark { color: var(--teal); font-size: 1.25rem; }
.ticker-search { flex: 1 1 200px; min-width: 160px; max-width: 420px; }
.ticker-search input {
    width: 100%;
    padding: 0.5rem 0.85rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
}
.ticker-search input:focus { outline: none; border-color: var(--teal); }
.topnav-right { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.who { color: var(--text-light); font-size: 0.85rem; }

/* ── Content ─────────────────────────────────────────────────────────── */
.content { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
}
.card h2 { margin-bottom: 0.5rem; }
.muted { color: var(--text-light); }
.small { font-size: 0.85rem; margin-top: 0.75rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--teal-dim); color: #04211d; }
.btn-primary:hover { background: var(--teal); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-light); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }

/* ── Flash / alerts ──────────────────────────────────────────────────── */
.flash-messages { margin-bottom: 1.5rem; }
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert.error { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: var(--red); color: var(--tint-error-text); }
.alert.warning { background: color-mix(in srgb, var(--amber) 12%, transparent); border-color: var(--amber); color: var(--tint-warning-text); }
.alert.success { background: color-mix(in srgb, var(--green) 12%, transparent); border-color: var(--green); color: var(--tint-success-text); }

/* ── Login ───────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.25rem;
}
.login-card .brand { font-size: 1.6rem; display: block; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--text-light); font-size: 0.9rem; margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.35rem; }
.form-group input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
}
.form-group input:focus { outline: none; border-color: var(--teal); }
.checkbox { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text-light); margin-bottom: 1.25rem; }

/* ── Top-nav links + banner + footer ─────────────────────────────────── */
/* flex-wrap so the 5 links reflow to a second line on narrow phones instead of
   pushing the row past the viewport (audit P2/P3: 51px overflow at 390px, 121px at
   320px). Inherently responsive — it wraps only when the links don't fit, so on
   desktop/tablet (one line, ample room) the row-gap is never used and rendering is
   unchanged. The column-gap stays 1.1rem; row-gap 0.5rem spaces wrapped lines. */
.topnav-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; }
.topnav-links a { color: var(--text-light); text-decoration: none; font-size: 0.9rem; font-weight: 600; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.topnav-links a:hover { color: var(--text); }
.topnav-links a.active { color: var(--teal); border-bottom-color: var(--teal); }
.banner { padding: 0.6rem 1.5rem; font-size: 0.88rem; text-align: center; }
.banner-degraded { background: color-mix(in srgb, var(--red) 15%, transparent); border-bottom: 1px solid var(--red); color: var(--tint-error-text); }
.page-footer { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem 2rem; color: var(--text-light); font-size: 0.78rem; }

/* ── Page head ───────────────────────────────────────────────────────── */
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.page-head h1 .muted { font-weight: 400; font-size: 1.1rem; }
.back-link, .link-cue { color: var(--teal); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.back-link { display: inline-block; margin-bottom: 0.5rem; }
.link-cue:hover, .back-link:hover { text-decoration: underline; }

/* ── Stat cards + grids ──────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; text-decoration: none; color: var(--text); }
a.stat-card:hover { border-color: var(--teal); }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--teal); }
.stat-label { color: var(--text-light); font-size: 0.85rem; margin-top: 0.25rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-head h2 { font-size: 1.05rem; }
.hint-card { background: color-mix(in srgb, var(--teal) 6%, transparent); border-color: var(--teal-dim); }

.briefing-teaser { display: block; text-decoration: none; color: var(--text); }
.briefing-teaser-date { font-size: 1.15rem; font-weight: 600; }
.dive-list { list-style: none; }
.dive-list li { border-top: 1px solid var(--border); }
.dive-list li:first-child { border-top: none; }
.dive-list a { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0; text-decoration: none; color: var(--text); }
.dive-ticker { font-weight: 700; min-width: 3rem; }

/* ── Tables ──────────────────────────────────────────────────────────── */
/* overflow-x:auto (not hidden) so wide tables scroll WITHIN their card on
   mobile instead of clipping the right columns or forcing the page wide
   (P2 #6). max-width:100% keeps the card itself inside the viewport. */
.table-card { padding: 0; overflow-x: auto; max-width: 100%; }
/* Generic scroll wrapper for tables not inside a .table-card (e.g. the
   ticker History tab). */
.table-scroll { overflow-x: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; padding: 0.75rem 1rem; color: var(--text-light); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--border); background: var(--bg-elev-2); }
.data-table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-elev-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ticker-link { color: var(--teal); font-weight: 700; text-decoration: none; }
.ticker-link:hover { text-decoration: underline; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.pos-pill, .status-pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pos-pill { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--on-teal); }
.status-pill { background: var(--bg-elev-2); color: var(--text-light); border: 1px solid var(--border); }
.status-pending, .status-sent { color: var(--amber); }
.status-resolved_win, .status-win { color: var(--green); }
.status-resolved_loss, .status-loss { color: var(--red); }

/* ── Per-row watchlist controls (reorder + remove, D74) ──────────────── */
.manage-col { text-align: right; }
.row-controls { white-space: nowrap; text-align: right; }
.row-controls form { display: inline-block; margin: 0; }
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1;
    padding: 0.2rem 0.35rem;
    border-radius: 6px;
    transition: color 0.12s ease, background 0.12s ease;
}
.icon-btn:hover { color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent); }
.icon-btn:disabled { color: color-mix(in srgb, var(--text-light) 40%, transparent); cursor: default; background: transparent; }
.icon-remove:hover { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* ── Verdict (the headline visual on the Tier-2 page) ────────────────── */
.verdict-banner { border-radius: 14px; padding: 1.75rem 2rem; margin-bottom: 1rem; border: 1px solid var(--border); }
.verdict-eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--text-light); margin-bottom: 0.35rem; }
.verdict-label { font-size: 2.1rem; font-weight: 800; line-height: 1.1; }
.verdict-strong_consideration { background: color-mix(in srgb, var(--green) 14%, transparent); border-color: var(--green); }
.verdict-strong_consideration .verdict-label { color: var(--on-green); }
.verdict-watchlist_candidate { background: color-mix(in srgb, var(--teal) 14%, transparent); border-color: var(--teal); }
.verdict-watchlist_candidate .verdict-label { color: var(--on-teal); }
.verdict-worth_tracking { background: color-mix(in srgb, var(--amber) 14%, transparent); border-color: var(--amber); }
.verdict-worth_tracking .verdict-label { color: var(--on-amber); }
.verdict-pass { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: var(--red); }
.verdict-pass .verdict-label { color: var(--on-red); }
.verdict-unavailable .verdict-label { color: var(--text-light); }
.analyzed-line { margin-bottom: 1rem; }
.action-row { margin-bottom: 1.25rem; }

.verdict-chip { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.verdict-chip.verdict-strong_consideration { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--on-green); }
.verdict-chip.verdict-watchlist_candidate { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--on-teal); }
.verdict-chip.verdict-worth_tracking { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--on-amber); }
.verdict-chip.verdict-pass { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--on-red); }
/* Degraded-verdict chip (D53 placeholder) — muted, mirrors the .verdict-banner
   .verdict-unavailable treatment for the Analyses table (D73). */
.verdict-chip.verdict-unavailable { background: var(--bg-elev-2); color: var(--text-light); }

/* ── Tabs ────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab-btn { background: none; border: none; color: var(--text-light); padding: 0.6rem 1rem; font-size: 0.92rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Ticker page bits ────────────────────────────────────────────────── */
.ticker-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.universe-line { color: var(--text-light); font-size: 0.85rem; }
.price-headline { text-align: right; }
.price-now { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-change { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.metric { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 0.85rem 1rem; }
.metric-label { color: var(--text-light); font-size: 0.78rem; }
.metric-val { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 0.2rem; }
.vol-band { font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: 999px; vertical-align: middle; }
.vol-very-high-vol { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--on-red); }
.vol-high-vol { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--on-amber); }
.vol-moderate-vol { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--on-teal); }
.vol-low-vol { background: var(--bg-elev-2); color: var(--text-light); }
.chart-card .chart-wrap { height: 340px; position: relative; }
.chart-legend { font-size: 0.78rem; color: var(--text-light); display: flex; gap: 1rem; }
.lg-price { color: var(--teal); }
.lg-flag { color: var(--amber); }
.flag-block { border-top: 1px solid var(--border); padding: 0.85rem 0; }
.flag-block:first-of-type { border-top: none; }
.flag-meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }
.flag-thesis { font-size: 0.92rem; }
.kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem 1.5rem; }
.kv { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.kv span { color: var(--text-light); }
.kv b { font-variant-numeric: tabular-nums; }

/* ── Empty states ────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state h2 { margin-bottom: 0.5rem; }
.empty-state p { max-width: 460px; margin: 0 auto; }

/* ── Prose (rendered markdown: briefings + analyses) ─────────────────── */
.prose { line-height: 1.7; }
.prose h1, .prose h2, .prose h3 { margin: 1.4rem 0 0.6rem; line-height: 1.3; }
.prose h1 { font-size: 1.5rem; } .prose h2 { font-size: 1.25rem; color: var(--teal); }
.prose h3 { font-size: 1.05rem; }
.prose p { margin: 0.7rem 0; }
.prose ul, .prose ol { margin: 0.7rem 0 0.7rem 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose strong { color: var(--text); }
.prose em { color: var(--text-light); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.88rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.7rem; text-align: left; }
.prose th { background: var(--bg-elev-2); color: var(--text-light); }
.prose code { background: var(--bg-elev-2); padding: 0.1rem 0.35rem; border-radius: 5px; font-size: 0.88em; }
/* Named-miss cards: the synthesis renders each miss as a blockquote (markdown-
   only so it survives bleach, D85). The amber left-accent (D71 --amber) marks it
   as a miss; --bg-elev-2 gives the card fill. */
.prose blockquote {
    margin: 0.9rem 0; padding: 0.6rem 1rem;
    background: var(--bg-elev-2); border: 1px solid var(--border);
    border-left: 3px solid var(--amber); border-radius: 6px;
}
.prose blockquote p { margin: 0.35rem 0; }

/* ── Retrospective tabs (D85): server-side ?tab= selection, no client JS ─── */
.tab-nav { display: flex; gap: 0.5rem; margin: 0.5rem 0 1.25rem; flex-wrap: wrap; }
.tab-link {
    padding: 0.45rem 1rem; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
    background: var(--bg-elev-2); color: var(--text-light);
    border: 1px solid var(--border); text-decoration: none;
}
.tab-link:hover { color: var(--text); }
/* Solid-teal active pill mirrors .btn-primary (readable in both themes; --on-teal
   is a foreground-on-tint var and would be teal-on-teal here). */
.tab-link.tab-active { background: var(--teal-dim); color: #04211d; border-color: var(--teal-dim); }
.tab-link.tab-active:hover { color: #04211d; }
.tab-content { display: block; }
.tab-content-hidden { display: none; }
.tab-heading { font-size: 1.2rem; margin: 0.25rem 0 0.75rem; }

/* ── Holdings: add-position form ─────────────────────────────────────── */
.page-head.holdings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.form-card { margin-top: 1.25rem; }
.form-head { align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.position-form .field-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.1rem;
}
.position-form .field { margin-bottom: 1.1rem; }
.position-form label { display: block; font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.35rem; }
.position-form input, .position-form textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}
.position-form input:focus, .position-form textarea:focus { outline: none; border-color: var(--teal); }
.position-form textarea { resize: vertical; }
.position-form .hint { margin-top: 0.5rem; line-height: 1.5; }

/* ── Holdings: graduation CLI-pointer ────────────────────────────────── */
.grad-link-wrap { margin-top: 1.25rem; }
.grad-link { color: var(--text-light); font-size: 0.88rem; text-decoration: none; }
.grad-link:hover { color: var(--teal); }
.grad-msg { margin-top: 0.75rem; }
.grad-msg p { margin: 0.5rem 0; }
.grad-card { margin-top: 0.75rem; padding: 1.25rem 1.5rem; }
.grad-card-head { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.5rem; }
.grad-ticker { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.grad-date { color: var(--text-light); }
.grad-thesis { margin: 0.5rem 0 1rem; color: var(--text-light); line-height: 1.5; }
.grad-thesis em { color: var(--text-light); }

/* ── Watchlist: add-ticker form + awaiting-data banner (D64) ─────────── */
.add-ticker { margin: 1.25rem 0; }
.add-ticker-summary { cursor: pointer; font-weight: 600; color: var(--teal); list-style: none; }
.add-ticker-summary::-webkit-details-marker { display: none; }
.add-ticker[open] .add-ticker-summary { margin-bottom: 1rem; }
.add-ticker-form .field-row {
    display: grid;
    grid-template-columns: 0.8fr 2fr auto;
    gap: 1rem;
    align-items: end;
    margin-bottom: 0.5rem;
}
.add-ticker-form .field { margin-bottom: 0; }
.add-ticker-form label { display: block; font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.35rem; }
.add-ticker-form input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}
.add-ticker-form input:focus { outline: none; border-color: var(--teal); }
.add-ticker-form .hint { margin-top: 0.5rem; line-height: 1.5; }

.pos-pill.pending { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--tint-pending-text); }
.banner-row td { padding-top: 0; border-top: none; }
.row-banner {
    background: color-mix(in srgb, var(--amber) 8%, transparent);
    border-left: 3px solid var(--tint-pending-text);
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text-light);
}

/* "yours" ownership badge on user-added watchlist rows (D68). Muted gray reads
   as informational metadata (ownership), distinct from .pos-pill (teal =
   analysis state) and .pos-pill.pending (amber = awaiting ingestion). */
.user-added-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--text-light) 14%, transparent);
    color: var(--text-light);
    letter-spacing: 0.02em;
    vertical-align: middle;
}

/* ── Run fresh analysis: button, spinner, error (D66) ────────────────── */
.analysis-action { display: flex; align-items: center; }
.analyze-form { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.analyze-btn[disabled] { opacity: 0.6; cursor: progress; }
.analyze-spinner { display: flex; align-items: center; gap: 0.7rem; }
.analyze-status-text { color: var(--text-light); font-size: 0.92rem; }
.analyze-error { color: var(--red); margin: 0 0 0.6rem; font-size: 0.92rem; }
.spinner {
    width: 1.05rem;
    height: 1.05rem;
    border: 2px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    display: inline-block;
    animation: mb-spin 0.8s linear infinite;
}
@keyframes mb-spin { to { transform: rotate(360deg); } }

/* ── Daily-judgment surface (M3.7 Day 2 / D78) ───────────────────────────
   The arrow/dot glyphs carry their own themed color inline (style="…var(--…)")
   from the render helper, so they mode-shift automatically; these rules only do
   layout + the surrounding chrome. */
.judgment-arrow, .judgment-dots { vertical-align: middle; }
.judgment-dots { margin-left: 0.35rem; }

.read-col, .read-cell { white-space: nowrap; }
.read-link { display: inline-flex; align-items: center; text-decoration: none; }
.read-empty { color: var(--text-light); }

/* event-triggered re-read marker: a small amber dot beside the arrow (D71 var). */
.event-dot {
    display: inline-block;
    width: 6px; height: 6px;
    margin: 0 0.15rem 0 0.25rem;
    border-radius: 50%;
    background: var(--amber);
    vertical-align: middle;
}
.event-badge {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: color-mix(in srgb, var(--amber) 16%, transparent);
    color: var(--on-amber);
}

/* Read date + stale badge (D82). The date reads compactly beside the arrow; the
   amber "stale" pill (mirrors .event-badge) flags a read from a prior day —
   distinct copy from the D64 "Awaiting data" pending pill. */
.read-date { margin-left: 0.4rem; font-size: 0.72rem; color: var(--text-light); vertical-align: middle; }
.stale-badge {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: color-mix(in srgb, var(--amber) 16%, transparent);
    color: var(--on-amber);
    vertical-align: middle;
}

/* resolution outcome pills on the history page — reuse .status-pill base. */
.status-pill.status-win { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--on-green); border-color: var(--green); }
.status-pill.status-loss { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--on-red); border-color: var(--red); }
.status-pill.status-neutral { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--on-amber); border-color: var(--amber); }
.status-pill.status-pending { background: var(--bg-elev-2); color: var(--text-light); }

/* one-line scoreboard strip atop /watchlist — muted band, suppressed on noise. */
.scoreboard-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.55rem 0.95rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.scoreboard-body { color: var(--text); }
.scoreboard-body p { margin: 0; }
.scoreboard-link { color: var(--teal); text-decoration: none; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.ticker-link-list { line-height: 2; }

/* ── News proposal inbox (D162) ─────────────────────────────────────── */
.proposal-page-head .eyebrow {
    color: var(--teal);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}
.proposal-safety-card {
    border-color: var(--teal-dim);
    background: color-mix(in srgb, var(--teal) 6%, var(--bg-elev));
    margin-bottom: 1rem;
}
.proposal-safety-card p { max-width: 88ch; }
.research-request-card, .proposal-history-card { margin-bottom: 1rem; }
.research-request-form {
    display: grid;
    gap: 0.45rem;
    margin-top: 1rem;
}
.research-request-form label { color: var(--text-light); font-size: 0.85rem; }
.research-request-form input, .research-request-form textarea,
.proposal-history-form select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elev-2);
    color: var(--text);
    font: inherit;
}
.research-request-form textarea { resize: vertical; }
.research-request-form input:focus, .research-request-form textarea:focus,
.proposal-history-form select:focus { outline: none; border-color: var(--teal); }
.research-request-form .btn { justify-self: start; margin-top: 0.35rem; }
.research-queue { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.research-queue-item { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.research-queue-item > div { display: flex; gap: 0.55rem; align-items: baseline; }
.research-queue-item > .proposal-badge { margin-top: 0.35rem; }
.research-queue-item p { margin: 0.35rem 0 0; }
.proposal-history-form {
    display: grid;
    grid-template-columns: minmax(14rem, 1fr) auto;
    gap: 0.55rem;
    align-items: end;
}
.proposal-history-form label { grid-column: 1 / -1; }
.proposal-badge.decision-pending { border-color: var(--teal-dim); color: var(--on-teal); }
.proposal-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0 0.5rem;
}
.proposal-stat {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elev-2);
}
.proposal-stat strong { color: var(--teal); font-size: 1.35rem; }
.proposal-stat span { color: var(--text-light); font-size: 0.8rem; }
.proposal-run-time { margin-bottom: 1rem; }
.proposal-card { margin-bottom: 1rem; scroll-margin-top: 6rem; }
.proposal-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.proposal-card-head h2 { margin: 0.55rem 0 0; }
.proposal-badges, .proposal-tags, .proposal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.proposal-badge, .proposal-tags span {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elev-2);
    color: var(--text-light);
    font-size: 0.74rem;
    font-weight: 650;
}
.proposal-badge.coverage-uncovered { border-color: var(--amber); color: var(--on-amber); }
.proposal-badge.coverage-partial { border-color: var(--teal-dim); color: var(--on-teal); }
.proposal-badge.decision-accepted_for_validation { border-color: var(--green); color: var(--on-green); }
.proposal-badge.decision-rejected { border-color: var(--red); color: var(--on-red); }
.proposal-badge.decision-deferred { border-color: var(--amber); color: var(--on-amber); }
.proposal-why {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border-left: 3px solid var(--teal-dim);
    background: var(--bg-elev-2);
}
.proposal-why p { margin-top: 0.25rem; }
.proposal-block { margin-top: 1rem; }
.proposal-block h3 { font-size: 0.9rem; margin-bottom: 0.45rem; }
.proposal-block ul, .proposal-evidence ul { padding-left: 1.25rem; }
.proposal-block li, .proposal-evidence li { margin: 0.35rem 0; }
.proposal-tags span { color: var(--text); font-weight: 600; }
.proposal-keywords span { border-color: var(--teal-dim); }
.proposal-evidence { margin-top: 1rem; }
.proposal-evidence summary { color: var(--teal); cursor: pointer; font-weight: 650; }
.proposal-evidence a { color: var(--teal); }
.proposal-current-decision {
    margin-top: 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elev-2);
}
.proposal-current-decision .small { margin-left: 0.4rem; }
.proposal-current-decision p { margin-top: 0.4rem; }
.proposal-review-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.proposal-review-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}
.proposal-review-form textarea {
    width: 100%;
    resize: vertical;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elev-2);
    color: var(--text);
    font: inherit;
    margin-bottom: 0.65rem;
}
.proposal-review-form textarea:focus { outline: none; border-color: var(--teal); }
.proposal-reject { background: transparent; border-color: var(--red); color: var(--on-red); }
.proposal-reject:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }

@media (max-width: 820px) {
    .stat-grid, .metric-row { grid-template-columns: repeat(2, 1fr); }
    .two-col, .kv-grid { grid-template-columns: 1fr; }
    .topnav { flex-wrap: wrap; }
    .position-form .field-row { grid-template-columns: 1fr 1fr; }
    .add-ticker-form .field-row { grid-template-columns: 1fr; align-items: stretch; }
    .proposal-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .proposal-card-head { flex-direction: column; }
    .proposal-history-form { grid-template-columns: 1fr; }
    .proposal-history-form label { grid-column: auto; }
}

/* Narrow phones (P2 #6): tighten content gutters and table cell padding so
   the columns fit, and let the wrapped tables scroll horizontally if they
   still don't. */
@media (max-width: 480px) {
    .content { padding: 1.25rem 0.85rem; }
    .data-table { font-size: 0.82rem; }
    .data-table th { padding: 0.55rem 0.6rem; }
    .data-table td { padding: 0.55rem 0.6rem; }
    .position-form .field-row { grid-template-columns: 1fr; }
    .proposal-summary { grid-template-columns: 1fr; }
    .proposal-actions .btn { width: 100%; }
}
