/* stratum.css — shared look for every page (UI redesign, phase 1).
 *
 * Loaded AFTER each template's inline <style>, so it re-points the token set
 * those blocks already share (--surface-*, --fg-*, --pos/--neg/…, --bd*, --r-*)
 * to a shadcn-style zinc palette without touching the 36k lines that consume
 * them. `:root[data-theme=…]` outranks the inline `[data-theme="light"]`, so
 * both themes are overridden, whatever order the page declares them in.
 *
 * The rest of the file is the app shell: the sidebar (`templates/_sidebar.html`)
 * and the rules that hide each page's old nav once the sidebar is present.
 * Pages without the sidebar (login, onboarding) get the tokens only.
 */

/* ── Tokens: dark (default, matches the pages' own default) ─────────────── */
:root,
:root[data-theme="dark"] {
    --surface-0: #09090b;          /* page */
    --surface-1: #0f0f12;          /* cards */
    --surface-2: #18181b;          /* nested / hover / chip */
    --surface-3: #27272a;          /* inputs, raised chip */

    --fg-0: #fafafa;
    --fg-1: #d4d4d8;
    --fg-2: #a1a1aa;
    --fg-3: #52525b;

    --pos:    #4ade80;
    --pos-bg: rgba(74,222,128,0.10);
    --pos-bd: rgba(74,222,128,0.28);
    --neg:    #f87171;
    --neg-bg: rgba(248,113,113,0.10);
    --neg-bd: rgba(248,113,113,0.28);
    --warn:    #f59e0b;
    --warn-bg: rgba(245,158,11,0.10);
    --warn-bd: rgba(245,158,11,0.28);
    --info:    #60a5fa;
    --info-bg: rgba(96,165,250,0.10);
    --info-bd: rgba(96,165,250,0.28);
    --info-fill: #2563eb;          /* blue under white text: 5.2:1 (the text blue is 2.5:1) */
    /* Indigo: the accent is both a fill under white text and text on the page,
       and indigo-500 clears 4.5:1 for both on this ground. */
    --accent:    #6366f1;
    --accent-bg: rgba(99,102,241,0.12);
    --accent-bd: rgba(99,102,241,0.36);
    /* Conv #725: one colour per strategy, used identically in chips, the
       allocation bar and the Home chart layers. Home v3 (2026-10-27): orchid
       and cornflower, no strategy in green so green only ever means a gain.
       Text on the card: orchid 10.6:1, cornflower 7.8:1 (chip on its tint over
       a hovered row 7.7 / 6.0). Charts draw a dark tinted fill (*-fill) with
       the colour as its outline (*-line). */
    --ep:    #d9b6d9;
    --ep-bg: rgba(217,182,217,0.12);
    --ep-bd: rgba(217,182,217,0.38);
    --ep-line: #d9b6d9;
    --ep-fill: #3d2f3d;
    --tm:    #8fa6d6;
    --tm-bg: rgba(143,166,214,0.12);
    --tm-bd: rgba(143,166,214,0.40);
    --tm-line: #8fa6d6;
    --tm-fill: #2a3346;
    --other-line: #71717a;
    --other-fill: #232328;
    /* Conv #730: Home's cash fill (zinc-500), 3.96:1 on the card (was 1.3:1). */
    --st-cash: #71717a;

    --bd-soft:   #1f1f23;
    --bd:        #27272a;
    --bd-strong: #3f3f46;

    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;

    --elev-1: none;
    --elev-2: 0 4px 16px rgba(0,0,0,0.45);
    --elev-3: 0 16px 48px rgba(0,0,0,0.6);

    --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;

    --st-sidebar-w: 248px;
    --st-sidebar-bg: #0c0c0e;
    --st-item-active: #27272a;
    --st-badge-warn-bg: #f59e0b;
    --st-badge-warn-fg: #09090b;
}

/* ── Tokens: light ─────────────────────────────────────────────────────── */
:root[data-theme="light"] {
    --surface-0: #fafafa;
    --surface-1: #ffffff;
    --surface-2: #f4f4f5;
    --surface-3: #e4e4e7;

    --fg-0: #09090b;
    --fg-1: #3f3f46;
    --fg-2: #52525b;
    --fg-3: #a1a1aa;

    --pos:    #15803d;
    --pos-bg: rgba(21,128,61,0.08);
    --pos-bd: rgba(21,128,61,0.24);
    --neg:    #b91c1c;
    --neg-bg: rgba(185,28,28,0.08);
    --neg-bd: rgba(185,28,28,0.24);
    --warn:    #b45309;
    --warn-bg: rgba(180,83,9,0.08);
    --warn-bd: rgba(180,83,9,0.24);
    --info:    #1d4ed8;
    --info-bg: rgba(29,78,216,0.08);
    --info-bd: rgba(29,78,216,0.24);
    --info-fill: #1d4ed8;
    --accent:    #4f46e5;
    --accent-bg: rgba(79,70,229,0.08);
    --accent-bd: rgba(79,70,229,0.28);
    /* Conv #725 (was violet-700 / teal-800; chips on their tint over a
       hovered .st-row must stay >= 4.5:1, the 2026-10-13 amendment). */
    /* Home v3: orchid 6.4:1 and cornflower 5.8:1 as text on the white card
       (chip on its tint over a hovered row 5.2 / 4.7). The cornflower outline
       on charts is lighter (#6a84ba, 3.7:1 as a graphic); fills are pale tints
       carried by their outline. */
    --ep:    #7e4f7e;
    --ep-bg: rgba(126,79,126,0.08);
    --ep-bd: rgba(126,79,126,0.30);
    --ep-line: #7e4f7e;
    --ep-fill: #e9dae9;
    --tm:    #4a649d;
    --tm-bg: rgba(74,100,157,0.09);
    --tm-bd: rgba(74,100,157,0.32);
    --tm-line: #6a84ba;
    --tm-fill: #d9e2f3;
    --other-line: #8b8b94;   /* 3.4:1 on white (zinc-400 was 2.56) */
    --other-fill: #ececee;
    --st-cash: #71717a;   /* 4.83:1 on the white card */

    --bd-soft:   #f0f0f2;
    --bd:        #e4e4e7;
    --bd-strong: #d4d4d8;

    --elev-1: 0 1px 2px rgba(0,0,0,0.04);
    --elev-2: 0 4px 16px rgba(0,0,0,0.08);
    --elev-3: 0 16px 48px rgba(0,0,0,0.12);

    --st-sidebar-bg: #f4f4f5;
    --st-item-active: #e4e4e7;
    --st-badge-warn-bg: #b45309;
    --st-badge-warn-fg: #ffffff;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "tnum" 1;   /* numbers line up in every table */
}
.mono { font-family: var(--font-mono); }
.card { box-shadow: var(--elev-1); }

/* ── Filled buttons ────────────────────────────────────────────────────── */
/* Pages fill buttons with the text blue (--blue) under white text, which is
   2.5:1 in dark mode. Point the known ones at --info-fill; the attribute rules
   catch the same pairing written inline in page scripts. */
.run-btn, .compare-btn, .stabs button.active,
[style*="background:var(--blue);color:#fff"],
[style*="background:var(--blue);color:white"],
[style*="background:var(--blue); color:#fff"] { background: var(--info-fill) !important; }
/* Sign in is the page's one action: shadcn's primary (foreground-on-background). */
.login-box .btn { background: var(--fg-0); color: var(--surface-0); }
.login-box .btn:hover { opacity: 0.9; }

/* Segmented control (Performance strategy picker, Holdings filters). */
.st-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); }
.st-seg button {
    height: 30px; padding: 0 12px; border: none; border-radius: 6px; background: transparent;
    color: var(--fg-2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.st-seg button:hover { color: var(--fg-0); }
.st-seg button[aria-pressed="true"] { background: var(--surface-1); color: var(--fg-0); box-shadow: 0 0 0 1px var(--bd); }
.st-pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.st-pagehead h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }

/* All positions (Holdings) */
.st-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.st-table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--fg-2); padding: 8px 10px; border-bottom: 1px solid var(--bd); background: transparent !important; }
.st-table td { padding: 10px; border-bottom: 1px solid var(--bd-soft); }
.st-table .num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.st-table tr:last-child td { border-bottom: none; }
.st-chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--bd); background: var(--surface-2); color: var(--fg-1); }
/* Conv #725: the strategy chip carries the strategy's colour (Holdings, Home, Activity). */
.st-chip-ep { color: var(--ep); background: var(--ep-bg); border-color: var(--ep-bd); }
.st-chip-tm { color: var(--tm); background: var(--tm-bg); border-color: var(--tm-bd); }
.st-row { cursor: pointer; }
.st-row:hover td { background: var(--surface-2); }
.st-act {
    height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--neg-bd); background: var(--neg-bg); color: var(--neg);
    font: inherit; font-size: 12.5px; font-weight: 600;
}
.st-act:hover { background: var(--neg); color: var(--surface-0); }
.st-act:disabled { opacity: 0.5; cursor: default; }
/* Holdings: renderDashHoldings still draws the TM summary + table into
   #dash-h-table; the merged table replaces them. Only its drawdown alert stays. */
#st-allpos-card #dash-h-table > :not(#dd-alert) { display: none !important; }
#st-allpos-card #dash-h-empty { display: none !important; }
.st-kpis { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 14px; }
.st-kpis div { display: flex; flex-direction: column; gap: 2px; }
.st-kpis span:first-child { font-size: 12px; color: var(--fg-2); }
.st-kpis span:last-child { font-size: 18px; font-weight: 600; font-family: var(--font-mono); }

/* Performance: monthly returns table */
.st-months { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.st-months th { font-weight: 500; color: var(--fg-2); padding: 6px 4px; text-align: center; background: transparent !important; text-transform: none; letter-spacing: 0; }
.st-months tbody th { text-align: left; color: var(--fg-0); font-weight: 600; padding-right: 12px; }
.st-months td {
    text-align: center; padding: 9px 4px; border-radius: 4px; min-width: 44px;
    font-family: var(--font-mono); color: var(--fg-0); position: relative;
}
.st-months td.is-empty { background: var(--surface-2); opacity: 0.35; }
.st-months td.is-year { font-weight: 700; min-width: 64px; }
.st-months td small { display: block; font-size: 9px; color: var(--fg-2); line-height: 1; margin-top: 2px; }

/* Home */
.st-muted { color: var(--fg-2); font-size: 13.5px; }
.st-link { font-size: 13px; color: var(--fg-2); text-decoration: none; }
.st-link:hover { color: var(--fg-0); }
.st-kpi-card {
    display: flex; flex-direction: column; gap: 6px; padding: 16px 18px;
    background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-lg);
}
.st-kpi-card span { font-size: 12.5px; font-weight: 500; color: var(--fg-2); }
.st-kpi-card b { font-size: 22px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; }
.st-kpi-card em { font-style: normal; font-size: 12px; color: var(--fg-2); }
.st-cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.st-cardhead h2 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.st-split-bar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: 14px; }
.st-split-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.st-split-row i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.st-split-row span { flex: 1; }
.st-split-row span em { font-style: normal; font-size: 12px; margin-left: 4px; }
.st-split-row b { font-weight: 500; }
.st-split-row > em { font-style: normal; color: var(--fg-2); width: 40px; text-align: right; }

/* Home v2 (2026-10-12): hero, account value + P&L calendar, strategy cards. */
.st-home { display: flex; flex-direction: column; gap: 16px; max-width: 1400px; font-variant-numeric: tabular-nums; }
.st-hero-value, .st-home-readout > b { font-variant-numeric: normal; }
.st-home > .card, .st-home-row > .card { margin: 0; }
.st-up { color: var(--pos); }
.st-down { color: var(--neg); }
.st-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; vertical-align: middle; }
.st-dot-ep, .st-fill-ep { background: var(--ep); }
.st-dot-tm, .st-fill-tm { background: var(--tm); }
.st-fill-cash { background: var(--st-cash); }
.st-dot-flow { background: var(--fg-0); box-shadow: 0 0 0 2px var(--surface-1); }

/* Hero: no box. The value leads, today's move sits beside it, the per-strategy
   split and the source in one quiet line below; drawdown at the far right. */
.st-hero { display: flex; align-items: stretch; gap: 16px 28px; flex-wrap: wrap; padding: 4px 2px 2px; }
.st-hero-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.st-hero-label { font-size: 13px; font-weight: 500; color: var(--fg-2); }
.st-hero-value { font-size: 44px; line-height: 1.05; font-weight: 600; letter-spacing: -0.035em; color: var(--fg-0); }
.st-hero-value small { font-size: 0.5em; font-weight: 500; color: var(--fg-2); letter-spacing: -0.01em; }

/* Chart tooltip (Home): one HTML card. */
.st-home-canvas .st-tip {
    position: absolute; z-index: 5; pointer-events: none; opacity: 0; transition: opacity 0.1s;
    min-width: 200px; padding: 10px 12px; border-radius: var(--r-md);
    background: var(--surface-1); border: 1px solid var(--bd); box-shadow: var(--elev-2);
    font-size: 12.5px; color: var(--fg-1); font-variant-numeric: tabular-nums;
}
.st-tip-title { font-size: 12px; font-weight: 500; color: var(--fg-2); margin-bottom: 8px; }
.st-tip-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 2px 0; }
.st-tip-row > span { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.st-tip-row i { width: 10px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.st-tip-row i.is-blank { background: transparent; }
.st-tip-row b { font-weight: 500; color: var(--fg-0); white-space: nowrap; }
.st-tip-row b.st-up { color: var(--pos); }
.st-tip-row b.st-down { color: var(--neg); }
.st-tip-row.is-strong b, .st-tip-row.is-strong > span { font-weight: 600; color: var(--fg-0); }
.st-tip-row.is-muted > span, .st-tip-row.is-muted b:not(.st-up):not(.st-down) { color: var(--fg-2); }
.st-tip-row.is-muted > span { white-space: normal; }
.st-tip-rule { height: 1px; background: var(--bd-soft); margin: 6px 0; }
.st-home-canvas .st-tip.is-narrow { min-width: 0; max-width: 58%; padding: 8px 10px; font-size: 11.5px; }
.st-tip.is-narrow .st-tip-row { gap: 10px; }
.st-seg button:focus:not(:focus-visible) { outline: none; }

.st-home-main { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 0; padding: 0; overflow: hidden; }
.st-home-chartcol { padding: 18px 20px 14px; min-width: 0; }
.st-home-calcol { padding: 18px 18px 16px; border-left: 1px solid var(--bd-soft); background: var(--surface-0); min-width: 0; }
.st-home-chead { align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.st-home-readout { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-height: 30px; }
.st-seg-sm button { height: 26px; font-size: 12px; padding: 0 10px; }
.st-home-readout > b { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.st-home-readout > span { font-size: 13px; color: var(--fg-2); }
.st-home-canvas { position: relative; height: 300px; }
.st-home-note { margin-top: 10px; font-size: 12px; color: var(--fg-2); display: block; }
.st-home-note .st-dot { vertical-align: 0; }
.st-home-note .st-link { font-size: 12px; }

.st-cal-head { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 8px; margin-bottom: 12px; text-align: center; }
.st-cal-head > div { display: flex; flex-direction: column; gap: 2px; }
.st-cal-head > div > b { font-size: 14px; font-weight: 600; }
.st-cal-head > div > span { font-size: 12px; color: var(--fg-2); }
.st-cal-head > div > span b { font-weight: 500; }
.st-cal-nav {
    width: 28px; height: 28px; border-radius: var(--r-md); border: 1px solid var(--bd); background: var(--surface-1);
    color: var(--fg-1); font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
}
.st-cal-nav:hover:not(:disabled) { background: var(--surface-2); color: var(--fg-0); }
.st-cal-nav:disabled { opacity: 0.35; cursor: default; }
.st-cal { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) 50px; gap: 4px; }
.st-cal-dow { font-size: 11px; color: var(--fg-2); text-align: center; padding-bottom: 2px; font-weight: 500; }
.st-cal-day {
    --st-cal-a: 0%;
    display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
    aspect-ratio: 1 / 0.92; min-width: 0; padding: 6px 7px; border: 0; border-radius: var(--r-md);
    background: var(--surface-2); color: var(--fg-0); font: inherit; text-align: left; cursor: default;
}
.st-cal-day > span { font-size: 11.5px; color: var(--fg-2); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.st-cal-day > span .st-dot { width: 6px; height: 6px; }
.st-cal-day > b { font-size: 12px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.st-cal-day[data-day] { cursor: pointer; }
.st-cal-day[data-day]:hover { box-shadow: inset 0 0 0 1px var(--bd-strong); }
.st-cal-up { background: color-mix(in srgb, var(--pos) var(--st-cal-a), var(--surface-2)); }
.st-cal-down { background: color-mix(in srgb, var(--neg) var(--st-cal-a), var(--surface-2)); }
.st-cal-up > span, .st-cal-down > span { color: var(--fg-1); }
.st-cal-out { visibility: hidden; }
.st-cal-future { background: transparent; box-shadow: inset 0 0 0 1px var(--bd-soft); }
.st-cal-today { box-shadow: inset 0 0 0 1.5px var(--fg-2); }
.st-cal-sel, .st-cal-day.st-cal-sel[data-day]:hover { box-shadow: inset 0 0 0 2px var(--fg-0); }
.st-cal-day:focus-visible, .st-cal-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.st-cal-week { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; padding-right: 2px; }
.st-cal-week b { font-size: 11.5px; font-weight: 600; letter-spacing: -0.03em; }
.st-cal-detail { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-1); border: 1px solid var(--bd-soft); min-height: 40px; font-size: 12.5px; }
.st-cal-detail .st-muted { font-size: 12.5px; }
.st-cal-dhead { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.st-cal-dparts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--fg-2); }
.st-cal-dparts span { display: inline-flex; align-items: center; gap: 5px; }
.st-cal-dparts b { font-weight: 500; color: var(--fg-1); }
.st-cal-dparts b.st-up { color: var(--pos); }
.st-cal-dparts b.st-down { color: var(--neg); }
.st-cal-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.st-cal-stats div { display: flex; flex-direction: column; gap: 2px; }
.st-cal-stats span { font-size: 11px; color: var(--fg-2); }
.st-cal-stats b { font-size: 13px; font-weight: 600; letter-spacing: -0.02em; }

.st-home-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.st-strat-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.st-strat-nums { display: grid; grid-template-columns: repeat(2, minmax(0, auto)); gap: 12px 24px; }
.st-strat-nums div { display: flex; flex-direction: column; gap: 2px; }
.st-strat-nums span { font-size: 12px; color: var(--fg-2); }
.st-strat-nums b { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.st-strat-curve { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 1; max-width: 160px; }
.st-strat-curve span { font-size: 11px; color: var(--fg-2); }
.st-strat-spark { width: 100%; height: 40px; overflow: visible; }
.st-strat-foot { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--bd-soft); font-size: 12px; color: var(--fg-2); }

@media (max-width: 1280px) {
    .st-home-main { grid-template-columns: minmax(0, 1fr); }
    .st-home-calcol { border-left: 0; border-top: 1px solid var(--bd-soft); }
    .st-home-calcol > * { max-width: 560px; margin-left: auto; margin-right: auto; }
}
@media (max-width: 1100px) {
    .st-home-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .st-home-row > .card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .st-hero { align-items: flex-start; }
    .st-hero-value { font-size: 36px; }
    .st-home-chartcol, .st-home-calcol { padding: 14px; }
    .st-home-canvas { height: 240px; }
    .st-home-row { grid-template-columns: minmax(0, 1fr); }
    .st-cal { grid-template-columns: repeat(5, minmax(0, 1fr)) 40px; gap: 3px; }
    .st-cal-day { padding: 4px 5px; }
    .st-cal-day > b { font-size: 10.5px; }
    .st-cal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Home v3 (2026-10-27): hero tiles, underline tabs, legend chips, stats strip */
.st-hero-main { flex: 0 1 360px; justify-content: center; }
.st-hero-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--fg-2); }
.st-hero-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.st-hero-dd { font-size: 12.5px; color: var(--fg-2); }
.st-hero-dd b { font-weight: 600; color: var(--fg-1); }
.st-hero-dd b.st-down { color: var(--neg); }
.st-hero-tiles { flex: 1 1 640px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; min-width: 0; }
.st-tile { background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-lg); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.st-tile-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-tile-head .st-dot { width: 9px; height: 9px; border-radius: 3px; }
.st-tile-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.st-tile-nums { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-tile-nums b { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.st-tile-nums span { font-size: 12.5px; color: var(--fg-1); }
.st-tile-spark { flex: 0 0 auto; overflow: visible; }
.st-tile-zero { stroke: var(--bd-strong); stroke-dasharray: 2 3; stroke-width: 1; }
.st-tile-foot { font-size: 12px; color: var(--fg-2); border-top: 1px solid var(--bd-soft); padding-top: 8px; }

.st-home-chead { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.st-utabs { display: flex; gap: 22px; border-bottom: 1px solid var(--bd); }
.st-utabs button { font: inherit; font-size: 14.5px; font-weight: 500; color: var(--fg-2); background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 1px 9px; margin-bottom: -1px; cursor: pointer; }
.st-utabs button:hover { color: var(--fg-0); }
.st-utabs button[aria-pressed="true"] { color: var(--fg-0); font-weight: 600; border-bottom-color: var(--fg-0); }
.st-home-ctrls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-bottom: 4px; }
.st-pills { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--bd); border-radius: var(--r-md); }
.st-pills button { font: inherit; font-size: 12.5px; font-weight: 500; height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--fg-1); cursor: pointer; }
.st-pills button:hover:not(:disabled) { color: var(--fg-0); background: var(--surface-2); }
.st-pills button[aria-pressed="true"] { background: var(--fg-0); color: var(--surface-1); font-weight: 600; }
.st-pills button:disabled { opacity: 0.45; cursor: not-allowed; }   /* inactive control */
.st-utabs button:focus-visible, .st-pills button:focus-visible, .st-lchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.st-home-readout { margin-bottom: 8px; }
.st-home-readout > b { font-size: 32px; font-weight: 650; letter-spacing: -0.03em; }
.st-home-readout > span { font-size: 13.5px; color: var(--fg-1); }
.st-home-readout > span b { font-weight: 600; }
.st-home-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.st-lchip { font: inherit; font-size: 13px; color: var(--fg-1); display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid var(--bd); border-radius: 999px; background: var(--surface-1); cursor: pointer; }
.st-lchip i { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.st-lsw-ep { background: var(--ep-fill); box-shadow: inset 0 0 0 1.5px var(--ep-line); }
.st-lsw-tm { background: var(--tm-fill); box-shadow: inset 0 0 0 1.5px var(--tm-line); }
.st-lsw-other { background: var(--other-fill); box-shadow: inset 0 0 0 1.5px var(--other-line); }
.st-lsw-unsplit { background: color-mix(in srgb, var(--fg-2) 18%, transparent); box-shadow: inset 0 0 0 1.5px var(--fg-2); }   /* as its bars */
.st-lchip b { font-weight: 600; }
.st-lchip:hover:not(:disabled) { border-color: var(--bd-strong); }
.st-lchip[aria-pressed="false"] { background: transparent; color: var(--fg-2); text-decoration: line-through; }
.st-lchip[aria-pressed="false"] i { opacity: 0.35; }
.st-lchip:disabled { cursor: default; }
.st-lline { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg-2); margin-left: 4px; }
.st-lline i { width: 18px; height: 0; border-top: 2px solid var(--fg-0); }
.st-home-canvas { height: 320px; }
.st-home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-top: 14px; border-top: 1px solid var(--bd-soft); padding-top: 12px; }
.st-stat { display: flex; flex-direction: column; gap: 2px; padding: 0 14px; border-left: 1px solid var(--bd-soft); min-width: 0; }
.st-stat:first-child { border-left: 0; padding-left: 0; }
.st-stat span { font-size: 12px; color: var(--fg-2); }
.st-stat b { font-size: 16px; font-weight: 600; white-space: nowrap; }
.st-stat em { font-style: normal; font-size: 12px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
    .st-hero-main { flex-basis: 100%; }
    .st-hero-tiles { grid-template-columns: minmax(0, 1fr); }
    .st-home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
    .st-stat:nth-child(odd) { border-left: 0; padding-left: 0; }
    .st-home-readout > b { font-size: 26px; }
}

/* EP desk: one heading style (card titles lose the uppercase), shadcn-style
   buttons for the bare .btn the page never defined, and an on/off toggle for
   auto-refresh instead of a green fill. */
[id^="dpanel-"] .card-title,
#dpanel-ep .ep-header-title { font-size: 15px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-0); }
.st-ep-h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--fg-0); }
#dpanel-ep .btn,
#dpanel-ep .ep-header-settings-btn,
#dpanel-ep .cockpit-recon-btn,
.signals-table .btn-skip {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
    border: 1px solid var(--bd); border-radius: var(--r-md); background: var(--surface-1); color: var(--fg-1);
    font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; box-shadow: var(--elev-1);
}
#dpanel-ep .btn:hover,
#dpanel-ep .ep-header-settings-btn:hover,
#dpanel-ep .cockpit-recon-btn:hover,
.signals-table .btn-skip:hover { background: var(--surface-2); color: var(--fg-0); border-color: var(--bd-strong); }
#dpanel-ep .ep-header-settings-btn.active { background: var(--surface-2); color: var(--fg-0); border-color: var(--bd-strong); }
#dpanel-ep .st-toggle[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent-bd); color: var(--accent); }
#dpanel-ep .st-toggle::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--fg-3); }
#dpanel-ep .st-toggle[aria-pressed="true"]::before { background: var(--accent); }
#dpanel-ep .ep-header-run,
.signals-table .btn-confirm {
    height: 30px; padding: 0 14px; border: 1px solid var(--fg-0); border-radius: var(--r-md);
    background: var(--fg-0); color: var(--surface-0); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.signals-table .btn-skip { height: 28px; font-size: 12.5px; }
.signals-table .btn-confirm { height: 28px; font-size: 12.5px; }
#dpanel-ep .ep-header-run:hover, .signals-table .btn-confirm:hover { opacity: 0.88; }
/* Pending signals: sans text, mono numbers, sentence-case headers. */
.signals-table { font-family: var(--font-sans); font-size: 13.5px; }
.signals-table th { background: transparent; font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--fg-2); }
.signals-table td { font-family: var(--font-mono); font-size: 13px; }
.signals-table td:first-child { font-family: var(--font-sans); font-weight: 600; }
.signals-table tr:hover td { background: var(--surface-2); }
/* Closed trades */
.st-ep-reason { color: var(--fg-2); font-size: 12.5px; }
.st-ep-reason span { color: var(--fg-2); }  /* Conv #725: --fg-3 is 2.5:1 on both surfaces; captions use --fg-2 */

/* Strategy settings (and every other .s-* form: scout, presets). Sections get
   real headings; fields are shadcn inputs; the save row sticks to the bottom
   of the window so Save is reachable from anywhere in the long form. */
.st-page-h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg-0); }
.s-section {
    margin: 28px 0 14px !important; padding: 20px 0 0 !important; border: none !important;
    border-top: 1px solid var(--bd) !important;
    font-size: 15px !important; font-weight: 600 !important; letter-spacing: 0 !important;
    text-transform: none !important; color: var(--fg-0) !important;
}
.s-row { gap: 14px 20px; margin-bottom: 14px; }
.s-field { gap: 6px; min-width: 0; }
.s-field label { font-size: 13px; font-weight: 500; color: var(--fg-0); }
.s-field .s-hint { font-size: 12px; line-height: 1.45; color: var(--fg-2); margin-top: 0; }
.s-field input[type=number], .s-field input[type=text], .s-field select,
.s-preset-bar select, .s-preset-name-input {
    height: 36px; box-sizing: border-box; padding: 0 10px !important;
    background: var(--surface-1) !important; border: 1px solid var(--bd) !important; border-radius: var(--r-md) !important;
    color: var(--fg-0) !important; font-family: var(--font-sans) !important; font-size: 14px !important;
    font-variant-numeric: tabular-nums; box-shadow: var(--elev-1);
}
.s-field input:focus, .s-field select:focus, .s-preset-bar select:focus, .s-preset-name-input:focus {
    outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-bg);
}
.s-field input:disabled, .s-field select:disabled { opacity: 0.5; }
.s-field input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin-top: 2px; }
.s-preset-bar { padding: 12px !important; background: var(--surface-2) !important; border: 1px solid var(--bd) !important; border-radius: var(--r-lg) !important; }
.s-save-btn, .s-reset-btn, .s-preset-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px !important;
    border-radius: var(--r-md) !important; font: inherit; font-size: 14px !important; font-weight: 500 !important; cursor: pointer;
}
.s-save-btn { background: var(--fg-0) !important; color: var(--surface-0) !important; border: 1px solid var(--fg-0) !important; }
.s-reset-btn, .s-preset-btn { background: var(--surface-1) !important; color: var(--fg-1) !important; border: 1px solid var(--bd) !important; box-shadow: var(--elev-1); }
.s-reset-btn:hover, .s-preset-btn:hover { background: var(--surface-2) !important; color: var(--fg-0) !important; }
.st-save-bar {
    position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center;
    margin: 24px 0 0; padding: 14px 0;
    background: color-mix(in srgb, var(--surface-1) 92%, transparent); backdrop-filter: blur(6px);
    border-top: 1px solid var(--bd);
}

/* TM rebalance: no coloured left border on the cards (Settings shares the rule); the error
   path's Retry button (.held-btn, written by loadData) keeps the outline style. */
#dpanel-signals .card, #dpanel-settings > div > .card { border-left: 1px solid var(--bd) !important; }
#dpanel-signals .held-btn {
    height: 30px; padding: 0 12px !important; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-size: 13px !important; font-weight: 500; box-shadow: var(--elev-1);
}
#dpanel-signals .held-btn:hover { background: var(--surface-2); color: var(--fg-0); }

/* TM rebalance (Conv #825): static/js/tm_rebalance.js draws #signals-content — the header line with
   the rules, the status row (four cells: label, value, one sub-line; it wraps on a narrow screen), the
   attention strip (one row per real exception), the underline view tabs with their counts, the rank
   ladder (a 3 px zone bar per cell), the Book and plan / Next in line / Rankings / Scout tables (each
   scrolls inside its own .st-tm-tablewrap; numbers mono, right-aligned, headers aligned like their
   column) and the Book totals row. Tokens only, so both themes follow. */
.st-tm { display: flex; flex-direction: column; gap: 14px; font-variant-numeric: tabular-nums; }
.st-tm-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; }
.st-tm-headmain { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 520px; }
.st-tm-titleline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.st-tm-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg-0); }
.st-tm-sub { font-size: 12.5px; color: var(--fg-2); }
.st-tm-rules { font-size: 12.5px; line-height: 1.5; color: var(--fg-2); }
.st-tm-tools { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.st-tm-btn {
    display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.st-tm-btn:hover { background: var(--surface-2); color: var(--fg-0); }
.st-tm-btn.is-on { background: var(--surface-2); color: var(--fg-0); border-color: var(--bd-strong); }
.st-tm-linkbtn { min-height: 30px; padding: 0; border: 0; background: none; color: var(--fg-1); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer; }
.st-tm-linkbtn:hover { color: var(--fg-0); text-decoration: underline; }
.st-tm-status {
    display: flex; flex-wrap: wrap; gap: 1px; overflow: hidden;
    background: var(--bd-soft); border: 1px solid var(--bd); border-radius: var(--r-lg);
}
.st-tm-cell { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--surface-1); }
.st-tm-cell > span { font-size: 12px; color: var(--fg-2); }
.st-tm-cell > b { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--fg-0); overflow-wrap: break-word; }
.st-tm-cell > b.st-up { color: var(--pos); }
.st-tm-cell > b.st-down { color: var(--neg); }
.st-tm-cell > em { font-style: normal; font-size: 12px; line-height: 1.4; color: var(--fg-2); }
.st-tm-attn {
    display: flex; flex-direction: column; padding: 4px 16px;
    background: var(--warn-bg); border: 1px solid var(--warn-bd); border-radius: var(--r-lg);
}
.st-tm-attn[hidden] { display: none; }
.st-tm-attn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; padding: 8px 0; }
.st-tm-attn-row + .st-tm-attn-row { border-top: 1px solid var(--bd-soft); }
.st-tm-attn-row > b { font-size: 13px; font-weight: 600; color: var(--fg-0); }
.st-tm-attn-dot { background: var(--warn); }
.st-tm-attn-row.is-neg .st-tm-attn-dot { background: var(--neg); }
.st-tm-attn-text { flex: 1 1 420px; min-width: 0; font-size: 13px; line-height: 1.45; color: var(--fg-1); }
/* padding: room for the 2 px + 2 px focus ring inside the sideways-scrolling strip */
.st-tm-tabs { display: flex; align-items: flex-end; gap: 4px; padding: 4px 4px 0; border-bottom: 1px solid var(--bd); overflow-x: auto; scrollbar-width: none; }
.st-tm-tabs::-webkit-scrollbar { display: none; }
.st-tm-tab {
    flex: 0 0 auto; min-height: 44px; margin-bottom: -1px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent;
    background: none; color: var(--fg-2); font: inherit; font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.st-tm-tab:hover { color: var(--fg-0); }
.st-tm-tab.is-active { color: var(--fg-0); border-bottom-color: var(--tm); }
.st-tm-count { margin-left: 4px; font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--fg-2); }
.st-tm-view { display: flex; flex-direction: column; gap: 14px; }
.st-tm-card {
    display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 16px 18px;
    background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-lg);
}
.st-tm-cardhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.st-tm-cardhead h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--fg-0); }
.st-tm-note { flex: 1 1 320px; min-width: 0; font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.st-tm-cardtools { display: inline-flex; gap: 8px; margin-left: auto; }
.st-tm-caption { margin: 0; font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.st-tm-empty { margin: 0; padding: 6px 0; font-size: 13px; line-height: 1.5; color: var(--fg-2); }
.st-tm-dim { color: var(--fg-2); }
/* Rank ladder: one cell per executor rank; the zone bar is the target (--tm), the band (neutral)
   or below the band (faint); held, buy and sell cells carry their state. */
.st-tm-ladderwrap { overflow-x: auto; }
.st-tm-ladder { display: flex; gap: 6px; align-items: stretch; min-width: 760px; }
.st-tm-lcell { flex: 1 1 0; min-width: 56px; display: flex; flex-direction: column; gap: 6px; }
.st-tm-zone { display: block; height: 3px; border-radius: 2px; background: var(--bd-strong); }
.st-tm-lcell.is-target .st-tm-zone { background: var(--tm); }
.st-tm-lcell.is-band .st-tm-zone { background: var(--other-line); }
.st-tm-lcell.is-none .st-tm-zone { background: transparent; }
.st-tm-lbox {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
    border: 1px solid var(--bd); border-radius: var(--r-md); font-family: var(--font-mono);
}
.st-tm-lbox > b { font-size: 13px; font-weight: 600; color: var(--fg-2); }
.st-tm-lrank { font-size: 11px; color: var(--fg-2); }
.st-tm-ltag { min-height: 16px; font-family: var(--font-sans); font-size: 11px; color: var(--fg-2); }
.st-tm-lcell.is-held .st-tm-lbox { background: var(--tm-fill); border-color: var(--tm-bd); }
.st-tm-lcell.is-buy .st-tm-lbox { background: var(--pos-bg); border-color: var(--pos-bd); }
.st-tm-lcell.is-sell .st-tm-lbox { background: var(--neg-bg); border-color: var(--neg-bd); }
.st-tm-lcell:is(.is-held, .is-buy, .is-sell) .st-tm-lbox > b { color: var(--fg-0); }
.st-tm-lcell.is-held .st-tm-ltag { color: var(--fg-1); }
.st-tm-lcell.is-buy .st-tm-ltag { color: var(--pos); }
.st-tm-lcell.is-sell .st-tm-ltag { color: var(--neg); }
.st-tm-lgap { flex: none; width: 24px; display: flex; align-items: center; justify-content: center; color: var(--fg-2); }
.st-tm-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 12px; color: var(--fg-2); }
.st-tm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.st-tm-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--bd-strong); }
.st-tm-legend i.is-target { background: var(--tm); }
.st-tm-legend i.is-band { background: var(--other-line); }
.st-tm-move { font-family: var(--font-mono); font-size: 11px; color: var(--fg-2); }
.st-tm-move.st-up { color: var(--pos); }
.st-tm-move.st-down { color: var(--neg); }
.st-tm-move.is-new { font-family: var(--font-sans); color: var(--pos); }
/* Tables */
.st-tm-tablewrap { overflow-x: auto; }
.st-tm-table { min-width: 640px; }
.st-tm-table th, .st-tm-table td { white-space: nowrap; padding-left: 8px; padding-right: 8px; vertical-align: middle; }
.st-tm-table th:first-child, .st-tm-table td:first-child { padding-left: 4px; }   /* the focus ring fits inside the scroll box */
.st-tm-table th.num { text-align: right; }
.st-tm-table td.num { font-variant-numeric: tabular-nums; }
.st-tm-book { min-width: 1000px; }   /* stage B: fits a ~1190 px content width; scrolls in its box below ~1000 px */
/* At the rebalance is the slack column (the EP desk pattern): it takes what the other columns leave, the
   badge keeps its size and the reason ellipsizes, its full text in the span's title. */
.st-tm-book th.st-tm-actcell, .st-tm-book td.st-tm-actcell { width: 100%; max-width: 0; }
.st-tm-act { display: flex; align-items: center; gap: 8px; min-width: 0; }
.st-tm-act > .st-tm-badge { flex: none; }
.st-tm-act > .st-tm-reason { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the Since header keeps one width in every state ("Since 2 Nov" loaded, "Since reb." before the placement day is known) */
.st-tm-sparkhd { display: inline-block; min-width: 72px; }   /* the line's width: Rank, 10 d keeps one width with "…" / "—" */
.st-tm-sincehd { display: inline-block; min-width: 12ch; text-align: right; }   /* a cell's own min-width is not honoured; its content's is */
/* placeholders align like their column: right in Since and Earnings (td.num), left in Rank, 10 d */
.st-tm-book td.num { text-align: right; }
.st-tm-book th, .st-tm-book td { padding-left: 5px; padding-right: 5px; }   /* eleven columns: the reason keeps its full text at ~1190 px */
.st-tm-book td.st-tm-sparkcell { text-align: left; }
.st-tm-rank { min-width: 980px; }
.st-tm-prom, .st-tm-cand { min-width: 360px; }
.st-tm-rk { margin-right: 6px; font-family: var(--font-mono); color: var(--fg-0); }
.st-tm-pos { color: var(--fg-2); }
/* 30 px hit box; the negative margin keeps the row height the td padding sets */
.st-tm-tk { display: inline-flex; align-items: center; min-height: 30px; margin: -4px 0; padding: 0; border: 0; background: none; color: var(--fg-0); font: inherit; font-family: var(--font-mono); font-weight: 600; cursor: pointer; vertical-align: middle; }
.st-tm-tk:hover { text-decoration: underline; }
.st-tm-sec { font-size: 12px; color: var(--fg-2); }
.st-tm-tkcell .st-tm-sec { margin-left: 8px; }
.st-tm-book .st-tm-tkcell .st-tm-sec { display: inline-block; max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.st-tm-scout {
    margin-left: 6px; padding: 0 6px; border: 1px solid var(--tm-bd); border-radius: var(--r-sm);
    background: var(--tm-bg); color: var(--tm); font-size: 11px;
}
/* Next in line: 'held back · streak 1 of 2', 'displaced by the band' (text, Conv #825 follow-up) */
.st-tm-flag {
    margin-left: 6px; padding: 0 6px; border: 1px solid var(--bd); border-radius: var(--r-sm);
    color: var(--fg-1); font-size: 11px; white-space: nowrap;
}
.st-tm-badge {
    display: inline-block; margin-right: 8px; padding: 1px 8px; border: 1px solid var(--bd); border-radius: var(--r-sm);
    font-size: 12px; font-weight: 500; color: var(--fg-1);
}
.st-tm-badge.is-buy { color: var(--pos); background: var(--pos-bg); border-color: var(--pos-bd); }
.st-tm-badge.is-sell { color: var(--neg); background: var(--neg-bg); border-color: var(--neg-bd); }
.st-tm-reason { font-size: 12px; color: var(--fg-2); }
.st-tm-book tr.is-sell td:first-child { box-shadow: inset 2px 0 0 var(--neg); }
.st-tm-wbar { position: relative; display: inline-block; width: 44px; height: 6px; margin-right: 8px; border-radius: 3px; background: var(--surface-3); vertical-align: middle; }
.st-tm-wbar > i { position: absolute; left: 0; top: 0; height: 6px; border-radius: 3px; background: var(--tm); }
.st-tm-wbar > s { position: absolute; top: -2px; width: 1px; height: 10px; background: var(--fg-1); }
.st-tm-wtxt { display: inline-block; min-width: 6ch; text-align: right; }
.st-tm-table tfoot td { padding-top: 10px; padding-bottom: 10px; border-top: 1px solid var(--bd); border-bottom: 0; color: var(--fg-2); }
.st-tm-table tfoot td.st-up { color: var(--pos); }
.st-tm-table tfoot td.st-down { color: var(--neg); }
.st-tm-table tfoot .st-tm-strong { font-weight: 600; color: var(--fg-0); }
.st-tm-table tfoot .st-tm-strong.st-up { color: var(--pos); }
.st-tm-table tfoot .st-tm-strong.st-down { color: var(--neg); }
.st-tm-booklabel { font-weight: 500; }
.st-tm-under {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; padding-top: 10px;
    border-top: 1px solid var(--bd-soft); font-size: 12px; color: var(--fg-2);
}
.st-tm-secrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.st-tm-secrow > b { font-weight: 500; color: var(--fg-1); }
.st-tm-secbar { display: inline-flex; width: 96px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-3); }
.st-tm-secbar > i { display: block; height: 100%; }
.st-tm-secbar > .s0 { background: var(--tm); }
.st-tm-secbar > .s1 { background: var(--other-line); }
.st-tm-secbar > .s2 { background: var(--fg-1); }
.st-tm-secbar > .s3 { background: var(--bd-strong); }
.st-tm-secbar > .s4 { background: var(--fg-2); }
.st-tm-secbar > .s5 { background: var(--tm-bd); }
.st-tm-secbar > .is-cash { background: var(--surface-3); }
.st-tm-chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--bd); border-radius: var(--r-sm); font-size: 12px; font-weight: 500; }
.st-tm-chip.is-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-bd); }
/* Stage B (Conv #825): the 10-pass rank line (best at the top), the earnings date (amber on or before the next
   placement day) and the last-rebalance line under Book and plan. */
.st-tm-sparkcell { vertical-align: middle; }
.st-tm-spark { display: block; color: var(--tm); }
.st-tm-spark polyline { fill: none; stroke: currentColor; stroke-width: 1.5px; stroke-linejoin: round; stroke-linecap: round; }
.st-tm-spark circle { fill: currentColor; stroke: none; }   /* the last pass: where "now" is */
.st-tm-spark.is-sell { color: var(--neg); }
.st-tm-earn.is-soon { color: var(--warn); }
.st-tm-lastreb { flex: 1 1 100%; min-width: 0; text-align: left; }   /* its own row under the sector line */
/* Stage C (Conv #825): the Since rebalance view — its own status row, "Picked, and what was next in line" with a
   diverging bar on a fixed ±12 % scale (0 at the middle tick; a figure beyond the scale fills to the end and its end
   is squared off), the divider row before the next names, and "Every rebalance so far" with the average row. */
.st-tm-since { min-width: 760px; }
.st-tm-hist { min-width: 820px; }
.st-tm-since td.num, .st-tm-hist td.num { text-align: right; }
/* headers in the page's table face (.st-table .num would set mono on th.num); row labels keep their own face */
.st-tm-table.st-tm-since th, .st-tm-table.st-tm-hist th { font-family: var(--font-sans); }
/* Changes is the slack column (the Book's pattern): it takes what the others leave and its text ellipsizes, the
   full text in the span's title */
.st-tm-hist th.st-tm-chgcell, .st-tm-hist td.st-tm-chgcell { width: 100%; max-width: 0; }
.st-tm-chg { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-tm-what { font-size: 12.5px; color: var(--fg-1); }
.st-tm-since tr.is-next .st-tm-what { color: var(--fg-2); }
.st-tm-since tr.st-tm-divrow td { padding-top: 12px; border-top: 1px solid var(--bd); font-size: 12px; font-weight: 500; color: var(--fg-2); white-space: normal; }
.st-tm-dbarhd { min-width: 160px; font-weight: 500; }
/* three labels on the track's width: the left end, 0 over the centre tick (1fr auto 1fr keeps it centred whatever
   the end labels' widths), the right end */
.st-tm-dbarscale { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; }
.st-tm-dbarscale > span:first-child { text-align: left; }
.st-tm-dbarscale > span:last-child { text-align: right; }
.st-tm-dbarcell { min-width: 160px; }
.st-tm-dbar { position: relative; display: block; width: 100%; min-width: 160px; height: 8px; border-radius: 4px; background: var(--surface-3); }
.st-tm-dbar > i { position: absolute; top: 0; height: 8px; border-radius: 4px; }
.st-tm-dbar > i.is-pos { background: var(--pos); }
.st-tm-dbar > i.is-neg { background: var(--neg); }
.st-tm-dbar > i.is-pos.is-clip { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.st-tm-dbar > i.is-neg.is-clip { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.st-tm-dbar > s { position: absolute; left: 50%; top: -3px; width: 1px; height: 14px; background: var(--fg-2); }
.st-tm-of { margin-right: 6px; font-size: 11px; }   /* before the figure: the figure keeps the column's right edge */
.st-tm-histlabel { font-family: var(--font-mono); color: var(--fg-0); }
.st-tm-hist tr.is-open .st-tm-histlabel { font-weight: 600; }
.st-tm-avgnote { color: var(--fg-2); white-space: normal; }
/* Stage E (Conv #825): Sell… / Replace… at the end of a held row's At the rebalance cell (the badge and the reason keep
   their place, the reason ellipsizes before the buttons do), the guard line under the Book table (amber; the
   decision-day advisory neutral), the Replace panel (chips, two labelled inputs, its buttons) and the Manual overrides
   card on Since rebalance. */
.st-tm-act > .st-tm-manual { flex: none; margin-left: auto; padding-left: 8px; }
.st-tm-manual { display: inline-flex; gap: 6px; }
.st-tm-mbtn {
    display: inline-flex; align-items: center; min-height: 26px; padding: 0 8px; border: 1px solid var(--bd); border-radius: var(--r-sm);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer;
}
.st-tm-mbtn:hover:not(:disabled) { background: var(--surface-2); color: var(--fg-0); }
.st-tm-mbtn[aria-expanded="true"] { border-color: var(--bd-strong); background: var(--surface-2); color: var(--fg-0); }
.st-tm-mbtn:disabled { cursor: not-allowed; opacity: 0.45; }
.st-tm-guardline {
    margin: 0; padding: 8px 12px; border: 1px solid var(--warn-bd); border-radius: var(--r-md);
    background: var(--warn-bg); font-size: 12.5px; line-height: 1.45; color: var(--fg-1);
}
.st-tm-guardline.is-note { border-color: var(--bd); background: var(--surface-2); }
.st-tm-rpbody { display: flex; flex-direction: column; gap: 10px; }
.st-tm-rpline { margin: 0; font-size: 13px; line-height: 1.5; color: var(--fg-1); }
.st-tm-rpline.is-dim { font-size: 12.5px; color: var(--fg-2); }
.st-tm-rpline.is-warn { color: var(--warn); }
.st-tm-rpline.is-err { color: var(--neg); }
.st-tm-rpchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.st-tm-rplabel { margin-right: 4px; font-size: 12px; font-weight: 500; color: var(--fg-1); }
.st-tm-rpdim { font-size: 12.5px; color: var(--fg-2); }
.st-tm-rpchip {
    display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; cursor: pointer;
}
.st-tm-rpchip:hover:not(:disabled) { background: var(--surface-2); color: var(--fg-0); }
.st-tm-rpchip[aria-pressed="true"] { border-color: var(--tm-bd); background: var(--tm-bg); color: var(--fg-0); }
.st-tm-rpfields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.st-tm-rpfield { display: inline-flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-2); }
.st-tm-rpfield.is-wide { flex: 1 1 320px; }
.st-tm-rpfield input {
    box-sizing: border-box; width: 140px; min-height: 32px; padding: 0 10px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-0); color: var(--fg-0); font: inherit; font-size: 13px;
}
.st-tm-rpfield.is-wide input { width: 100%; }
.st-tm-rpbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.st-tm-rpbtn.is-go { border-color: var(--tm-bd); background: var(--tm-bg); color: var(--fg-0); }
.st-tm-rpbtn:disabled { cursor: not-allowed; opacity: 0.45; }
.st-tm-ovtable { min-width: 900px; }
.st-tm-ovtable td.num { text-align: right; }
.st-tm-ovdate, .st-tm-ovpair { font-family: var(--font-mono); color: var(--fg-0); }
.st-tm-ovreason { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; color: var(--fg-1); }
.st-tm-ovst { font-size: 12.5px; color: var(--fg-1); }
.st-tm-ovst.is-pending, .st-tm-ovst.is-too_old, .st-tm-ovst.is-no_ledger, .st-tm-ovst.is-cannot_tell { color: var(--fg-2); }
.st-tm-ovwin { font-size: 12.5px; color: var(--fg-2); }
.st-tm-ovfoot { white-space: normal; }
.st-tm-ovnote { margin: 0; font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.st-tm-ovfail { color: var(--fg-1); }
/* Rankings: tier switch (.st-seg), search, one table with heavier rules after N and the exit rank. */
.st-tm-ranktools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.st-tm-find { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-2); }
.st-tm-find input {
    box-sizing: border-box; width: 140px; min-height: 32px; padding: 0 10px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-0); color: var(--fg-0); font: inherit; font-size: 13px;
}
.st-tm-stamp { margin-left: auto; font-size: 12px; color: var(--fg-2); }
.st-tm-rankmeta { font-size: 12px; color: var(--fg-2); }
.st-tm-rankfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.st-tm-sortbtn { display: inline-flex; align-items: center; min-height: 30px; margin: -4px 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; white-space: nowrap; cursor: pointer; vertical-align: middle; }
.st-tm-sortbtn:hover { color: var(--fg-0); }
.st-tm-rank tr.is-cut td { border-top: 2px solid var(--other-line); }
.st-tm-status-held { font-size: 12.5px; color: var(--fg-1); }
.st-tm-status-buy { font-size: 12.5px; color: var(--pos); }
.st-tm-status-sell { font-size: 12.5px; color: var(--neg); }
/* Scout: two cards side by side, a progress segment per month-end the rule needs. */
.st-tm-scoutgrid { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.st-tm-scoutgrid > .st-tm-card { flex: 1 1 380px; }
.st-tm-scoutgrid > .st-tm-card + .st-tm-card { flex: 2 1 520px; }
.st-tm-prog { display: inline-flex; gap: 4px; margin-right: 8px; vertical-align: middle; }
.st-tm-prog > i { display: block; width: 18px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.st-tm-prog > i.is-on { background: var(--tm); }
@media (max-width: 600px) {
    .st-tm-cell { flex-basis: 140px; padding: 10px 12px; }
    .st-tm-attn { padding: 4px 12px; }
    .st-tm-card { padding: 14px 12px; }
    .st-tm-btn { min-height: 36px; }
    .st-tm-stamp { flex-basis: 100%; margin-left: 0; }
    .st-tm-table th, .st-tm-table td { padding-left: 6px; padding-right: 6px; }
    /* The page's phone rule makes every table a block with thead and tbody as two tables: keep one
       grid (head, rows and the Book row line up); .st-tm-tablewrap scrolls. */
    #signals-content table.st-tm-table { display: table; overflow: visible; }
    #signals-content .st-tm-table thead { display: table-header-group; width: auto; }
    #signals-content .st-tm-table tbody { display: table-row-group; width: auto; }
    /* Since rebalance: the ticker / period column stays put while the rest scrolls under it (opaque, card colour) */
    .st-tm-since tr:not(.st-tm-divrow) > :first-child, .st-tm-hist tr > :first-child {
        position: sticky; left: 0; z-index: 1; background: var(--surface-1); box-shadow: inset -1px 0 0 var(--bd-soft);
    }
    /* .st-table th sets a transparent background with !important: the sticky header cell needs its own */
    .st-tm-since thead th:first-child, .st-tm-hist thead th:first-child { background: var(--surface-1) !important; }
    /* keep that column narrow: the average label wraps, a 'not queued' flag goes under the period */
    .st-tm-hist tfoot td:first-child { white-space: normal; }
    .st-tm-hist .st-tm-histlabel .st-tm-flag { display: block; width: max-content; margin: 2px 0 0; }
    /* stage E: 36 px buttons on a phone; the panel's fields take the full width */
    .st-tm-mbtn, .st-tm-rpchip, .st-tm-rpbtn { min-height: 36px; }
    .st-tm-rpfield, .st-tm-rpfield.is-wide { flex: 1 1 100%; }
    .st-tm-rpfield input { width: 100%; }
}

/* Activity: the per-record delete shows on row hover (always on touch). */
#tx-table-wrap .tx-del-btn { opacity: 0; border-radius: 6px; }
#tx-table-wrap tr:hover .tx-del-btn, #tx-table-wrap .tx-del-btn:focus-visible { opacity: 1; }
@media (hover: none) { #tx-table-wrap .tx-del-btn { opacity: 1; } }
/* Conv #731: the ledger-delete control exists only in Edit ledger mode. */
#tx-table-wrap .tx-del-btn { display: none; }
body.st-ledger-edit #tx-table-wrap .tx-del-btn { display: inline-block; }
#tx-edit-toggle[aria-pressed="true"] { border-color: var(--warn); color: var(--warn); }
/* Conv #731 (V11): Edit ledger sits beside the strategy filter (one right-hand group). Where the
   table is wider than its scroll box (about 710 px of columns) the revealed delete control was out
   of view: while editing there, the derived Realized P&L column steps aside so the row fits, and the
   delete column is pinned to the scroll box's right edge so the control stays in view even when the
   data is wider still (the container rules sit with the B1 review fixes, below). */
.st-tx-headtools { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
#tx-count-label:empty { display: none; }

/* Table headers in the shell read like .st-table's: sentence case, no grey
   band. The pages' own rule is 11px uppercase with letter-spacing, and light
   mode fills it with --bg3. */
body.st-shell th { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; color: var(--fg-2); background: transparent; }

/* EP settings: a shadcn dialog. Header, executor-mode row and footer stay put
   while the sections scroll; each section is a card of label/control rows.
   toggleEPSettings() flips the overlay's inline display, so no rule sets it. */
.st-dialog-overlay {
    position: fixed; inset: 0; z-index: 1000; padding: 32px 16px;
    background: rgb(0 0 0 / 0.5); backdrop-filter: blur(2px);
}
.st-dialog {
    display: flex; flex-direction: column; max-width: 880px; max-height: calc(100vh - 64px); margin: 0 auto;
    background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-xl);
    box-shadow: var(--elev-3); overflow: hidden; font-size: 13px; color-scheme: light;
}
:root[data-theme="dark"] .st-dialog { color-scheme: dark; }
.st-dialog-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 18px 20px 14px; border-bottom: 1px solid var(--bd);
}
.st-dialog-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg-0); }
.st-dialog-head p { margin: 4px 0 0; font-size: 13px; color: var(--fg-2); }
.st-dialog-close {
    width: 30px; height: 30px; flex-shrink: 0; border: none; border-radius: var(--r-md);
    background: transparent; color: var(--fg-2); font-size: 20px; line-height: 1; cursor: pointer;
}
.st-dialog-close:hover { background: var(--surface-2); color: var(--fg-0); }
.st-dialog-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--bd); }
.st-es-body {
    flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px 20px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; align-items: start;
}
.st-es-body > div { padding: 14px 16px 10px; background: var(--surface-0); border: 1px solid var(--bd); border-radius: var(--r-lg); min-width: 0; }
.st-es-h { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--fg-0); }
.st-es-h span { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--fg-2); }  /* Conv #725: contrast */
.st-es-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.st-es-fields > :not(.st-es-label) { justify-self: end; }
.st-es-label { display: flex; align-items: center; min-height: 30px; font-size: 13px; color: var(--fg-1); }
.st-es-label .metric-tip { margin-left: 6px; background: transparent; }
.st-dialog .st-es-input, .st-dialog .st-es-select {
    height: 30px; box-sizing: border-box; padding: 0 8px;
    background: transparent; border: 1px solid var(--bd); border-radius: var(--r-md);
    color: var(--fg-0); font-family: var(--font-sans); font-size: 13px; font-variant-numeric: tabular-nums;
    box-shadow: var(--elev-1);
}
.st-es-input { width: 92px; text-align: right; }
.st-es-input.st-es-wide { width: 150px; text-align: left; }
.st-es-input.st-es-readonly { width: 170px; text-align: left; background: var(--surface-2); color: var(--fg-2); box-shadow: none; }
.st-es-select { width: 136px; }
.st-es-select option { background: var(--surface-1); color: var(--fg-0); }
.st-es-input:focus, .st-es-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.st-es-check { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.st-es-exec {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 20px 14px;
    padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--bd); border-radius: var(--r-lg);
}
.st-es-exec label { font-size: 13px; font-weight: 500; color: var(--fg-0); }
.st-es-exec .st-es-select { width: auto; background: var(--surface-1); }
.st-es-note { margin-left: auto; font-size: 12px; color: var(--fg-2); }
.st-es-status { font-size: 13px; color: var(--pos); }
@media (max-width: 600px) {
    .st-dialog-overlay { padding: 0; }
    .st-dialog { max-height: 100vh; border-radius: 0; }
    .st-es-body { grid-template-columns: minmax(0, 1fr); padding: 12px; }
    .st-es-note { margin-left: 0; }
}

/* ── Shell: sidebar ────────────────────────────────────────────────────── */
.st-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 900;
    width: var(--st-sidebar-w); box-sizing: border-box;
    display: flex; flex-direction: column; gap: 12px;
    padding: 12px;
    background: var(--st-sidebar-bg);
    border-right: 1px solid var(--bd);
    color: var(--fg-0);
    font-family: var(--font-sans);
    overflow-y: auto;
}
.st-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 6px; color: var(--fg-0); text-decoration: none;
    font-size: 16px; font-weight: 600; letter-spacing: -0.02em;
}
/* Sized here, not by attribute alone: some pages style bare `svg` (monitoring
   sets width:100%), which would otherwise blow these up. */
.st-sidebar svg, .st-menu-btn svg { flex-shrink: 0; max-width: none; }
.st-brand svg { width: 24px !important; height: 24px !important; }
.st-brand svg rect { fill: var(--fg-0); }
.st-brand svg path { stroke: var(--st-sidebar-bg); }

/* Account switcher: holds #ep-account-select, which the multi-account
   selector script fills in. Hidden while there is only one account. */
/* Conv #718: holder marker under the brand */
.st-holder {
    margin: 0 2px; padding: 4px 8px; border: 1px solid var(--bd); border-radius: var(--r-md, 6px);
    font-size: 12px; font-weight: 500; color: var(--fg-2); background: var(--surface-2); text-align: center;
}
.st-account { display: none; flex-direction: column; gap: 4px; padding: 0 2px; }
.st-account.is-multi { display: flex; }
.st-account label { font-size: 12px; font-weight: 500; color: var(--fg-2); padding: 0 6px; }
.st-account select {
    width: 100%; height: 36px; padding: 0 10px;
    border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-0);
    font: inherit; font-size: 14px; font-weight: 500;
}

.st-group { display: flex; flex-direction: column; gap: 1px; }
.st-group-label { padding: 6px 8px 4px; font-size: 12px; font-weight: 500; color: var(--fg-2); }
.st-divider {
    display: flex; align-items: center; gap: 8px; padding: 4px 8px 0;
    font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--fg-2);
}
.st-divider::before, .st-divider::after { content: ""; height: 1px; flex: 1; background: var(--bd); }
/* Conv #725: "Same for all accounts" explains the account switcher; without a
   second account (#st-account lacks .is-multi, see stratum-shell.js) it is hidden. */
.st-account:not(.is-multi) ~ .st-divider { display: none; }

.st-item {
    display: flex; align-items: center; gap: 10px;
    height: 34px; padding: 0 8px; border-radius: 7px;
    font-size: 14px; color: var(--fg-1); text-decoration: none;
    cursor: pointer;
}
.st-item:hover { background: var(--surface-2); color: var(--fg-0); }
.st-item.is-active { background: var(--st-item-active); color: var(--fg-0); font-weight: 500; }
.st-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.st-item svg { width: 16px !important; height: 16px !important; opacity: 0.85; }
.st-item .st-label { flex: 1; }
.st-badge {
    min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
    border-radius: 999px; font-size: 11.5px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-3); color: var(--fg-2);
}
.st-badge:empty { display: none; }
.st-badge.is-warn { background: var(--st-badge-warn-bg); color: var(--st-badge-warn-fg); }

.st-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.st-theme {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px;
    padding: 3px; border-radius: var(--r-md); background: var(--surface-2);
}
.st-theme button {
    height: 28px; border: none; border-radius: 6px; background: transparent;
    color: var(--fg-2); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.st-theme button[aria-pressed="true"] { background: var(--surface-1); color: var(--fg-0); box-shadow: var(--elev-1); }
.st-user {
    display: flex; align-items: center; gap: 10px; padding: 6px;
    font-size: 14px;
}
.st-avatar {
    width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
    background: var(--surface-3); color: var(--fg-0);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.st-user .st-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-user .st-who span:last-child { font-size: 12px; color: var(--fg-2); }
.st-signout { font-size: 13px; color: var(--fg-2); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.st-signout:hover { color: var(--fg-0); background: var(--surface-2); }

/* ── Shell: page offset and retired nav ────────────────────────────────── */
body.st-shell { margin-left: var(--st-sidebar-w); }
/* The sidebar replaces these. They stay in the DOM because page scripts
   still reference them (switchDashTab toggles .dtab.active, etc.). */
body.st-shell > nav.topnav { display: none; }
body.st-shell #dash-header,
body.st-shell #dash-header-row > div[style*="width:1px"] { display: none; }
body.st-shell .dash-tab-bar > .dtab:not(#nav-refresh) { display: none; }
body.st-shell .dash-tab-bar { border-bottom: none; justify-content: flex-end; }
/* Page-level banners are built with an inline left:0; keep them off the sidebar. */
body.st-shell #error-banner { left: var(--st-sidebar-w) !important; }
/* Top of the dashboard: one quiet status line instead of the live strip and
   tab bar (both stay in the DOM, see dashboard.html). */
body.st-shell #live-strip { display: none !important; }
body.st-shell .dash-tab-bar { display: none; }
body.st-shell #sticky-top { padding: 0; margin-bottom: 20px; box-shadow: none; }
body.st-shell #dash-header-row { min-height: 44px; padding-bottom: 8px !important; gap: 14px !important; border-bottom: 1px solid var(--bd) !important; }
.st-status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-2); }
.st-status i { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }
.st-status b { font-weight: 500; color: var(--fg-1); }
.st-status span::before { content: "·"; margin-right: 8px; color: var(--fg-3); }
body.st-shell #freshness-indicator::before { content: "Data "; color: var(--fg-2); }
body.st-shell #livesrc-indicator::before { content: "Quotes "; color: var(--fg-2); }
.st-refresh {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
    border: 1px solid var(--bd); border-radius: var(--r-md); background: var(--surface-1);
    color: var(--fg-1); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; flex-shrink: 0;
}
.st-refresh:hover { color: var(--fg-0); background: var(--surface-2); }

/* The multi-account selector's header copy moves into the sidebar. */
body.st-shell #dash-header-row > #ep-account-select { display: none !important; }

/* ── Shell: phones and narrow windows ─────────────────────────────────── */
.st-menu-btn { display: none; }
@media (max-width: 900px) {
    body.st-shell { margin-left: 0; margin-top: 52px; }
    /* Conv #731: the page's sticky header (#sticky-top, top:0) slid under the
       fixed Menu button after any scroll; it now sticks below the button. */
    body.st-shell #sticky-top { top: 52px; }
    /* Conv #731 (V4 / R2): an opaque band above the parked header, so content scrolling
       past is not drawn half-clipped around the Menu button. It lives in #sticky-top's
       own z-index context (position: sticky is its containing block): below the Menu
       button (950), the sidebar and the dialogs; left/right 0 adds no overflow. */
    body.st-shell #sticky-top::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 52px; background: var(--surface-0); }
    body.st-shell #error-banner { left: 0 !important; }
    .st-sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--elev-3); }
    body.st-nav-open .st-sidebar { transform: none; }
    .st-menu-btn {
        display: inline-flex; align-items: center; gap: 8px;
        position: fixed; top: 10px; left: 10px; z-index: 950;
        height: 36px; padding: 0 12px;
        border: 1px solid var(--bd); border-radius: var(--r-md);
        background: var(--surface-1); color: var(--fg-0);
        font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    }
    body.st-nav-open .st-menu-btn { left: calc(var(--st-sidebar-w) + 10px); }
}
@media print {
    .st-sidebar, .st-menu-btn { display: none !important; }
    body.st-shell { margin-left: 0; }
}

/* ── Research pages (Backtest, Walk-forward, Ensemble, Compare, Scanners) ──
   They share one layout: .page = .form-panel (settings) + .results-panel.
   The page CSS subtracts the old 53px top nav from the height; the sidebar
   replaces that nav, so the columns now fill the window. Everything is
   scoped to the shell and styles the shared classes only. */
@media (min-width: 1101px) {
    body.st-shell .page { height: 100vh; }
    body.st-shell .page.moded { height: calc(100vh - 45px); }
}
body.st-shell .form-panel { background: var(--surface-1); border-right-color: var(--bd); padding: 20px 20px 32px; }
body.st-shell .section-hdr {
    font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--fg-0);
    margin: 24px 0 12px; padding: 18px 0 0; border-bottom: none; border-top: 1px solid var(--bd);
}
body.st-shell .form-panel > .section-hdr:first-child,
body.st-shell .section-hdr:first-child { margin-top: 0; padding-top: 0; border-top: none; }
body.st-shell .field label { font-size: 13px; font-weight: 500; color: var(--fg-0); }
body.st-shell .field input[type=text], body.st-shell .field input[type=number],
body.st-shell .field input[type=date], body.st-shell .field select {
    height: 36px; box-sizing: border-box; padding: 0 10px; border-radius: var(--r-md);
    background: var(--surface-1); border: 1px solid var(--bd); color: var(--fg-0);
    font-size: 14px; font-variant-numeric: tabular-nums; box-shadow: var(--elev-1);
}
body.st-shell .field input[type=date] { width: 100%; min-width: 0; }
body.st-shell .field-row > * { min-width: 0; }
body.st-shell .field input:focus, body.st-shell .field select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
body.st-shell .toggle-row { background: transparent; border: 1px solid var(--bd); border-radius: var(--r-md); padding: 8px 12px; }
body.st-shell .toggle-row label { color: var(--fg-1); }
body.st-shell .toggle-row input[type=checkbox] { accent-color: var(--accent); }
/* Run is each page's one primary action: shadcn's foreground-on-background.
   The general filled-button rule above repaints .run-btn with --info-fill;
   Cancel (red) and Load Universe (grey) set their own background inline and keep it. */
body.st-shell .run-btn { min-height: 40px; padding: 0 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; }
body.st-shell .run-btn:not([style*="background"]) {
    background: var(--fg-0) !important; color: var(--surface-0); border: 1px solid var(--fg-0);
}
body.st-shell .run-btn:hover { opacity: 0.88; }
/* The filled-button rule at the top paints every .run-btn with --info-fill
   !important, which beat these two buttons' inline colours: Cancel came out
   blue and Load Universe became a second primary. */
body.st-shell .run-btn[style*="background:var(--red)"] { background: var(--neg) !important; color: #fff; border: 1px solid var(--neg); }
body.st-shell #sb-load-btn { background: var(--surface-1) !important; color: var(--fg-0) !important; border: 1px solid var(--bd) !important; box-shadow: var(--elev-1); }
body.st-shell #sb-load-btn:hover { background: var(--surface-2) !important; opacity: 1; }
/* Results tabs and the Backtest mode strip: text tabs with an underline. */
body.st-shell .results-tab-bar, body.st-shell .mode-strip { gap: 4px; border-bottom-color: var(--bd); background: transparent; }
body.st-shell .rtab {
    padding: 8px 12px; border: none; border-radius: 0; margin-bottom: -1px;
    border-bottom: 2px solid transparent; background: none; color: var(--fg-2); font-size: 13.5px; font-weight: 500;
}
body.st-shell .rtab:hover { color: var(--fg-0); background: none; }
body.st-shell .rtab.active { color: var(--fg-0); background: none; border-bottom-color: var(--fg-0); }
body.st-shell .card-title, body.st-shell .chart-title {
    font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--fg-0);
}
body.st-shell .results-header { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
/* The idle placeholder's emoji art goes; its title and hint stay. */
body.st-shell .idle-msg .icon { display: none; }
body.st-shell .idle-msg { color: var(--fg-2); }
body.st-shell .scan-empty > .icon { display: none; }
/* Scanners' Combined / Breakouts / Parabolic switch reads like .st-seg. */
body.st-shell .scanner-tabs { gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); }
body.st-shell .scanner-tab { height: 32px; padding: 0 10px; border: none; border-radius: 6px; background: transparent; color: var(--fg-2); font-size: 13px; font-weight: 500; }
body.st-shell .scanner-tab:hover:not(.active) { background: transparent; color: var(--fg-0); }
body.st-shell .scanner-tab.active { background: var(--surface-1); color: var(--fg-0); box-shadow: 0 0 0 1px var(--bd); }
/* Outline buttons. Backtest's result actions use .held-btn, which that page
   never defined (they rendered as browser-default buttons). */
body.st-shell .results-panel .held-btn {
    display: inline-flex; align-items: center; height: 32px; padding: 0 12px !important; white-space: nowrap;
    border: 1px solid var(--bd); border-radius: var(--r-md); background: var(--surface-1); color: var(--fg-1);
    font: inherit; font-size: 13px !important; font-weight: 500; cursor: pointer; box-shadow: var(--elev-1);
}
body.st-shell .results-panel .held-btn:hover { background: var(--surface-2); color: var(--fg-0); }
body.st-shell .metric-label { font-size: 12.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--fg-2); }
body.st-shell .metric-card { background: var(--surface-1); border-color: var(--bd); box-shadow: var(--elev-1); }

/* ── Live vs backtest (/monitoring) ── */
body.st-shell .mon-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
body.st-shell .mon-head .sub { font-size: 13px; color: var(--fg-2); }
/* EP/BO/TM and the range chips read like .st-seg. */
body.st-shell .stabs, body.st-shell .chipset { border: none; background: var(--surface-2); border-radius: var(--r-md); }
body.st-shell .stabs button, body.st-shell .chipset button { font-size: 13px; font-weight: 500; color: var(--fg-2); }
body.st-shell .stabs button.active, body.st-shell .chipset button.sel {
    background: var(--surface-1) !important; color: var(--fg-0); box-shadow: 0 0 0 1px var(--bd);
}
body.st-shell .filters select, body.st-shell .filters input[type=date] {
    height: 32px; border-color: var(--bd); background: var(--surface-1); color: var(--fg-0); font-size: 13px; border-radius: var(--r-md);
}
body.st-shell .flabel { font-size: 12.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--fg-2); }
body.st-shell .pill-phase, body.st-shell .empty-state .badge-phase {
    font-size: 11.5px; font-weight: 600; letter-spacing: 0; text-transform: none; border-radius: 5px;
}

/* ── Breakout watchlist ── */
#dpanel-breakout #breakout-scan-btn {
    height: 32px; padding: 0 14px !important; background: var(--fg-0) !important; color: var(--surface-0) !important;
    border: 1px solid var(--fg-0) !important; border-radius: var(--r-md) !important; font-weight: 600 !important;
}
#dpanel-breakout #breakout-scan-btn:hover { opacity: 0.88; }
#dpanel-breakout .card > div > label { font-size: 13px !important; color: var(--fg-1) !important; display: inline-flex; align-items: center; gap: 6px; }
#dpanel-breakout .card > div > label input[type=checkbox] { accent-color: var(--accent); }
#dpanel-breakout .card > div > label select {
    height: 30px; padding: 0 6px !important; border: 1px solid var(--bd) !important; border-radius: var(--r-md) !important;
    background: var(--surface-1) !important; color: var(--fg-0) !important; font: inherit; font-size: 13px;
}

/* ── Research leftovers ── */
/* Small outline buttons in the settings column (Backtest's OOS presets). */
body.st-shell .form-panel .held-btn {
    height: 28px; padding: 0 10px !important; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-size: 12.5px !important; font-weight: 500; cursor: pointer;
}
body.st-shell .form-panel .held-btn:hover { background: var(--surface-2); color: var(--fg-0); }
/* Collapsible sections (Ensemble, Walk-forward): one bordered card whose
   summary is the header row, instead of a grey box inside a grey box. */
body.st-shell .form-panel details {
    background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-lg); padding: 0 12px; margin-bottom: 8px;
}
body.st-shell .form-panel details > summary {
    display: flex; align-items: center; gap: 8px; list-style: none; padding: 10px 0; margin: 0;
    background: transparent; border: none; border-radius: 0; color: var(--fg-0); font-size: 13.5px; font-weight: 500;
}
body.st-shell .form-panel details > summary::-webkit-details-marker { display: none; }
body.st-shell .form-panel details > summary::before {
    content: '\25B6'; font-size: 8px; color: var(--fg-3); transition: transform 0.15s;
}
body.st-shell .form-panel details[open] > summary::before { transform: rotate(90deg); }
body.st-shell .form-panel details[open] > summary { margin-bottom: 4px; }
body.st-shell .form-panel details > .ens-body { padding: 0 0 12px; }
body.st-shell .ens-strat-section > summary { color: var(--fg-0); }
/* Ensemble allocation grid. */
body.st-shell .ens-body table { font-size: 13px !important; }
body.st-shell .ens-body td { padding: 4px; border-bottom: 1px solid var(--bd-soft); }
body.st-shell .ens-body input[type=number] {
    width: 100%; min-width: 0; height: 30px; box-sizing: border-box; padding: 0 4px; text-align: center;
    border: 1px solid var(--bd); border-radius: 6px; background: var(--surface-1); color: var(--fg-0);
    font: inherit; font-size: 13px; font-variant-numeric: tabular-nums;
}
body.st-shell .ens-body input[type=number]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
/* Walk-forward saved runs: small outline actions under each run. */
.wf-run-act {
    height: 24px; padding: 0 8px; border: 1px solid var(--bd); border-radius: 6px; background: var(--surface-1);
    color: var(--fg-1); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
}
.wf-run-act:hover { background: var(--surface-2); color: var(--fg-0); }
.wf-run-act.wf-run-del:hover { color: var(--neg); border-color: var(--neg-bd); background: var(--neg-bg); }
.wf-saved-table td { vertical-align: top; border-bottom: 1px solid var(--bd-soft); }

/* Native controls (checkboxes, select menus, date pickers, scrollbars) follow
   the theme; without this they stayed light in dark mode. */
:root, :root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* ── Performance ── */
.perf-kpi { background: var(--surface-1); border-color: var(--bd); box-shadow: var(--elev-1); }
.perf-kpi-label { font-size: 12.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--fg-2); }
.perf-kpi-sub { font-size: 12px; color: var(--fg-2); }
/* Range buttons (All/1Y/YTD/1M/1W) read like .st-seg. */
div:has(> .perf-range-btn) { gap: 2px !important; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); }
.perf-range-btn { height: 28px; padding: 0 10px; border: none; border-radius: 6px; background: transparent; color: var(--fg-2); font-size: 12.5px; font-weight: 500; }
.perf-range-btn:hover { color: var(--fg-0); border-color: transparent; }
.perf-range-btn.active { background: var(--surface-1); color: var(--fg-0); border-color: transparent; box-shadow: 0 0 0 1px var(--bd); }

/* Monitoring sets every svg to width:100%; keep the shell's icons at size. */
.st-menu-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
/* Research pages stacked (≤1100px): the Backtest mode strip's .page.moded
   height outranked the page's own height:auto, which clipped the settings
   into a short scroll box on phones. */
@media (max-width: 1100px) { body.st-shell .page.moded { height: auto; } }

/* ── Phones (≤600px) ── */
@media (max-width: 600px) {
    /* The status line: status + Refresh on one row, Data · Quotes under it.
       The page's own ≤600px rule stacks every child in a column. */
    body.st-shell #dash-header-row {
        flex-direction: row !important; flex-wrap: wrap; align-items: center;
        row-gap: 2px !important; column-gap: 12px !important; min-height: 0;
    }
    body.st-shell #dash-header-row .st-status { flex: 1 0 calc(100% - 110px); font-size: 12.5px; }
    body.st-shell #dash-header-row #st-refresh { order: 1; }
    body.st-shell #freshness-indicator, body.st-shell #livesrc-indicator { order: 2; margin-left: 0 !important; font-size: 11px !important; }
    /* Holdings: the columns a phone needs (ticker, strategy, value, %, the
       action); the rest are hidden instead of scrolling the Sell/Exit button
       off-screen. */
    #st-allpos-table .st-hide-sm, #tx-table-wrap .st-hide-sm { display: none; }
    #tx-table-wrap .st-table th, #tx-table-wrap .st-table td { padding-left: 6px; padding-right: 6px; }
    #st-allpos-table .st-table th, #st-allpos-table .st-table td { padding-left: 6px; padding-right: 6px; }
    #st-allpos-table .st-act { padding: 0 10px; }
    body.st-shell .st-pagehead h1 { font-size: 20px; }
    /* EP desk sub-tabs scroll sideways instead of running off the edge. */
    #ep-subnav { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
    #ep-subnav .dtab { flex-shrink: 0; }
}

/* Keyboard focus: one visible ring on every interactive element in the shell
   (pages had outline:none in places, and buttons had no ring at all). */
body.st-shell :is(button, a, summary, select, [role="button"], [tabindex]):focus-visible {
    outline: 2px solid var(--accent) !important; outline-offset: 2px;
}
/* Login: sentence-case field labels like the rest of the app. */
.login-box label { text-transform: none !important; letter-spacing: 0 !important; font-size: 13px !important; font-weight: 500 !important; color: var(--fg-0) !important; }

/* Conv #731 · B3 — ticker chart modal (#ep-chart-panel): header, position strip, range and
   overlay controls, readout, legend and the context row (fills · news since entry · key stats).
   Additions only; tokens from the theme blocks above, both themes. */
#ep-chart-panel .cp-shell {
    width: 100%; max-width: 1180px; max-height: 92vh; overflow: auto; box-sizing: border-box;
    padding: 16px 20px 18px; color: var(--fg-1);
    background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-xl); box-shadow: var(--elev-3);
}
/* A dialog opened from the modal (Sell partial…, Exit…) stacks above it (#ep-chart-panel is z 9998). */
body.cp-open .st-dialog-overlay { z-index: 9999; }

.cp-hdr { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; position: relative; }
.cp-hdr [hidden] { display: none !important; }
.cp-tk { font-size: 18px; font-weight: 700; color: var(--fg-0); letter-spacing: -0.01em; }
.cp-px { font-size: 18px; font-weight: 600; color: var(--fg-0); }
.cp-chg { font-size: 13px; font-weight: 600; }
.cp-hdr .cp-ext {
    display: inline-flex; align-items: center; gap: 5px; margin: 0; padding: 2px 9px;
    border: 1px solid var(--bd); border-radius: 999px; background: var(--surface-2); color: var(--fg-1); font-size: 12px;
}
.cp-hdr .cp-ext b { color: var(--fg-0); font-weight: 600; }
.cp-sector, .cp-info { font-size: 12px; color: var(--fg-2); }
.cp-hdr-r { margin-left: auto; display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.cp-mode { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--fg-1); }
.cp-mode .st-dot { width: 7px; height: 7px; }
.cp-actions { display: inline-flex; gap: 6px; }
.cp-act, .cp-navbtn {
    height: 30px; padding: 0 12px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.cp-navbtn { min-width: 30px; padding: 0 9px; font-size: 15px; line-height: 1; }
.cp-act:hover, .cp-navbtn:hover { background: var(--surface-2); color: var(--fg-0); }
.cp-act-exit { color: var(--neg); border-color: var(--neg-bd); }
.cp-act-exit:hover { background: var(--neg-bg); color: var(--neg); }
.cp-act:disabled { opacity: 0.5; cursor: default; }
/* Conv #829 stage 3: Buy... (a ticker that is not an open EP position), Exit... dimmed outside regular hours, and the
   header's one-line note (Exit off-hours). */
.cp-act-buy { color: var(--pos); border-color: var(--pos-bd); }
.cp-act-buy:hover { background: var(--pos-bg); color: var(--pos); }
.cp-act-off { opacity: 0.6; }
#cp-hdr-note { flex: 1 0 100%; margin: 0; font-size: 12px; line-height: 1.35; color: var(--warn); }

/* Position strip: seven cells, one row on a desktop. */
.cp-strip {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin: 0 0 14px;   /* seven cells; Conv #829 1b: To trail · To stop · vs VWAP wrap into a second row (a [hidden] cell is not a grid item) */
    background: var(--surface-0); border: 1px solid var(--bd); border-radius: var(--r-lg);
}
.cp-sc { padding: 9px 12px; border-left: 1px solid var(--bd-soft); min-width: 0; }
.cp-sc:first-child { border-left: 0; }
.cp-sc[hidden] { display: none; }
/* Conv #829 1b: To trail · To stop · vs VWAP sit in a second row; on the seven-column desktop layout each takes two
   columns so "−$1.75 · 4.0 % · 1.5R" stays on one line. The 4- and 2-column layouts below keep their own borders. */
@media (min-width: 1181px) {
    .cp-sc:nth-child(n+8) { grid-column: span 2; border-top: 1px solid var(--bd-soft); }
    .cp-sc:nth-child(8) { border-left: 0; }
    .cp-sc:nth-child(8)[hidden] + .cp-sc { border-left: 0; }   /* To trail hidden: To stop is the row's first cell */
}
.cp-sl { display: block; font-size: 11.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-sv { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-ss { display: block; margin-top: 1px; font-style: normal; font-size: 11.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-strip .cp-pos, #ep-chart-context .cp-pos { color: var(--pos); }
.cp-strip .cp-neg, #ep-chart-context .cp-neg { color: var(--neg); }
.cp-strip .cp-warn, #ep-chart-context .cp-warn { color: var(--warn); }

/* Range · readout · overlay chips. */
.cp-ctrl { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.cp-ctrl .st-seg [hidden] { display: none; }
.cp-readout { min-width: 0; font-size: 11.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }  /* Conv #829: an overlay in #cp-pane, see below */
.cp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.cp-ov {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
    border: 1px solid var(--bd); border-radius: 999px; background: transparent; color: var(--fg-2);
    font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
}
.cp-ov i { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; opacity: 0.45; }
.cp-ov:hover { color: var(--fg-0); }
.cp-ov[aria-pressed="true"] { background: var(--surface-2); color: var(--fg-0); border-color: var(--bd-strong); }
.cp-ov[aria-pressed="true"] i { opacity: 1; }
.cp-ov[hidden] { display: none; }

/* Legend: every overlay drawn; the range note at the far end. */
.cp-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 16px; margin-top: 6px; font-size: 11.5px; color: var(--fg-2); }
.cp-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cp-legend i { display: inline-block; width: 14px; flex-shrink: 0; box-sizing: border-box; }
.cp-legend .cp-lg-end { margin-left: auto; }

/* Context row: Fills / Signal · News since entry · Key stats. */
.cp-context {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) minmax(0, 1.2fr); gap: 24px;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--bd-soft);
}
.cp-col { min-width: 0; }
#ep-chart-context .cp-section { margin-top: 0; }
.cp-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 6px; }
.cp-h h3 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--fg-0); }
.cp-h-meta { font-size: 11px; color: var(--fg-2); }
.cp-linkbtn { margin-left: auto; padding: 0; border: 0; background: none; color: var(--fg-2); font: inherit; font-size: 11.5px; cursor: pointer; }
.cp-linkbtn:hover { color: var(--fg-0); text-decoration: underline; }
.cp-note { margin-top: 6px; font-size: 11.5px; color: var(--fg-2); }
.cp-tl { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; font-size: 12px; color: var(--fg-1); }
.cp-tl i { flex: 0 0 7px; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--fg-2); }
.cp-tl i.is-buy { background: var(--pos); }
.cp-tl i.is-sell { background: var(--neg); }
.cp-tl i.is-brake { background: var(--st-cash); }
.cp-tl span { min-width: 0; overflow-wrap: anywhere; }
.cp-sig-info { font-size: 12.5px; color: var(--fg-0); margin-bottom: 6px; }
.cp-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; margin: 0; font-size: 12px; }
.cp-kv dt { color: var(--fg-2); }
.cp-kv dd { margin: 0; color: var(--fg-1); overflow-wrap: anywhere; }
.cp-news-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding: 3px 0; font-size: 12px; }
.cp-news-row.is-roundup { opacity: 0.55; }
.cp-news-d { flex-shrink: 0; color: var(--fg-2); white-space: nowrap; }
.cp-news-h { min-width: 0; color: var(--fg-1); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.cp-news-h:hover { color: var(--fg-0); text-decoration: underline; }
.cp-news-n { flex-shrink: 0; color: var(--fg-2); }
/* Key stats inside the context row: sentence-case header, nine cells, the 18 behind More. */
#ep-chart-context .cp-head { margin: 0 0 6px; gap: 4px 8px; }
#ep-chart-context .cp-title { font-size: 12.5px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-0); }
.cp-ks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; font-size: 11.5px; color: var(--fg-0); }
.cp-ks-cell { min-width: 0; }
.cp-ks-cell > span { display: block; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-ks-cell > b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-ks-cell > em { display: block; font-style: normal; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-ks-more { display: block; margin: 8px 0 0; }
#ep-chart-context .cp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }
#ep-chart-context .cp-cell:nth-child(6n) { border-right: 1px solid var(--bd-soft); }
#ep-chart-context .cp-cell:nth-child(3n) { border-right: 0; }
#ep-chart-context .cp-cell:nth-last-child(-n+6) { border-bottom: 1px solid var(--bd-soft); }
#ep-chart-context .cp-cell:nth-last-child(-n+3) { border-bottom: 0; }
#ep-chart-context .cp-foot { margin: 6px 0 0; }
.cp-news-all { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--bd-soft); }

@media (max-width: 900px) {
    .cp-strip { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cp-sc { border-left: 0; border-top: 1px solid var(--bd-soft); }
    .cp-sc:nth-child(-n+2) { border-top: 0; }
    .cp-sc:nth-child(2n) { border-left: 1px solid var(--bd-soft); }
    .cp-context { grid-template-columns: minmax(0, 1fr); gap: 18px; }
    .cp-chips { margin-left: 0; }
    .cp-legend .cp-lg-end { margin-left: 0; }
}
@media (max-width: 600px) {
    #ep-chart-panel .cp-shell { padding: 12px 12px 14px; max-height: calc(100vh - 16px); }
    .cp-hdr { padding-right: 40px; }
    .cp-hdr .cp-close { position: absolute; top: 0; right: 0; }
    .cp-hdr-r { margin-left: 0; }
    .cp-readout { white-space: normal; }
    #ep-chart-context .cp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #ep-chart-context .cp-cell:nth-child(3n) { border-right: 1px solid var(--bd-soft); }
    #ep-chart-context .cp-cell:nth-child(2n) { border-right: 0; }
    #ep-chart-context .cp-cell:nth-last-child(-n+3) { border-bottom: 1px solid var(--bd-soft); }
    #ep-chart-context .cp-cell:nth-last-child(-n+2) { border-bottom: 0; }
}

/* Conv #829: chart modal 1D — pane overlay readout, open marker, resize grip, full size */
.cp-pane { position: relative; }
.cp-pane .cp-readout {
    position: absolute; top: 6px; left: 42px; z-index: 3; max-width: calc(100% - 130px);   /* clear of the ruler button (price-measure.js: 26 px at 8,8) */
    pointer-events: none;
}
/* the translucent plate belongs to the text, so an empty readout draws nothing */
.cp-pane .cp-readout #ep-chart-ohlc {
    display: inline-block; max-width: 100%; box-sizing: border-box; vertical-align: top;
    overflow: hidden; text-overflow: ellipsis;
    padding: 2px 6px; border-radius: var(--r-sm);
    background: color-mix(in srgb, var(--surface-1) 82%, transparent);
}
.cp-pane .cp-readout #ep-chart-ohlc:empty { display: none; }
.cp-open-mark { position: absolute; top: 0; bottom: 26px; width: 0; border-left: 1px dotted var(--fg-3); pointer-events: none; z-index: 2; }
.cp-open-lbl, .cp-open-pre { position: absolute; bottom: 22%; font-size: 10.5px; line-height: 1; color: var(--fg-2); white-space: nowrap; }
.cp-open-lbl { left: 6px; }
.cp-open-pre { left: 0; transform: translateX(calc(-100% - 6px)); }
.cp-1d-note { left: 0; right: 0; top: 38%; text-align: center; font-size: 12.5px; color: var(--fg-2); z-index: 2; }
/* stage 2 (review): the last-session badge - top centre of the pane, below the readout row (which ends ~26 px down) and
   clear of the ruler button (26 px at 8,8 of the chart); above the canvas (z 2), below the readout (z 3) and the ruler (z 6) */
.cp-pane .cp-1d-prior {
    position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 2; pointer-events: none;
    max-width: calc(100% - 96px); box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    padding: 3px 10px; border: 1px solid var(--warn); border-radius: 999px;
    background: color-mix(in srgb, var(--warn) 24%, var(--surface-1)); color: var(--fg-0);
    font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; line-height: 1.35;
}
.cp-resize { position: relative; height: 10px; cursor: ns-resize; touch-action: none; }
.cp-resize::after {
    content: ""; position: absolute; left: 50%; top: 3px; width: 44px; height: 4px; margin-left: -22px;
    border-radius: 2px; background: var(--bd-strong);
}
.cp-resize:hover::after { background: var(--fg-3); }
.cp-fullbtn {
    display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
    height: 26px; min-width: 30px; padding: 0 8px; border: 1px solid var(--bd); border-radius: 999px;
    background: transparent; color: var(--fg-2); cursor: pointer; font: inherit;
}
.cp-fullbtn:hover { background: var(--surface-2); color: var(--fg-0); }
.cp-fullbtn[aria-pressed="true"] { background: var(--surface-2); color: var(--fg-0); border-color: var(--bd-strong); }
#ep-chart-panel.cp-full { padding: 0 !important; }
#ep-chart-panel.cp-full .cp-shell {
    width: 100vw; max-width: none; height: 100vh; max-height: none; border-radius: 0;
    display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto;   /* a short window scrolls instead of clipping */
}
#ep-chart-panel.cp-full .cp-shell > * { flex: 0 0 auto; }
#ep-chart-panel.cp-full #cp-pane { flex: 1 1 0; min-height: 280px; display: flex; flex-direction: column; }
#ep-chart-panel.cp-full #ep-chart-container { flex: 1 1 0; min-height: 0; height: auto !important; }
#ep-chart-panel.cp-full #ep-chart-context,
#ep-chart-panel.cp-full #cp-news-all { max-height: 26vh; overflow-y: auto; }
#ep-chart-panel.cp-full .cp-resize { display: none; }
/* stage 1b: legend profile mode switch (Up/Down | Delta), the st-seg look in two small buttons */
span.cp-vpm { display: inline-flex; gap: 6px; align-items: center; }
button.cp-vpm-b {
    font: inherit; font-size: 11.5px; padding: 1px 8px; border: 1px solid var(--bd);
    border-radius: var(--r-sm) 0 0 var(--r-sm); background: transparent; color: var(--fg-2); cursor: pointer;
}
button.cp-vpm-b + button.cp-vpm-b { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; }
button.cp-vpm-b[aria-pressed="true"] { background: var(--surface-2); color: var(--fg-0); }
@media (max-width: 600px) {
    .cp-resize, #cp-full { display: none; }
    /* on a phone the readout is a row above the chart again: a wrapped overlay would cover the top candles */
    .cp-pane .cp-readout { position: static; max-width: none; padding: 0 0 4px; }
    .cp-pane .cp-readout #ep-chart-ohlc { display: inline; padding: 0; background: none; overflow: visible; }
    /* stage 2 (review): the badge keeps its full text on a phone (the ruler sits at 8 px from the chart's left edge) */
    .cp-pane .cp-1d-prior { width: max-content; max-width: calc(100% - 80px); white-space: normal; text-align: center; }
}

/* Conv #824 · A — EP desk (#dpanel-ep): the header line, the status row (five cells: label, value,
   one sub-line; it wraps on a narrow screen), the attention strip (one row per real exception) and
   the underline view tabs with their counts. Tokens only, so both themes follow. */
.st-ep-top { justify-content: flex-start; gap: 8px 16px; }
.st-ep-mkt { font-size: 12.5px; color: var(--fg-2); }
.st-ep-mkt.is-open { color: var(--pos); }
.st-ep-top-tools { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.st-ep-stamp { font-size: 12px; color: var(--fg-2); }
.st-ep-status {
    display: flex; flex-wrap: wrap; gap: 1px; margin: 0 0 14px; overflow: hidden;
    background: var(--bd-soft); border: 1px solid var(--bd); border-radius: var(--r-lg);
}
.st-ep-cell { flex: 1 1 170px; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--surface-1); }
.st-ep-cell > span { font-size: 12px; color: var(--fg-2); }
.st-ep-cell > b { font-family: var(--font-mono); font-size: 17px; font-weight: 600; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-ep-cell > b.st-up { color: var(--pos); }
.st-ep-cell > b.st-down, .st-ep-cell > b.st-ep-neg { color: var(--neg); }
.st-ep-cell > b.st-ep-warn { color: var(--warn); }
.st-ep-cell > em { font-style: normal; font-size: 12px; line-height: 1.4; color: var(--fg-2); }
.st-ep-attn {
    display: flex; flex-direction: column; margin: 0 0 14px; padding: 4px 16px;
    background: var(--warn-bg); border: 1px solid var(--warn-bd); border-radius: var(--r-lg);
}
.st-ep-attn.is-neg { background: var(--neg-bg); border-color: var(--neg-bd); }
.st-ep-attn[hidden] { display: none; }
.st-ep-attn-list { display: flex; flex-direction: column; }
.st-ep-attn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; padding: 8px 0; }
.st-ep-attn-row + .st-ep-attn-row { border-top: 1px solid var(--bd-soft); }
.st-ep-attn-row > b { font-size: 13px; font-weight: 600; color: var(--fg-0); }
.st-ep-attn-dot { background: var(--warn); }
.st-ep-attn-row.is-neg .st-ep-attn-dot { background: var(--neg); }
.st-ep-attn-detail { min-width: 0; font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-1); }
.st-ep-attn-acts { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.st-ep-tabs {
    display: flex; align-items: flex-end; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--bd);
    overflow-x: auto; scrollbar-width: none;
}
.st-ep-tabs::-webkit-scrollbar { display: none; }
#ep-subnav .dtab {
    flex: 0 0 auto; min-height: 44px; margin-bottom: -1px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent;
    border-radius: 0; background: none; color: var(--fg-2); font-size: 13.5px; font-weight: 500;
}
#ep-subnav .dtab:hover { color: var(--fg-0); background: none; }
#ep-subnav .dtab.active { color: var(--fg-0); border-bottom-color: var(--fg-0); }
#ep-subnav .dtab[data-count]:not([data-count=""])::after {
    content: attr(data-count); margin-left: 6px; font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--fg-2);
}

/* Positions card (Desk, Conv #824 · A): numeric columns size to their content with one uniform gap;
   headers centre over numeric columns and sit left over text; Exit plan is the one slack column
   (one line, ellipsis); P&L and Today are two right-aligned parts; a Book totals row closes the
   table. On a narrow screen the table scrolls inside its own box. */
.st-ep-poscard { margin: 0 0 16px; }
.st-ep-poshead { align-items: baseline; flex-wrap: wrap; justify-content: flex-start; }
.st-ep-poshead .st-ep-h3 { display: inline-flex; align-items: baseline; gap: 6px; }
.st-ep-count { font-family: var(--font-mono); font-weight: 500; color: var(--fg-2); }
.st-ep-sortnote { font-size: 12.5px; }
.st-ep-tablewrap { overflow-x: auto; }
.st-ep-pos { min-width: 1040px; }
.st-ep-pos th, .st-ep-pos td { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.st-ep-pos td { vertical-align: middle; }
.st-ep-pos th:first-child, .st-ep-pos td:first-child { padding-left: 2px; }
.st-ep-pos th.num, .st-ep-pos th.st-ep-c { text-align: center; }
.st-ep-pos td.st-ep-c { text-align: center; color: var(--fg-2); }
.st-ep-pos .st-ep-plan { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); font-size: 12.5px; }
.st-ep-pos th.st-ep-plan { color: var(--fg-2); font-size: 12px; }
.st-ep-pos tr.is-risk td { background: var(--neg-bg); }
.st-ep-pos tr.is-risk td:first-child { box-shadow: inset 2px 0 0 var(--neg); padding-left: 8px; }
.st-ep-two > span { display: inline-block; text-align: right; }
.st-ep-two > .st-ep-pct { min-width: 8ch; margin-left: 8px; font-weight: 400; }
.st-ep-pos tfoot td { padding-top: 10px; padding-bottom: 10px; border-top: 1px solid var(--bd); border-bottom: 0; color: var(--fg-2); }
.st-ep-pos tfoot td.st-ep-two > span:first-child { font-weight: 600; color: var(--fg-0); }
.st-ep-pos tfoot td.st-ep-two.st-up > span:first-child { color: var(--pos); }
.st-ep-pos tfoot td.st-ep-two.st-down > span:first-child { color: var(--neg); }
.st-ep-pos tfoot td.st-ep-risk { font-weight: 600; color: var(--fg-0); }
.st-ep-tk { padding: 0; border: 0; background: none; color: var(--fg-0); font: inherit; font-weight: 600; cursor: pointer; }
.st-ep-tk:hover { text-decoration: underline; }
.st-ep-pct { color: var(--fg-2); }
.st-ep-dist { display: inline-flex; align-items: center; gap: 10px; }
.st-ep-dist > span:last-child { min-width: 7ch; text-align: right; }
.st-ep-bar { display: block; flex-shrink: 0; width: 56px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.st-ep-bar > i { display: block; height: 100%; background: var(--fg-2); }
.st-ep-bar.is-warn > i { background: var(--warn); }
.st-ep-bar.is-neg > i { background: var(--neg); }
.st-ep-warn { color: var(--warn); }
.st-ep-neg { color: var(--neg); }
.st-ep-menucell { width: 1%; text-align: right; }
.st-ep-menu-btn {
    min-width: 32px; height: 26px; padding: 0 8px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-1); color: var(--fg-1); font: inherit; font-size: 15px; line-height: 1; cursor: pointer;
}
.st-ep-menu-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--fg-0); border-color: var(--bd-strong); }
.st-ep-menu-btn:disabled { opacity: 0.5; cursor: default; }
.st-ep-menu {
    position: fixed; z-index: 400; min-width: 172px; padding: 4px; text-align: left; white-space: nowrap;
    background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-md); box-shadow: var(--elev-2);
}
.st-ep-menu button {
    display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--r-sm); background: none;
    color: var(--fg-1); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.st-ep-menu button:hover:not(:disabled), .st-ep-menu button:focus-visible { background: var(--surface-2); color: var(--fg-0); }
.st-ep-menu button[data-act="exit"] { color: var(--neg); }
.st-ep-menu button:disabled { opacity: 0.45; cursor: default; }
.st-ep-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.st-ep-notice { margin-bottom: 8px; padding: 6px 10px; border-left: 3px solid var(--warn); border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn); font-size: 12.5px; }
.st-ep-empty { margin: 0; padding: 14px 0; color: var(--fg-2); font-size: 13px; }

/* Closest to an entry (Desk, Conv #824 · B): the positions card's frame; numeric columns sized to their
   content, State the one slack column (at least 140 px; it wraps, it is not cut); the To-trigger bar amber below the trigger and
   green at or through it; Buy… a plain button. On a narrow screen the table scrolls inside its own box. */
.st-ep-nearall { margin-left: auto; }
.st-ep-near { min-width: 980px; }
.st-ep-near th, .st-ep-near td { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; vertical-align: middle; }
.st-ep-near th:first-child, .st-ep-near td:first-child { padding-left: 2px; }
.st-ep-near th.num { text-align: center; }
.st-ep-near td.st-ep-tkc { font-weight: 600; color: var(--fg-0); }
.st-ep-near td.st-ep-setup { color: var(--fg-1); }
.st-ep-near .st-ep-state { width: 100%; min-width: 140px; white-space: normal; color: var(--fg-1); }
.st-ep-near td.st-ep-state.st-up { color: var(--pos); }
.st-ep-near td.st-ep-state.st-ep-warn { color: var(--warn); }
.st-ep-near td.st-ep-state.st-ep-neg { color: var(--neg); }
.st-ep-bar.is-pos > i { background: var(--pos); }
.st-ep-buycell { width: 1%; text-align: right; }
.st-ep-buy {
    min-height: 30px; padding: 0 12px; border: 1px solid var(--bd-strong); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--fg-0); font: inherit; font-family: var(--font-sans); font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.st-ep-buy:hover:not(:disabled) { background: var(--surface-3); }
.st-ep-buy:disabled { opacity: 0.5; cursor: default; }
@media (max-width: 600px) {
    /* The page's phone rule makes every table a block with thead and tbody as two tables: keep one grid; .st-ep-tablewrap scrolls. */
    #ep-near table.st-ep-near { display: table; overflow: visible; }
    #ep-near .st-ep-near thead { display: table-header-group; width: auto; }
    #ep-near .st-ep-near tbody { display: table-row-group; width: auto; }
}

/* Label / value rows (the executor card's facts). */
.st-ep-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; font-size: 13px; }
.st-ep-facts.is-list { grid-template-columns: minmax(0, 1fr); gap: 7px; }
.st-ep-facts > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.st-ep-facts > div > span:first-child { flex-shrink: 0; color: var(--fg-2); }
.st-ep-facts > div > span:last-child { min-width: 0; text-align: right; color: var(--fg-0); }
.st-ep-facts .mono { font-family: var(--font-mono); }
.st-ep-linkbtn { padding: 0; border: 0; background: none; color: var(--fg-2); font: inherit; font-family: var(--font-sans); font-size: 12.5px; cursor: pointer; }
.st-ep-linkbtn:hover { color: var(--fg-0); text-decoration: underline; }

/* Executor card: header, facts (one per row since Conv #824 · E; the R43.E pills lose their chrome there and
   keep their state colour), the brakes table. */
#dpanel-ep .st-ep-cockpit { background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-lg); overflow: visible; }
#dpanel-ep .st-ep-exechead { gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--bd-soft); }
#dpanel-ep .st-ep-cockpit .st-ep-facts { padding: 14px 16px; border-bottom: 1px solid var(--bd-soft); }
#dpanel-ep .st-ep-facts .cockpit-pill { padding: 0; border: 0; background: none; font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; letter-spacing: 0; animation: none; }
#dpanel-ep .st-ep-facts .cockpit-pill.pill-idle { color: var(--fg-2); }
#dpanel-ep .st-ep-facts .cockpit-pill.pill-info { color: var(--fg-1); }
#dpanel-ep .st-ep-fv { display: inline-flex; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; gap: 0 6px; font-family: var(--font-mono); font-size: 12.5px; }
#dpanel-ep .st-ep-fv > span:not(.cockpit-pill) { color: var(--fg-2); }
#dpanel-ep .st-ep-fv > span.st-ep-warn { color: var(--warn); }
#dpanel-ep #executor-bp { color: var(--fg-0); }
.st-ep-brakes-table td { padding-top: 7px; padding-bottom: 7px; font-size: 13px; }
.st-ep-brakes-table th, .st-ep-brakes-table td { white-space: nowrap; }

@media (max-width: 600px) {
    .st-ep-top-tools { margin-left: 0; }
    .st-ep-cell { flex-basis: 140px; padding: 10px 12px; }
    .st-ep-attn { padding: 4px 12px; }
    .st-ep-attn-acts { margin-left: 0; }
    .st-ep-sortnote { flex-basis: 100%; }
    #ep-positions .st-table th, #ep-positions .st-table td { padding-left: 6px; padding-right: 6px; }
    .st-ep-facts { grid-template-columns: minmax(0, 1fr); }
    /* The page's phone rule makes every table a block with thead and tbody as two tables: keep one grid (head, rows and the Book row line up); .st-ep-tablewrap scrolls. */
    #ep-positions table.st-ep-pos { display: table; overflow: visible; }
    #ep-positions .st-ep-pos thead { display: table-header-group; width: auto; }
    #ep-positions .st-ep-pos tbody { display: table-row-group; width: auto; }
}
/* Conv #731 · B1 — sentence case in the executor card: the mode picker's label and the
   pending-signals mode badge lose their capitals (the values are the setting's own words). */
#dpanel-ep .cockpit-mode-label, #dpanel-ep .executor-mode-badge { text-transform: none; letter-spacing: 0; }
.st-ep-empty.st-ep-neg { color: var(--neg); }   /* Conv #731 · B1: the positions card's load failure */
/* Conv #731 · B1 review fixes. V1: the sr-only "Actions" header label is absolutely positioned;
   with no positioned ancestor inside the scroll box it laid out against the page and scrolled
   the whole page sideways at 768-1213 px (the same fix as .wt-tbl-wrap). */
.st-ep-tablewrap { position: relative; }
/* V8: the Mark column's freshness dots in the target's palette - live / recent green, stale
   amber, close / none grey - scoped to the Positions card (the table and the foot's key), so
   the other .live-dot users keep the R26 colours. */
#ep-briefing-panel .live-dot { box-shadow: none; }
#ep-briefing-panel .live-dot.live, #ep-briefing-panel .live-dot.recent { background: var(--pos); }
#ep-briefing-panel .live-dot.stale { background: var(--warn); }
#ep-briefing-panel .live-dot.cache, #ep-briefing-panel .live-dot.none { background: var(--fg-3); }
/* Conv #731 (V11): Activity in Edit ledger when the table's box is narrower than the table needs
   (a phone, a tablet, a laptop window with the sidebar open; see the note by #tx-edit-toggle). A
   browser without container queries keeps the plain table, the control reachable by scrolling. */
#tx-table-wrap { container-type: inline-size; }
@container (max-width: 760px) {
    body.st-ledger-edit #tx-table-wrap th:nth-last-child(2), body.st-ledger-edit #tx-table-wrap td:nth-last-child(2) { display: none; }
    body.st-ledger-edit #tx-table-wrap th:last-child, body.st-ledger-edit #tx-table-wrap td:last-child { position: sticky; right: 0; z-index: 1; background: var(--surface-1) !important; }
    body.st-ledger-edit #tx-table-wrap .st-row:hover td:last-child { background: var(--surface-2) !important; }
}

/* Conv #731 · B2 — what the old Watching sub-tab's rules still serve: the muted sizing line and the census
   (System's Sizing fact and Scanner card since Conv #824 stage E), the section menu, the
   caps lines and the details summaries. Tokens only, so both themes follow; muted text is --fg-2 (--fg-3
   only as a fill). Conv #824 · C removed the header strip, the three groups, the no-level chips, the Spent
   and expired line and the caps popover; the Watching table's rules follow the census below. */

/* Sizing: one muted line; the two inputs show while editing (Run a pass now… is the Scanner card's, stage E). */
#dpanel-ep .wt-sizing { gap: 8px 14px; padding: 0 0 12px; margin-bottom: 14px; border-bottom: 1px solid var(--bd-soft); font-size: 12.5px; color: var(--fg-2); }
.wt-sizing-txt { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; }
.wt-sizing-txt .mono { color: var(--fg-1); }
.wt-sizing:not(.is-editing) .ep-header-inputs { display: none; }

/* The census frame chip, the section menu's popover, the caps lines, the details summaries. */
.wt-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 9px;
    border: 1px solid var(--bd); border-radius: 999px; background: var(--surface-2); color: var(--fg-1);
    font-size: 12px; line-height: 1.3; white-space: nowrap;
}
.wt-chip[hidden] { display: none; }
.wt-chip.is-warn { color: var(--warn); border-color: var(--warn-bd); background: var(--warn-bg); }
.wt-popd { position: static; }
.wt-popd > summary, .st-ep-gone > summary, #ep-census-details > summary { list-style: none; cursor: pointer; }
.wt-popd > summary::-webkit-details-marker, .st-ep-gone > summary::-webkit-details-marker, #ep-census-details > summary::-webkit-details-marker { display: none; }
.wt-menu > summary.st-ep-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
.wt-pop {
    position: absolute; z-index: 300; top: calc(100% + 6px); left: 0; min-width: 220px; max-width: calc(100vw - 32px);
    padding: 10px 12px; background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-md);
    box-shadow: var(--elev-2); font-size: 12.5px; line-height: 1.5; color: var(--fg-1); white-space: normal;
}
.wt-pop-menu { left: auto; right: 0; min-width: 210px; padding: 4px; }
.wt-pop-menu button {
    display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--r-sm); background: none;
    color: var(--fg-1); font: inherit; font-size: 13px; text-align: left; white-space: nowrap; cursor: pointer;
}
.wt-pop-menu button:hover, .wt-pop-menu button:focus-visible { background: var(--surface-2); color: var(--fg-0); }
#ep-watching-foot > div + div { margin-top: 6px; }
#ep-watching-foot b { font-weight: 600; color: var(--fg-0); margin-right: 6px; }
.wt-pop-h { margin-bottom: 6px; font-weight: 600; color: var(--fg-0); }
.wt-t-pos { color: var(--pos); }
.wt-t-mut { color: var(--fg-2); }
.wt-when-open { display: none; }
details[open] > summary .wt-when-open { display: inline; }
details[open] > summary .wt-when-closed { display: none; }

/* Census: collapsed under its summary line (the funnel, the frame chip, the stamp, the gate sentence). */
#ep-census-details { margin: 0 0 16px; background: var(--surface-1); border: 1px solid var(--bd); border-radius: var(--r-lg); }
#ep-census-details > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 16px; font-size: 12.5px; color: var(--fg-2); }
#ep-census-details[open] > summary { border-bottom: 1px solid var(--bd-soft); }
#ep-census-details > #ep-census-section { padding: 12px 16px 0; }
.wt-census-h { font-size: 14px; font-weight: 600; color: var(--fg-0); }
#wt-census-funnel { color: var(--fg-1); }
.wt-census-stamp:empty, .wt-census-lead:empty { display: none; }
.wt-census-all { margin-left: auto; white-space: nowrap; }
.wt-census-all[hidden] { display: none; }
#ep-census-details > summary:hover .wt-census-all { color: var(--fg-0); }

/* Watching (Conv #824 · C): one card - the controls row (family and stage chips with counts, the Find box,
   the section menu), the lever line, one table (Ticker · Family · Trigger · Last · To trigger · Stop plan ·
   Gap day · age · State · the row menu) and the collapsed "No longer watched" line. Numeric columns sized
   to their content, headers centred over numbers and left over text, State the one slack column (it
   wraps); the table scrolls in .st-ep-tablewrap and the row-menu column stays at its right edge. */
.st-ep-wtctl { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 10px; }   /* the section menu's popover anchors to its right edge */
.st-ep-wtfilters { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.st-ep-wtgrp { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.st-ep-wtf {
    display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
    border: 1px solid var(--bd); border-radius: 999px; background: transparent; color: var(--fg-2);
    font: inherit; font-family: var(--font-sans); font-size: 12.5px; cursor: pointer;
}
.st-ep-wtf:hover { color: var(--fg-0); }
.st-ep-wtf.is-on { background: var(--surface-3); border-color: var(--bd-strong); color: var(--fg-0); }
.st-ep-wtn { font-family: var(--font-mono); font-size: 12px; }
.st-ep-wtfind { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: 12.5px; color: var(--fg-2); }
.st-ep-wtfind input {
    width: 110px; min-height: 32px; padding: 0 10px; border: 1px solid var(--bd); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--fg-0); font-family: var(--font-mono); font-size: 12.5px;
}
.st-ep-lever { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--fg-2); }
.st-ep-lever[hidden] { display: none; }
.st-ep-wt { min-width: 1040px; }
.st-ep-wt th, .st-ep-wt td { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; vertical-align: middle; }
.st-ep-wt th:first-child, .st-ep-wt td:first-child { padding-left: 2px; }
.st-ep-wt th.num { text-align: center; }
.st-ep-wt .st-ep-state { width: 100%; min-width: 140px; white-space: normal; color: var(--fg-1); }
.st-ep-wt td.st-ep-state.st-up { color: var(--pos); }
.st-ep-wt td.st-ep-state.st-ep-warn { color: var(--warn); }
.st-ep-wt td.st-ep-state.st-ep-neg { color: var(--neg); }
.st-ep-wtfam { color: var(--fg-1); }
.st-ep-wtrow { cursor: pointer; }
.st-ep-wtrow:hover td { background: var(--surface-2); }
.st-ep-wtrow.is-off .st-ep-wtfam, .st-ep-wtrow.is-off td.st-ep-state { color: var(--fg-2); }
.st-ep-wtrow .live-dot { margin-right: 6px; }
.st-ep-wt .st-ep-menucell { position: sticky; right: 0; background: var(--surface-1); }   /* no z-index: the open menu (fixed, z 400) stacks above the next rows */
.st-ep-wt th.st-ep-menucell { background: var(--surface-1) !important; }   /* .st-table th sets transparent !important */
.st-ep-wtrow:hover td.st-ep-menucell { background: var(--surface-2); }
.st-ep-wt .st-ep-menu-btn { height: 24px; min-width: 30px; }
.st-ep-menu button[data-wt-act="remove"] { color: var(--neg); }
.st-ep-gone { margin-top: 12px; font-size: 12.5px; color: var(--fg-2); }
.st-ep-gone[hidden] { display: none; }
.st-ep-gone > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 4px 0; }
.st-ep-gone-show { color: var(--fg-1); }
.st-ep-gone > summary:hover, .st-ep-gone > summary:hover .st-ep-gone-show { color: var(--fg-0); }
.st-ep-gone-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.st-ep-gone-h { margin-top: 10px; font-weight: 600; color: var(--fg-1); }
.st-ep-gone-it {
    padding: 4px 10px; border: 1px solid var(--bd); border-radius: var(--r-sm); background: transparent;
    color: var(--fg-1); font: inherit; font-family: var(--font-mono); font-size: 12px; cursor: pointer;
}
.st-ep-gone-it:hover { border-color: var(--bd-strong); color: var(--fg-0); }
.st-ep-gone-caps:not(:empty) { margin-top: 10px; color: var(--fg-1); }

@media (max-width: 600px) {
    .wt-chip { white-space: normal; }
    #ep-census-details > summary { padding: 10px 12px; }
    #ep-census-details > #ep-census-section { padding: 12px 12px 0; }
    .wt-census-all { margin-left: 0; }
    .st-ep-wtfind { margin-left: 0; }
    /* The page's phone rule makes every table a scrolling block with thead and tbody as two separate
       tables: keep one grid; .st-ep-tablewrap scrolls, the row-menu column stays at its right edge. */
    #ep-watchlist-body table.st-ep-wt { display: table; overflow: visible; }
    #ep-watchlist-body .st-ep-wt thead { display: table-header-group; width: auto; }
    #ep-watchlist-body .st-ep-wt tbody { display: table-row-group; width: auto; }
    .st-ep-wt .st-ep-menucell { box-shadow: inset 1px 0 0 var(--bd); }
}

/* Conv #731 · B3 review fixes (additions only: these rules follow the B3 block and win over it).
   V2 / CC-6: the strip never cuts a value. The sub-line (risk at entry, brake, sessions) and the
   headline value wrap at a space instead of taking an ellipsis, and from 901 to 1180 px the strip
   runs four columns, so money values fit on one line there too. */
.cp-ss { white-space: normal; overflow-wrap: anywhere; }
.cp-sv { white-space: normal; }
@media (max-width: 1180px) and (min-width: 901px) {
    .cp-strip { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .cp-sc:nth-child(4n+1) { border-left: 0; }
    .cp-sc:nth-child(n+5) { border-top: 1px solid var(--bd-soft); }
}
/* V12 / CC-6: on a phone the chart follows the header and the controls (the position strip moves
   below the legend), and the crosshair readout wraps so Vol and RVOL stay readable. */
@media (max-width: 600px) {
    #ep-chart-panel .cp-shell { display: flex; flex-direction: column; }
    #ep-chart-panel .cp-shell > * { flex-shrink: 0; }
    #ep-chart-panel .cp-hdr { order: 1; }
    #ep-chart-panel .cp-ctrl { order: 2; }
    #ep-chart-panel #ep-chart-container { order: 3; }
    #ep-chart-panel #cp-pane { order: 3; }
    #ep-chart-panel #cp-legend { order: 4; }
    #ep-chart-panel #ep-chart-position { order: 5; margin: 12px 0 0; }
    #ep-chart-panel #ep-chart-context { order: 6; }
    #ep-chart-panel #cp-news-all { order: 7; }
    .cp-readout { white-space: normal; overflow-wrap: anywhere; }
}

/* Conv #731 · B2 review fixes (additions only: these rules follow the B2 block and win over it).
   V5: the section menu stacks under the sticky header (z 100) when the page scrolls while it is open; it
   still paints over the cards and the sticky row-menu cells. V6: dimming is by colour, not opacity, so dimmed
   text keeps >= 4.5:1 in both themes (a roundup headline: --fg-2; the "+N" marks it too). Conv #824 · C: the
   Watching rows' phone, late and dim rules and the BASE chip colour went with the grouped tables. */
.wt-pop { z-index: 90; }
.cp-news-row.is-roundup { opacity: 1; }
.cp-news-row.is-roundup .cp-news-h { color: var(--fg-2); }
.cp-news-row.is-roundup a.cp-news-h:hover { color: var(--fg-0); }

/* Trades (Conv #824 · D): one statistics row (the status row's cells, seven of them), R per exit and By month
   side by side (stacked on a narrow screen), the Exits card - its filter chips are Watching's (.st-ep-wtf), its
   table has the numeric columns sized to their content under centred headers and Exit reason as the one slack
   column (it wraps); the table scrolls in .st-ep-tablewrap. Bars are spans sized in % of their track. Last rule:
   the Desk card's lever-off rows, muted as on Watching (Conv #824 · D, g1). */
#ep-history-section [hidden] { display: none; }
.st-ep-trstats .st-ep-cell { flex-basis: 140px; }
.st-ep-trstats .st-ep-cell > b { font-size: 16px; }
.st-ep-trcharts { display: flex; flex-wrap: wrap; gap: 0 16px; }
.st-ep-trcharts > .st-ep-trhist { flex: 1 1 420px; min-width: 0; }
.st-ep-trcharts > .st-ep-trmonth { flex: 1 1 360px; min-width: 0; }
.st-ep-trcap { margin: 0 0 12px; font-size: 12.5px; color: var(--fg-2); }
.st-ep-trbins { display: flex; align-items: flex-end; gap: 6px; font-family: var(--font-mono); font-size: 11.5px; }
.st-ep-trbin { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.st-ep-trbin > b { font-weight: 500; color: var(--fg-1); }
.st-ep-trbin > span:last-child { color: var(--fg-2); white-space: nowrap; }
.st-ep-trtrack { position: relative; display: block; width: 100%; height: 120px; border-bottom: 1px solid var(--bd); }
.st-ep-trtrack > i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px 3px 0 0; background: var(--pos); }
.st-ep-trtrack > i.is-neg { background: var(--neg); }
.st-ep-trmonths { display: flex; flex-direction: column; gap: 9px; font-family: var(--font-mono); font-size: 12.5px; }
.st-ep-trmrow { display: grid; grid-template-columns: 76px minmax(60px, 1fr) 96px 104px; column-gap: 12px; align-items: center; }
.st-ep-trmrow > span:first-child { color: var(--fg-2); }
.st-ep-trmbar { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.st-ep-trmbar > i { display: block; height: 100%; background: var(--pos); }
.st-ep-trmbar > i.is-neg { background: var(--neg); }
.st-ep-trusd { text-align: right; font-weight: 500; }
.st-ep-trmeta { text-align: right; color: var(--fg-2); }
.st-ep-trx { min-width: 860px; }
.st-ep-trx th, .st-ep-trx td { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; vertical-align: middle; }
.st-ep-trx th:first-child, .st-ep-trx td:first-child { padding-left: 2px; }
.st-ep-trx th.num { text-align: center; }
.st-ep-trx .st-ep-reason { width: 100%; min-width: 180px; white-space: normal; }
.st-ep-trx td.st-ep-reason { color: var(--fg-1); }
.st-ep-trx tr.is-part td.st-ep-reason { color: var(--fg-2); }
.st-ep-trx td.st-ep-trtk { font-weight: 600; color: var(--fg-0); }
.st-ep-trx td.st-ep-trd { color: var(--fg-2); }
.st-ep-trmore { margin: 10px 0 0; }
.st-ep-near tr.is-off td.st-ep-setup, .st-ep-near tr.is-off td.st-ep-state { color: var(--fg-2); }

@media (max-width: 600px) {
    /* The page's phone rule makes every table a scrolling block with thead and tbody as two separate
       tables: keep one grid; .st-ep-tablewrap scrolls. */
    #ep-history-section table.st-ep-trx { display: table; overflow: visible; }
    #ep-history-section .st-ep-trx thead { display: table-header-group; width: auto; }
    #ep-history-section .st-ep-trx tbody { display: table-row-group; width: auto; }
    .st-ep-trmrow { grid-template-columns: 64px minmax(40px, 1fr) 84px 88px; column-gap: 8px; }
    .st-ep-trbins { gap: 3px; font-size: 10.5px; overflow-x: auto; }
    .st-ep-trbin { flex: 1 0 28px; }   /* up to 18 bins: a label never narrower than its text; the row scrolls */
}

/* Home: calendar $ / % switch */
.st-cal-tools { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
.st-cal-tools .st-seg-sm button { min-width: 30px; padding: 0 8px; }
.st-strat-nums b small { font-size: 12px; font-weight: 500; margin-left: 4px; letter-spacing: 0; }

/* Price charts: two-point measure (static/js/price-measure.js) */
.pm-layer { position: absolute; z-index: 5; pointer-events: none; overflow: hidden; }
.pm-svg { position: absolute; left: 0; top: 0; }
.pm-btn { position: absolute; z-index: 6; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    padding: 0; border: 1px solid var(--bd); border-radius: var(--r-sm); background: var(--surface-2); color: var(--fg-2); cursor: pointer; opacity: .85; }
.pm-btn:hover { opacity: 1; color: var(--fg-0); }
.pm-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; opacity: 1; }
.pm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pm-on canvas { cursor: crosshair !important; }
.pm-read { position: absolute; white-space: nowrap; box-sizing: border-box; padding: 7px 28px 7px 10px; pointer-events: auto;
    background: var(--surface-2); border: 1px solid var(--bd); border-radius: var(--r-md); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.pm-head { font-family: var(--font-mono); font-size: 15px; font-weight: 600; line-height: 1.25; }
.pm-head .pm-sub { font-size: 12px; font-weight: 500; color: var(--fg-1); margin-left: 4px; }
.pm-meta { font-size: 11px; line-height: 1.4; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.pm-x { position: absolute; top: 3px; right: 4px; width: 20px; height: 20px; padding: 0; border: 0; background: none;
    color: var(--fg-2); font-size: 16px; line-height: 1; cursor: pointer; border-radius: var(--r-sm); }
.pm-x:hover { color: var(--fg-0); background: var(--surface-3); }

/* System (Conv #824 · E): one column of four cards - Executor (the override strip, the head with the Live / Paper
   chip, the mode select and Reconcile now, the line under the select, the facts one per row with the Sizing inputs),
   Orders and signals today, Broker-side brakes, Scanner (six funnel steps, the gate sentence, Run a pass now…, the
   census rows behind their disclosure). The live controls keep their markup; these rules only restyle them. Tokens
   only, so both themes follow; each table keeps one grid against the page's phone table rule and scrolls in
   .st-ep-tablewrap. */
#dpanel-ep .st-ep-syscard { margin: 0 0 16px; }
#dpanel-ep #executor-cockpit { padding: 0; overflow: hidden; }
#dpanel-ep #executor-cockpit .st-ep-exechead { flex-wrap: wrap; gap: 8px 12px; }
#dpanel-ep #executor-cockpit .cockpit-recon-btn { min-height: 32px; padding: 0 12px; border-radius: var(--r-md); font-size: 12.5px; }
#dpanel-ep .cockpit-mode select:disabled { cursor: not-allowed; opacity: 0.5; }
.st-ep-sysmodediff { margin: 0; padding: 8px 16px; border-bottom: 1px solid var(--bd-soft); background: var(--warn-bg); color: var(--warn); font-size: 12.5px; }
.st-ep-sysmodediff[hidden] { display: none; }
#dpanel-ep #ep-exec-facts { gap: 0; padding: 2px 16px; border-bottom: 0; }
#dpanel-ep #ep-exec-facts > div { flex-wrap: wrap; align-items: baseline; gap: 2px 16px; padding: 9px 0; border-bottom: 1px solid var(--bd-soft); }
#dpanel-ep #ep-exec-facts > div:last-child { border-bottom: 0; }
#dpanel-ep #ep-exec-facts > div[hidden] { display: none; }
#dpanel-ep #ep-exec-facts .st-ep-sysv { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-0); text-align: right; }
#dpanel-ep #ep-exec-facts .st-ep-sysv.is-ok { color: var(--pos); }
#dpanel-ep #ep-exec-facts .st-ep-sysv.is-warn { color: var(--warn); }
#dpanel-ep #ep-exec-facts .st-ep-sysv.is-neg { color: var(--neg); }
#dpanel-ep #executor-cb-text { display: none; }
#dpanel-ep #ep-sys-f-sizing .wt-sizing { flex: 1 1 auto; justify-content: flex-end; flex-wrap: wrap; gap: 6px 12px; padding: 0; margin: 0; border: 0; font-size: 12.5px; color: var(--fg-2); }
#dpanel-ep #ep-sys-f-sizing .wt-sizing-txt { justify-content: flex-end; font-family: var(--font-mono); color: var(--fg-0); }
#dpanel-ep #ep-sys-f-sizing .wt-sizing-txt .st-ep-linkbtn { font-family: var(--font-sans); }
#dpanel-ep #ep-sys-f-sizing .ep-header-inputs { flex-basis: 100%; justify-content: flex-end; }
#wt-basis:empty { display: none; }
#wt-basis { color: var(--fg-2); }
.st-ep-sysnote { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--fg-2); text-align: right; }
.st-ep-sysnote[hidden] { display: none; }
#ep-sys-orders .st-cardhead, #ep-sys-brakes .st-cardhead, #ep-sys-scan .st-cardhead { align-items: center; }
#ep-sys-orders .signals-count { padding: 1px 8px; border: 1px solid var(--bd); border-radius: 999px; background: var(--surface-2); color: var(--fg-1); font-family: var(--font-mono); font-size: 12px; }
#ep-sys-orders .signals-count.zero { color: var(--fg-2); }
.st-ep-sysblk + .st-ep-sysblk { margin-top: 16px; }
.st-ep-sysblk[hidden], #ep-sys-orders .st-ep-tablewrap[hidden], #ep-sys-orders .st-ep-empty[hidden], #ep-sys-brakes .st-ep-empty[hidden] { display: none; }
.st-ep-sysh4 { display: flex; align-items: baseline; gap: 6px; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--fg-0); }
.st-ep-sysh4 .st-ep-count { font-size: 12px; }
.st-ep-syssig, .st-ep-sysord, .st-ep-sysbrk { min-width: 560px; }
.st-ep-syssig th, .st-ep-syssig td, .st-ep-sysord th, .st-ep-sysord td, .st-ep-sysbrk th, .st-ep-sysbrk td { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.st-ep-syssig th.num, .st-ep-sysord th.num, .st-ep-sysbrk th.num { text-align: center; }
.st-ep-syssig td:last-child, .st-ep-sysbrk td:last-child { width: 100%; }
.st-ep-sysbrk th:last-child { text-align: right; }   /* Shares takes the slack: its head sits over the right-aligned numbers */
.st-ep-sysord .st-ep-sysdetail { width: 100%; min-width: 24ch; white-space: normal; overflow-wrap: anywhere; color: var(--fg-2); }
.st-ep-sysst { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-1); }
.st-ep-sysst.is-pos { color: var(--pos); }
.st-ep-sysst.is-info { color: var(--info); }
.st-ep-sysst.is-warn { color: var(--warn); }
.st-ep-sysst.is-neg { color: var(--neg); }
.st-ep-sysact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 6px; padding: 8px 12px;
    border-left: 3px solid var(--info); border-radius: var(--r-sm); background: var(--info-bg); font-size: 13px; }
.st-ep-sysact.is-neg { border-left-color: var(--neg); background: var(--neg-bg); }
.st-ep-sysact.is-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.st-ep-sysact-what b { font-weight: 600; color: var(--fg-0); }
.st-ep-sysact-what > span { color: var(--fg-1); }
.st-ep-sysact-do { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.st-ep-sysbtn.is-neg { border-color: var(--neg-bd); color: var(--neg); }
.st-ep-sysbtn.is-warn { border-color: var(--warn-bd); color: var(--warn); }
.st-ep-syssteps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.st-ep-syssteps[hidden] { display: none; }
.st-ep-sysstep { flex: 1 1 64px; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); }
.st-ep-sysstep > b { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--fg-0); }
.st-ep-sysstep > span { font-size: 11.5px; color: var(--fg-2); }
.st-ep-syslead { margin: 0 0 12px; font-size: 12.5px; color: var(--fg-2); }
#dpanel-ep #ep-sys-scan > .ep-header-run { height: 32px; padding: 0 12px; border: 1px solid var(--bd); border-radius: var(--r-md); background: var(--surface-2); color: var(--fg-0); font-size: 12.5px; font-weight: 500; }
#dpanel-ep #ep-sys-scan > .ep-header-run:hover { border-color: var(--bd-strong); opacity: 1; }
#dpanel-ep #ep-sys-scan > .ep-header-run:disabled { opacity: 0.55; cursor: default; }
#ep-sys-scan #ep-census-details { margin: 12px 0 0; background: transparent; }
#ep-sys-scan .wt-census-all { margin-left: 0; color: var(--fg-1); }
#ep-sys-scan #wt-census-funnel[hidden], #ep-sys-scan #wt-census-lead[hidden] { display: none; }

@media (max-width: 600px) {
    #dpanel-ep #executor-cockpit .cockpit-row-primary { flex-wrap: wrap; overflow: visible; }
    #dpanel-ep #ep-exec-facts > div > span:last-child { text-align: left; }
    #dpanel-ep #ep-sys-f-sizing .wt-sizing, #dpanel-ep #ep-sys-f-sizing .wt-sizing-txt, #dpanel-ep #ep-sys-f-sizing .ep-header-inputs { justify-content: flex-start; }
    .st-ep-sysnote { text-align: left; }
    /* The page's phone rule makes every table a block with thead and tbody as two tables: each System table keeps one grid; .st-ep-tablewrap scrolls. */
    #ep-sys-orders table.st-ep-syssig { display: table; overflow: visible; }
    #ep-sys-orders .st-ep-syssig thead { display: table-header-group; width: auto; }
    #ep-sys-orders .st-ep-syssig tbody { display: table-row-group; width: auto; }
    #ep-sys-orders table.st-ep-sysord { display: table; overflow: visible; }
    #ep-sys-orders .st-ep-sysord thead { display: table-header-group; width: auto; }
    #ep-sys-orders .st-ep-sysord tbody { display: table-row-group; width: auto; }
    #ep-sys-brakes table.st-ep-sysbrk { display: table; overflow: visible; }
    #ep-sys-brakes .st-ep-sysbrk thead { display: table-header-group; width: auto; }
    #ep-sys-brakes .st-ep-sysbrk tbody { display: table-row-group; width: auto; }
    #ep-census-body table { display: table; overflow: visible; }
    #ep-census-body thead { display: table-header-group; width: auto; }
    #ep-census-body tbody { display: table-row-group; width: auto; }
}

/* ── Conv #826: Strategy settings page ── */
/* Tabs EP · TM · Capital, a section list beside one section at a time, each
   setting one row inside a group card. Checkboxes stay native inputs drawn as
   switches by .ss-switch; every colour is a token, so the light theme holds. */
#dpanel-settings [hidden] { display: none !important; }
.ss-page { max-width: 1400px; display: flex; flex-direction: column; }
.ss-head { align-items: flex-end; margin-bottom: 12px; }
.ss-head p { margin: 4px 0 0; }
.ss-pane { display: flex; flex-direction: column; gap: 16px; }

/* Tabs: the EP desk's underline tabs (.st-ep-tabs / #ep-subnav .dtab). */
.ss-tabs {
    display: flex; align-items: flex-end; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--bd);
    overflow-x: auto; scrollbar-width: none;
}
.ss-tabs::-webkit-scrollbar { display: none; }
.ss-tab {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: -1px;
    padding: 0 14px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
    color: var(--fg-2); font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.ss-tab:hover { color: var(--fg-0); background: none; }
.ss-tab.active, .ss-tab[aria-selected="true"] { color: var(--fg-0); border-bottom-color: var(--fg-0); }
.ss-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ss-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 2px; background: var(--fg-2); }
.ss-dot-ep { background: var(--ep); }
.ss-dot-tm { background: var(--tm); }
.ss-dot-cap { background: var(--fg-2); }
.ss-tab-s { font-size: 12px; font-weight: 400; color: var(--fg-2); }
.ss-tab-s:empty { display: none; }

/* The strategy header card: cells left to right, the last one on the right. */
#dpanel-settings .card.ss-run {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 36px; padding: 14px 16px;
}
.ss-run > * { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 340px; }
.ss-run > .ss-run-side { flex: 0 0 auto; }
.ss-run > :last-child:not(:first-child), .ss-run > .ss-run-side { margin-left: auto; align-items: flex-end; text-align: right; }
.ss-run-k, .ss-run > * > label:first-child:not(.ss-switch) { font-size: 12px; font-weight: 400; color: var(--fg-2); }
.ss-run-v { display: flex; align-items: center; gap: 8px; min-height: 30px; font-weight: 500; color: var(--fg-0); }
.ss-run-sub, .ss-run small, .ss-run .s-hint { font-size: 12px; line-height: 1.45; color: var(--fg-2); }
#dpanel-settings #ss-tm-on-text { font-weight: 500; color: var(--fg-0); }
#dpanel-settings #ss-tm-budget { font-family: var(--font-mono); color: var(--fg-0); }
#dpanel-settings #s-tm-enabled-warn { font-size: 12px; line-height: 1.45; }
/* The base preset bar, carried verbatim, sits inline in its cell. */
#dpanel-settings .ss-run .s-preset-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 !important;
    padding: 0 !important; background: none !important; border: 0 !important; border-radius: 0 !important;
}
#dpanel-settings .ss-run .s-preset-bar select,
#dpanel-settings .ss-run .s-preset-name-input {
    height: 30px; flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 0 8px !important;
    background: var(--surface-2) !important; border-color: var(--bd-strong) !important; border-radius: var(--r-sm) !important;
    font-size: 13px !important;
}
#dpanel-settings .ss-run .s-preset-bar select { width: auto !important; }
#dpanel-settings .ss-run .s-preset-name-input { width: 150px; }
#dpanel-settings .ss-run .s-preset-btn { height: 30px; padding: 0 10px !important; font-size: 13px !important; }

/* Section list beside the open section. */
.ss-body { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px 28px; }
.ss-nav { flex: 0 0 232px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ss-nav-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; box-sizing: border-box;
    padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: transparent;
    color: var(--fg-1); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.ss-nav-item:hover { background: var(--surface-2); color: var(--fg-0); }
.ss-nav-item[aria-pressed="true"] { background: var(--surface-3); color: var(--fg-0); }
.ss-nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ss-nav-name { font-weight: 500; }
.ss-nav-meta { font-size: 11.5px; color: var(--fg-2); }
.ss-main { flex: 999 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.ss-sec { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ss-sec-head { display: flex; flex-direction: column; gap: 2px; }
.ss-sec-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--fg-0); }
.ss-sec-head p { margin: 0; }
.ss-wrap { display: block; min-width: 0; }
.ss-sec > .ss-wrap > .ss-group + .ss-group { margin-top: 12px; }

/* Group cards: the app's card with no inner padding; rows carry their own. */
#dpanel-settings .card.ss-group { padding: 0; min-width: 0; }
.ss-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 11px 16px; }
.ss-group-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--fg-0); }
.ss-group-note { min-width: 0; font-size: 12px; color: var(--fg-2); }
.ss-group-side { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin-left: auto; }
.ss-group-off { font-size: 12px; color: var(--fg-2); }
.ss-sum { font-family: var(--font-mono); font-size: 12px; color: var(--fg-2); }
.ss-sum:empty { display: none; }
.ss-sum.is-warn { color: var(--warn); }
.ss-group.is-off > .ss-group-body { display: none; }
.ss-sec.is-master-off > .ss-group ~ .ss-group, .ss-sec.is-master-off > .ss-wrap { display: none !important; }

/* Rows: label and description on the left, the control and its unit on the right. */
.ss-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; padding: 9px 16px;
    border-top: 1px solid var(--bd-soft);
}
.ss-row.is-dim { opacity: .45; }
.ss-row-l { flex: 1 1 240px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; row-gap: 1px; }
.ss-row-label { font-size: 13.5px; font-weight: 500; color: var(--fg-0); }
.ss-row-l .metric-tip { margin-left: 6px; }
.ss-row-desc { flex: 1 0 100%; font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.ss-row-c {
    flex: 0 0 auto; min-width: 200px; max-width: 100%; margin-left: auto; display: flex; flex-wrap: wrap;
    align-items: center; justify-content: flex-end; gap: 8px; font-family: var(--font-mono);
}
.ss-unit { flex: 0 0 44px; width: 44px; font-family: var(--font-sans); font-size: 12px; color: var(--fg-2); }
.ss-row-c:not(:has(.ss-unit)):not(:has(select)):not(:has(input[type=text]))::after { content: ""; flex: 0 0 44px; }
.ss-row-c input[type=number], .ss-row-c input[type=text], .ss-row-c select {
    height: 30px; box-sizing: border-box; padding: 0 8px; margin: 0;
    background: var(--surface-2); border: 1px solid var(--bd-strong); border-radius: var(--r-sm);
    color: var(--fg-0); font-family: var(--font-sans); font-size: 13px; font-variant-numeric: tabular-nums;
}
.ss-row-c input[type=number] { width: 84px; text-align: right; font-family: var(--font-mono); }
.ss-row-c input[type=text] { width: 220px; max-width: 100%; }
.ss-row-c select { width: auto !important; max-width: 100%; padding-right: 4px; cursor: pointer; }
.ss-row-c input:focus, .ss-row-c select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.ss-row-c input:disabled, .ss-row-c select:disabled { opacity: .5; cursor: default; }
/* The custom-universe upload field, carried verbatim: its name input and the "Choose CSV" label wrap right. */
#dpanel-settings #s-upload-universe-field .ss-row-c > div { flex-wrap: wrap; justify-content: flex-end; }
#dpanel-settings #s-upload-universe-field .ss-row-c label:not(.ss-switch) { font-family: var(--font-sans); }
#dpanel-settings #s-universe-info { margin: 0 16px 12px !important; }

/* Switch: the native checkbox stays in the DOM and focusable, invisible over the track. */
.ss-switch {
    position: relative; display: inline-flex; flex: 0 0 auto; width: 36px; height: 20px;
    margin: 0; padding: 0; vertical-align: middle; cursor: pointer;
}
.ss-switch > input[type=checkbox] {
    position: absolute !important; inset: 0; z-index: 1; width: 100% !important; height: 100% !important;
    margin: 0 !important; padding: 0; opacity: 0; cursor: pointer;
}
.ss-switch-ui {
    position: absolute; inset: 0; border-radius: 999px; background: var(--bd-strong);
    transition: background-color .15s ease; pointer-events: none;
}
.ss-switch-ui::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--fg-0); transition: transform .15s ease;
}
:root[data-theme="light"] .ss-switch-ui { background: color-mix(in srgb, var(--fg-2) 40%, var(--surface-3)); }
:root[data-theme="light"] .ss-switch > input:checked + .ss-switch-ui { background: var(--accent); }
:root[data-theme="light"] .ss-switch-ui::after {
    background: var(--surface-1); box-shadow: 0 1px 2px color-mix(in srgb, var(--fg-0) 25%, transparent);
}
.ss-switch > input:checked + .ss-switch-ui { background: var(--accent); }
.ss-switch > input:checked + .ss-switch-ui::after { transform: translateX(16px); }
.ss-switch > input:focus-visible + .ss-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.ss-switch > input:disabled { cursor: default; }
.ss-switch > input:disabled + .ss-switch-ui { opacity: .5; }
@media (prefers-reduced-motion: reduce) {
    .ss-switch-ui, .ss-switch-ui::after { transition: none; }
}

/* A text-like button or link (Reset all TM / EP settings…, Import from a backtest run). */
.ss-quiet-btn {
    padding: 0; border: 0; background: transparent; color: var(--fg-2); font: inherit; font-size: 12px;
    text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.ss-quiet-btn:hover { color: var(--fg-0); }
.ss-quiet-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* Stage 4: the per-pane save bars are gone (each pane keeps a .ss-loadbar; the Save buttons and
   the status lines are in #ss-foot, styled in the stage 4 section at the end of this file). */
.ss-loadnote { font-size: 12.5px; color: var(--fg-2); }
/* A form that does not hold the saved settings yet (loading, or the load failed) is not shown:
   the template's placeholder values must never read as the stored ones. The load bar and its note stay. */
.ss-pane.is-unloaded > .ss-run, .ss-pane.is-unloaded > .ss-body, .ss-pane.is-unloaded > #ep-s-unreadable { display: none !important; }
.ss-pane.is-unloaded > .ss-loadbar { position: static; border-top: 0; }
.ss-run-khead { display: flex; align-items: center; gap: 2px; }
/* The executor select shows its longest option in full; its header cell sizes to it. */
#dpanel-settings #executor-mode-row { flex: 0 0 auto; max-width: none; }
#dpanel-settings #executor-mode-row select.st-es-select { max-width: none; }
/* The sidebar's link to the dashboard tour (it left the Strategy settings page). */
.st-foot .st-tourlink { display: block; padding: 0 2px 8px; font-size: 12px; color: var(--fg-2); text-decoration: none; }
.st-foot .st-tourlink:hover { color: var(--fg-0); text-decoration: underline; }

/* Capital: allocation bar, lane table, figures, history. */
.ss-alloc {
    display: flex; gap: 2px; height: 10px; margin: 4px 0 8px; border-radius: 5px; overflow: hidden;
    background: var(--surface-2);
}
.ss-alloc > span { flex: 0 1 0; min-width: 0; }
#dpanel-settings #ss-cap-bar-ep { background: var(--ep); }
#dpanel-settings #ss-cap-bar-tm { background: var(--tm); }
#dpanel-settings #ss-cap-bar-un { background: color-mix(in srgb, var(--fg-2) 55%, var(--surface-2)); }
.ss-alloc + div, .ss-alloc-leg { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0 0 12px; font-size: 12px; color: var(--fg-2); }
.ss-leg-i { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
/* The unallocated part of the bar is a muted neutral; its legend dot matches it. */
.ss-alloc-leg .ss-dot-cap { background: color-mix(in srgb, var(--fg-2) 55%, var(--surface-2)); }
.ss-tablewrap td > .ss-dot { margin-right: 8px; vertical-align: 1px; }
.ss-tablewrap { overflow-x: auto; margin: 8px 0 12px; }
.ss-tablewrap > .st-table { min-width: 780px; margin: 0 !important; }
.ss-tablewrap .st-table th.num { text-align: right; font-family: var(--font-sans); }
.ss-tablewrap input[type=number] {
    width: 110px !important; height: 30px; box-sizing: border-box; padding: 0 8px; margin: 0;
    background: var(--surface-2); border: 1px solid var(--bd-strong); border-radius: var(--r-sm);
    color: var(--fg-0); font-family: var(--font-mono); font-size: 13px; text-align: right;
}
.ss-tablewrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.ss-tablewrap input:disabled { opacity: .5; }
.ss-figs {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 24px;
    margin: 4px 0 12px; padding-top: 14px; border-top: 1px solid var(--bd-soft);
}
.ss-figs > * { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ss-fig-k, .ss-figs label { font-size: 12px; font-weight: 400; color: var(--fg-2); }
.ss-figs .mono { font-size: 15px; color: var(--fg-0); overflow-wrap: anywhere; }
.ss-fig-sub, .ss-figs .s-hint { margin: 0; font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.ss-cap-save {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px;
    padding-top: 14px; border-top: 1px solid var(--bd-soft);
}
.ss-cap-save label { font-size: 12px; font-weight: 400; color: var(--fg-2); }
#dpanel-settings #cap-alloc-card #cap-note {
    flex: 1 1 260px; min-width: 0;
    height: 32px; box-sizing: border-box; padding: 0 10px; max-width: 100%;
    background: var(--surface-2); border: 1px solid var(--bd-strong); border-radius: var(--r-sm); color: var(--fg-0);
}
#dpanel-settings #cap-alloc-card #cap-note:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
#dpanel-settings #cap-alloc-history { display: flex; flex-direction: column; font-size: 13px; }
#dpanel-settings #cap-alloc-history > div { padding: 7px 0; border-top: 1px solid var(--bd-soft); color: var(--fg-1); overflow-wrap: anywhere; }

/* Stage 2: the EP tab. */
/* Save buttons. EP's Save is .ss-save-btn only (it must not be the first .s-save-btn);
   TM's carries .s-save-btn and .ss-save-btn, and both classes give it the same values
   (the .s-save-btn look above, whose !important wins on TM anyway), so they do not fight. */
.ss-save-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; box-sizing: border-box; padding: 0 16px;
    background: var(--fg-0); color: var(--surface-0); border: 1px solid var(--fg-0); border-radius: var(--r-md);
    font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.ss-save-btn:hover { opacity: .88; }
.ss-save-btn:disabled, .ss-save-btn:disabled:hover { opacity: .5; cursor: default; }
/* The header: EP on, Executor, Sizing basis; the link to the backtest page. */
#dpanel-settings #ss-ep-on-text { font-weight: 500; color: var(--fg-0); }
#dpanel-settings #ss-ep-basis { font-weight: 500; color: var(--fg-0); overflow-wrap: anywhere; }
.ss-run select.st-es-select {
    align-self: flex-start; width: auto; max-width: 100%; height: 30px; box-sizing: border-box;
    padding: 0 4px 0 8px; margin: 0; background: var(--surface-2); border: 1px solid var(--bd-strong);
    border-radius: var(--r-sm); color: var(--fg-0); font-family: var(--font-sans); font-size: 13px; cursor: pointer;
}
.ss-run select.st-es-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.ss-run select.st-es-select:disabled { opacity: .5; cursor: default; }
.ss-run .st-es-note { margin-left: 0; }     /* .st-es-note's auto margin pushes it right in a column cell */
a.ss-quiet-btn, a.ss-quiet-btn:visited { color: var(--fg-2); text-decoration: underline; text-underline-offset: 2px; }
a.ss-quiet-btn:hover { color: var(--fg-0); }
/* The Conv #715 banner spans the pane; its inline colours stay, its inline margin goes. */
#dpanel-settings #ep-s-unreadable { margin: 0 !important; }
/* EP controls keep their st-es-* classes. The row rules above already win where those fight
   the layout (.ss-row-c input[type=number] 0,2,1 over .st-es-input 0,1,0; the select width is
   !important; .ss-switch > input[type=checkbox] 0,2,1 with !important sizes over .st-es-check);
   spelled out here for the EP classes. */
.ss-row-c input.st-es-input[type=number] { width: 84px; }
.ss-row-c input.st-es-input[type=text] { width: 220px; max-width: 100%; text-align: left; }
.ss-row-c input.st-es-readonly { background: transparent; border-color: var(--bd); color: var(--fg-2); cursor: default; }
.ss-row-c select.st-es-select { width: auto !important; max-width: 100%; }
/* A control's own note under the row (the broker stop mode note). */
.ss-row-foot { flex: 1 0 100%; min-width: 0; text-align: right; font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.ss-row-foot .st-es-note { margin-left: 0; }
/* The breakout line under the EP section list. */
.ss-nav-foot {
    margin: 10px 0 0; padding: 8px 10px 0; border-top: 1px solid var(--bd-soft);
    font-size: 12px; line-height: 1.45; color: var(--fg-2);
}

/* Stage 3: the defaults. Each row's third cell holds the app's default, a dot and a Reset
   when the value differs; every row has the cell (empty where no default is shown), so the
   controls' right edges stay aligned (the 44 px unit slot of .ss-row-c above still applies). */
.ss-row-d {
    flex: 0 0 176px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0;
    font-size: 12px; color: var(--fg-2); white-space: nowrap;
}
.ss-def-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ss-row.is-changed .ss-def-text, .ss-group-head.is-changed .ss-def-sw { color: var(--fg-0); }
/* A default the form cannot hold: the reason is the title ("?"). */
.ss-def-text.is-why { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.ss-def-text.is-why::after { content: " ?"; }
.ss-def-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.ss-def-reset {
    flex: 0 0 auto; padding: 2px 6px; border: 1px solid var(--bd-strong); border-radius: 5px; background: transparent;
    color: var(--fg-1); font: inherit; font-size: 11.5px; line-height: 1.3; cursor: pointer;
}
.ss-def-reset:hover { background: var(--surface-2); color: var(--fg-0); }
.ss-def-reset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ss-def-reset:disabled, .ss-def-reset:disabled:hover { background: transparent; color: var(--fg-2); opacity: .5; cursor: default; }
/* A row's own note (.ss-row-foot) comes after the default cell in the markup: it goes to its own
   line under the row and stays under the control, not under the default cell. */
.ss-row > .ss-row-foot { order: 1; padding-right: 196px; box-sizing: border-box; }
/* Group switches: the default sits in the group head, before the switch. */
.ss-def-sw { font-size: 12px; color: var(--fg-2); white-space: nowrap; }
.ss-def-sw:empty { display: none; }
.ss-group-side .ss-def-reset { margin-left: -2px; }
/* The EP header's EP on and Executor cells: the default as small text, no Reset. */
.ss-run-def { font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.ss-run-def:empty { display: none; }
/* The Executor cell: the answer to a mode change (the colour is set with the text). */
.ss-run-status { font-size: 12px; line-height: 1.45; }
.ss-run-status:empty { display: none; }
/* The page header: "Changed from default" and its count, on the EP and TM tabs. */
.ss-head-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.ss-chg {
    display: inline-flex; align-items: center; gap: 8px; height: 32px; box-sizing: border-box; padding: 0 12px;
    border: 1px solid var(--bd-strong); border-radius: var(--r-sm); background: transparent;
    color: var(--fg-1); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.ss-chg:hover { background: var(--surface-2); color: var(--fg-0); }
.ss-chg[aria-pressed="true"] { background: var(--surface-3); color: var(--fg-0); }
.ss-chg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ss-chg-count, #dpanel-settings #ss-chg-count { font-family: var(--font-mono); font-size: 12px; color: var(--fg-2); }
.ss-chg-count:empty, #dpanel-settings #ss-chg-count:empty { display: none; }
/* The section list: "n changed". */
.ss-nav-chg { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); }
.ss-nav-meta .ss-nav-chg::before { content: " · "; font-family: var(--font-sans); color: var(--fg-2); }
/* The filter prefixes each group title with its section name. */
.ss-group-sec { font-weight: 400; color: var(--fg-2); }
/* "Changed from default" on: every section of the strategy, only the rows and groups that
   differ. A switched-off group, a section whose master is off, and a sub-field its mode hides
   show their differing rows dimmed (the stage 1 rules hide them with !important). */
.ss-main.is-filtered .ss-row.ss-nomatch, .ss-main.is-filtered .ss-group.ss-nomatch { display: none !important; }
.ss-main.is-filtered .ss-group.is-off > .ss-group-body { display: block; opacity: .45; }
.ss-main.is-filtered .ss-sec.is-master-off > .ss-group ~ .ss-group:not(.ss-nomatch),
.ss-main.is-filtered .ss-sec.is-master-off > .ss-wrap { display: block !important; opacity: .45; }
.ss-main.is-filtered .ss-wrap[style*="none"] { display: block !important; opacity: .45; }
.ss-main.is-filtered .ss-group.is-off .ss-wrap[style*="none"],
.ss-main.is-filtered .ss-sec.is-master-off .ss-wrap .ss-wrap[style*="none"] { opacity: 1; }   /* already dimmed by its group or section */

/* Phones: tabs and the section list scroll sideways, rows put the label over the control. */
@media (max-width: 600px) {
    .ss-tab { padding: 0 12px; }
    .ss-body { gap: 12px; }
    .ss-nav {
        flex: 1 1 100%; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none;
        padding-bottom: 2px;
    }
    .ss-nav::-webkit-scrollbar { display: none; }
    .ss-nav-item { flex: 0 0 auto; width: auto; }
    .ss-main { flex-basis: 100%; }
    #dpanel-settings .card.ss-run { gap: 12px 20px; padding: 12px; }
    .ss-run > * { max-width: none; }
    .ss-run > :last-child:not(:first-child), .ss-run > .ss-run-side { margin-left: 0; align-items: flex-start; text-align: left; }
    .ss-group-head { padding: 10px 12px; }
    .ss-row { padding: 9px 12px; }
    .ss-row-l { flex-basis: 100%; }
    .ss-row-c { flex: 1 1 100%; min-width: 0; margin-left: 0; justify-content: flex-start; }
    .ss-row-c input[type=number], .ss-row-c input[type=text], .ss-row-c select,
    #dpanel-settings .ss-run .s-preset-bar select, #dpanel-settings .ss-run .s-preset-name-input,
    .ss-tablewrap input[type=number], #dpanel-settings #cap-alloc-card #cap-note { font-size: 16px !important; }
    .ss-row-c input[type=text] { width: 100%; }
    #dpanel-settings #s-upload-universe-field .ss-row-c > div { justify-content: flex-start; }
    #dpanel-settings .ss-tablewrap > table.st-table { display: table; overflow: visible; }
    #dpanel-settings .ss-figs .mono { font-size: 15px !important; }
    #dpanel-settings #ss-tm-budget { font-size: 14px !important; }
    #dpanel-settings .ss-run .s-preset-bar { align-items: stretch; }
    .ss-run > * { flex-basis: 100%; }
    .ss-run select.st-es-select { font-size: 16px !important; }
    .ss-row-c input.st-es-input[type=text] { width: 100%; }
    .ss-row-foot { text-align: left; }
    .ss-nav-foot { display: none; }      /* the section list is a sideways scroller here */
    /* Stage 3: the default goes under the control, left aligned; the header tools under the title. */
    .ss-row-d { flex: 1 1 100%; justify-content: flex-start; }
    .ss-row-d:empty { display: none; }
    .ss-row > .ss-row-foot { padding-right: 0; }
    .ss-head-tools { flex: 1 1 100%; margin-left: 0; }
}
/* Review of the stage 3 renders. */
.ss-nav-chg { font-family: var(--font-sans); }
@media (max-width: 600px) {
    /* a long select (the sizing basis) stays inside the row instead of widening the page */
    .ss-row-c > select { flex: 0 1 auto; min-width: 0; max-width: 100%; }
}

/* Stage 4: "Find a setting" and the unsaved-changes bar. */
/* The search field in the page header, before "Changed from default". */
.ss-find {
    width: 220px; height: 32px; box-sizing: border-box; padding: 0 10px; margin: 0;
    background: var(--surface-2); border: 1px solid var(--bd-strong); border-radius: var(--r-sm);
    color: var(--fg-0); font: inherit; font-size: 13px; -webkit-appearance: none; appearance: none;
}
.ss-find::placeholder { color: var(--fg-2); opacity: 1; }
.ss-find:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
/* Each pane keeps its load note at its foot; the per-pane save bars are gone. */
.ss-loadbar { padding: 4px 0; }
/* The foot of the page: the three save status lines, then the bar. It stays at the bottom of
   the window while the page scrolls, on the page's own surface. */
.ss-foot {
    position: sticky; bottom: 0; z-index: 5; margin-top: 16px;
    background: var(--surface-0);      /* opaque: rows scrolling under the bar must not read through its chips */
}
.ss-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; min-height: 0; font-size: 13px; }
.ss-status > * { padding-top: 8px; }
/* An empty status takes no room (#s-msg also carries the inline display:none its save toggles). */
.ss-status > :empty { display: none; }
/* The bar: shown while anything is unsaved ([hidden] wins: #dpanel-settings [hidden] above). */
.ss-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
    padding: 12px 0; border-top: 1px solid var(--bd-strong);
}
.ss-bar-n { flex: 0 0 auto; font-weight: 600; color: var(--warn); }
.ss-bar-chips { display: flex; flex-wrap: wrap; gap: 6px 10px; flex: 1 1 420px; min-width: 0; }
.ss-bar-chip {
    max-width: 100%; box-sizing: border-box; padding: 3px 8px; border: 1px solid var(--bd-strong); border-radius: var(--r-sm);
    font-size: 12px; line-height: 1.45; color: var(--fg-1); overflow-wrap: anywhere;
}
.ss-bar-who, .ss-bar-old { color: var(--fg-2); }
.ss-bar-new { color: var(--fg-0); }
.ss-bar-old, .ss-bar-new { font-family: var(--font-mono); }
.ss-bar-guard { color: var(--warn); }
.ss-bar-more { font-size: 12px; color: var(--fg-2); }
.ss-bar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ss-bar-actions .ss-quiet-btn { font-size: 13px; margin-right: 4px; }
.ss-save-n { font-size: 12px; color: var(--fg-2); }
/* "Unsaved" beside a row's label or a group's title; "unsaved" on a section, a tab, the EP header. */
.ss-unsaved, .ss-tab-u, .ss-nav-u { font-size: 11.5px; font-weight: 400; color: var(--warn); }
.ss-unsaved { margin-left: 8px; }
.ss-run-cell > .ss-unsaved { margin-left: 0; }   /* the EP header's cells are columns */
.ss-nav-meta .ss-nav-u::before { content: " · "; color: var(--fg-2); }
@media (max-width: 600px) {
    .ss-head-tools { flex-wrap: wrap; }
    .ss-find { width: 100%; font-size: 16px; }
    .ss-bar-chips { flex-basis: 100%; }
    .ss-bar-actions { flex: 1 1 100%; }
}
/* Review of the stage 4 renders: on a phone the bar is the count and the buttons (the chips took
   two fifths of the screen; the rows, sections and tabs carry the marks), and the tabs keep room
   for their "unsaved" mark. */
@media (max-width: 600px) {
    .ss-bar-chips, .ss-bar-more, .ss-save-n { display: none !important; }
    .ss-tab-s { display: none; }
}
