/* Theming.
 *
 * The app was written dark, with every colour spelled as a literal hex across
 * five thousand lines. The tokens below were extracted from those literals
 * rather than designed fresh: each --token holds EXACTLY the colour that was
 * already there, so the dark theme is byte-for-byte what it always was and the
 * only thing that changed is where the value is written down.
 *
 * WHICH COLOURS BECAME TOKENS. The greys did -- surfaces, borders and text --
 * because those are what a theme actually is. The signal colours mostly did
 * not: red means down and green means up on either ground, and a token per
 * indicator line would be a palette, not a theme. The handful that did are the
 * ones too pale to survive a white background.
 *
 * DARK IS THE DEFAULT and stays it. A viewer who has never touched the setting
 * gets exactly what they had before; light is opt-in, stored per browser, and
 * applied by theme.js before first paint.
 */
:root {
    color-scheme: dark;

    /* Surfaces, deepest to most raised. */
    --bg-deepest: #10131c;
    --bg-deeper:  #161a24;
    --bg-app:     #1b202c;
    --bg-panel:   #1e222d;
    --bg-sunken:  #1c2028;
    --bg-raised:  #232730;

    /* Lines. --border is ordinary separation, --border-strong is a division
       that should read as structural, --border-bright is an active edge. */
    --border:        #2a2e39;
    --border-strong: #3c434c;
    --border-bright: #4a4f5a;

    /* Text, brightest to faintest. --text-dim is the workhorse for secondary
       labels; the two below it are for things deliberately receding. */
    --text-brightest: #e8eaed;
    --text-bright:    #d7dbe0;
    --text:           #d1d4dc;
    --text-soft:      #b8bcc4;
    --text-softer:    #a8adb8;
    --text-muted:     #9199a6;
    --text-dim:       #8a8f98;
    --text-dimmer:    #6b7280;
    --text-faint:     #6b7481;
    --text-faintest:  #5c636e;

    /* Signal colours, held as tokens because they are TEXT as well as marks.
     *
     * Measured against white, every one of these is a failure: the ambers land
     * at 1.9-2.4:1, the green at 2.8, the red at 3.5, where readable body text
     * wants 4.5. They were chosen for #1b202c, where they are 5.9-8.5:1 and
     * correct. Seventy-two inline `style="color:#..."` strings across the views
     * used them directly, which is why the light theme looked washed out in
     * exactly the places that carry the most words -- the commentary, the
     * backdrop notes, the "reconstructed day" warnings.
     *
     * Their DARK values are the literals those strings already used, so the
     * dark theme is unchanged. The one deliberate convergence is amber: six
     * near-identical golds (#eab308, #d4b34a, #eda100, #e0a33e, #e0a030,
     * #c9a227) now share --warn, because six shades of caution that nobody
     * ever sees side by side is not a palette, it is an accident. */
    --neg:       #ef5350;
    --good:      #4caf50;
    --pos:       #62d2a2;
    --pos-soft:  #7fd18f;
    --accent:    #6cb8ff;
    --link:      #8ab4f8;
    --warn:      #eda100;
    --shadow:    rgba(0, 0, 0, 0.4);
}

/* Light.
 *
 * NOT AN INVERSION. Flipping each token to its complement gives grey text on
 * grey panels, because a dark theme separates surfaces by making them lighter
 * and a light theme has to separate them by making them darker -- the ladder
 * runs the other way and the steps are not the same size. Dark surfaces are
 * ordered deepest-to-raised and light ones ground-to-recessed, so --bg-deepest
 * is the darkest thing on one theme and a mid grey on the other.
 *
 * The text ladder keeps its ORDER but compresses: on a dark ground the eye
 * tolerates a wide spread between primary and faint text, and on a white one
 * the faint end has to stay much darker than its inverse would be or it
 * disappears entirely. */
:root[data-theme="light"] {
    color-scheme: light;

    /* Surfaces, and the correction that took two goes.
     *
     * The first light theme kept each token's ORDINAL POSITION -- --bg-deeper
     * stayed one step recessed from --bg-app, as it is in dark -- which sounds
     * like faithfulness and produced mud. .breadth-card uses --bg-deeper, so
     * every card on Market Breadth rendered as a grey panel sunk into a nearly
     * white page: no separation, no hierarchy, and the whole screen one flat
     * wash. Preserving the RELATIONSHIP was the wrong goal.
     *
     * A dark theme signals "raised" by getting lighter, and the page therefore
     * sits near the bottom of its range. A light theme signals "raised" by
     * getting WHITER, and the page has to sit below its surfaces -- so the
     * ground is the grey one and the cards are white. That is the same
     * observation as the comment above, applied rather than only written down.
     *
     * So the card tokens all resolve to white here, and only what is genuinely
     * recessed -- an input well, a hover strip, a table's header band -- goes
     * darker than the page. */
    --bg-app:     #eceef2;   /* the ground: the only broad grey */
    --bg-panel:   #ffffff;   /* cards */
    --bg-deeper:  #ffffff;   /* cards -- recessed in dark, raised here */
    --bg-raised:  #ffffff;   /* cards */
    --bg-sunken:  #e3e7ee;   /* wells and hover strips, below the ground */
    --bg-deepest: #d9dee6;   /* header bands, the deepest recess */

    --border:        #d2d7e0;
    --border-strong: #c2c7d0;
    --border-bright: #a7aeba;

    --text-brightest: #0b0d12;
    --text-bright:    #14171e;
    --text:           #1c2029;
    --text-soft:      #333a45;
    --text-softer:    #444c58;
    --text-muted:     #4a5160;
    --text-dim:       #525a67;
    --text-dimmer:    #565e6c;
    --text-faint:     #5f6775;
    --text-faintest:  #676e7c;

    --neg:      #c0392f;
    --good:     #1b7a31;
    --pos:      #0b7a55;
    --pos-soft: #167a45;
    --accent:   #1668c4;
    --link:     #1a56b8;
    --warn:     #8a5c00;
    --shadow:   rgba(15, 20, 30, 0.18);
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-app);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* App-level navigation: switches between full-screen views (Chart, Sector
   Rotation, Watchlist, ...) -- distinct from #toolbar below it, which holds
   controls scoped to the Chart view itself (sector picker, interval, etc.),
   not app-wide navigation. See nav.js. */
#appNav {
    flex: 0 0 auto;
    display: flex;
    gap: 2px;
    padding: 6px 8px 0;
    background: var(--bg-deeper);
    border-bottom: 1px solid var(--border);
    /* The tabs refuse to shrink, so on a window too narrow for all fourteen
       the row would otherwise be clipped and the last ones unreachable.
       Scrolling keeps them reachable; at any normal width there is nothing to
       scroll and this is invisible. */
    overflow-x: auto;
    scrollbar-width: none;
}

#appNav::-webkit-scrollbar {
    height: 0;
}

.app-nav-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    /* Fourteen tabs plus the account block is a tight row on a laptop. Flex
       items shrink by default, and a shrunk button wraps its label onto two
       lines, which is what made the bar twice as tall as it needs to be.
       Refusing to shrink keeps every tab on one line. */
    flex: 0 0 auto;
    white-space: nowrap;
}

.app-nav-btn:hover {
    color: var(--text);
}

.app-nav-btn.active {
    background: var(--bg-app);
    color: var(--text);
    border-color: var(--border);
}

.auth-badge {
    /* No margin-left:auto here. #alertBellWrap already carries one, and a
       second auto margin makes flex split the leftover space between the two
       -- opening a gap in the middle of the account block and taking width
       from the tabs. One auto margin, on the first item of the group, pushes
       the whole group right and gives the rest of the row to the nav. */
    align-self: center;
    color: var(--text-dim);
    font-size: 12px;
    padding: 4px 6px;
    white-space: nowrap;
}

.auth-logout-btn {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 10px;
    margin: 0 8px;
    font-size: 12px;
    cursor: pointer;
}

.auth-logout-btn:hover {
    color: var(--text);
}

/* Controls hidden because this person could not use them.
 *
 * One rule, set by permissions.js from the SAME requirement the route
 * enforces -- data-needs="page:chart:write" mirrors
 * RequirePage(PageChart, Write). It replaces a `body.role-guest
 * [data-admin-only]` rule that asked whether somebody was an administrator --
 * a question the server stopped asking when requireAdmin() was deleted, and
 * which hid the Indicators button and the whole drawing toolbar from every
 * named user however their permissions were set.
 *
 * !important because several of the gated elements carry their own display
 * (#leftSidebar is a flex column), and a class that loses to the element's
 * own rule would hide nothing. */
.perm-hidden {
    display: none !important;
}

/* Each full-screen view fills the remaining space below #appNav; only the
   active one is ever rendered. #viewChart wraps the app's existing
   #toolbar + #mainArea unchanged -- nav.js only ever toggles this class,
   nothing about the chart itself. */
.app-view {
    display: none;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.app-view.active {
    display: flex;
}

.view-placeholder {
    margin: auto;
    text-align: center;
    color: var(--text-dim);
    max-width: 420px;
}

.view-placeholder h2 {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 8px;
}

/* Sector Rotation view (see rotation.js) */
#rotationToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

/* Sector Map (see sectormap.js): a collapsible Sector -> Industry ->
   Sub-Industry mindmap, purely informational (no editing). The last pane
   on Sector Rotation rather than a view of its own -- it shows how the
   taxonomy the other six panes rank over is arranged.

   Its old #sectormapToolbar is a .rotation-subtoolbar now, so the toolbar
   rule went with the view: the pane sits below #rotationToolbar, whose
   border already separates the two, and a second rule 40px under the first
   read as a boxed-in strip. Padding matches #rrgWrap so every pane's
   content starts on the same left edge. */
#sectormapPane {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
}

#sectormapPane.active {
    display: flex;
}

.sectormap-hint {
    color: var(--text-dim);
    font-size: 12px;
}

/* No padding of its own any more -- #sectormapPane carries it, the way
   #rrgWrap does for the RRG canvas. */
#sectormapWrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.sectormap-node-rect {
    fill: var(--bg-panel);
    stroke: var(--border-strong);
    cursor: pointer;
}

.sectormap-node-rect:hover {
    stroke: #5b9cf6;
}

.sectormap-node-text {
    fill: var(--text);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.sectormap-node-count {
    fill: var(--text-dim);
    font-size: 11px;
}

.sectormap-link {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 1.5;
}

.sectormap-node-rect.depth-0 { fill: #1b2a4a; stroke: #3a5c9e; }
.sectormap-node-rect.depth-1 { fill: var(--bg-panel); stroke: var(--border-strong); }
.sectormap-node-rect.depth-2 { fill: #202a20; stroke: #3f6a3f; }

/* Ratio Scan view (see ratioscan.js) -- unlike every other toolbar in the
   app, this one had no dedicated rule at all, so it fell back to plain
   block flow (buttons/select/span as inline content, wrapping like text)
   instead of a single flex row -- worse still combined with the
   Comparison <select> below sizing itself to its widest OPTION ("Industry
   vs Total Market") even while showing the much shorter "All", eating
   most of the row and pushing Refresh/Force Refresh onto their own
   wrapped second line. */
#ratioScanToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Same toolbar convention as #ratioScanToolbar -- was previously a bare
   div with no flex rule at all, so the kind-toggle div (block-level)
   forced everything after it onto a second row regardless of width. */
#actionScanToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

#actionScanSymbolFilter {
    max-width: 160px;
}

#actionScanIndustryFilter {
    max-width: 220px;
}

/* Scans page's ticker-history lookup (see tickerscanhistory.go) -- a
   secondary, independent panel below the main scan table, same toolbar
   shape as #ratioScanToolbar (this app's own toolbar convention). */
#tickerScanHistoryToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    color: var(--text-dim);
    font-size: 13px;
}

#tickerScanHistoryInput {
    width: 200px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: inherit;
    margin-left: 6px;
}

#tickerScanHistoryWrap {
    flex: 0 0 auto;
    max-height: 260px;
    overflow: auto;
    border-top: 1px solid var(--border);
}

#rotationToolbar button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#rotationToolbar button:hover {
    background: var(--border);
}

#rotationToolbar button:disabled {
    opacity: 0.5;
    cursor: default;
}

.rotation-status {
    color: var(--text-dim);
    font-size: 12.5px;
}

.rotation-level-toggle {
    display: flex;
    gap: 2px;
}

.rotation-level-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-strong);
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

.rotation-level-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.rotation-level-btn:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.rotation-level-btn:hover {
    color: var(--text);
}

/* !important on background/border-color: every toolbar this class appears
   in (#rotationToolbar, #scansToolbar, #watchlistToolbar, etc.) has its
   own "#idToolbar button { background; border; }" rule, an ID selector
   that otherwise always beats this class selector's specificity -- which
   silently made the active-tab highlight nearly invisible (only color/
   font-weight ever actually applied) everywhere .rotation-level-btn is
   used, not just on any one page. */
.rotation-level-btn.active {
    background: #2a3a4d !important;
    color: var(--text);
    font-weight: 600;
    border-color: var(--accent) !important;
    box-shadow: inset 0 0 0 1px var(--accent);
}

.rotation-level-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.rotation-level-btn:disabled:hover {
    color: var(--text-dim);
}

.rotation-date-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 13px;
}

.rotation-date-label input[type="date"],
.rotation-date-label select {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: inherit;
    color-scheme: dark;
}

.rotation-latest-date-note {
    color: var(--text-dimmer);
    font-size: 12px;
    white-space: nowrap;
}

/* Each mode's own Sector/Industry[/Stocks] toggle + mode-specific controls
   (see index.html/rotation.js) -- physically inside that mode's own wrap,
   so it reads as "this level toggle belongs to Table/RRG/Bottoming"
   instead of one shared bar above all three. */
.rotation-subtoolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    flex-wrap: wrap;
}

#rotationTableWrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0 16px 16px;
}

#rotationTable {
    max-width: none;
}

.rs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

.rs-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-app);
    text-align: right;
    font-weight: 500;
    color: var(--text-dim);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
}

.rs-table thead th:first-child,
.rs-table td.rotation-name {
    text-align: left;
}

/* Sector/Industry columns render their body cells as .rotation-name (left-
   aligned, see above) everywhere they appear (Watchlist, Scans, etc.), but
   aren't thead th:first-child, so without this they'd default to the
   right-aligned header style while their own column's data sits flush
   left underneath -- misaligned. */
.rs-table thead th[data-key="sector"],
.rs-table thead th[data-key="industry"] {
    text-align: left;
}

.rs-table thead th:hover {
    color: var(--text);
}

/* Marks whichever column a table is currently sorted by -- set/cleared via
   rotation.js's updateSortIndicators, replacing the old "sorted by X"
   caption text with an in-header indicator that can't drift out of sync
   with the actual active column. */
.rs-table thead th[data-sort="asc"]::after {
    content: " \25B2";
    color: var(--accent);
}

.rs-table thead th[data-sort="desc"]::after {
    content: " \25BC";
    color: var(--accent);
}

.rs-table td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid var(--bg-raised);
    color: var(--text);
}

.rs-table tbody tr:hover td {
    background: var(--bg-panel);
}

.rotation-name {
    color: var(--text);
    font-weight: 500;
}

.rotation-name.clickable {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    text-decoration-color: var(--text-faintest);
}

.rotation-name.clickable:hover {
    color: var(--accent);
    text-decoration-color: var(--accent);
}

.rs-pos {
    color: #279d82;
}

.rs-neg {
    color: #c86164;
}

/* Secondary ink for a state that is not the one to act on ("Setting up"
   beside "Broke out"). Full opacity in the dim token, never a fade -- see
   "Do not fade text with opacity" in AGENTS.md. */
.rs-dim {
    color: var(--text-dim);
}

/* 3D RS is Sector/Industry only -- hidden (header + cells) at the Stocks
   level, see rotation.js's renderTable. */
.rs-table.hide-3d .col-3d {
    display: none;
}

/* 1D RS is Industry only -- hidden (header + cells) at Sector/Stocks. */
.rs-table.hide-1d .col-1d {
    display: none;
}

.rotation-empty-row td {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    padding: 30px 12px;
}

/* Bottoming-out screener (see rotation.js's renderBottoming) */
#bottomingWrap {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
    overflow: auto;
}

#bottomingWrap.active {
    display: flex;
}

#bottomingExplainer {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12.5px;
    padding: 10px 0 14px;
}

#bottomingTable {
    max-width: none;
}

.context-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
}

.context-badge-full { background: rgba(39, 157, 130, 0.18); color: #279d82; }
.context-badge-partial { background: rgba(201, 162, 39, 0.18); color: #c9a227; }
.context-badge-none { background: rgba(138, 143, 152, 0.12); color: var(--text-dim); }

.bottoming-summary-cell {
    white-space: normal;
    min-width: 260px;
}

.check-chip {
    display: inline-block;
    padding: 1px 6px;
    margin: 1px 3px 1px 0;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.check-chip-done { background: rgba(39, 157, 130, 0.18); color: #279d82; }
.check-chip-due { background: rgba(138, 143, 152, 0.10); color: var(--text-dim); }

/* Volume flow screener (see rotation.js's renderVolumeFlow) */
#volumeFlowWrap {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
    overflow: auto;
}

#volumeFlowWrap.active {
    display: flex;
}

#volumeFlowExplainer {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12.5px;
    padding: 10px 0 14px;
}

#volumeFlowTable {
    max-width: none;
}

/* Combined RS + Volume Flow screener (see rotation.js's renderRSVolumeFlow) */
#rsVolumeFlowWrap {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
    overflow: auto;
}

#rsVolumeFlowWrap.active {
    display: flex;
}

#accumWrap {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
    overflow: auto;
}

#accumWrap.active {
    display: flex;
}

#accumExplainer {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12.5px;
    margin: 8px 0;
}

.accum-agree-pin {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(39, 157, 130, 0.18);
    color: #279d82;
    margin-left: 6px;
}

/* Accumulation rows open a detail popup (openAccumDetail in rotation.js).
   The "What the scan saw" text used to be a column here, 340-620px wide,
   which made every row several lines tall and the table wide enough to
   scroll sideways. The row now carries a small Details button instead. */
#accumTable tr.accum-row { cursor: pointer; }
#accumTable tr.accum-row:hover td { background: rgba(108, 184, 255, 0.05); }
.accum-detail-cell { text-align: center !important; }
.accum-detail-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--accent);
    font-size: 12px;
    padding: 2px 10px;
    cursor: pointer;
}
.accum-detail-btn:hover { background: rgba(108, 184, 255, 0.12); }

dialog.accum-detail-dialog { width: min(760px, 94vw); }
.accum-state-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 8px;
}
.accum-state-chip.is-forming { background: rgba(108, 184, 255, 0.16); color: var(--accent); }
.accum-state-chip.is-firing { background: rgba(201, 162, 39, 0.18); color: #c9a227; }
.accum-detail-state { margin: 0 0 12px; color: var(--text-dim); }
.accum-detail-h {
    margin: 4px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}
.accum-detail-list { margin: 0 0 14px; padding-left: 18px; }
.accum-detail-list li { margin: 3px 0; }
.accum-detail-worth {
    border-left: 3px solid #c9a227;
    background: rgba(201, 162, 39, 0.08);
    padding: 8px 12px;
    border-radius: 3px;
    margin-bottom: 14px;
}
.accum-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.accum-detail-action {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    padding: 5px 12px;
    cursor: pointer;
}
.accum-detail-action:hover { background: rgba(127, 127, 127, 0.12); }
.accum-detail-action.is-primary { border-color: var(--accent); color: var(--accent); }

/* The approach chip. Blue rather than green or amber: an approach is neither
   a confirmation nor a warning, it is a different and earlier reading, and the
   accent colour is the one this app already uses for "this is the active
   thing" rather than for a verdict. */
.accum-forming-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(108, 184, 255, 0.16);
    color: var(--accent);
    margin-left: 6px;
}

/* A row rebuilt after the fact rather than computed on the day. Muted grey:
   it is a provenance note, not a judgement about the signal. */
.accum-recon-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 9.5px;
    font-weight: 700;
    background: rgba(138, 143, 152, 0.16);
    color: var(--text-dim);
    margin-left: 6px;
}

/* The divider above the approaches. A row of the table rather than a heading
   outside it, so it scrolls and aligns with the rows it introduces. */
.accum-section-head {
    text-align: left !important;
    padding: 10px 8px 6px;
    font-size: 11.5px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    background: #12161f;
}

/* The NEW chip. Amber rather than green or red: a young member is not a fault
   and not an endorsement, it is a caveat about how much history is underneath
   the numbers on the row. Same shape as the agreement pin beside it. */
.new-member-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(201, 162, 39, 0.18);
    color: #c9a227;
    margin-left: 6px;
}

#rsVolumeFlowExplainer {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12.5px;
    margin-left: 0;
    padding: 10px 0 14px;
}

#rsVolumeFlowTable {
    max-width: none;
}

/* .watchlist-summary-cell's own max-width: 640px (below) suits the Scans/
   Watchlist tables it was written for, which sit alongside several other
   substantial columns. Volume Flow/RS + Volume Flow only have 2-4 narrow
   numeric columns before it, so there's much more real width free for
   Detection Summary to use -- letting it use max-width:none here means
   its content wraps across fewer, longer lines instead of being
   artificially squeezed into a 640px column with room to spare. */
#volumeFlowTable .watchlist-summary-cell,
#rsVolumeFlowTable .watchlist-summary-cell,
#bottomingTable .watchlist-summary-cell {
    max-width: none;
}

/* The constituent popups are the exception, and it is the same exception the
   review table makes below.

   Uncapped, a Detection Summary sentence wins the entire width budget under
   width:max-content -- it is one long line and max-content grants it -- so the
   popup stretches to the viewport to lay out prose while the numbers beside it
   are squeezed back into a scrollbar. That is the failure the old comment on
   .constituent-rotation-dialog predicted, and it is why only the bottoming
   popup was sized to its table for so long.

   Capping the sentence resolves it: the column wraps to two or three lines, the
   numeric columns take their natural width, and the popup sizes to the table
   rather than to the prose. The page-level tables above keep max-width:none
   because they have a whole viewport to spend and no max-content sizing. */
#volumeFlowConstituentTable .watchlist-summary-cell,
#rsVolumeFlowConstituentTable .watchlist-summary-cell,
#bottomingConstituentTable .watchlist-summary-cell {
    max-width: 420px;
    min-width: 240px;
}

/* The review table is the exception: fourteen columns, and its Notes cell is
   the only one that grows without limit. Left uncapped it would win the whole
   width budget under width:max-content -- four legs joined by " · " is a long
   single line -- and squeeze every number back into the scroll. 320px wraps it
   to two or three lines and leaves the columns being compared readable, which
   is the point of the view. */
#bottomingReviewTable .watchlist-summary-cell {
    max-width: 320px;
    min-width: 200px;
}

/* Relative Rotation Graph (see rotation.js's drawRRG) */
#rrgWrap {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
}

#rrgWrap.active {
    display: flex;
}

#rrgLegend {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0 12px;
    flex-wrap: wrap;
}

.rrg-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-dim);
}

.rrg-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.rrg-swatch-leading { background: #279d82; }
.rrg-swatch-weakening { background: #c9a227; }
.rrg-swatch-lagging { background: #c86164; }
.rrg-swatch-improving { background: #3d7ab5; }

.rrg-legend-note {
    color: var(--text-faintest);
    font-size: 12px;
    margin-left: auto;
}

/* Scans page's client-side EMA/RS filter row: narrows the already-fetched
   rows to only those whose MatchedEMA is checked (EMA 40 Divergence only)
   and/or whose Relative Strength falls in range (any scan with RS data),
   no re-fetch needed since the backend already reports both per row.
   :not([hidden]) matters here, not just cosmetic -- a plain `display: flex`
   on this class silently wins the cascade over the `hidden` attribute's own
   UA-stylesheet `display: none` (author rules beat UA rules at equal
   specificity), so scans.js's `el.hidden = true` toggle was a no-op and
   this row rendered on every scan tab regardless of which one was active. */
.scans-ema-filter:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0 10px;
    font-size: 13px;
    color: var(--text-dim);
}


/* The Scans filter rows flow as ONE wrapping line (2026-10-16): unfolded,
   Board, the dates and the dropdowns took five lines over the Multibagger
   table. Each row is display: contents so its controls join the container's
   flex flow; the rows stay as elements because scans.js moves the date,
   market-cap and Board controls between them and fold.js hides them by row
   (its !important rule beats this one). A label and its control sit in a
   .scans-facet box so a wrap never parts them. Info rows and the Turnaround
   preset strip keep a full line. */
#scansFilterRows {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 16px;
    row-gap: 6px;
    padding: 2px 0 8px;
    font-size: 13px;
    color: var(--text-dim);
}
[data-fold-scope].fold-filters-closed #scansFilterRows { padding: 0; row-gap: 0; }
#scansFilterRows > [data-fold="filters"]:not([hidden]) { display: contents; }
#scansFilterRows > [data-fold="info"]:not([hidden]),
#scansFilterRows > #turnPresetStrip:not([hidden]) { flex: 1 1 100%; }
#scansFilterRows .scans-facet,
#scansFilterRows .scans-facet-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
#scansFilterRows .scans-facet-group { flex-wrap: wrap; gap: 6px 10px; }
/* The Turnaround row's 1px separator has no job in a gapped flow and took a line of its own. */
#scansFilterRows .turn-row-sep { display: none; }
.scans-ema-filter-label {
    font-weight: 600;
    color: var(--text-dim);
}

/* #ema40EmaOnlyGroup wraps the EMA:/50/100/200 controls so scans.js can
   hide just that part (EMA 40 Divergence only) while leaving RS between
   visible for any scan with RS data -- needs its own flex+gap since
   wrapping them in a span takes them out of .scans-ema-filter's own direct
   flex children, where the parent's gap would otherwise apply. */
#ema40EmaOnlyGroup:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 14px;
}

.scans-ema-filter label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: var(--text);
}

.scans-ema-filter input[type="number"] {
    width: 56px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 13px;
    font-family: inherit;
}

#rrgCanvas {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

/* Blocking startup gate: shown only when the local ticker cache is stale
   (see app.js's runStartupRefreshGate) -- covers everything, including the
   toolbar, so the sector selector/chart can't be touched until the initial
   full-catalog refresh finishes. Higher z-index than the overlay context
   menu (2000) so it can never be clicked through. */
.startup-refresh-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 5000;
    align-items: center;
    justify-content: center;
}

/* Higher than .startup-refresh-overlay -- login has to gate everything,
   including that overlay, since nothing else should even start until
   someone's authenticated. */
.auth-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 6000;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 24px 32px;
    min-width: 340px;
}

.auth-box h3 {
    margin: 0 0 14px;
    font-size: 15px;
}

.auth-intro {
    color: var(--text-dim);
    font-size: 12px;
    margin: 0 0 14px;
}

.startup-refresh-box {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 24px 32px;
    min-width: 320px;
    text-align: center;
}

.startup-refresh-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.startup-refresh-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    overflow: hidden;
}

.startup-refresh-bar-fill {
    height: 100%;
    width: 0%;
    background: #2962ff;
    transition: width 0.15s ease-out;
}

.startup-refresh-text {
    margin-top: 10px;
    color: var(--text-dim);
    font-size: 12px;
}

#mainArea {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

#leftSidebar {
    flex: 0 0 auto;
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: var(--bg-app);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

#leftSidebar button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 15px;
    padding: 0;
    cursor: pointer;
}

#leftSidebar button:hover {
    background: var(--border);
    border-color: var(--border-strong);
}

/* Drawing tools are grouped TradingView-style: the rail shows one button per
   category, and hovering/clicking it opens a flyout that names each tool.
   The rail stays 40px, so the flyout is absolutely positioned out of it and
   the sidebar itself must not clip or scroll it away -- hence visible
   overflow here and a scroll container that is the flyout, not the rail. */
#leftSidebar {
    overflow: visible;
}

.draw-group {
    position: relative;
}

.draw-flyout {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 4px;
    z-index: 60;
    min-width: 210px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px 0;
    background: var(--bg-panel, var(--bg-app));
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.draw-group.open .draw-flyout {
    display: block;
}

.draw-flyout-header {
    padding: 8px 12px 4px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #8b8f96);
}

/* Overrides the 32px square icon-button sizing above, which is meant for the
   rail itself -- inside a flyout these are full-width named rows. */
#leftSidebar .draw-flyout button {
    width: 100%;
    height: auto;
    justify-content: flex-start;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 0;
    font-size: 12px;
    white-space: nowrap;
}

/* One fixed-width gutter for the glyph so every label starts on the same
   column, whether the glyph is a single character or a five-letter wave
   label like ABCDE. */
.draw-ico {
    flex: 0 0 auto;
    width: 34px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted, #8b8f96);
}

#leftSidebar .draw-flyout button:hover .draw-ico {
    color: var(--text);
}

/* The Elliott Wave labels (12345, ABCDE, WXY) do not fit at icon size. */
.draw-ico:not(:empty) {
    letter-spacing: 0;
}

.draw-flyout button[data-overlay^="ew"] .draw-ico {
    font-size: 8px;
    letter-spacing: 0.5px;
}

.sidebar-separator {
    width: 24px;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

#chartArea {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#toolbar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
}

/* These were two explicit rows (the mode toggle and symbol picker, then
   everything else). Since 2026-10-13 ui.css flows them as ONE wrapping row
   (.toolbar-row { display: contents }) and the stock-only controls moved to
   #chartStockBar beside the chart tabs: the split had left the first row
   two-thirds empty while the second wrapped onto a third line. The rules
   below still size each row's children. */
.toolbar-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 30px;
}

/* Both are plain <span> wrappers (inline by default), which lays out their
   children one per text-line when space is tight -- stacking "Index A:",
   its combo, the swap button, etc. vertically instead of flowing as a
   row. inline-flex keeps them a single flex-wrap group of their own. */
#standardSectorGroup,
#ratioPickers {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

#toolbar label,
#chartStockBar label {
    color: var(--text-dim);
    margin-left: 6px;
}

#toolbar select,
#chartStockBar select,
#chartStockBar button,
#toolbar button,
.dialog-buttons button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
}

#toolbar select:hover,
#chartStockBar select:hover,
#chartStockBar button:hover,
#toolbar button:hover,
.dialog-buttons button:hover {
    background: var(--border);
    cursor: pointer;
}

#statusLabel {
    margin-left: auto;
    color: var(--text-dim);
}

.refresh-status {
    margin-left: auto;
    color: #6a7280;
    font-size: 12px;
}

.refresh-status:empty {
    margin-left: 0;
}

.sector-combo {
    width: 320px;
}

/* Ratio mode shows two of these side by side plus a swap/save button in
   the same row -- narrower than the standard combo, but still wide enough
   that a typical "Sector - X" / "Industry - X - Y" name isn't truncated. */
#ratioPickers .sector-combo {
    width: 260px;
}

.ratio-save-btn {
    color: #f2c14e;
}

.sector-combo-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-combo-input:focus {
    outline: none;
    border-color: #2962ff;
}

.sector-combo-menu {
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
}

.sector-combo-menu button {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-combo-menu .sector-combo-empty {
    padding: 8px 12px;
    color: var(--text-dim);
    font-size: 12px;
}

/* Industry rows are a group's children -- indented and slightly dimmed so
   they read as "part of the sector above them", not a peer of it.
   The indent was 20px, which is what the menu's buttons already carry, so
   every row started at the same x and the nesting was invisible on screen --
   reported by the owner on 2026-10-02 and the reason for the explicit 34px.
   The tick is a marker rather than whitespace alone: these labels are long
   enough to be ellipsised, and indentation on its own only moves where the
   text gets cut, which reads as a narrower row and not as a child. */
.sector-combo-menu button.sector-row-child {
    padding-left: 34px;
    color: var(--text-muted);
    position: relative;
}

.sector-combo-menu button.sector-row-child::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 50%;
    width: 9px;
    height: 0;
    border-top: 1px solid var(--border-strong);
}

/* The roll-up "Sector - X" row heads its group (app.js sectorsFirst moves it
   above its industries; the seed's own order puts it last) -- bold with a
   divider above to mark the group boundary, so scanning the list reads as
   repeated "sector, then its industries" blocks instead of one flat,
   undifferentiated list. The first row needs no divider over it. */
.sector-combo-menu button.sector-row-total {
    font-weight: 600;
    color: var(--text);
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

.sector-combo-menu button.sector-row-total:first-child {
    border-top: none;
    margin-top: 0;
}

/* Individual stock tickers (Ratio mode's combos only -- see makeIndexCombo)
   are a different kind of row than a Sector/Industry basket, so they get
   their own subtle marker rather than reading as an ungrouped basket. */
.sector-combo-menu button.sector-row-stock {
    font-style: italic;
    color: var(--text-muted);
}

.stock-search {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    width: 130px;
}

.stock-search:focus {
    outline: none;
    border-color: #2962ff;
}

#stockSearchExitButton {
    color: #ef5350;
}

.stock-sector-info {
    color: var(--text-dim);
    font-size: 12px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    min-width: 160px;
    z-index: 1000;
    box-shadow: 0 4px 12px var(--shadow);
}

.dropdown-menu.open {
    display: block;
}

.dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 8px 12px;
    color: var(--text);
}

.dropdown-menu button:hover {
    background: var(--border);
    cursor: pointer;
}

#chartContainerWrap {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

#chartContainer {
    width: 100%;
    height: 100%;
    background: var(--bg-app);
}

/* Multi-timeframe RSI panel: a plain sibling of #chartContainer, positioned
   over its top-right corner via #chartContainerWrap's own relative
   position -- deliberately NOT a child of #chartContainer itself, since
   KLineChart renders its own internal wrapper div there (with its own
   position:relative) and this avoids any risk of that internal rendering
   clobbering or repositioning an overlay nested inside it. */
/* .chart-top-right-panels is the shared positioned wrapper for every
   top-right chart overlay (currently .mtf-rsi-panel and
   .ema-breadth-panel) -- a plain HTML sibling of #chartContainer for the
   same reason .mtf-rsi-panel originally was (see the comment above), just
   factored out so multiple panels can stack via flex gap instead of each
   one hand-tuning its own top/right pixel offset. */
.chart-top-right-panels {
    position: absolute;
    top: 10px;
    right: 70px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* The interactive top-right panels: the stock panel card (click opens the
   stock panel), the basket valuation card (click opens its drill-down) and
   the EMA breadth card (click lists which stocks sit above which average). Hit-testing is re-enabled per panel, by id, so
   it beats the .mtf-rsi-panel rule below; the wrapper stays
   pointer-events:none so the remaining panels keep letting chart drags
   pass through.

   A panel added here that is meant to be clicked but left out of this list
   is not merely unstyled -- it is inert, and inert in a way no console
   error reports: the element has its handler, a synthetic click still
   fires it, and only a real mouse misses it. */
#stockPanelCard,
#groupValPanel,
#emaBreadthPanel {
    pointer-events: auto;
}

.mtf-rsi-panel {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(30, 34, 45, 0.85);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    pointer-events: none;
    user-select: none;
}

.ema-breadth-panel .mtf-rsi-value {
    min-width: 68px;
}

.ema-breadth-panel .mtf-rsi-value .ema-breadth-above {
    color: #4caf50;
}

.ema-breadth-panel .mtf-rsi-value .ema-breadth-below {
    color: #f44336;
}

.mtf-rsi-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Elliott Wave confirmation checks: one row per check, a coloured mark
   for the verdict and the check's short name; the reason is the row's
   tooltip. The panel takes pointer events, unlike its siblings, so the
   tooltips can be read. */
.ew-checks-panel {
    pointer-events: auto;
    position: relative;
}

/* The chip: one row, always visible, click pins the flyout open. */
.ew-checks-chip {
    gap: 8px;
    cursor: pointer;
}

.ew-checks-chip .ew-check-pass,
.ew-checks-chip .ew-check-fail,
.ew-checks-chip .ew-check-na {
    font-variant-numeric: tabular-nums;
}

/* The flyout: the full list, hanging to the left of the chip so the
   cards below the chip in the stack are never covered or pushed down. */
.ew-checks-body {
    display: none;
    position: absolute;
    top: -1px;
    right: calc(100% + 8px);
    width: 215px;
    background: rgba(30, 34, 45, 0.95);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 6px 10px;
}

.ew-checks-panel:hover .ew-checks-body,
.ew-checks-panel.pinned .ew-checks-body {
    display: block;
}

:root[data-theme="light"] .ew-checks-body { background: rgba(255, 255, 255, 0.96); }

.ew-checks-panel .ew-check-title {
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 2px;
}

.ew-checks-body .mtf-rsi-row {
    justify-content: flex-start;
    gap: 6px;
    cursor: help;
}

.ew-check-mark {
    display: inline-block;
    width: 12px;
    text-align: center;
    font-weight: 700;
}

/* The three-timeframe reversal flag on the chip, and the chip's border
   while it is set. */
.ew-rev { font-weight: 700; }
.ew-rev-up { color: #4caf50; }
.ew-rev-down { color: #ff5252; }
.ew-checks-panel.ew-rev-on { border-color: #ffca28; }
.ew-rev-title { margin-top: 6px; }

.ew-check-pass .ew-check-mark { color: #4caf50; }
.ew-check-fail .ew-check-mark { color: #ff5252; }
.ew-check-na .ew-check-mark { color: var(--text-dim); }
.ew-check-na .ew-check-name { color: var(--text-dim); }

.mtf-rsi-label {
    color: var(--text-dim);
    font-weight: 600;
}

.mtf-rsi-value {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 32px;
    text-align: right;
}

.mtf-rsi-value.mtf-rsi-overbought {
    color: #f44336;
}

.mtf-rsi-value.mtf-rsi-oversold {
    color: #4caf50;
}

.mtf-rsi-value.rs-strong {
    color: #4caf50;
}

.mtf-rsi-value.rs-weak {
    color: #f44336;
}

/* Market-structure trend cells. Green/red match rs-strong/rs-weak so the two
   panels read as one system, but the value is wider than an RSI reading -- it
   carries the state AND the break that set it ("Up BoS") -- so this cell gets
   its own width rather than stretching the shared .mtf-rsi-value minimum. */
.mtf-rsi-value.ms-up {
    color: #4caf50;
}

.mtf-rsi-value.ms-down {
    color: #f44336;
}

.mtf-rsi-value.ms-range {
    color: #9598a1;
}

#mtfStructurePanel .mtf-rsi-value {
    min-width: 58px;
}

dialog.app-dialog {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 16px 20px;
    min-width: 260px;
}

dialog.app-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

dialog.app-dialog h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
}

/* Sized to the table, not to a number chosen when these had six columns.

   640px was that number, and the constituent popups outgrew it: the Relative
   Strength drill-down carries seven RS horizons and everything past 3M sat off
   the edge behind a scrollbar, on a viewport with several hundred pixels of
   unused space either side of the popup. A reader comparing horizons cannot
   compare the ones they have to scroll to find.

   width: max-content asks for the table's natural width, max-width keeps it
   inside the viewport, and the wrap's own overflow still scrolls when even the
   full viewport is not enough -- so a table too wide for any screen degrades to
   scrolling rather than to clipping. min-width holds the old floor and yields
   below it, since min-width beats max-width in the cascade and a bare 640px
   would push a narrow window sideways. */
.constituent-rotation-dialog {
    width: max-content;
    min-width: min(640px, 94vw);
    max-width: 94vw;
    max-height: 92vh;
    box-sizing: border-box;
}

/* Column layout, so a long table scrolls inside the popup while its heading,
   toggle and Close button stay put. [open] and not the bare class: a dialog is
   hidden by the UA's own display:none, an author display would win over it,
   and a closed popup would render into the page. */
.constituent-rotation-dialog[open] {
    display: flex;
    flex-direction: column;
}

.constituent-rotation-dialog > div {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.constituent-rotation-table-wrap {
    max-height: 60vh;
    overflow: auto;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Inside a popup that is already capped, the wrap takes what is left instead
   of keeping its own separate cap -- two competing limits would leave dead
   space under a table that had more rows to show. */
.constituent-rotation-dialog .constituent-rotation-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.field-row label {
    color: var(--text-dim);
}

.field-row input[type="number"] {
    width: 90px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
}

.field-row input[type="color"] {
    width: 40px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: none;
}

.field-row input[type="text"],
.field-row input[type="password"] {
    flex: 1 1 auto;
    width: 220px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.dialog-error {
    color: #ef5350;
    font-size: 12px;
    min-height: 16px;
    margin-top: -4px;
    margin-bottom: 6px;
}

.custom-index-list {
    margin-top: 14px;
    border-top: 1px solid var(--border-strong);
    padding-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.custom-index-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
}

.custom-index-row .custom-index-name {
    font-weight: 600;
}

.custom-index-row .custom-index-tickers {
    color: var(--text-dim);
    font-size: 12px;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0 8px;
}

.custom-index-row button {
    background: transparent;
    border: none;
    color: #ef5350;
    cursor: pointer;
    padding: 0 4px;
    font-size: 13px;
}

.custom-index-row button:hover {
    opacity: 0.75;
}

.custom-index-search {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
    margin-top: 10px;
}

.view-stocks-subtitle {
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 12px;
}

.stock-chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
    max-height: 320px;
    min-width: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.stock-chip {
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    text-align: center;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.stock-chip:hover {
    background: var(--border);
    border-color: #2962ff;
    color: #ffffff;
}

/* Chart tab bar: the sector/custom-index view is the permanent first tab
   (never closable -- it's the one with persisted drawings/indicators);
   stocks opened from the Stocks popup or the Stock search box each get
   their own closable tab alongside it, so switching to look at a
   constituent never disturbs the sector tab's own state. See
   app.js's setActiveTab/openStockTab. */
.chart-tab-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px 0;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.chart-tab-bar:empty {
    display: none;
}

.chart-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px 0 10px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: var(--text-dim);
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}

.chart-tab-label {
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    padding: 6px 0;
    cursor: pointer;
}

.chart-tab.active {
    background: #262b38;
    border-color: var(--border-strong);
    color: var(--text);
}

.chart-tab:not(.active):hover {
    color: var(--text);
}

.chart-tab-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
}

.chart-tab-close:hover {
    background: #3a1d1f;
    color: #ef5350;
}

.rsi-levels-section {
    border-top: 1px solid var(--border-strong);
    margin-top: 4px;
    padding-top: 10px;
}

.rsi-levels-section h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
}

/* Chart Settings is two columns: the chart's own settings on the left and
   Price Action Concepts on the right, so fourteen more switches widen the
   dialog instead of doubling its height. Stacks below 860px. */
#chartSettingsDialog {
    width: min(960px, 96vw);
    max-width: 96vw;
}

.chart-settings-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    column-gap: 24px;
    align-items: start;
}

.chart-settings-side {
    border-left: 1px solid var(--border-strong);
    padding-left: 20px;
}

@media (max-width: 860px) {
    .chart-settings-columns {
        grid-template-columns: minmax(0, 1fr);
    }
    .chart-settings-side {
        border-left: 0;
        padding-left: 0;
        border-top: 1px solid var(--border-strong);
        margin-top: 8px;
        padding-top: 10px;
    }
}

.pa-settings-section h4 {
    margin: 0 0 4px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
}

.pa-settings-note {
    margin: 0 0 10px 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-dim);
}

.pa-settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 6px;
    margin-bottom: 10px;
}

.pa-settings-grid label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
}

.rsi-levels-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.rsi-level-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rsi-level-row input[type="number"] {
    width: 70px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
}

.rsi-level-row input[type="color"] {
    width: 32px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: none;
}

.rsi-level-row select {
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
}

.rsi-level-row button {
    background: transparent;
    border: none;
    color: #ef5350;
    cursor: pointer;
    padding: 0 4px;
    font-size: 13px;
    margin-left: auto;
}

.rsi-level-row button:hover {
    opacity: 0.75;
}

#addRsiLevelButton {
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-dim);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

#addRsiLevelButton:hover {
    color: var(--text);
    border-color: #5a6270;
}

.custom-index-empty {
    color: var(--text-dim);
    font-size: 12px;
}

.overlay-context-menu {
    display: none;
    position: absolute;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 8px;
    z-index: 2000;
    box-shadow: 0 4px 12px var(--shadow);
}

.overlay-context-menu-row {
    display: flex;
    gap: 4px;
}

.overlay-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid var(--border-strong);
    padding: 0;
    cursor: pointer;
}

.overlay-context-menu-row button:not(.overlay-color-swatch) {
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.overlay-context-menu-row button:not(.overlay-color-swatch):hover,
.overlay-color-swatch:hover {
    background: var(--border);
}

.overlay-context-menu-delete {
    background: #3a1d1f;
    color: #ef5350;
    border: 1px solid #5c2b2d;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}

.overlay-context-menu-delete:hover {
    background: #4a2224;
}

.overlay-context-menu-relabel {
    display: none;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}

.overlay-context-menu-relabel:hover {
    background: var(--border);
}

.overlay-context-menu-edit-text {
    display: none;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}

.overlay-context-menu-edit-text:hover {
    background: var(--border);
}

.overlay-context-menu-edit-levels {
    display: none;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}

.overlay-context-menu-edit-levels:hover {
    background: var(--border);
}

/* Fib retracement/extension level editor: same floating-panel-at-click-point
   approach as .text-note-editor below, one row per level (visibility,
   percentage, color, remove) plus add/save/cancel controls. */
.fib-levels-editor {
    position: absolute;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid #2962ff;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 220px;
}

.fib-levels-editor-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 260px;
    overflow-y: auto;
}

.fib-levels-editor-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fib-levels-editor-pct {
    width: 60px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 5px;
    font-size: 12px;
}

.fib-levels-editor-color {
    width: 24px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: none;
    cursor: pointer;
}

.fib-levels-editor-remove {
    margin-left: auto;
    background: transparent;
    color: #ef5350;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
}

.fib-levels-editor-remove:hover {
    color: #ff7a75;
}

.fib-levels-editor-add {
    align-self: flex-start;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.fib-levels-editor-add:hover {
    background: var(--border);
}

.fib-levels-editor-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--border-strong);
    padding-top: 8px;
}

.fib-levels-editor-default-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-dim);
    margin-right: auto;
    cursor: pointer;
}

.fib-levels-editor-footer button {
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.fib-levels-editor-footer button:hover {
    background: var(--border);
}

.fib-levels-editor-save {
    background: #1a3a6b !important;
    border-color: #2962ff !important;
}

.fib-levels-editor-save:hover {
    background: #204a86 !important;
}

/* Text drawing tool's inline editor: a plain textarea floated over the
   chart at the click point (page coordinates, same positioning approach
   as .overlay-context-menu above) -- canvas overlays can't host a real
   text cursor, so typing happens here and only the committed value is
   handed to the textNote overlay. */
.text-note-editor {
    position: absolute;
    z-index: 2000;
    min-width: 120px;
    min-height: 28px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid #2962ff;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: inherit;
    resize: both;
}

/* Alert bell (see watchlist.js) -- lives in #appNav, pushed to the right so
   it's reachable from every view, not just the Watchlist tab. */
#alertBellWrap {
    position: relative;
    margin-left: auto;
    align-self: center;
}

#alertBellButton {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 15px;
    padding: 5px 9px;
    cursor: pointer;
}

#alertBellButton:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.alert-bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 100px;
    background: #c86164;
    color: var(--bg-app);
    font-size: 10px;
    font-weight: 600;
    line-height: 15px;
    text-align: center;
}

.alert-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 500;
}

#alertDropdownHeader {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

#alertMarkAllReadButton {
    background: transparent;
    color: var(--accent);
    border: none;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

#alertDropdownList {
    overflow: auto;
}

.alert-row {
    padding: 8px 12px;
    border-bottom: 1px solid var(--bg-raised);
    font-size: 12.5px;
}

.alert-row:last-child {
    border-bottom: none;
}

.alert-row.alert-unread {
    background: rgba(108, 184, 255, 0.06);
}

.alert-row.alert-failure .alert-row-meta {
    color: #e05d5d;
}

.alert-row.alert-failure.alert-unread {
    background: rgba(224, 93, 93, 0.08);
}

.alert-row-meta {
    color: var(--text-dim);
    font-size: 11px;
    margin-bottom: 2px;
}

.alert-empty {
    padding: 20px 12px;
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
}

/* Strength Scan pane (see watchlist.js) -- the Scans page's first tab. */

#watchlistToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

#watchlistToolbar button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#watchlistToolbar button:hover {
    background: var(--border);
}

#watchlistFilterBar {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 0 16px 12px;
    font-size: 12.5px;
    color: var(--text-dim);
}

.watchlist-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.watchlist-filter-group input[type="number"] {
    width: 60px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12.5px;
}

.watchlist-filter-group input[type="text"] {
    width: 140px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12.5px;
}

.watchlist-filter-checkboxes {
    gap: 14px;
}

.watchlist-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

#watchlistFilterClearButton {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 12.5px;
    cursor: pointer;
}

#watchlistFilterClearButton:hover {
    background: var(--border);
}

#watchlistExplainer {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12.5px;
    margin-left: 0;
    padding: 10px 16px 14px;
}

#scansStrengthPane .rs-table {
    flex: 1 1 auto;
    display: block;
    overflow: auto;
    padding: 0 16px 16px;
    box-sizing: border-box;
}

/* The ratio board scrolls inside its own wrapper: html/body disable
   page-level scroll everywhere (see line 13), and a table with no scrollable
   ancestor simply overflows off-screen. Same fix as #scansStrengthPane /
   #viewPnl / #viewPortfolio, moved from the table to a wrapper so the
   sibling detail row's nested content does not inherit it. */
#ratioBoardWrap,
#ratioStocksWrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0 16px 16px;
    box-sizing: border-box;
}

.watchlist-summary-cell {
    white-space: normal;
    min-width: 260px;
    max-width: 640px;
    text-align: left;
}

/* Weekly Flow column is only meaningful on the Weekly scan -- hidden (header
   + cells) while Daily is selected, mirroring .rs-table.hide-3d above. */
#watchlistTable.hide-flow .col-wl-flow {
    display: none;
}

/* Valuation view (see industryvaluation.js): toolbar fixed, everything
   below scrolls -- the member drill-down and triage cards extend the page
   well past one screen. */
#viewIndustryvaluation {
    overflow-y: auto;
    padding: 10px 16px 24px;
}
/* .app-view is a column flex container, and flex children SHRINK to fit
   by default -- which compressed the cards instead of letting the view
   scroll. Pin every direct child to its natural height so overflow-y
   actually engages. */
#viewIndustryvaluation > * {
    flex: 0 0 auto;
}
#industryvaluationToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 10px;
}

/* Valuation view cards collapse: the title is the toggle (see
   industryvaluation.js), a caret shows the state, and a collapsed card
   hides everything but its title row. */
#viewIndustryvaluation .breadth-card-title {
    cursor: pointer;
    user-select: none;
}
#viewIndustryvaluation .breadth-card-title::before {
    content: "▾ ";
    opacity: 0.6;
}
#viewIndustryvaluation .breadth-card.collapsed .breadth-card-title::before {
    content: "▸ ";
}
#viewIndustryvaluation .breadth-card.collapsed > *:not(.breadth-card-title) {
    display: none;
}

/* Scans view (see scans.js) -- same layout as the Watchlist view above. */
#viewScans {
    flex: 1 1 auto;
    min-height: 0;
}

/* The Scans page is two stacked bars: the tab strip picking a scan, then that
   scan's own actions. They used to be one bar, because every scan shared the
   same Refresh/Force Refresh/status controls. Strength Scan does not -- it
   carries a Daily/Weekly toggle, an as-of date and Send to Telegram -- so the
   strip had to come out of the toolbar to survive a pane switch.

   No border-bottom here: the pane's own toolbar draws the separator, and two
   rules 34px apart read as a boxed-in strip rather than as tabs. */
#scansModeBar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding: 10px 16px 0;
}

/* Each scan mode's body. Repeats .app-view's box because it takes over that
   role once the view holds more than one of them: the table underneath needs a
   flex column with min-height:0 above it or it stops scrolling and pushes the
   page instead. */
.scans-pane {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* display:flex outranks the user-agent's [hidden] { display: none }, so the
   hidden pane would otherwise still be laid out. */
.scans-pane[hidden] {
    display: none;
}

#scansToolbar {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

#scansToolbar > button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#scansToolbar > button:hover {
    background: var(--border);
}

#scansExplainer {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12.5px;
    margin-left: 0;
    padding: 10px 16px 14px;
}

/* #scansTable itself stays a genuine display:table (the default) so its
   native auto-layout algorithm can stretch Detection Summary to fill
   whatever width is left over -- the other rs-table views instead put
   display:block+overflow:auto directly on the <table>, which works for
   scrolling but breaks that native column-stretching (thead/tbody each end
   up as their own anonymous table box sized to shrink-to-fit content,
   leaving a blank gutter on wide windows). Scrolling + the sticky thead
   (position:sticky on th, see .rs-table thead th above) work identically
   with the overflow:auto container one level up instead, so #scansTableWrap
   carries that role here rather than the table itself. */
#scansTableWrap {
    flex: 1 1 auto;
    overflow: auto;
    padding: 0 16px 16px;
    box-sizing: border-box;
}

.classification-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
}

.classification-badge-bottom { background: rgba(39, 157, 130, 0.18); color: #279d82; }

/* Market Breadth view (see breadth.js) -- same #app-view/toolbar shell as
   Rotation/Watchlist/Scans, but its own card-grid layout underneath rather
   than a single table. */
#viewBreadth {
    min-height: 0;
}

#breadthToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

#industryemaToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

#industryemaToolbar button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#industryemaToolbar button:hover {
    background: var(--border);
}

#industryemaToolbar button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Pushes Refresh + the status text after it to the right edge of the
   toolbar, keeping the Daily/Weekly toggle pinned left on the same row. */
#industryemaRefreshButton {
    margin-left: auto;
}

#breadthToolbar button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#breadthToolbar button:hover {
    background: var(--border);
}

#breadthContent {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.breadth-card {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.breadth-card-title {
    color: var(--text-dim);
    font-size: 12.5px;
    font-weight: 500;
    margin-bottom: 10px;
}

#breadthTop {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

#breadthGaugeCard {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.breadth-gauge-svg {
    width: 100%;
    max-width: 220px;
}

.breadth-gauge-band {
    fill: none;
    stroke-width: 18;
}

.breadth-gauge-band-extreme-fear { stroke: #dc2626; }
.breadth-gauge-band-fear { stroke: #eab308; }
.breadth-gauge-band-neutral { stroke: var(--text-dimmer); }
.breadth-gauge-band-greed { stroke: #4f9d6f; }
.breadth-gauge-band-extreme-greed { stroke: #22c55e; }

.breadth-gauge-needle {
    stroke: var(--text);
    stroke-width: 3;
    stroke-linecap: round;
    /*
      No transform-origin here, deliberately. The needle's transform attribute
      is rotate(deg 110 110), which already carries its own origin -- and
      SVG expands that to translate(110,110) rotate(deg) translate(-110,-110).
      Setting transform-origin applies a SECOND translation of the same 110,110
      around the whole list, so the needle rotates about (220,220) instead of
      the hub: measured, its base landed at (97.1, 124.7) rather than on the
      hub at (110,110), visibly detached and low-left of it.
    */
    transition: transform 0.4s ease;
}

.breadth-gauge-hub {
    fill: var(--text);
}

.breadth-gauge-score {
    font-size: 30px;
    font-weight: 600;
    color: var(--text);
    margin-top: -18px;
}

.breadth-gauge-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-dim);
}

.breadth-zone-extreme-fear { color: #dc2626; }
.breadth-zone-fear { color: #eab308; }
.breadth-zone-neutral { color: #9aa0a8; }
.breadth-zone-greed { color: #4f9d6f; }
.breadth-zone-extreme-greed { color: #22c55e; }

#breadthSummaryCards {
    flex: 1 1 400px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-content: start;
}

.breadth-stat-card {
    display: flex;
    flex-direction: column;
}

.breadth-stat-row {
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.breadth-stat-up { color: #279d82; }
.breadth-stat-down { color: #c86164; }
.breadth-stat-sep { color: var(--text-dimmer); margin: 0 6px; font-weight: 400; }
.breadth-stat-flat { color: var(--text-dim); font-size: 12.5px; font-weight: 400; margin-left: 8px; }

.breadth-stat-sub {
    color: var(--text-dimmer);
    font-size: 11.5px;
    margin-top: 4px;
}

#breadthEmaBars {
    flex: 0 0 auto;
}

.breadth-ema-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.breadth-ema-label {
    flex: 0 0 60px;
    color: var(--text-dim);
    font-size: 12.5px;
}

.breadth-ema-track {
    flex: 1 1 auto;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-raised);
    overflow: hidden;
}

.breadth-ema-fill {
    height: 100%;
    background: #279d82;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.breadth-ema-fill-below {
    background: #c86164;
}

.breadth-ema-pct {
    flex: 0 0 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    font-size: 12.5px;
}

.breadth-card-note {
    color: var(--text-dimmer);
    font-size: 11.5px;
    margin: -6px 0 10px;
}

/*
 * The regime note follows a canvas rather than a title.
 *
 * The rule above pulls a note UP by 6px so it tucks under the heading it
 * belongs to. Below the ribbon that same pull drags the text across the bottom
 * of the drawing. An id rule rather than a change to the shared class, because
 * every other card still wants the tuck.
 */
#breadthRegimeNote {
    margin-top: 12px;
    line-height: 1.5;
}

#breadthTrendCard {
    flex: 0 0 auto;
}

#breadthRangeControls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -4px 0 12px;
}

#breadthRangeControls button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

#breadthRangeControls button:hover:not(:disabled) {
    background: var(--border);
}

#breadthRangeControls button:disabled {
    opacity: 0.4;
    cursor: default;
}

#breadthRangeDate {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    color-scheme: dark;
}

#breadthRangeNote {
    color: var(--text-dimmer);
    font-size: 11.5px;
    margin-left: 4px;
}

.breadth-range-date-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
}

.breadth-range-date-wrap input[type="date"] {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    color-scheme: dark;
}

/* Divides the From/To date pair from the trailing-window Prev/Next/Latest
   buttons that follow -- those two groups do two different things (an
   explicit range vs stepping a fixed 60-day window) so a visual break
   keeps them from reading as one continuous control. */
#breadthRangePrev {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-strong);
}

#breadthTrendWrap {
    position: relative;
}

#breadthTrendSvg {
    width: 100%;
    height: 280px;
    display: block;
    overflow: visible;
}

.breadth-trend-band-label {
    font-size: 10.5px;
    font-weight: 600;
}

.breadth-trend-gridline {
    stroke: var(--bg-raised);
    stroke-width: 1;
}

.breadth-trend-axis-label {
    font-size: 10px;
    fill: var(--text-dimmer);
}

.breadth-trend-empty {
    fill: var(--text-dim);
    font-size: 13px;
}

.breadth-trend-line {
    fill: none;
    stroke: #eef0f2;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.breadth-trend-dot {
    stroke: var(--bg-deeper);
    stroke-width: 1.5;
}

.breadth-trend-end-label {
    font-size: 12.5px;
    font-weight: 700;
    fill: var(--text);
}

.breadth-trend-crosshair {
    stroke: var(--text-dimmer);
    stroke-width: 1;
    stroke-dasharray: 2, 3;
    opacity: 0;
    pointer-events: none;
}

.breadth-trend-crosshair.visible {
    opacity: 1;
}

.breadth-trend-hover-dot {
    fill: none;
    stroke: var(--text);
    stroke-width: 1.5;
    opacity: 0;
    pointer-events: none;
}

.breadth-trend-hover-dot.visible {
    opacity: 1;
}

.breadth-trend-hit {
    fill: transparent;
}

.breadth-tooltip {
    position: absolute;
    pointer-events: none;
    background: #0d0d0d;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
    opacity: 0;
    transition: opacity 0.08s ease;
    white-space: nowrap;
    z-index: 5;
    box-shadow: 0 4px 16px var(--shadow);
}

.breadth-tooltip.visible {
    opacity: 1;
}

.breadth-tooltip-date {
    font-weight: 650;
    margin-bottom: 3px;
}

.breadth-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    color: var(--text-dim);
}

.breadth-tooltip-row b {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.breadth-tooltip-zone {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 650;
    margin-top: 4px;
}

.breadth-trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 4px 2px;
    font-size: 12px;
    color: var(--text-dim);
}

.breadth-trend-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.breadth-trend-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex: 0 0 auto;
    display: inline-block;
}

#breadthNarrativeCard {
    flex: 0 0 auto;
}

.breadth-segments-empty {
    color: var(--text-dim);
    font-size: 13px;
}

.breadth-segment {
    display: grid;
    grid-template-columns: 128px 14px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--bg-raised);
    font-size: 13px;
}

.breadth-segment:last-child {
    border-bottom: none;
}

.breadth-segment-dates {
    color: var(--text-dim);
    font-size: 12px;
    white-space: nowrap;
}

.breadth-segment-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.breadth-segment-desc b {
    font-weight: 650;
}

.breadth-segment-days {
    color: var(--text-dimmer);
    font-size: 11.5px;
    white-space: nowrap;
}

#breadthSectorCard {
    flex: 1 1 auto;
}

#breadthSectorCard .rs-table {
    max-width: none;
}

.breadth-history-details {
    flex: 0 0 auto;
}

.breadth-history-details summary {
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    list-style: none;
}

.breadth-history-details summary::-webkit-details-marker {
    display: none;
}

.breadth-history-details summary::before {
    content: "▸ ";
    color: var(--text-dimmer);
}

.breadth-history-details[open] summary::before {
    content: "▾ ";
}

.breadth-history-details[open] summary {
    margin-bottom: 12px;
}

.breadth-history-table-wrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.breadth-history-table-wrap .rs-table {
    max-width: none;
}

.breadth-zone-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 650;
}
.classification-badge-pullback { background: rgba(108, 184, 255, 0.16); color: var(--accent); }

/* ---------------------------------------------------------------
   Paper trading: chart-window toolbar controls (Buy/Sell/Qty/Size
   popover/position strip/toggle) and the separate P&L page.
   --------------------------------------------------------------- */
.paper-qty-input {
    width: 56px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 13px;
}

.paper-size-toggle-btn,
.paper-buy-btn,
.paper-sell-btn {
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border-strong);
}

.paper-size-toggle-btn {
    background: var(--bg-panel);
    color: var(--text);
}

.paper-size-toggle-btn:hover {
    background: var(--border);
}

.paper-buy-btn {
    background: rgba(38, 166, 154, 0.18);
    color: #26a69a;
    border-color: #26a69a;
    font-weight: 650;
}

.paper-buy-btn:hover {
    background: rgba(38, 166, 154, 0.3);
}

.paper-sell-btn {
    background: rgba(239, 83, 80, 0.18);
    color: #ef5350;
    border-color: #ef5350;
    font-weight: 650;
}

.paper-sell-btn:hover {
    background: rgba(239, 83, 80, 0.3);
}

.paper-buy-btn:disabled,
.paper-sell-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.pnl-close-btn {
    background: rgba(239, 83, 80, 0.18);
    color: #ef5350;
    border: 1px solid #ef5350;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}

.pnl-close-btn:hover {
    background: rgba(239, 83, 80, 0.3);
}

.pnl-close-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.pnl-action-cell {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.pnl-save-btn {
    background: rgba(41, 98, 255, 0.18);
    color: var(--accent);
    border: 1px solid #2962ff;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}

.pnl-save-btn:hover {
    background: rgba(41, 98, 255, 0.3);
}

.pnl-save-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.pnl-autoclose-note {
    color: #ffb74d;
}

.paper-size-popover {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--text-dim);
}

.paper-size-popover label {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.paper-size-popover input {
    width: 64px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 5px;
    font-size: 12.5px;
}

.paper-size-result {
    color: var(--text);
    white-space: nowrap;
}

.paper-position-strip {
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    padding: 3px 8px;
    border-radius: 100px;
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    white-space: nowrap;
}

.paper-pnl-positive {
    color: #26a69a;
    border-color: rgba(38, 166, 154, 0.5);
}

.paper-pnl-negative {
    color: #ef5350;
    border-color: rgba(239, 83, 80, 0.5);
}

#viewPnl {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

#pnlToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

#pnlToolbar button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#pnlToolbar button:hover {
    background: var(--border);
}

.pnl-capital-field {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 12.5px;
}

.pnl-capital-field input {
    width: 100px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13px;
}

.pnl-summary-line {
    color: var(--text);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

#viewPnl h3 {
    margin: 16px 16px 4px;
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 600;
}

#viewPnl .rs-table {
    padding: 0 16px;
}

.pnl-positions-total-row td {
    border-top: 2px solid var(--border-strong);
    font-weight: 650;
    color: var(--text);
}

.pnl-detail-input {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12.5px;
}

.pnl-sl-input,
.pnl-target-input {
    width: 70px;
}

.pnl-notes-input {
    width: 180px;
}

.pnl-detail-input:focus {
    outline: none;
    border-color: #2962ff;
}

.pnl-badge {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    vertical-align: middle;
}

.pnl-badge-target {
    background: rgba(38, 166, 154, 0.22);
    color: #26a69a;
}

.pnl-badge-sl {
    background: rgba(239, 83, 80, 0.22);
    color: #ef5350;
}

#viewPortfolio {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

#portfolioToolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

#portfolioToolbar button {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#portfolioToolbar button:hover {
    background: var(--border);
}

#portfolioToolbar button:disabled {
    opacity: 0.5;
    cursor: default;
}

#portfolioEmptyState {
    margin: 16px;
}

#viewPortfolio h3 {
    margin: 16px 16px 4px;
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 600;
}

#viewPortfolio .rs-table {
    padding: 0 16px;
}

.portfolio-tiles {
    display: flex;
    gap: 12px;
    padding: 16px 16px 0;
    flex-wrap: wrap;
}

.portfolio-tile {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 16px;
    min-width: 140px;
}

.portfolio-tile-label {
    color: var(--text-dim);
    font-size: 12px;
}

.portfolio-tile-value {
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.portfolio-flags {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px 0;
}

.portfolio-flag {
    color: #fab219;
    font-size: 12.5px;
}

.portfolio-tile-sub {
    color: var(--text-dim);
    font-size: 11.5px;
    margin-top: 2px;
}

#portfolioAllocationSection {
    padding: 16px;
}

#portfolioAllocationBody {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 12px;
    flex-wrap: wrap;
}

#portfolioDonut {
    width: 220px;
    height: 220px;
    flex: 0 0 auto;
}

#portfolioAllocationLegend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 6px;
}

.portfolio-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
}

.portfolio-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex: 0 0 auto;
}

.portfolio-legend-label {
    flex: 1 1 auto;
}

.portfolio-legend-pct {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.portfolio-legend-empty {
    color: var(--text-dim);
    font-style: italic;
    font-size: 12.5px;
}

/* Actions Scan view (see actionscan.js) -- same overflow fix as
   #scansStrengthPane/#viewRatioscan above: html/body disable page-level scroll
   everywhere (see line 13), so with 7000+ rows and no scrollable ancestor
   the table simply overflowed off-screen with no way to reach most of it. */
#viewActionscan {
    flex: 1 1 auto;
    min-height: 0;
}

#viewActionscan .rs-table {
    flex: 1 1 auto;
    display: block;
    overflow: auto;
    padding: 0 16px 16px;
    box-sizing: border-box;
}

/* Actions Scan: expandable filing-history rows */
.actionscan-row { cursor: pointer; }
.actionscan-history-row td { background: rgba(128, 128, 128, 0.07); font-size: 12px; padding: 8px 14px; }
.actionscan-history-item { margin: 4px 0; line-height: 1.5; }
.actionscan-history-item em { opacity: 0.75; }

/* ---------------------------------------------------------------
   My Watchlist view + price alerts
   --------------------------------------------------------------- */

#mywlToolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    flex-wrap: wrap;
}

#mywlAddInput {
    width: 260px;
}

.mywl-alerts-heading {
    margin: 18px 12px 4px;
    font-size: 14px;
    color: var(--text);
}

.mywl-live-badge,
.mywl-stale-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11.5px;
    white-space: nowrap;
}

.mywl-live-badge {
    background: rgba(38, 166, 154, 0.15);
    color: #26a69a;
}

.mywl-stale-badge {
    background: rgba(138, 143, 152, 0.15);
    color: var(--text-dim);
}

.mywl-remove-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
}

.mywl-remove-btn:hover {
    color: #ef5350;
}

.mywl-empty {
    color: var(--text-dim);
    padding: 14px;
    text-align: center;
}

.price-alert-popover select {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 3px 5px;
    font-size: 12.5px;
}

.price-alert-popover input {
    width: 84px;
}

.price-alert-list {
    display: flex;
    align-items: center;
    gap: 6px;
}

.price-alert-list-item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 1px 4px 1px 8px;
    color: var(--text);
    white-space: nowrap;
}

.price-alert-del-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 11px;
    padding: 0 3px;
}

.price-alert-del-btn:hover {
    color: #ef5350;
}

.mywl-add-menu {
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
}

.mywl-add-menu button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.mywl-add-menu button.mywl-suggest-active {
    background: var(--border);
}

.mywl-suggest-exch {
    color: var(--text-dim);
    font-size: 11px;
}

/* ---------------------------------------------------------------- admin
   The administration view. No desktop counterpart: two hardcoded accounts
   needed no management screen. Styled from the same tokens as everything
   else so it does not read as bolted on. */

#viewAdmin {
    padding: 8px 12px;
    overflow: auto;
}

#adminToolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#adminUsersTable,
#adminAuditTable {
    width: 100%;
    max-width: 1400px;
}

/* The action column carries five buttons per row, so they have to be small
   enough not to set the row height for every other column. */
.admin-row-btn {
    font-size: 11px;
    padding: 2px 7px;
    margin-right: 4px;
}

#adminAuditTable td:last-child {
    color: var(--text-dim);
    font-size: 11px;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#adminUserDialog {
    width: 560px;
    max-width: 92vw;
}

#adminUserDialogFields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
}

#adminPermissionsWrap {
    /* The grid is fourteen rows; capping it keeps the dialog's own actions
       reachable without scrolling the whole page. */
    max-height: 40vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin: 8px 0;
}

#adminPermissionsTable {
    width: 100%;
}

#adminCapabilitiesWrap {
    margin-bottom: 10px;
}

#adminCapabilitiesList {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

#adminPresetRow {
    margin: 6px 0;
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

#adminUserDialogError,
#adminPasswordError {
    color: #ef5350;
}

/* The market-cap filter, shared by Scans, Strength Scan and Valuation.
   Narrow inputs because the values are small integers in crore and a
   full-width number field next to them reads as a search box. */
.mktcap-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.mktcap-filter label {
    color: var(--text-dim);
    font-size: 12px;
}

.mktcap-input {
    width: 84px;
    background: #0f1219;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12px;
}

.mktcap-dash {
    color: var(--text-dim);
}

/* ChartKit -- shared SVG chart chrome. Matches the breadth trend chart's
   palette so a fundamentals chart and a breadth chart read as one app. */
.ck-gridline {
    stroke: var(--bg-raised);
    stroke-width: 1;
}

.ck-zeroline {
    stroke: var(--border-strong);
    stroke-width: 1;
}

.ck-axis {
    font-size: 10px;
    fill: var(--text-dimmer);
}

.ck-empty {
    fill: var(--text-dim);
    font-size: 13px;
}

.ck-crosshair {
    stroke: var(--text-faintest);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.ck-wrap {
    position: relative;
}

.ck-wrap svg {
    width: 100%;
    display: block;
}

.ck-tooltip {
    position: absolute;
    display: none;
    pointer-events: none;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 11.5px;
    color: var(--text);
    white-space: nowrap;
    z-index: 5;
}

.ck-legend {
    font-size: 11.5px;
    color: var(--text-dim);
    margin: 2px 0 6px;
}

/* The earnings ranking table. rs-table right-aligns everything but the first
   header and .rotation-name cells, which suits a table of pure numbers; this
   one mixes a rank, a name, a bar and four figures, so the two columns that
   are not numbers are aligned to match their headers. Scoped to this table so
   the shared rules stay as every other view expects them. */
#earningsRankTable thead th[data-key="basket"],
#earningsRankTable thead th[data-key="breadth"] {
    text-align: left;
}

#earningsRankTable tbody td:first-child,
#earningsRankTable tbody td.rank-breadth {
    text-align: left;
}

#earningsRankTable tbody td {
    padding: 7px 12px;
}

#earningsRankTable tbody tr:hover td {
    background: var(--bg-panel);
}

/* The divergence mark: a group whose total disagrees with most of its members.
   Sized down and set in the muted colour so it reads as an annotation on the
   figure rather than as a warning about it. */
.rank-diverge {
    font-size: 11px;
    color: var(--warn);
    margin-left: 4px;
    cursor: help;
}

/* Events Summary column: the readable one-liner replaces four sparse
   columns; give it room but never let one filing sentence own the row. */
#actionScanTable td.actionscan-summary {
    max-width: 520px;
    white-space: normal;
    line-height: 1.35;
    font-size: 12.5px;
    color: #b8bcc8;
}

/* ------------------------------------------------------------------ F&O */

#viewFno {
    flex-direction: column;
    padding: 12px 16px;
    gap: 12px;
    overflow-y: auto;
}

#fnoToolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#fnoToolbar select {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
}

#fnoRefreshButton {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
}

#fnoRefreshButton:hover { border-color: var(--border-bright); }

#fnoSummary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.fno-card {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 120px;
}

.fno-card-title {
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 4px;
}

.fno-card-value {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

.fno-sub { color: var(--text-dim); font-size: 12px; font-weight: 400; }

.fno-ivrank {
    font-size: 11.5px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--border);
    color: var(--text);
    vertical-align: middle;
}
.fno-ivrank.fno-iv-high { background: #3a2530; color: #f38ba8; }
.fno-ivrank.fno-iv-low  { background: #1e3230; color: var(--pos); }

#fnoChainWrap { overflow: auto; flex: 1; }

#fnoChainTable {
    border-collapse: collapse;
    width: 100%;
    font-size: 12.5px;
    color: var(--text);
}

#fnoChainTable th {
    position: sticky;
    top: 0;
    background: var(--bg-deepest);
    color: var(--text-dim);
    font-weight: 500;
    padding: 6px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    z-index: 1;
}

#fnoChainTable th.fno-side-head { text-align: center; color: var(--text); }
#fnoChainTable th.fno-strike-head { text-align: center; }

#fnoChainTable td {
    padding: 4px 8px;
    text-align: right;
    border-bottom: 1px solid var(--bg-sunken);
    white-space: nowrap;
}

#fnoChainTable td.fno-strike {
    text-align: center;
    font-weight: 600;
    background: var(--bg-deepest);
    color: #e6c07b;
}

#fnoChainTable td.fno-strike.fno-below-spot { color: var(--link); }

#fnoChainTable tr.fno-atm td { background: #1b2030; }
#fnoChainTable tr.fno-atm td.fno-strike { background: #232a40; }

#fnoChainTable td.fno-illiquid, #fnoChainTable td.fno-illiquid * { color: #565b66; }

td.fno-oi { position: relative; min-width: 130px; }

.fno-oi-bar {
    position: absolute;
    top: 2px;
    bottom: 2px;
    right: 0;
    opacity: 0.18;
    border-radius: 2px;
}
.fno-oi-call { background: #f38ba8; }
.fno-oi-put  { background: var(--pos); }

.fno-oi-chg { font-size: 11px; margin-left: 6px; }
.fno-oi-chg.pos { color: var(--pos); }
.fno-oi-chg.neg { color: #f38ba8; }

.fno-buildup {
    font-size: 10.5px;
    padding: 1px 5px;
    border-radius: 6px;
    margin-left: 6px;
    vertical-align: middle;
}
.fno-bu-long   { background: #1e3230; color: var(--pos); }
.fno-bu-cover  { background: #1e2e3a; color: var(--link); }
.fno-bu-short  { background: #3a2530; color: #f38ba8; }
.fno-bu-unwind { background: #33291e; color: #e6c07b; }

#fnoStrategyBar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fno-strategy-label { color: var(--text-dim); font-size: 13px; }

.fno-dir-btn {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12.5px;
    cursor: pointer;
}
.fno-dir-btn:hover { border-color: var(--border-bright); }
.fno-dir-btn.active { background: #232a40; border-color: #3a4468; }

.fno-strategy-read {
    color: var(--text);
    font-size: 13.5px;
    padding: 8px 2px 2px;
}

.fno-strategy-empty {
    color: var(--text-dim);
    font-size: 13px;
    padding: 8px 2px;
}

.fno-picks {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

.fno-pick {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    max-width: 420px;
    min-width: 300px;
    flex: 1;
}

.fno-pick-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    color: var(--text-brightest);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.fno-pick-net { font-size: 13px; font-weight: 500; }
.fno-pick-net.pos { color: var(--pos); }
.fno-pick-net.neg { color: #e6c07b; }

.fno-pick-legs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.fno-leg {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg-deepest);
    border: 1px solid var(--border);
}
.fno-leg.buy  { color: var(--pos); }
.fno-leg.sell { color: #f38ba8; }

.fno-pick-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text); margin-bottom: 6px; }

.fno-pick-why {
    margin: 0;
    padding-left: 18px;
    color: var(--text-softer);
    font-size: 12.5px;
    line-height: 1.5;
}

.fno-paper-btn {
    margin-top: 8px;
    background: #232a40;
    border: 1px solid #3a4468;
    color: var(--text);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12.5px;
    cursor: pointer;
}
.fno-paper-btn:hover { border-color: #5a6488; }

.fno-paper-head {
    color: var(--text-brightest);
    font-size: 14px;
    font-weight: 600;
    padding-top: 6px;
}

.fno-paper-strategy {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 8px;
}

.fno-paper-strategy-head {
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.fno-close-btn {
    background: var(--bg-deepest);
    border: 1px solid var(--border);
    color: #f38ba8;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11.5px;
    cursor: pointer;
    margin-left: auto;
}
.fno-close-btn:hover { border-color: var(--border-bright); }

.fno-paper-legs, .fno-paper-trades table {
    border-collapse: collapse;
    font-size: 12.5px;
    color: var(--text);
    width: 100%;
}
.fno-paper-legs th, .fno-paper-trades th {
    color: var(--text-dim);
    font-weight: 500;
    text-align: left;
    padding: 3px 10px 3px 0;
}
.fno-paper-legs td, .fno-paper-trades td {
    padding: 3px 10px 3px 0;
    border-top: 1px solid var(--bg-sunken);
}

.fno-paper-trades { margin-top: 8px; color: var(--text-dim); font-size: 13px; }
.fno-paper-trades summary { cursor: pointer; }

#fnoScanCounts { display: flex; flex-direction: column; gap: 8px; }

#fnoScanChips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.fno-scan-chip {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 12.5px;
    cursor: pointer;
}
.fno-scan-chip.active { border-color: #5a6488; background: #232a40; }
.fno-scan-chip.fno-bu-long b   { color: var(--pos); }
.fno-scan-chip.fno-bu-short b  { color: #f38ba8; }
.fno-scan-chip.fno-bu-cover b  { color: var(--link); }
.fno-scan-chip.fno-bu-unwind b { color: #e6c07b; }

.fno-scan-classes { margin-left: auto; display: flex; gap: 6px; }

#fnoScanTableWrap { overflow: auto; flex: 1; margin-top: 10px; }

#fnoScanTable {
    border-collapse: collapse;
    width: 100%;
    font-size: 12.5px;
    color: var(--text);
}
#fnoScanTable th {
    position: sticky; top: 0;
    background: var(--bg-deepest); color: var(--text-dim); font-weight: 500;
    padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border);
}
#fnoScanTable th:first-child, #fnoScanTable td:first-child { text-align: left; }
#fnoScanTable td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--bg-sunken); white-space: nowrap; }

.fno-scan-row { cursor: pointer; }
.fno-scan-row:hover td { background: #1b2030; }
.fno-scan-name { color: var(--link); font-weight: 600; cursor: pointer; }

.fno-pos { color: var(--pos); }
.fno-neg { color: #f38ba8; }

.fno-bt-tablewrap { overflow: auto; margin-top: 8px; }
.fno-bt-table { border-collapse: collapse; width: 100%; font-size: 12.5px; color: var(--text); }
.fno-bt-table th {
    background: var(--bg-deepest); color: var(--text-dim); font-weight: 500;
    padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border);
}
.fno-bt-table th:first-child, .fno-bt-table td:first-child { text-align: left; }
.fno-bt-table td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--bg-sunken); white-space: nowrap; }
#fnoBacktestDetail { margin-top: 14px; }

.fno-bt-cell { cursor: pointer; }
.fno-bt-cell:hover td { background: #1b2030; }

.fno-bt-inner {
    border-collapse: collapse;
    font-size: 12px;
    color: var(--text-softer);
    margin: 4px 0 8px 12px;
}
.fno-bt-inner th { color: var(--text-dim); font-weight: 500; text-align: left; padding: 2px 14px 2px 0; }
.fno-bt-inner td { padding: 2px 14px 2px 0; border-top: 1px solid var(--bg-sunken); white-space: nowrap; }

.fno-pick-history {
    font-size: 12.5px;
    color: var(--text);
    margin: 6px 0 2px;
    padding: 6px 8px;
    background: var(--bg-deepest);
    border-radius: 6px;
}

#fnoBacktestControls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

#fnoBtSearch {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    width: 220px;
}
#fnoBtSearch:focus { outline: none; border-color: #5a6488; }

.fno-bt-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.fno-bt-sortable:hover { color: var(--text); }

dialog.fno-bt-dialog {
    width: 1000px;
    max-width: 94vw;
}

dialog.fno-bt-dialog #fnoBacktestDetail {
    max-height: 70vh;
    overflow: auto;
}

.fno-bt-dialog-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

#fnoBtDialogClose {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 6px;
    padding: 2px 9px;
    cursor: pointer;
    font-size: 13px;
}
#fnoBtDialogClose:hover { color: var(--text); border-color: var(--border-bright); }

.fno-card-warn { border-color: #6b4a1f; }
.fno-card-warn .fno-card-title { color: #d9a94e; }

.fno-hz-chip {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 8px;
    background: #33291e;
    color: #d9a94e;
    vertical-align: middle;
}

.fno-hz-warning {
    background: #2b2515;
    border: 1px solid #6b4a1f;
    border-radius: 8px;
    color: #e0c893;
    font-size: 13px;
    line-height: 1.55;
    padding: 12px 16px;
    margin-bottom: 10px;
    max-width: 900px;
}
.fno-hz-warning b { color: #f0d9a8; }

.fno-hz-aligned {
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 6px;
    background: #1e2e3a;
    color: var(--link);
    margin-left: 6px;
}

#fnoHeroZeroWrap { overflow: auto; flex: 1; margin-top: 4px; }
#fnoHeroZeroTable {
    border-collapse: collapse;
    width: 100%;
    font-size: 12.5px;
    color: var(--text);
}
#fnoHeroZeroTable th {
    position: sticky; top: 0;
    background: var(--bg-deepest); color: var(--text-dim); font-weight: 500;
    padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border);
}
#fnoHeroZeroTable th:first-child, #fnoHeroZeroTable td:first-child { text-align: left; }
#fnoHeroZeroTable td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--bg-sunken); white-space: nowrap; }

/* Inside the scrolling F&O view, the flexed table wraps must not collapse
   to slivers (overflow:auto zeroes their min-height); give them a real
   minimum so the view itself scrolls when content above is tall. */
#fnoChainWrap { min-height: 65vh; }
#fnoScanTableWrap, #fnoHeroZeroWrap { min-height: 55vh; }

.fno-live-chip {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--pos);
    background: #1a2b25;
    border-radius: 10px;
    padding: 2px 10px;
    animation: none;
}

/* News badges + the shared headline dialog (news.js) */
.news-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(201, 162, 39, 0.18);
    color: #c9a227;
    margin-left: 6px;
    cursor: pointer;
}

#newsOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 600;
    align-items: center;
    justify-content: center;
}

#newsDialog {
    background: #161a20;
    border: 1px solid #2a2f38;
    border-radius: 8px;
    width: min(560px, 92vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

#newsDialogHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #2a2f38;
}

#newsDialogHead h3 {
    margin: 0;
    font-size: 14px;
}

#newsDialogClose {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
}

#newsDialogList {
    overflow-y: auto;
    padding: 6px 14px 12px;
}

.news-row {
    padding: 8px 0;
    border-bottom: 1px solid #22262e;
}

.news-row:last-child {
    border-bottom: none;
}

.news-row a {
    color: var(--text-bright);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
}

.news-row a:hover {
    text-decoration: underline;
}

.news-row-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 2px;
}

.news-source {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 100px;
    font-size: 10.5px;
    background: rgba(39, 157, 130, 0.15);
    color: #279d82;
}

.news-source-exchange {
    background: rgba(90, 130, 220, 0.15);
    color: #7a9ce0;
}

.news-time {
    font-size: 11px;
    color: var(--text-dim);
}

.news-empty {
    color: var(--text-dim);
    font-size: 12.5px;
    padding: 14px 0;
}

/* Hover-to-copy ticker glyph (tickercopy.js) */
.ticker-copy {
    display: inline-block;
    margin-left: 6px;
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s;
}

td:hover > .ticker-copy,
span:hover > .ticker-copy,
div:hover > .ticker-copy,
li:hover > .ticker-copy {
    opacity: 1;
}

/* The copy-all glyph stocklist.js puts in a stock list's name header, the
   same small ⧉ the Scans tabs' Ticker header has always carried. */
.th-copy-tickers {
    font-size: 0.85em;
    padding: 0 5px;
    cursor: pointer;
}

.ticker-copy:hover {
    color: var(--text-bright);
}

.ticker-copy-done {
    color: #279d82 !important;
    opacity: 1 !important;
}

.fno-live-dot { color: var(--pos); font-size: 10px; vertical-align: 1px; }

/* ------------------------------------------------------------- branding */

#appBrand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 6px 6px;
    flex: 0 0 auto;
    cursor: default;
    user-select: none;
}

#appBrandMark { display: block; }

#appBrandName {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.09em;
    color: var(--text-brightest);
}

/*
 * The Playbook.
 *
 * Prose-heavy, unlike every other screen here, so it sets a reading measure and
 * a looser line height rather than inheriting the dense table styling the rest
 * of the app is built around. A wall of 11px text at table leading is not
 * something anyone reads to the end.
 */
#viewPlaybook .breadth-card {
    margin-bottom: 12px;
    max-width: 1100px;
}

.playbook-prose {
    color: var(--text-soft);
    font-size: 12.5px;
    line-height: 1.65;
    max-width: 78ch;
}

.playbook-prose p {
    margin: 0 0 9px;
}

.playbook-prose strong {
    color: var(--text);
}

.playbook-caveat {
    border-left: 2px solid var(--border);
    color: var(--text-dim);
    padding-left: 10px;
}

/* WORKED / FAILED / MIXED. Deliberately the first thing in the heading: an
   outcome disclosed after the narrative is one the reader has already decided
   about. */
.playbook-badge {
    border: 1px solid;
    border-radius: 3px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-right: 6px;
    padding: 1px 5px;
    vertical-align: 1px;
}

#playbookCaseNav {
    flex-wrap: wrap;
    margin: 4px 0 12px;
    max-width: 1100px;
}

.playbook-nums {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 10px 0 14px;
}

.playbook-num-label {
    color: var(--text-dimmer);
    font-size: 10.5px;
    margin-bottom: 2px;
}

.playbook-num-value {
    font-size: 17px;
    font-weight: 600;
}

.playbook-section-title {
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    margin: 14px 0 8px;
    text-transform: uppercase;
}

.playbook-steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.playbook-steps > li {
    border-left: 1px solid var(--border);
    margin-bottom: 12px;
    padding: 0 0 2px 14px;
}

.playbook-step-head {
    align-items: center;
    color: var(--text);
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    gap: 8px;
    margin-bottom: 4px;
}

/* The step number sits ON the rail, so the sequence reads as a sequence
   rather than as four unrelated cards. */
.playbook-step-n {
    background: var(--border);
    border-radius: 50%;
    color: var(--text-dim);
    display: inline-block;
    font-size: 10px;
    height: 16px;
    line-height: 16px;
    margin-left: -23px;
    text-align: center;
    width: 16px;
}

.playbook-step-date {
    color: var(--text-dimmer);
    font-size: 11px;
}

.playbook-step-body {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.6;
    max-width: 78ch;
}

.playbook-open {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 10.5px;
    padding: 2px 7px;
}

.playbook-open:hover {
    border-color: var(--border-bright);
    color: var(--text);
}

#playbookOddsTable th {
    font-weight: 500;
}

#playbookOddsTable td,
#playbookOddsTable th {
    text-align: right;
}

/*
 * Basket-name suggestions (typeahead.js).
 *
 * Rendered into document.body and positioned absolutely rather than inside the
 * row, because both tables that use it live in scrolling containers with their
 * own stacking contexts -- a menu nested in the cell was clipped by the table
 * on every row but the last.
 */
.typeahead-menu {
    background: var(--bg-deeper);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    max-height: 240px;
    max-width: 520px;
    overflow-y: auto;
    position: absolute;
    z-index: 9999;
}

.typeahead-item {
    color: var(--text);
    cursor: pointer;
    font-size: 11.5px;
    padding: 4px 9px;
    white-space: nowrap;
}

.typeahead-item:hover,
.typeahead-item.active {
    background: var(--bg-panel);
    color: #fff;
}

/* ------------------------------------------------------------------
   Playbook: episode and name cards, and the dialogs they open.

   The page used to be a strip of nine tab buttons over one long scrolling
   case, which meant the only way to find out what an episode was about was to
   click it and read. Cards state the outcome, the headline number and the
   names involved before anything is opened, and the reading itself moved into
   a dialog so the page stays a place to choose from rather than a place to
   scroll through.
   ------------------------------------------------------------------ */

.playbook-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    margin-top: 10px;
}

.playbook-card {
    background: #161a25;
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font: inherit;
    gap: 5px;
    padding: 9px 10px;
    text-align: left;
    transition: border-color .12s, background .12s;
}

.playbook-card:hover {
    background: #1a1f2b;
    border-color: var(--border-bright);
}

.playbook-card-top {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.playbook-card-name {
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .2px;
}

.playbook-card-title {
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.4;
    /* Two lines, so a long title cannot make one card twice the height of the
       rest and break the grid's rhythm. The whole title is in the dialog. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.playbook-card-sub {
    color: var(--text-dimmer);
    font-size: 10.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playbook-card-figure {
    font-size: 16px;
    font-weight: 600;
    margin-top: auto;
    padding-top: 3px;
}

.playbook-card-figure-label {
    color: var(--text-dimmer);
    display: block;
    font-size: 10px;
    font-weight: 400;
}

.playbook-card-foot {
    color: var(--text-dimmer);
    font-size: 10px;
    margin-top: auto;
    padding-top: 3px;
}

.playbook-filters {
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.playbook-name-count {
    color: var(--text-dimmer);
    font-size: 10.5px;
    margin-left: 6px;
}

.playbook-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 6px 0 2px;
}

.playbook-chip {
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font-size: 10.5px;
    gap: 5px;
    padding: 3px 9px;
}

.playbook-chip:hover {
    border-color: var(--border-bright);
}

.playbook-chip-dot {
    border-radius: 50%;
    height: 6px;
    width: 6px;
}

.playbook-dialog {
    max-height: 86vh;
    max-width: 980px;
    width: 92vw;
}

.playbook-dialog-head {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding-bottom: 8px;
}

.playbook-dialog-head h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 2px;
}

.playbook-dialog-head button {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 2px 4px;
}

.playbook-dialog-head button:hover {
    color: var(--text);
}

.playbook-dialog-body {
    max-height: calc(86vh - 70px);
    overflow-y: auto;
    padding-top: 10px;
}

.playbook-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 2px;
}

.playbook-name-meta {
    color: var(--text-dim);
    font-size: 11px;
    margin-bottom: 8px;
}

/* Wide tables scroll inside their own box rather than widening the dialog,
   which on a narrow window would otherwise push the close button off-screen. */
.playbook-table-scroll {
    overflow-x: auto;
}

.playbook-firing-table th,
.playbook-firing-table td {
    text-align: right;
    white-space: nowrap;
}

.playbook-firing-table th {
    font-weight: 500;
}

.playbook-linklike {
    background: none;
    border: none;
    color: #6ea8fe;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.playbook-linklike:hover {
    text-decoration: underline;
}

.playbook-chip-note {
    color: var(--text-dimmer);
    font-size: 9.5px;
}

/* Industries read as containers rather than instruments: a left edge marks
   them apart in a grid that is otherwise all stocks. */
.playbook-industry-card {
    border-left: 2px solid #3d5a80;
}

/* What a screen has measured, stated above its table. The warning variant is
   for screens demoted to pattern-detectors: a real pattern whose payoff was
   measured and found absent. Muted rather than alarming -- the point is to
   inform, not to shout. */
.scans-odds-line {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted, #5f6b7a);
    margin: 6px 0 10px;
    padding: 7px 10px;
    border-left: 3px solid var(--rule, #d4dae2);
    background: rgba(127, 143, 166, 0.06);
}
.scans-odds-line.scans-odds-warn {
    border-left-color: #9a6a00;
}

/* The "How to use" button on each screen's toolbar (explainer.js). */
.scans-info-btn {
    font-size: 11px;
    padding: 2px 8px;
}

/* The Commentary column's summaries run to six or more sentences, which made a single Momentum
   Brackets row about 300px tall. Clamped to four lines; the row expands on
   click because the full text is the evidence and must stay reachable. */
#scansTable .watchlist-summary-cell {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
    cursor: pointer;
}

#scansTable .watchlist-summary-cell.expanded {
    display: table-cell;
    -webkit-line-clamp: none;
    line-clamp: none;
    overflow: visible;
}

/* The one-click paper trade button on Momentum Brackets rows. Styled like the
   Capex Cycles Interpret button, because it is the same kind of thing: a
   per-row action rather than a value. */
.momentum-paper-btn {
    font-size: 11px;
    padding: 1px 8px;
    white-space: nowrap;
}

/* The earnings "what moved this quarter" block and its table selection. */
.movers-box {
    margin-top: 8px;
    padding: 8px 10px;
    border-left: 2px solid var(--warn);
    background: rgba(237, 161, 0, 0.05);
    font-size: 0.92em;
    line-height: 1.5;
}
.movers-box .mover-name { font-weight: 600; }
#earningsTotalsTable tbody tr.row-selected { background: rgba(237, 161, 0, 0.10); }
#earningsTotalsTable tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

/* A card may hold several collapsible sections of its own.
   The Earnings card is one card with seven charts in it, and every heading in
   it is a .breadth-card-title -- so before this, clicking any one of them
   toggled the whole card and took the other six with it. */
#viewIndustryvaluation .card-section.collapsed > *:not(.breadth-card-title) {
    display: none;
}
#viewIndustryvaluation .card-section.collapsed > .breadth-card-title::before {
    content: "\25B8 ";
}

/* The caption above a bar: how far it moved from the bar to its left. Smaller
   than the axis because there are one per bar and they must not compete with
   the bars themselves. */
.ck-barlabel {
    font-size: 9px;
    font-weight: 500;
}

/* The EMA breadth card is a button into the member list (see app.js). */
.ema-breadth-panel { cursor: pointer; }
.ema-breadth-panel:hover { background: rgba(255, 255, 255, 0.06); }

/* Which stocks sit above which average: one column per bucket, each stock
   named once under the longest average it clears. */
.ema-members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.ema-members-col {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    min-width: 0;
}
.ema-members-head { font-weight: 600; font-size: 0.92em; }
.ema-members-count {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 500;
}
.ema-members-sub { font-size: 0.78em; opacity: 0.6; margin-bottom: 6px; }
.ema-members-list { max-height: 52vh; overflow-y: auto; }
.ema-members-empty { font-size: 0.85em; opacity: 0.5; }
.ema-member {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: inherit;
    padding: 2px 4px;
    border-radius: 3px;
    font: inherit;
    font-size: 0.86em;
    cursor: pointer;
}
.ema-member:hover { background: rgba(255, 255, 255, 0.09); text-decoration: underline; }

/* The delivery grid: every group down the page, every quarter across it.
   Dense on purpose -- the value is being able to scan a column, which needs
   the whole grain visible at once. */
.delivery-grid { font-size: 0.82em; border-collapse: separate; border-spacing: 0; }
.delivery-grid th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel-bg, #1c1f26);
    text-align: center;
    font-weight: 600;
    padding: 4px 6px;
    white-space: nowrap;
}
.delivery-grid th[data-q] { cursor: pointer; }
.delivery-grid td { padding: 3px 6px; }
.delivery-grid .grid-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
/* The group name stays put while the quarters scroll sideways -- a cell in the
   middle of a wide grid is meaningless without the row it belongs to. */
.delivery-grid .grid-name-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--panel-bg, #1c1f26);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.delivery-grid thead th.grid-name-col { z-index: 3; }
.delivery-grid tbody tr { cursor: pointer; }
.delivery-grid tbody tr:hover .grid-name-col { color: var(--warn); }

/* The valuation read's quick look: percentile positions and the price against
   its anchor band, drawn above the prose that explains them. */
.vd-visuals {
    margin: 4px 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}
.vd-row {
    display: grid;
    grid-template-columns: 130px 1fr 46px;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.vd-row .vd-note { grid-column: 2 / 4; font-size: 0.78em; opacity: 0.55; margin-top: -2px; }
.vd-label { font-size: 0.85em; opacity: 0.8; }
.vd-value { font-size: 0.9em; font-variant-numeric: tabular-nums; text-align: right; }
.vd-unit { font-size: 0.75em; opacity: 0.6; }
.vd-track {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(76,175,80,0.18), rgba(227,73,72,0.18));
}
.vd-track-tall { height: 12px; background: rgba(255, 255, 255, 0.05); }
.vd-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,0.12); }
.vd-marker {
    position: absolute; top: -3px; width: 3px; height: 14px;
    border-radius: 2px; transform: translateX(-1.5px);
}
.vd-band {
    position: absolute; top: 0; bottom: 0;
    background: rgba(237, 161, 0, 0.22);
    border-left: 1px solid rgba(237,161,0,0.5);
    border-right: 1px solid rgba(237,161,0,0.5);
}
.vd-median { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--warn); }
.vd-price {
    position: absolute; top: -4px; width: 3px; height: 20px;
    border-radius: 2px; transform: translateX(-1.5px);
}
.vd-anchor { margin-top: 10px; }
.vd-visuals > .vd-anchor:first-child { margin-top: 0; }
/* The price zones (zoneBar, 2026-10-20): the band in rupees, today's price
   labelled above the bar so it never lands on the top edge's label. */
.vd-zone-head { font-size: 0.9em; margin-bottom: 2px; }
.vd-scale-top { margin: 2px 0 1px; }
.vd-zone-cheap, .vd-zone-dear { position: absolute; top: 0; bottom: 0; }
.vd-zone-cheap { background: rgba(76, 175, 80, 0.22); }
.vd-zone-dear { background: rgba(227, 73, 72, 0.22); }
.vd-lenses { margin-top: 12px; }
.vd-row[title], .vd-anchor[title], .rx-change td[title], .gb-text[title] { cursor: help; }
.vd-anchor .vd-track { margin-top: 4px; }
/* Labels sit under the value they mark rather than spread across the bar:
   a legend reading "anchor 4,841" in the middle of a scale whose anchor tick
   is at nine percent is a caption claiming a position it does not have. */
.vd-scale {
    position: relative;
    height: 14px;
    font-size: 0.72em;
    opacity: 0.75;
    margin-top: 3px;
}
.vd-scale span {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}
.vd-note { font-size: 0.78em; opacity: 0.6; }

/* The Good & Bad summary over the valuation read (goodbad.js, 2026-10-15).
   Tokens only, so both themes come out right without an override: text in
   --text and --text-dim, the two signal colours only on the column titles
   and the cards' left rule, never on body text (a coloured sentence on a
   tint is where the light theme's contrast faults lived). */
.gb { margin: 2px 0 14px; }
.gb-lead { font-size: 1.05em; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.gb-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .gb-cols { grid-template-columns: 1fr; } }
.gb-col-title { margin: 0 0 6px; font-size: 0.82em; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.gb-good .gb-col-title { color: var(--pos); }
.gb-bad .gb-col-title { color: var(--neg); }
.gb-card {
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: 6px;
    padding: 8px 10px 7px;
    margin-bottom: 8px;
    background: var(--bg-deeper);
}
.gb-good .gb-card { border-left-color: var(--pos); }
.gb-bad .gb-card { border-left-color: var(--neg); }
.gb-head { font-weight: 700; color: var(--text); line-height: 1.3; }
.gb-text { color: var(--text-dim); font-size: 0.92em; line-height: 1.45; margin-top: 2px; }
.gb-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.gb-src {
    font-size: 0.78em;
    padding: 1px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}
.gb-src:hover { color: var(--text); border-color: var(--border-bright); }
.gb-measured {
    font-size: 0.74em;
    font-weight: 600;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 0 7px;
    cursor: help;
}
.gb-none, .gb-more { color: var(--text-dim); font-size: 0.88em; margin: 2px 0 6px; }
.gb-foot { color: var(--text-dim); font-size: 0.8em; margin: 4px 0 0; }
.gb-full { margin-top: 14px; border-top: 1px solid var(--border-strong); padding-top: 8px; }
.gb-full-title { margin: 2px 0 8px; font-size: 1em; color: var(--text); }
.gb-flash { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; transition: outline-color 1.2s; }

/* The Results section under the anchor pictures (valuationdetail.js
   resultsSection, 2026-10-15): the growth matrix, what the results changed,
   and the quarters. Growth is coloured by direction with the theme's own
   signal inks, which clear 5:1 on both grounds; the bars under sales and
   profit are shape, not text, so they carry no contrast duty. The tables
   scroll sideways inside the section on a narrow window rather than push
   the dialog wider. */
.rx { margin: 4px 0 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; }
.rx-title { margin: 0 0 8px; font-size: 1em; color: var(--text); }
.rx-h { margin: 14px 0 6px; font-size: 0.92em; color: var(--text); }
.rx-sub { font-weight: 400; font-size: 0.82em; color: var(--text-dim); }
.rx-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.86em; }
.rx-table th { text-align: right; font-weight: 600; color: var(--text-dim); padding: 3px 8px 5px; border-bottom: 1px solid var(--border-strong); vertical-align: bottom; }
.rx-table th:first-child { text-align: left; padding-left: 0; }
.rx-table td { text-align: right; padding: 4px 8px 5px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; white-space: nowrap; }
.rx-table td.rx-name { text-align: left; padding-left: 0; color: var(--text-dim); }
.rx-table td.rx-val { color: var(--text); font-weight: 600; }
.rx-table .rx-sep { border-left: 1px solid var(--border-strong); }
.rx-change th.rx-now, .rx-change td.rx-now { font-weight: 700; }
.rx-change td.rx-now:not(.qx-up):not(.qx-down) { color: var(--text); }
.rx-table tr.qx-latest td { font-weight: 700; }
.rx-table tr.qx-latest td.rx-name { color: var(--text); }
.qx-bar { display: block; height: 3px; border-radius: 2px; margin: 2px 0 0 auto; min-width: 2px; }
.qx-bar-sales { background: var(--accent); opacity: 0.55; }
.qx-bar-profit { background: var(--pos); opacity: 0.7; }
.qx-bar-loss { background: var(--neg); opacity: 0.7; }
.rx-table td.qx-up, .qx-up { color: var(--pos); }
.rx-table td.qx-down, .qx-down { color: var(--neg); }
.rx-table td.qx-flat, .qx-flat { color: var(--text-dim); }
.qx-oneoff { color: var(--warn); margin-left: 3px; font-size: 0.8em; cursor: help; }
.qx-foot { margin: 6px 0 0; font-size: 0.8em; color: var(--text-dim); }
.rx-pending { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--border-bright); color: var(--text-dim); font-size: 0.88em; }
.rx-pending-late { border-left-color: var(--warn); color: var(--warn); }
/* The journey: each quarter's read when filed, and the re-rating track. */
.rx-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.rx-strip-q { display: flex; flex-direction: column; gap: 3px; min-width: 104px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.82em; cursor: help; }
.rx-strip-label { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rx-read { align-self: flex-start; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--text); font-weight: 600; white-space: nowrap; }
.rx-read.good { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
.rx-read.bad { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.rx-read.loss { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.vd-track-chart { margin-top: 14px; }
.rx-strip-more { color: var(--text-dim); }
.rx-strip-rank { color: var(--text-dim); font-variant-numeric: tabular-nums; }
/* Where in a run of good quarters (recoveryRun): the 2nd and 3rd after a weak patch are the measured ones. */
.rx-strip-run { color: var(--text-dim); }
.rx-strip-run-key { color: var(--pos); font-weight: 600; }
/* The quarter-before strip: figures, not a read, so no hover card. */
.rx-strip-qoq { cursor: default; min-width: 150px; }
.rx-strip-line { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rx-was { color: var(--text-dim); }
.rx-rerate-lead { margin: 0 0 6px; font-size: 0.88em; color: var(--text); }
/* Multibagger: the percentile said in a word beside the figure, at the measured cuts only. */
/* Multibagger commentary (2026-10-16): the Turnaround screen's pre-turn read
   in the accent, a "check:" list in the warning ink; green and red are the
   shared .rs-pos / .rs-neg. */
.mb-preturn { color: var(--accent); }
.mb-check { color: var(--warn); }
.mb-band { font-size: 0.82em; white-space: nowrap; cursor: help; }

/* "Copy tickers" in a popup heading (see tickerlist.js).

   Sits beside the <h3> rather than in the button row at the foot, because it
   acts on the list and the list is what the heading names -- and because the
   foot of these dialogs scrolls away on a long table while the heading does
   not. Always visible, unlike .ticker-copy's hover-reveal: that one appears
   per row where a permanent icon on every line would be noise, while this one
   is the only one in the dialog. */
.ticker-list-copy {
    margin-left: 10px;
    padding: 2px 8px;
    font-size: 11px;
    vertical-align: middle;
    color: #b8bdc6;
    background: #262b36;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
}

.ticker-list-copy:hover {
    color: var(--text-brightest);
    background: #2e3440;
    border-color: #4a5361;
}

/* Market Review: the whole universe on one table (see marketreview.js).

   Same show/hide contract as #sectormapPane -- display:none until the mode
   button adds .active -- because rotation.js's switchMode toggles both the
   same way and a pane that differed would need its own special case there. */
#marketReviewPane {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
}

#marketReviewPane.active {
    display: flex;
}

/* The table takes what the toolbar leaves and scrolls inside it, rather than
   growing the page: two thousand rows would put the filter row off-screen,
   and the filters are what make the table usable. */
#marketReviewTableWrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
}

/* The setup score is the column the eye goes to first, so it carries the only
   background in the table. Four is rare -- four of 2,314 on the day this was
   built -- and should look it. */
.mr-setup {
    text-align: center;
    font-weight: 600;
    border-radius: 3px;
}

.mr-setup-4 { background: #1d4d2b; color: #d6f5de; }
.mr-setup-3 { background: #24402c; color: #bfe3c9; }
.mr-setup-2 { color: #9aa4b0; }
.mr-setup-1,
.mr-setup-0 { color: var(--text-faint); }

/* A divergence inside its live window, versus one merely recent. The
   distinction is the whole point of the column: "4 days ago" and "2 days ago"
   are the same fact until you know the window is three. */
.mr-live {
    color: var(--pos-soft);
    font-weight: 600;
}

.mr-muted {
    color: var(--text-faint);
}

/* The four legs, shown as letters rather than summed into a number.
   Measured on 2026-09-11 across 2,314 names: a quiet base is true of 52%, flow
   arriving of 49%, RS improving of 40% -- and a live divergence of 2%. The
   rare one is coloured differently because a total treats them as equal and
   they are not. */
.mr-legs {
    font-family: Consolas, monospace;
    letter-spacing: 2px;
    white-space: nowrap;
}

.mr-leg-on   { color: var(--pos-soft); }
.mr-leg-rare { color: #ffd479; font-weight: 700; }
.mr-leg-off  { color: var(--border-strong); }

/* The disclosed-deals column. Kept on one line: "2B/1S ×2 (14)" wraps into
   something unreadable the moment the window narrows, and the cell is short
   enough that not wrapping costs nothing. */
.mr-deals {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* The theme picker.
 *
 * Three small marks rather than three words: it sits in a nav bar that is
 * already full of labelled buttons, and a fourth label competing with them for
 * attention would be louder than a setting most people touch once. */
.theme-picker {
    display: inline-flex;
    gap: 1px;
    margin: 0 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.theme-choice {
    background: transparent;
    border: 0;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 4px 7px;
}

.theme-choice:hover {
    background: var(--bg-raised);
    color: var(--text);
}

.theme-choice.active {
    background: var(--border);
    color: var(--text-brightest);
}

/* Light-theme corrections.
 *
 * Everything below is a colour the tokens could not reach: a tinted chip whose
 * background was a dark hex, or a text colour legible on #1b202c and invisible
 * on white. Every rule here was found by AUDITING THE PARSED STYLESHEET rather
 * than by reading it -- a script walked document.styleSheets under the light
 * theme, computed the relative luminance of every declared background and
 * colour that was not already a token, and reported the ones facing the wrong
 * way. It found 59. Reading five thousand lines would have found most of them
 * and missed the rest, and the ones it missed would each have been a page
 * somebody opened once and found unreadable.
 *
 * The audit is worth re-running after any change that adds colour:
 *
 *   for (const r of document.styleSheets[0].cssRules) { ... }   // see git log
 *
 * Kept in ONE block at the end rather than scattered beside the rules they
 * correct. A reader asking "what does light mode change" gets an answer in one
 * place, and a rule that stops needing a correction can be deleted from here
 * without touching the dark theme it belongs to.
 *
 * DELIBERATELY NOT CORRECTED: the modal scrims (.auth-overlay, #newsOverlay,
 * dialog::backdrop) and .breadth-tooltip stay dark. A dark scrim behind a
 * dialog and a dark tooltip over a chart are what both themes do -- inverting
 * them would make the dialog float on a pale haze that hides nothing. Their
 * alpha is lowered, because 0.85 over a white page is a heavier curtain than
 * the same value over a dark one. */

/* The tooltip that stays dark needs its text told so.
   Found by the audit, and it is the exact failure a hand-written light theme
   produces: .breadth-tooltip sets its own near-black background and takes
   colour from var(--text), so deciding to leave the background alone turned
   its text dark as well and made it invisible. A surface that opts out of the
   theme has to opt its foreground out too. */
:root[data-theme="light"] .breadth-tooltip { color: #e8eaed; }
:root[data-theme="light"] .breadth-tooltip .breadth-tooltip-row { color: #a8adb8; }
:root[data-theme="light"] .breadth-tooltip .breadth-tooltip-row b { color: #e8eaed; }

/* Tables are a surface, and on a grey ground they have to say so.
 *
 * .rs-table's rows carry no background -- in dark they sit on the page and the
 * borders do the work, which is right there. With the light ground moved to
 * grey so cards can be white, those same transparent rows made every data
 * table on Sector Rotation, Scans, Ratio Scan and Market Review a grey sheet on
 * a grey page. The sticky header already uses --bg-app, and a header band only
 * reads as one when the rows beneath it are lighter.
 *
 * Light only: dark keeps the transparent rows it was designed with. */
:root[data-theme="light"] .rs-table {
    background: var(--bg-panel);
}

/* Scrims: same colour, less of it. */
:root[data-theme="light"] .auth-overlay { background: rgba(18, 22, 30, 0.5); }
:root[data-theme="light"] .startup-refresh-overlay { background: rgba(18, 22, 30, 0.45); }
:root[data-theme="light"] #newsOverlay { background: rgba(18, 22, 30, 0.35); }
:root[data-theme="light"] dialog.app-dialog::backdrop { background: rgba(18, 22, 30, 0.3); }

/* Panels and cards that were a darker shade of the app. On a light theme the
   same separation has to come from a border and a shadow, because a surface
   lighter than white does not exist. */
:root[data-theme="light"] .mtf-rsi-panel { background: rgba(255, 255, 255, 0.92); }
:root[data-theme="light"] .accum-section-head { background: var(--bg-deepest); }
:root[data-theme="light"] .playbook-card { background: var(--bg-panel); }
:root[data-theme="light"] .playbook-card:hover { background: var(--bg-sunken); }
:root[data-theme="light"] #newsDialog { background: var(--bg-panel); border-color: var(--border); }
:root[data-theme="light"] .mktcap-input { background: var(--bg-panel); }
:root[data-theme="light"] .chart-tab.active { background: var(--bg-panel); }

/* Selected and active states. Each was a dark wash of its accent; on white the
   wash goes the other way -- pale ground, saturated text. */
:root[data-theme="light"] .rotation-level-btn.active { background: #dbe8fa !important; }
:root[data-theme="light"] .fib-levels-editor-save { background: #1668c4 !important; color: #ffffff; }
:root[data-theme="light"] .fib-levels-editor-save:hover { background: #1257a6 !important; }
:root[data-theme="light"] .ticker-list-copy { background: var(--bg-sunken); color: var(--text-dim); }
:root[data-theme="light"] .ticker-list-copy:hover { background: var(--bg-deepest); color: var(--text); }
:root[data-theme="light"] .overlay-context-menu-delete { background: #fbe4e3; border-color: #e8b4b1; color: #b02a24; }
:root[data-theme="light"] .overlay-context-menu-delete:hover { background: #f6d3d1; }
:root[data-theme="light"] .chart-tab-close:hover { background: #f6d3d1; }

/* White text over a hover background that is now white itself. Both of these
   were invisible rather than merely low-contrast. */
:root[data-theme="light"] .stock-chip:hover { color: var(--text-brightest); }
:root[data-theme="light"] .typeahead-item:hover,
:root[data-theme="light"] .typeahead-item.active { background: #dbe8fa; color: var(--text-brightest); }

/* Pale ambers and creams: readable on a dark ground, and on white they are the
   colour of the page. */
:root[data-theme="light"] .ratio-save-btn { color: #8a6200; }
:root[data-theme="light"] .pnl-autoclose-note { color: #8a5c00; }
:root[data-theme="light"] .mr-leg-rare { color: #8a6200; }
:root[data-theme="light"] #actionScanTable td.actionscan-summary { color: var(--text-dim); }

/* F&O: the densest set of tinted chips in the app, and the reason the audit
   was worth writing rather than eyeballing. */
:root[data-theme="light"] .fno-bu-long,
:root[data-theme="light"] .fno-ivrank.fno-iv-low,
:root[data-theme="light"] .fno-live-chip { background: #dff3ea; color: #0b6b4b; }
:root[data-theme="light"] .fno-bu-short,
:root[data-theme="light"] .fno-ivrank.fno-iv-high { background: #fbe3ea; color: #a3253f; }
:root[data-theme="light"] .fno-bu-unwind,
:root[data-theme="light"] .fno-hz-chip { background: #f6ecd8; color: #7a5a12; }
:root[data-theme="light"] .fno-bu-cover,
:root[data-theme="light"] .fno-hz-aligned { background: #dde9f7; color: #1a4f8a; }
:root[data-theme="light"] .fno-hz-warning { background: #fdf3dc; border-color: #d9b566; color: #6b4a1f; }
:root[data-theme="light"] .fno-hz-warning b { color: #513714; }
:root[data-theme="light"] .fno-card-warn { border-color: #d9a94e; }
:root[data-theme="light"] .fno-scan-chip.active,
:root[data-theme="light"] .fno-dir-btn.active,
:root[data-theme="light"] .fno-paper-btn { background: #e6ebf7; border-color: #9aa6cc; }
:root[data-theme="light"] .fno-scan-row:hover td,
:root[data-theme="light"] .fno-bt-cell:hover td { background: #eef1f7; }
:root[data-theme="light"] #fnoChainTable tr.fno-atm td { background: #eef1f7; }
:root[data-theme="light"] #fnoChainTable tr.fno-atm td.fno-strike { background: #e0e6f4; }
:root[data-theme="light"] #fnoChainTable td.fno-strike,
:root[data-theme="light"] .fno-pick-net.neg,
:root[data-theme="light"] .fno-scan-chip.fno-bu-unwind b { color: #7a5a12; }

/* The setup-score cells on Market Review: dark greens that read as holes in a
   white table. */
:root[data-theme="light"] .mr-setup-4 { background: #cdeed8; color: #124a24; }
:root[data-theme="light"] .mr-setup-3 { background: #e0f0e5; color: #1d4d2b; }
:root[data-theme="light"] .mr-setup-2 { color: var(--text-dim); }
:root[data-theme="light"] .mr-setup-1,
:root[data-theme="light"] .mr-setup-0 { color: var(--text-faintest); }
:root[data-theme="light"] .mr-leg-off { color: #c3c8d0; }

/* The up/down pair. #26a69a and #ef5350 are the standard candle colours and
   stay the candle colours; as TEXT at 13px on white they are too light to
   read, so the text uses of them are darkened while the charts keep theirs. */
:root[data-theme="light"] .rs-pos { color: #0b7a55; }
:root[data-theme="light"] .rs-neg { color: #c0392f; }

/* ── Stage cycle ribbon ────────────────────────────────────────────────────
 *
 * Stage is a POSITION IN A CYCLE, so the control that shows it is a cycle
 * rather than four counters. The same twelve slots are drawn twice: once above
 * the table for the loaded rows, and once inside each row, so the market view
 * and the stock view are the same object at two scales.
 *
 * Stage-family colour is new here because the palette had no use for four
 * ordered states before. Defined for both themes beside the tokens they sit
 * on: the dark values are lifted to read on --bg-panel, the light ones dropped
 * to read on white, which is the same non-inversion the token block explains.
 */
:root {
    --stage-1: #6aa6f5;
    --stage-2: #4fc38d;
    --stage-3: #dda44e;
    --stage-4: #e8706a;
    --stage-1-bg: rgba(106, 166, 245, 0.13);
    --stage-2-bg: rgba(79, 195, 141, 0.13);
    --stage-3-bg: rgba(221, 164, 78, 0.13);
    --stage-4-bg: rgba(232, 112, 106, 0.13);
}
:root[data-theme="light"] {
    --stage-1: #2c62b0;
    --stage-2: #12805a;
    --stage-3: #8f6316;
    --stage-4: #b23b35;
    --stage-1-bg: rgba(44, 98, 176, 0.10);
    --stage-2-bg: rgba(18, 128, 90, 0.10);
    --stage-3-bg: rgba(143, 99, 22, 0.10);
    --stage-4-bg: rgba(178, 59, 53, 0.10);
}

.stage-ribbon-wrap {
    border: 1px solid var(--border);
    background: var(--bg-sunken);
    border-radius: 6px;
    padding: 9px 11px 8px;
    margin: 0 0 10px;
}
.stage-ribbon-head {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 7px;
}
.stage-ribbon {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
}
.stage-seg {
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 5px 2px 4px;
    text-align: center;
    min-width: 0;
    cursor: pointer;
    background: none;
    font: inherit;
    color: inherit;
}
.stage-seg:hover { border-color: var(--border-bright); }
.stage-seg[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }
.stage-seg .k { display: block; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.stage-seg .n { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }
.stage-seg.empty { opacity: 0.4; }
.stage-f1 { background: var(--stage-1-bg); color: var(--stage-1); }
.stage-f2 { background: var(--stage-2-bg); color: var(--stage-2); }
.stage-f3 { background: var(--stage-3-bg); color: var(--stage-3); }
.stage-f4 { background: var(--stage-4-bg); color: var(--stage-4); }
.stage-phase {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
    margin-top: 5px;
}
.stage-phase span {
    grid-column: span 3;
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    text-align: center;
    padding-top: 3px;
    border-top: 2px solid currentColor;
}
.stage-ribbon-note {
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px dashed var(--border);
    font-size: 11.5px;
    color: var(--text-muted);
}
.stage-ribbon-note b { color: var(--text-bright); font-weight: 600; }

/* The per-row ribbon. Twelve slots, the monthly block filled and the weekly
 * marked with a caret beneath, so a disagreement between the frames is visible
 * without reading two labels and comparing them. */
.stage-mini {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1px;
    align-items: end;
    height: 16px;
    min-width: 108px;
}
.stage-mini i {
    display: block;
    height: 4px;
    border-radius: 1px;
    background: var(--border-strong);
    position: relative;
}
.stage-mini i.m { height: 12px; }
.stage-mini i.w::after {
    content: "";
    position: absolute;
    left: 50%;
    translate: -50% 0;
    bottom: -5px;
    border: 3px solid transparent;
    border-bottom-color: var(--warn);
}
.stage-mini-label {
    font-size: 10.5px;
    color: var(--text-dim);
    margin-top: 4px;
    white-space: nowrap;
}
.stage-mini-label b { color: var(--text-soft); font-weight: 600; }
.stage-diverge td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* The daily frame's marker: a dot above the slot, so three frames read at a
 * glance without three labels to compare. Monthly is the block, weekly the
 * caret below, daily the dot above. */
.stage-mini i.d::before {
    content: "";
    position: absolute;
    left: 50%;
    translate: -50% 0;
    top: -5px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--accent);
}

/* ── Stage history panel ───────────────────────────────────────────────────
 *
 * The table says where a name sits today. This says how it got there: the
 * cycle is a sequence, each stage lasted a knowable number of months, and
 * price moved a knowable amount while it did.
 */
.stage-hist-back {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 5vh 16px; overflow: auto;
}
.stage-hist {
    background: var(--bg-panel); border: 1px solid var(--border-strong);
    border-radius: 8px; width: min(820px, 100%);
    box-shadow: 0 12px 40px var(--shadow);
}
.stage-hist-head {
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.stage-hist-head h3 { margin: 0; font-size: 16px; color: var(--text-brightest); }
.stage-hist-close {
    margin-left: auto; background: none; border: 1px solid var(--border);
    color: var(--text-muted); border-radius: 5px; cursor: pointer;
    padding: 3px 9px; font: inherit; font-size: 12px;
}
.stage-hist-close:hover { color: var(--text-bright); border-color: var(--border-bright); }
.stage-hist-body { padding: 14px 16px 16px; }
.stage-hist-sum {
    display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px;
    font-size: 12.5px; color: var(--text-muted);
}
.stage-hist-sum b { color: var(--text-bright); font-weight: 600; }
.stage-hist table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.stage-hist th {
    text-align: left; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-dim); font-weight: 700; padding: 0 8px 6px 0; white-space: nowrap;
}
.stage-hist td { padding: 5px 8px 5px 0; border-top: 1px solid var(--border); vertical-align: top; }
.stage-hist td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-hist .pill {
    display: inline-block; min-width: 30px; text-align: center;
    padding: 1px 6px; border-radius: 4px; font-weight: 600; font-size: 11.5px;
}
.stage-hist .running { color: var(--warn); font-size: 11px; }
.stage-hist-note {
    margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border);
    font-size: 11.5px; color: var(--text-muted); line-height: 1.55;
}
.stage-hist-trigger {
    background: none; border: 0; padding: 0; font: inherit; color: inherit;
    text-align: left; cursor: pointer; width: 100%;
}
.stage-hist-trigger:hover .stage-mini-label { color: var(--text-bright); }
.stage-hist-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The four zones, above the twelve slots they group. A grouping the model
 * teaches; no new boundary is drawn here. */
.stage-zones {
    display: grid;
    grid-template-columns: 3fr 2fr 4fr 3fr;
    gap: 3px;
    margin-bottom: 4px;
}
.stage-zone {
    border-radius: 3px 3px 0 0;
    padding: 3px 6px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}
.stage-zone .zn {
    font-size: 9.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stage-zone .zc {
    margin-left: auto;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}
.stage-guide {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}
.stage-guide div {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}
.stage-guide b {
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    padding-top: 2px;
}

/* View / persona strip, and the explainer's zone headings. */
.stage-strip-label {
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    align-self: center;
    margin-right: 4px;
}
.stage-zone-head {
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    padding-top: 12px !important;
}

/* BUG 3: the strip's first label was clipped at the left edge. .scans-ema-filter
 * is laid out for buttons that start at the rail, and a text label sitting in
 * that first slot lost its leading characters. Give the row its own padding and
 * let it wrap rather than overflow. */

/* The persona's reading, which is prose and needs room without pushing the
 * numeric columns off the row. */
.stage-guide-cell {
    max-width: 260px;
    white-space: normal;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--text-muted);
}

.stage-hist-frames {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 10px 0 4px;
}

/* The educational explainer. Richer than the one-paragraph note the other
 * scans carry, because this screen has twelve sub-stages and two readings of
 * each to describe. */
.stage-edu { max-width: 78ch; }
.stage-edu p { margin: 0 0 9px; line-height: 1.55; }
.stage-edu-table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.stage-edu-table th {
    text-align: left; font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-dim); font-weight: 700; padding: 0 10px 5px 0;
}
.stage-edu-table td {
    padding: 4px 10px 4px 0; border-top: 1px solid var(--border);
    vertical-align: top; line-height: 1.45;
}
.stage-edu-note { color: var(--text-muted); border-top: 1px dashed var(--border); padding-top: 9px; }

/* Chrome above the table was eight rows deep before a single stock. The strip
 * now holds the presets, the views and the persona on one line, and wraps
 * rather than growing a second row until it has to. */

.stage-strip-sep {
    display: inline-block;
    width: 1px;
    height: 16px;
    background: var(--border-strong);
    margin: 0 8px;
    vertical-align: middle;
}

/* The presets, views and persona share one row; it wraps rather than
 * overflowing, and carries its own gutter so a label in the first slot is
 * not clipped at the rail the way the old separate strip was. */
/* :not([hidden]) matters here. This is an ID rule, so it outranks the UA
   [hidden] { display: none } -- the strip stayed on screen whenever
   renderStagePresets had filled it, which is to say on every tab visited
   after Stage Setups. Turnaround showed "Measured best / Deep rebounds /
   READING AS Investor" above its own filters, describing a different screen.
   The class rule beside it, .scans-ema-filter, already guards this way. */
#stagePresetStrip:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    row-gap: 4px;
    padding-left: 10px;
    padding-right: 10px;
}

/* A BETWEEN spell in the stage history is not a stage, and must not look like
   one. Dashed and dim: present, readable, plainly outside the four families. */
.pill.stage-between {
    background: transparent;
    color: var(--text-dim);
    border: 1px dashed var(--border);
    letter-spacing: 0.04em;
    cursor: help;
}

/* The stage-group panel: sectors and industries read as charts of their own.
   Compact and scrollable, because there are ~205 industries and the panel sits
   above the table rather than replacing it. */
.stage-group-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 6px; }
.stage-group-active { margin-left: auto; font-size: 12px; color: var(--text-soft); }
.stage-group-active b { color: var(--text-bright); }
.stage-groups-wrap { max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); }
.stage-groups { width: 100%; border-collapse: collapse; font-size: 12px; }
.stage-groups th { position: sticky; top: 0; background: var(--bg-raised); text-align: left; padding: 4px 6px; font-weight: 600; font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; z-index: 1; }
.stage-groups td { padding: 3px 6px; border-top: 1px solid var(--border); white-space: nowrap; }
.stage-groups th.num, .stage-groups td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stage-groups td.num.pos { color: var(--stage-2); }
.stage-groups td.num.neg { color: var(--stage-4); }
.stage-group-row { cursor: pointer; }
.stage-group-row:hover td { background: var(--bg-raised); }
.stage-group-row.active td { background: var(--bg-raised); box-shadow: inset 2px 0 0 var(--accent); }
.stage-group-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.stage-dist-cell { min-width: 140px; }
.stage-dist { display: inline-flex; width: 140px; height: 9px; border-radius: 2px; overflow: hidden; background: var(--bg-sunken); vertical-align: middle; }
.stage-dist i { display: block; height: 100%; }
.stage-dist i.stage-f0 { background: var(--border); }
.stage-dist.empty { opacity: 0.35; }

/* Drawing tool properties dialog: one tabbed panel serving every tool, built
   from that tool's schema (see TOOL_PROPERTY_SCHEMAS in chart-app.js). Same
   floating, page-coordinate placement as .fib-levels-editor above. */
.tool-props-editor {
    position: absolute;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    min-width: 300px;
    max-height: 80vh;
}

.tool-props-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.tool-props-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #8b8f96);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
}

.tool-props-close:hover {
    color: var(--text);
}

.tool-props-tabs {
    display: flex;
    gap: 16px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
}

.tool-props-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted, #8b8f96);
    cursor: pointer;
    font-size: 12px;
    padding: 8px 2px;
}

.tool-props-tab.active {
    color: var(--text);
    border-bottom-color: #2962ff;
}

/* The body is the one part that gives up height: chartpanels.js caps the
   panel at the chart's height, and a flex child keeps its content height
   (min-height: auto) unless told otherwise, so without min-height: 0 the
   Style tab of a long tool ran past the panel's foot instead of scrolling. */
.tool-props-body {
    padding: 8px 12px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* Dragged by the title, as on TradingView (chartpanels.js). */
.chart-panel-handle { cursor: move; user-select: none; touch-action: none; }
.chart-panel-dragging { opacity: .97; }
#indicatorDialogFields { overflow-y: auto; }
.rsi-settings-scroll { overflow-y: auto; padding-right: 4px; }

.tool-props-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
}

/* The label takes the slack so every control lines up on the right edge,
   which is what makes a long settings list scannable. */
.tool-props-label {
    flex: 1 1 auto;
}

.tool-props-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-props-controls select {
    min-width: 108px;
    padding: 3px 4px;
}

.tool-props-controls input[type="number"] {
    width: 72px;
    padding: 3px 4px;
}

.tool-props-controls input[type="color"] {
    width: 34px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
}

.tool-props-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.tool-props-default-label {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted, #8b8f96);
}

.tool-props-footer button {
    padding: 5px 14px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.tool-props-ok {
    background: #2962ff;
    border-color: #2962ff;
    color: #fff;
}

/* Template row of the properties dialog: a saved-set picker plus its two
   actions, sitting between the fields and the Ok/Cancel footer. */
.tool-props-template-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
}

.tool-props-template-row > span {
    color: var(--text-muted, #8b8f96);
}

.tool-props-template-select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 3px 4px;
}

.tool-props-template-name {
    flex: 1 1 auto;
    min-width: 0;
    padding: 4px 6px;
    background: var(--bg-app);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
}

.tool-props-template-row button {
    flex: 0 0 auto;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.tool-props-template-row button:hover {
    background: var(--border);
}

/* TradingView's Fibonacci level grid: two columns of tick, ratio and colour. */
.fib-grid-wrap {
    padding: 4px 0 6px;
}

.fib-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 14px;
}

.fib-grid-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fib-grid-value {
    width: 70px;
    padding: 3px 4px;
}

.fib-grid-color {
    width: 30px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
}

.fib-grid-texts {
    margin-top: 8px;
}

.fib-grid-texts summary {
    cursor: pointer;
    color: var(--text-dim);
}

.tool-props-caption {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.tool-props-range {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tool-props-range input[type="range"] {
    width: 96px;
}

.tool-props-range span {
    min-width: 32px;
    text-align: right;
    color: var(--text-dim);
}

.tool-props-date {
    padding: 2px 4px;
}

.tool-props-hint {
    margin-top: 6px;
    color: var(--text-dim);
}

/* Folding panels above the Stage Setups table. Folded, each is one line that
   still says what it holds, so the table gets the screen back. */
.stage-panel-head { display: flex; align-items: center; gap: 10px; }
.stage-panel-head > span:first-child { flex: 0 0 auto; }
.stage-panel-sum { text-transform: none; letter-spacing: 0; color: var(--text-soft); font-size: 11.5px; }
.stage-panel-head .stage-group-active { margin-left: auto; }
.stage-panel-toggle { margin-left: auto; padding: 1px 8px; font-size: 11px; }
.stage-panel-head .stage-group-active + .stage-panel-toggle { margin-left: 0; }
.stage-ribbon-wrap.folded { padding-bottom: 6px; margin-bottom: 6px; }
.stage-ribbon-wrap.folded .stage-ribbon-head { margin-bottom: 4px; }

/* The Stage Setups preset strip sits inside the scan toolbar, on the same line
   as Refresh, so the two rows the page used to spend above the ribbon are one.
   The odds sentence moved to the status tooltip and the preset's own tooltip. */
#scansToolbar #stagePresetStrip:not([hidden]) { padding: 0; gap: 4px; }
#scansToolbar #scansStatus { white-space: nowrap; }

/* Zone labels on the ribbon are filters, like the segments under them. */
.stage-zone { cursor: pointer; }
.stage-zone:hover { filter: brightness(1.15); }
.stage-zone[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Basket timing card (Market Breadth view) -- see docs/BASKET-TIMING.md. */
.timing-summary { font-size: 13px; line-height: 1.5; }
.timing-summary div + div { margin-top: 4px; }
.timing-group-title { font-weight: 600; margin: 12px 0 6px; font-size: 13px; }
.timing-table td { vertical-align: top; font-size: 12px; line-height: 1.45; }
.timing-table td:first-child { min-width: 220px; }
.timing-meaning { opacity: 0.7; font-size: 11px; margin-top: 2px; }
.timing-age { max-width: 320px; font-size: 11px; }
.timing-state { display: inline-block; padding: 1px 7px; border-radius: 10px; font-weight: 600; font-size: 11px; }
.timing-state.on { background: rgba(38, 166, 154, 0.18); color: #26a69a; }
.timing-state.off { background: rgba(160, 160, 160, 0.18); opacity: 0.8; }
.timing-verdict { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; white-space: nowrap; }
.timing-verdict-good { background: rgba(38, 166, 154, 0.18); color: #26a69a; }
.timing-verdict-bad { background: rgba(239, 83, 80, 0.18); color: #ef5350; }
.timing-verdict-weak { background: rgba(255, 183, 77, 0.18); color: #ffb74d; }
.timing-verdict-none { background: rgba(160, 160, 160, 0.14); opacity: 0.75; }
.timing-month-good td { color: #26a69a; }
.timing-month-bad td { color: #ef5350; }

/* The turnaround screen's stage badge. Three verdicts that must be
   distinguishable at a glance without reading the word: a seed, a quarter
   that already delivered, and a name the cash-quality test threw out. */
.turn-stage {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.turn-stage-setup { background: rgba(56, 139, 253, 0.16); color: #58a6ff; }
.turn-stage-confirmed { background: rgba(63, 185, 80, 0.16); color: #56d364; }
.turn-stage-excluded { background: rgba(248, 81, 73, 0.16); color: #f85149; }
/* Repair is a THIRD reading, not a weaker setup: the interest bill is what
   was holding earnings down and it is easing. Amber rather than the blue of
   setup, so the two are not read as degrees of the same thing. */
.turn-stage-repair { background: rgba(210, 153, 34, 0.18); color: #d29922; }

/* The board badge. Only SME gets one: it is the row that reads differently
   (half-yearly periods, thinner disclosure, no Events coverage), and badging
   the mainboard majority too would spend the eye's attention on the case that
   needs none. Amber rather than a verdict colour -- this is a caveat about how
   to read the row, not a judgement on the company. */
.turn-board {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: rgba(210, 153, 34, 0.18);
    color: #d29922;
    cursor: help;
}
.turn-board-main { color: var(--text-dim); font-size: 12px; }

/* What the turnover floor is costing, per board, right next to the control
   that sets it. Hidden until a floor is set: an empty chip beside a blank
   input would read as a broken button. */
.turn-thin-count {
    background: rgba(210, 153, 34, 0.14);
    color: #d29922;
    border: none;
    border-radius: 9px;
    padding: 1px 8px;
    font-size: 11px;
    cursor: pointer;
}
.turn-thin-count:hover { background: rgba(210, 153, 34, 0.24); }

/* ---- Turnaround: help panel and row-detail dialog --------------------- */

/* The help panel reuses .stage-edu's frame; only the pieces Stage Setups has
   no equivalent for are defined here. */
.turn-edu h4 {
    margin: 16px 0 6px 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.turn-edu .turn-warn {
    border-left: 2px solid var(--warn, #b8860b);
    padding-left: 10px;
    margin: 10px 0;
}

.turn-edu .turn-gates {
    line-height: 1.7;
}

/* The score/risk weights read as numbers in a sentence otherwise. */
.turn-w {
    display: inline-block;
    min-width: 22px;
    padding: 1px 5px;
    border-radius: 3px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    background: var(--bg-raised, rgba(127, 127, 127, 0.14));
    border: 1px solid var(--border, rgba(127, 127, 127, 0.3));
}

.turn-w-hi {
    background: rgba(200, 60, 60, 0.16);
    border-color: rgba(200, 60, 60, 0.45);
}

/* A turnaround row is clickable across its whole width. */
tr.turn-row {
    cursor: pointer;
}

tr.turn-row:hover {
    background: var(--bg-raised, rgba(127, 127, 127, 0.08));
}

dialog.turn-dialog {
    width: min(980px, 94vw);
    max-height: 88vh;
    padding: 0;
    overflow: hidden;
}

.turn-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-strong);
}

.turn-dialog-head h3 {
    margin: 0;
    font-size: 16px;
}

.turn-dialog-sub {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-dim);
}

.turn-dialog-head button {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 15px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.turn-dialog-head button:hover {
    color: var(--text);
}

.turn-dialog-body {
    padding: 14px 18px 18px;
    overflow: auto;
    max-height: calc(88vh - 62px);
    font-size: 13px;
    line-height: 1.55;
}

/* Six figures across the top: the numbers a reader checks before reading a
   word of the chain. */
.turn-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.turn-stat {
    border: 1px solid var(--border, rgba(127, 127, 127, 0.28));
    border-radius: 5px;
    padding: 7px 10px;
}

.turn-stat-k {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.turn-stat-v {
    font-size: 17px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

.turn-stat-n {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 1px;
}

.turn-vizrow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-bottom: 14px;
}

.turn-viz-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.turn-viz-label span {
    text-transform: none;
    letter-spacing: 0;
}

/* Price position. The shaded band is the zone the gates allow, so a marker
   inside it explains the pass without reading a number. */
.turn-bar {
    position: relative;
    height: 9px;
    border-radius: 5px;
    background: var(--bg-raised, rgba(127, 127, 127, 0.16));
    border: 1px solid var(--border, rgba(127, 127, 127, 0.28));
}

.turn-bar-band {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(70, 140, 220, 0.22);
}

.turn-bar-mark {
    position: absolute;
    top: -3px;
    width: 3px;
    height: 15px;
    margin-left: -1px;
    border-radius: 2px;
    background: var(--text);
}

.turn-bar-ends {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
}

.turn-bar-mid {
    font-variant-numeric: tabular-nums;
}

/* Margin vs own median. The tick is the median; a fill short of it is the
   depressed-earnings half of the whole argument. */
.turn-mbar {
    position: relative;
    height: 9px;
    border-radius: 5px;
    background: var(--bg-raised, rgba(127, 127, 127, 0.16));
    border: 1px solid var(--border, rgba(127, 127, 127, 0.28));
    overflow: hidden;
}

.turn-mbar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background: rgba(70, 160, 110, 0.55);
}

.turn-mbar-fill.is-below {
    background: rgba(200, 140, 60, 0.6);
}

.turn-mbar-med {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--text);
}

.turn-board-note,
.turn-trigger,
.turn-exclude,
.turn-div {
    border-radius: 4px;
    padding: 7px 10px;
    margin-bottom: 10px;
    font-size: 12px;
}

.turn-trigger {
    background: rgba(70, 140, 220, 0.12);
}

/* The board note carries the reading caveat, so it is loud on SME and quiet
   on the mainboard -- where "quarterly filer, Events has this board" is a
   confirmation rather than a warning. */
.turn-board-note {
    background: rgba(210, 153, 34, 0.12);
    border-left: 2px solid rgba(210, 153, 34, 0.6);
}

.turn-board-note-main {
    background: var(--bg-raised, rgba(127, 127, 127, 0.1));
    border-left: 2px solid rgba(127, 127, 127, 0.35);
    color: var(--text-dim);
}

.turn-trigger-none {
    background: var(--bg-raised, rgba(127, 127, 127, 0.1));
    color: var(--text-dim);
}

.turn-exclude {
    background: rgba(200, 60, 60, 0.14);
    border-left: 2px solid rgba(200, 60, 60, 0.6);
}

.turn-div {
    background: none;
    padding: 0 0 6px 0;
    margin: 0 0 6px 0;
}

/* Chain and risk side by side: they are an argument and its cross-check, and
   reading them as one list loses that. */
.turn-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.turn-cols h4 {
    margin: 0 0 6px 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.turn-list {
    margin: 0;
    padding-left: 16px;
}

.turn-list li {
    margin-bottom: 5px;
}

.turn-empty {
    color: var(--text-dim);
    font-style: italic;
    margin: 0;
}

.turn-foot {
    margin: 16px 0 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--border, rgba(127, 127, 127, 0.25));
    font-size: 11px;
    color: var(--text-dim);
}

/* ---- Turnaround read inside the valuation card ----------------------- */

.turn-card {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border-strong);
}

.turn-card h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.turn-card-asof {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-dim);
}

.turn-card h4 {
    margin: 12px 0 4px 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.turn-card-verdict {
    margin: 0 0 8px 0;
    padding: 7px 10px;
    border-radius: 4px;
    font-size: 13px;
}

.turn-card-pass {
    background: rgba(70, 160, 110, 0.14);
}

/* Not a warning. Most companies fail a gate, and the sentence beside it is
   the useful part -- styled as information, not as a problem. */
.turn-card-fail {
    background: var(--bg-raised, rgba(127, 127, 127, 0.12));
    color: var(--text-dim);
}

.turn-card-exclude {
    margin: 0 0 8px 0;
    padding: 7px 10px;
    border-radius: 4px;
    font-size: 12px;
    background: rgba(200, 60, 60, 0.14);
    border-left: 2px solid rgba(200, 60, 60, 0.6);
}

.turn-card-context {
    margin: 0 0 6px 0;
    font-size: 12px;
    color: var(--text-dim);
}

.turn-card-list {
    margin: 0;
    padding-left: 16px;
    font-size: 12px;
}

.turn-card-list li {
    margin-bottom: 4px;
}

.turn-card-foot {
    margin: 12px 0 0 0;
    font-size: 11px;
    color: var(--text-dim);
}

/* The looked-up row's verdict. Deliberately not styled as a warning: most
   companies fail a gate, and the sentence beside it is the information. */
.turn-gate {
    margin-bottom: 12px;
    padding: 9px 12px;
    border-radius: 4px;
    font-size: 13px;
    background: var(--bg-raised, rgba(127, 127, 127, 0.12));
    border-left: 2px solid var(--border-strong);
}

.turn-gate span {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-dim);
}

#turnLookup #turnLookupNote {
    font-style: italic;
}

/* A hairline between the filters and the lookup, which share one row: they
   do different jobs (narrow the table / ask about a stock that is not on it)
   and reading them as one control set invites the wrong expectation. */
.turn-row-sep {
    display: inline-block;
    width: 1px;
    height: 16px;
    margin: 0 10px -3px;
    background: var(--border-strong);
}

#turnLookup {
    display: inline-block;
}

/* The unscored panel. Full width under the two columns, because it is not a
   third opinion on the thesis -- it is the ground the other two argue over. */
.turn-perf {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border, rgba(127, 127, 127, 0.25));
}

.turn-perf-note {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
}

/* The turnaround card's two panes: the reading (a verdict about today) and
   the history (what followed, last time this happened). */
.turn-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--border); }
.turn-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 7px 14px; font: inherit; font-size: 13px; color: var(--muted);
  cursor: pointer; margin-bottom: -1px;
}
.turn-tab:hover { color: var(--fg); }
.turn-tab.is-on { color: var(--fg); border-bottom-color: var(--accent, #4c8dff); font-weight: 600; }

.turn-hist-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0 14px; }
.turn-hist-table th, .turn-hist-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.turn-hist-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.turn-hist-table td.num, .turn-hist-table th.num { text-align: right; white-space: nowrap; }
.turn-hist-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.turn-hist-up { color: var(--up, #1a9a5a); }
.turn-hist-dn { color: var(--down, #d04545); }
.turn-hist-na { color: var(--muted); }
/* The Nifty-relative figure is the one that matters and the one a reader
   skips, so it sits beside the raw move rather than in a column of its own. */
.turn-hist-rel { color: var(--muted); font-size: 11px; }
.turn-hist-note { color: var(--muted); font-size: 12px; margin: 6px 0; line-height: 1.5; }
.turn-hist-summary h4, .turn-hist-changes h4 { margin: 14px 0 4px; font-size: 13px; }

/* One row per filing: the score badge, and the reasons that made it. */
.turn-hist-score {
  display: inline-block; min-width: 26px; padding: 1px 5px; border-radius: 4px;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 11px;
}
.turn-hist-score.is-up { background: rgba(26, 154, 90, 0.16); color: var(--up, #1a9a5a); }
.turn-hist-score.is-dn { background: rgba(208, 69, 69, 0.16); color: var(--down, #d04545); }
.turn-hist-score.is-flat { background: rgba(128, 128, 128, 0.16); color: var(--muted); }
.turn-hist-reason { line-height: 1.45; padding: 1px 0 1px 8px; border-left: 2px solid transparent; }
.turn-hist-reason.is-up { border-left-color: var(--up, #1a9a5a); }
.turn-hist-reason.is-dn { border-left-color: var(--down, #d04545); }
.turn-hist-reason + .turn-hist-reason { margin-top: 3px; }
/* A bucket nothing landed in is still worth showing -- an absent row reads as
   "this never happened to this company", which is the same as n=0 but looks
   like an omission. */
.turn-hist-empty { opacity: 0.45; }

/* Capital spending reads beside the performance panel, not as a warning:
   large capex funded by the business is a fact, not a risk. */
.turn-capital { border-left: 3px solid var(--accent, #4c8dff); padding-left: 12px; }

/* The verdict badge and its panel.
   
   Five values on a deliberate colour order rather than a good-to-bad ramp:
   AVOID is red because it is a finding about honesty, not a weak thesis;
   VERIFY is amber because the action is to read, not to dismiss; WATCH is
   blue because the thesis survives and only the entry is missing; IGNORE is
   grey because most of the market is grey and saying so plainly is the
   point. Only CANDIDATE is green, and it still means open the filings. */
.turn-verdict {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}
.turn-verdict-candidate { background: rgba(63, 185, 80, 0.18); color: #56d364; }
.turn-verdict-watch     { background: rgba(56, 139, 253, 0.16); color: #58a6ff; }
.turn-verdict-verify    { background: rgba(210, 153, 34, 0.18); color: #d29922; }
.turn-verdict-avoid     { background: rgba(248, 81, 73, 0.16); color: #f85149; }
.turn-verdict-ignore    { background: rgba(139, 148, 158, 0.16); color: #8b949e; }

.turn-verdict-panel {
    border: 1px solid var(--border, #30363d);
    border-left-width: 3px;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: rgba(255, 255, 255, 0.02);
}
.turn-verdict-panel-candidate { border-left-color: #56d364; }
.turn-verdict-panel-watch     { border-left-color: #58a6ff; }
.turn-verdict-panel-verify    { border-left-color: #d29922; }
.turn-verdict-panel-avoid     { border-left-color: #f85149; }
.turn-verdict-panel-ignore    { border-left-color: #8b949e; }

.turn-verdict-head { display: flex; align-items: baseline; gap: 10px; }
.turn-verdict-total { margin-left: auto; font-size: 20px; font-weight: 600; }
.turn-verdict-total span { font-size: 12px; opacity: 0.55; font-weight: 400; }
.turn-verdict-why { margin: 7px 0 12px; font-size: 13px; line-height: 1.5; }
.turn-verdict-note {
    margin: 11px 0 0;
    font-size: 11px;
    line-height: 1.5;
    opacity: 0.6;
}

/* One row per dimension: label, bar, value, and what the dimension asks.
   The note carries its own weight -- a reader seeing "quality 1/4" with no
   explanation has a number, not a finding. */
.turn-dims { display: grid; gap: 7px; }
.turn-dim {
    display: grid;
    grid-template-columns: 104px 1fr 44px;
    align-items: center;
    gap: 9px;
}
.turn-dim-k { font-size: 12px; font-weight: 600; }
.turn-dim-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(139, 148, 158, 0.18);
    overflow: hidden;
}
.turn-dim-fill { height: 100%; background: currentColor; opacity: 0.7; border-radius: 3px; }
.turn-dim-v { font-size: 13px; font-weight: 600; text-align: right; }
.turn-dim-v span { font-size: 11px; opacity: 0.5; font-weight: 400; }
.turn-dim-n {
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.45;
    opacity: 0.58;
    margin-top: -2px;
}

/* Unread is dimmer than ignore and outlined rather than filled: it is not a
   weaker rejection, it is the absence of a reading. A recently listed company
   has no twelve quarters to be below the median of. */
.turn-verdict-unread {
    background: transparent;
    color: #8b949e;
    box-shadow: inset 0 0 0 1px rgba(139, 148, 158, 0.35);
}
.turn-verdict-panel-unread { border-left-color: rgba(139, 148, 158, 0.5); }

/* Recovery is a fourth reading, not a stronger setup: the margin has already
   left its trough, which is the opposite of setup's "earnings have not moved
   yet". Teal so it is not read as a degree of the blue. */
.turn-stage-recovery { background: rgba(57, 197, 187, 0.16); color: #39c5bb; }

/* The working-capital release: the only turnaround that happens entirely on
   the balance sheet. Violet, so it is not read as a degree of the blue setup
   or the teal recovery -- nothing was built and no margin moved. */
.turn-stage-wc-release { background: rgba(163, 113, 247, 0.16); color: #a371f7; }

/* The turnaround preset strip. Each button carries its own live count, so a
   reader can see a preset is empty before clicking it rather than after. */
#turnPresetStrip { gap: 6px; flex-wrap: wrap; }
.turn-preset-n {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(139, 148, 158, 0.22);
}
.rotation-level-btn.active .turn-preset-n { background: rgba(0, 0, 0, 0.22); }

/* A name that was not on the scan last run. */
.turn-new { display:inline-block; padding:1px 6px; border-radius:8px; font-size:10px; font-weight:700; letter-spacing:.04em; background: rgba(63,185,80,.2); color:#56d364; }

/* Pre-turn: not a thesis, not nothing. Outlined amber -- the engine is
   cold, and this is the list to hold until it is not. */
.turn-verdict-pre-turn { background: transparent; color: #d29922; box-shadow: inset 0 0 0 1px rgba(210,153,34,.45); }
.turn-verdict-panel-pre-turn { border-left-color: rgba(210,153,34,.6); }
.turn-stage-pre-turn { background: rgba(210,153,34,.12); color: #d29922; }

/* Dropped: it was here last time. Red outline, not fill -- a warning about
   a change, not a finding about the accounts. */
.turn-stage-dropped { background: transparent; color: #f85149; box-shadow: inset 0 0 0 1px rgba(248,81,73,.5); }

/* The ledger under each dimension bar: one line per rung. Earned rungs
   carry their points; missed ones are dimmed but NAMED, because the miss is
   the information -- "6 of 8" tells a reader nothing until they can see
   which two. A charge (Quality is spent, not earned) reads in amber. */
.turn-ledger { list-style: none; margin: 5px 0 0; padding: 0; display: grid; gap: 2px; }
.turn-ledger li { font-size: 11px; line-height: 1.4; display: flex; gap: 6px; align-items: baseline; }
.turn-ledger-mark { width: 12px; flex: none; text-align: center; font-weight: 700; }
.turn-ledger .is-earned { opacity: 1; }
.turn-ledger .is-earned .turn-ledger-mark { color: #56d364; }
.turn-ledger .is-charged { opacity: 1; }
.turn-ledger .is-charged .turn-ledger-mark { color: #d29922; }
.turn-ledger .is-missed { opacity: 0.5; }
.turn-ledger-pts { opacity: 0.7; font-variant-numeric: tabular-nums; }

/* Where the price could go: the two-lever table. The "today" row is the
   anchor, the ceiling row is dimmed and italic -- it is what a promotional
   note calls a target, shown so a reader can see how far it sits from the
   median case. */
.turn-target { border: 1px solid var(--border, #30363d); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; background: rgba(255,255,255,0.02); }
.turn-target-head { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.turn-target-head span { font-weight: 400; font-size: 11px; opacity: .6; margin-left: 8px; }
.turn-tg-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 8px; }
.turn-tg-table th, .turn-tg-table td { padding: 4px 6px; border-bottom: 1px solid rgba(139,148,158,.15); text-align: left; }
.turn-tg-table th.num, .turn-tg-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.turn-tg-table .turn-tg-today td { font-weight: 600; }
.turn-tg-table .turn-tg-ceiling td { opacity: .6; font-style: italic; }
.turn-tg-table .is-up { color: #56d364; }
.turn-tg-table .is-dn { color: #f85149; }
.turn-tg-implied { font-size: 12px; line-height: 1.5; margin: 6px 0; padding: 6px 8px; border-left: 3px solid #d29922; background: rgba(210,153,34,.08); }
.turn-tg-inputs { font-size: 11px; line-height: 1.55; opacity: .75; margin: 6px 0; }
.turn-tg-notes { margin: 6px 0 0; padding-left: 18px; font-size: 11px; line-height: 1.5; opacity: .8; }
.turn-tg-foot { margin: 8px 0 0; font-size: 11px; line-height: 1.5; opacity: .55; }

/* Turnaround card, History tab: the screen replayed. */
.turn-replay-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.turn-replay-card { background: var(--bg-elev, rgba(255,255,255,0.04)); border: 1px solid var(--border, rgba(255,255,255,0.08)); border-radius: 8px; padding: 10px 12px; }
.turn-replay-card-label { font-size: 12px; opacity: 0.7; }
.turn-replay-card-value { font-size: 22px; font-weight: 600; margin: 2px 0; }
.turn-replay-card-sub { font-size: 11px; opacity: 0.6; }
.turn-replay-cagr td, .turn-replay-cagr th { padding-top: 4px; padding-bottom: 4px; }
.turn-replay-why { max-width: 440px; font-size: 12.5px; opacity: 0.9; }

/* Coiled industries (see coiled.js). Same show/hide contract as
   #marketReviewPane: display:none until rotation.js adds .active. */
#coiledPane {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 0 16px 16px;
}
#coiledPane.active { display: flex; }
#coiledTableWrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
#coiledTable .num, .coiled-member-table .num { text-align: right; font-variant-numeric: tabular-nums; }
#coiledTable tr.coiled-row { cursor: pointer; }
#coiledTable tr.coiled-row.is-open td { border-bottom-color: transparent; }
#coiledTable tr.coiled-detail > td { padding: 4px 12px 14px; background: rgba(255, 255, 255, 0.025); text-align: left; }
/* Industry names run to fifty characters; wrapping them five lines deep made
   every row as tall as the name. */
#coiledTable td.rotation-name { min-width: 260px; text-align: left; }
/* The detail row sits inside .rs-table, which right-aligns its cells and
   stretches nested tables; the reasoning and the member names read left. */
#coiledTable .coiled-member-table { width: auto; }
#coiledTable .coiled-member-table th,
#coiledTable .coiled-member-table td { text-align: left; }
#coiledTable .coiled-member-table td.num { text-align: right; }
#coiledTable .coiled-summary li { text-align: left; }

/* The tier is the column the eye goes to first, so it alone carries a fill.
   A is the only tier whose base rate beat the market, and should look it. */
.coiled-tier {
    display: inline-block;
    min-width: 1.6em;
    text-align: center;
    font-weight: 600;
    border-radius: 3px;
    padding: 0 4px;
}
.coiled-tier-A { background: #1d4d2b; color: #d6f5de; }
.coiled-tier-B { background: #33404d; color: #d5dde6; }
.coiled-tier-C { color: #8d97a3; border: 1px solid #3a4450; }
.coiled-new {
    margin-left: 6px;
    font-size: 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #f2c46d;
}
.coiled-scan {
    display: inline-block;
    font-size: 11px;
    padding: 0 5px;
    border-radius: 3px;
    background: rgba(124, 196, 255, 0.12);
    color: #a9d6ff;
    white-space: nowrap;
}
.coiled-scan-muted { background: rgba(255, 255, 255, 0.05); color: #8d97a3; }
.coiled-muted { color: #8d97a3; }
.coiled-up { color: #5fd39a; font-weight: 600; }
.coiled-down { color: #f2716a; }
.coiled-members { display: grid; gap: 8px; }
.coiled-summary { margin: 0; padding-left: 18px; color: #c3ccd6; font-size: 12.5px; line-height: 1.5; }
.coiled-member-table { width: auto; min-width: 420px; font-size: 12.5px; }
.coiled-member-table button.coiled-stock { background: none; border: 0; padding: 0; font: inherit; }
#coiledExplainer p { margin: 0 0 6px; max-width: 110ch; }

:root[data-theme="light"] #coiledTable tr.coiled-detail > td { background: rgba(0, 0, 0, 0.03); }
:root[data-theme="light"] .coiled-tier-A { background: #d7f0df; color: #14532d; }
:root[data-theme="light"] .coiled-tier-B { background: #e3e8ee; color: #25313d; }
:root[data-theme="light"] .coiled-scan { background: rgba(31, 111, 178, 0.1); color: #1f5f99; }
:root[data-theme="light"] .coiled-summary { color: #3a4550; }
#coiledTable td.num { white-space: nowrap; }
#coiledTable table.coiled-member-table { width: auto; max-width: 980px; }
.coiled-band {
    display: inline-block;
    font-size: 11px;
    padding: 0 5px;
    margin-right: 4px;
    border-radius: 3px;
    white-space: nowrap;
}
.coiled-band-dear { background: rgba(242, 113, 106, 0.15); color: #f2a19c; }
.coiled-band-fair { background: rgba(255, 255, 255, 0.06); color: #c3ccd6; }
.coiled-band-cheap { background: rgba(95, 211, 154, 0.14); color: #8fe3b8; }
.coiled-blocker { display: block; font-size: 11px; white-space: nowrap; }
:root[data-theme="light"] .coiled-band-dear { background: #fbe0de; color: #8a1f17; }
:root[data-theme="light"] .coiled-band-fair { background: #e3e8ee; color: #25313d; }
:root[data-theme="light"] .coiled-band-cheap { background: #d7f0df; color: #14532d; }
/* The Coiled member table's valuation and turnaround cells open their cards
   in a popup, so they read as buttons without looking like form controls. */
.coiled-cellbtn {
    background: none;
    border: 0;
    padding: 2px 4px;
    margin: -2px -4px;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
}
.coiled-cellbtn:hover { background: rgba(124, 196, 255, 0.10); }
.coiled-cellbtn:focus-visible { outline: 1px solid #7cc4ff; }
.coiled-cellbtn:disabled { opacity: 0.6; cursor: progress; }
:root[data-theme="light"] .coiled-cellbtn:hover { background: rgba(31, 111, 178, 0.08); }
/* Market Review: extension past 25% above the daily 50 EMA is the one
   coloured state in that column; the three structure marks sit tight. */
.mr-extended { color: #f2c46d; font-weight: 600; }
.mr-structure { display: inline-flex; gap: 3px; letter-spacing: 0; white-space: nowrap; }
:root[data-theme="light"] .mr-extended { color: #8a5a00; }

/* Bottoms (see bottoms.js). Same show/hide contract as #coiledPane. */
#bottomsPane { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; padding: 0 16px 16px; gap: 8px; }
#bottomsPane.active { display: flex; }
#bottomsIndustriesWrap, #bottomsStocksWrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
#bottomsIndustriesWrap[hidden], #bottomsStocksWrap[hidden] { display: none; }
#bottomsPane .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#bottomsPane th.bottoms-name, #bottomsPane td.bottoms-name { text-align: left; min-width: 150px; }
.bottoms-market { font-size: 12.5px; color: #c3ccd6; display: grid; gap: 4px; padding: 8px 12px; background: #171d28; border: 1px solid #2a3344; border-radius: 6px; }
.bottoms-market:empty { display: none; }
.bm-k { color: #8d97a3; }
.bm-sep { color: #4a5566; margin: 0 4px; }
.bm-correction { color: #f2c46d; }
.bm-leader { background: none; border: 1px solid #3b5a86; color: #a9d6ff; border-radius: 12px; padding: 0 8px; font: inherit; cursor: pointer; }
.bottoms-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.bottoms-presets[hidden] { display: none; }
.bottoms-preset { background: #1c2331; border: 1px solid #2a3344; color: #c3ccd6; padding: 3px 10px; border-radius: 14px; font: inherit; font-size: 12px; cursor: pointer; }
.bottoms-preset.active { background: #243652; border-color: #3b5a86; color: #fff; font-weight: 600; }
.bp-n { color: #8d97a3; margin-left: 2px; }
.bottoms-preset.active .bp-n { color: #a9d6ff; }
.bottoms-search { background: #1c2331; border: 1px solid #2a3344; color: #e6ebf2; padding: 4px 8px; border-radius: 6px; font: inherit; width: 160px; }
.bt-muted { color: #8d97a3; }
.bt-up { color: #5fd39a; }
.bt-down { color: #f2716a; }
.bt-thin { color: #f2c46d; }
.bt-phase { font-weight: 600; white-space: nowrap; }
.bt-phase-0 { color: #9aa4b2; }
.bt-phase-1, .bt-phase-2, .bt-phase-3 { color: #7cc4ff; }
.bt-phase-4 { color: #5fd39a; }
.bt-phase-5 { color: #3fb37f; }
.bt-ev { display: inline-block; font-size: 11px; padding: 0 5px; margin: 1px 0; border-radius: 3px; background: rgba(124, 196, 255, 0.12); color: #a9d6ff; white-space: nowrap; }
.bt-ev-good { background: rgba(95, 211, 154, 0.14); color: #8fe3b8; }
.bt-evidence { max-width: 360px; }
.bt-accounts { white-space: nowrap; font-size: 12px; }
.bt-link { background: none; border: 0; padding: 0; font: inherit; color: #7cc4ff; cursor: pointer; }
.bt-link:hover { text-decoration: underline; }
.bt-link:disabled { opacity: 0.6; cursor: progress; }
.bt-chip { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 3px; white-space: nowrap; }
.bt-gate { background: rgba(95, 211, 154, 0.16); color: #8fe3b8; }
.bt-shown { background: rgba(255, 255, 255, 0.07); color: #c3ccd6; }
.bt-neg { background: rgba(242, 113, 106, 0.14); color: #f2a19c; }
.bt-mkt { background: rgba(242, 196, 109, 0.15); color: #f2c46d; }
.bt-coiled { background: #1f5a3a; color: #bff0d4; }
.bt-strip { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; }
.bt-bar { width: 12px; border-radius: 2px; }
.bt-bar-0 { background: #3a4352; }
.bt-bar-1 { background: #4a5b7a; }
.bt-bar-2 { background: #5e7ba8; }
.bt-bar-3 { background: #7cc4ff; }
.bt-bar-4 { background: #5fd39a; }
.bt-bar-5 { background: #2f8a5f; }
tr.bt-ind-row { cursor: pointer; }
tr.bt-ind-row.is-open > td { background: rgba(124, 196, 255, 0.06); }
tr.bt-detail > td { background: rgba(0, 0, 0, 0.12); padding: 8px 12px; }
.bt-members { width: auto; font-size: 12.5px; }

dialog.bt-dialog { width: min(1040px, 96vw); max-height: 90vh; padding: 0; border: 1px solid #3b5a86; border-radius: 10px; background: #1c2331; color: #e6ebf2; }
dialog.bt-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.bt-dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px 8px; border-bottom: 1px solid #2a3344; }
.bt-dialog-head h3 { margin: 0; font-size: 18px; }
.bt-close { background: none; border: 1px solid #2a3344; color: #c3ccd6; border-radius: 6px; width: 30px; height: 30px; cursor: pointer; }
.bt-dialog-body { padding: 12px 18px 18px; overflow: auto; max-height: calc(90vh - 70px); display: grid; gap: 10px; font-size: 13px; }
.bt-tabs { display: flex; gap: 4px; align-items: center; }
.bt-tab { background: #151a23; border: 1px solid #2a3344; color: #c3ccd6; padding: 4px 12px; border-radius: 6px; font: inherit; cursor: pointer; }
.bt-tab.is-on { background: #2b3a54; color: #fff; font-weight: 600; }
.bt-spacer { flex: 1 1 auto; }
.bt-pane { display: grid; gap: 10px; }
.bt-pane[hidden] { display: none; }
.bt-banner { padding: 10px 12px; border-radius: 8px; background: #151a23; border: 1px solid #2a3344; }
.bt-banner-4, .bt-banner-5 { background: #16351f; border-color: #2f8a5f; }
.bt-banner-1, .bt-banner-2, .bt-banner-3 { background: #172a40; border-color: #3b5a86; }
.bt-banner-k { font-size: 11px; letter-spacing: 0.08em; color: #8d97a3; margin-right: 6px; }
.bt-baserate { font-size: 12.5px; color: #c3ccd6; line-height: 1.5; }
.bt-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.bt-cols h4, .bt-pane h4 { margin: 4px 0 6px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8d97a3; }
.bt-rung { display: grid; grid-template-columns: 18px 96px minmax(0, 1fr); gap: 6px; padding: 6px 8px; border-radius: 6px; background: #151a23; margin-bottom: 4px; }
.bt-rung.is-current { outline: 1px solid #3b5a86; }
.bt-rung.is-done .bt-mark { color: #5fd39a; }
.bt-mark { color: #8d97a3; font-weight: 600; }
.bt-rung-k { font-weight: 600; }
.bt-rung-v { color: #c3ccd6; }
.bt-note { font-size: 12px; color: #8d97a3; line-height: 1.5; }
.bt-ema { width: 100%; font-size: 12px; }
.bt-box { padding: 8px 10px; border-radius: 6px; background: #151a23; border: 1px solid #2a3344; color: #c3ccd6; }
.bt-box-break { background: #2a1c1c; border-color: #7a3a36; }
.bt-hist { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.bt-hist-year { font-size: 11px; color: #8d97a3; margin: 0 4px 0 8px; }
.bt-hist-cell { width: 9px; height: 16px; border-radius: 2px; background: #2a3344; }
.bt-hc-0 { background: #3a4352; }
.bt-hc-1, .bt-hc-2, .bt-hc-3 { background: #5e7ba8; }
.bt-hc-4 { background: #5fd39a; }
.bt-hc-5 { background: #2f8a5f; }
.bt-eps { width: auto; font-size: 12.5px; }
@media (max-width: 760px) { .bt-cols { grid-template-columns: minmax(0, 1fr); } }

:root[data-theme="light"] .bottoms-market { background: #f3f5f8; border-color: #d6dce4; color: #3a4550; }
:root[data-theme="light"] .bottoms-preset { background: #fff; border-color: #d6dce4; color: #3a4550; }
:root[data-theme="light"] .bottoms-preset.active { background: #e3ecf8; border-color: #6b8fc2; color: #14213d; }
:root[data-theme="light"] .bottoms-search { background: #fff; border-color: #d6dce4; color: #1f2933; }
:root[data-theme="light"] .bt-ev { background: rgba(31, 111, 178, 0.1); color: #1f5f99; }
:root[data-theme="light"] .bt-ev-good, :root[data-theme="light"] .bt-gate { background: #d7f0df; color: #14532d; }
:root[data-theme="light"] .bt-up { color: #1a7f4b; }
:root[data-theme="light"] .bt-down { color: #b3261e; }
:root[data-theme="light"] .bt-phase-4, :root[data-theme="light"] .bt-phase-5 { color: #1a7f4b; }
:root[data-theme="light"] .bt-phase-1, :root[data-theme="light"] .bt-phase-2, :root[data-theme="light"] .bt-phase-3 { color: #1f5f99; }
:root[data-theme="light"] dialog.bt-dialog { background: #fff; color: #1f2933; border-color: #6b8fc2; }
:root[data-theme="light"] .bt-rung, :root[data-theme="light"] .bt-banner, :root[data-theme="light"] .bt-box { background: #f3f5f8; border-color: #d6dce4; }
:root[data-theme="light"] .bt-banner-4, :root[data-theme="light"] .bt-banner-5 { background: #e3f4ea; border-color: #7cc49c; }
:root[data-theme="light"] .bt-box-break { background: #fbeaea; border-color: #e0a5a0; }
:root[data-theme="light"] .bt-rung-v, :root[data-theme="light"] .bt-baserate { color: #3a4550; }
#bottomsPane td, #bottomsPane th { text-align: left; }
#bottomsPane td.bt-evidence { min-width: 280px; }
#bottomsPane td.bt-accounts { min-width: 180px; }
.bm-split { color: #a9d6ff; }
:root[data-theme="light"] .bm-split { color: #1f5f99; }
#bottomsPhaseWrap[hidden] { display: none; }
/* The names are buttons (so they take focus and open the card); strip the
   browser button chrome so they read like every other name link in the app,
   as coiled.js does for its members. */
#bottomsPane button.bt-open, #bottomCardDialog button.bt-open { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* Playbook subpages (playbookscreens.js). */
.pb-subtabs { margin: 0 0 10px; }
.pb-pane[hidden] { display: none; }
.pb-ladder { display: grid; gap: 8px; margin: 10px 0 6px; }
.pb-ladder-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pb-ladder-k { width: 96px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #8d97a3; }
.pb-step { display: inline-flex; flex-direction: column; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent; }
.pb-step small { font-weight: 400; font-size: 11px; opacity: 0.85; }
.pb-step-good { background: rgba(95, 211, 154, 0.12); border-color: rgba(95, 211, 154, 0.35); color: #bff0d4; }
.pb-step-fund { background: rgba(124, 196, 255, 0.12); border-color: rgba(124, 196, 255, 0.35); color: #cfe7ff; }
.pb-step-weak { background: rgba(160, 172, 196, 0.10); border-color: rgba(160, 172, 196, 0.30); color: #c3ccd6; }
.pb-step-none { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.12); color: #9aa4b2; }
.pb-arrow { color: #5a6577; font-size: 16px; }
.pb-table-wrap { overflow-x: auto; }
.pb-compare { width: 100%; font-size: 12.5px; }
.pb-compare td, .pb-compare th { text-align: left; vertical-align: top; }
.pb-v { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.pb-v-good { background: rgba(95, 211, 154, 0.16); color: #8fe3b8; }
.pb-v-fund { background: rgba(124, 196, 255, 0.14); color: #a9d6ff; }
.pb-v-weak { background: rgba(242, 196, 109, 0.14); color: #f2c46d; }
.pb-v-bad { background: rgba(242, 113, 106, 0.14); color: #f2a19c; }
.pb-v-none { background: rgba(255, 255, 255, 0.07); color: #9aa4b2; }
details.pb-screen > summary { cursor: pointer; font-size: 14px; padding: 2px 0; list-style-position: inside; }
details.pb-screen > summary .pb-sum { color: #8d97a3; font-weight: 400; margin-left: 6px; }
details.pb-screen[open] > summary { margin-bottom: 8px; }
.pb-screen h4 { margin: 10px 0 4px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8d97a3; }
.pb-screen p, .pb-screen li { font-size: 13px; line-height: 1.55; color: #c3ccd6; }
.pb-screen ul { margin: 4px 0; padding-left: 20px; }
.pb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pb-mini { width: auto; max-width: 100%; font-size: 12.5px; margin: 4px 0; }
.pb-mini td, .pb-mini th { text-align: left; }
.pb-src { font-size: 11.5px; color: #8d97a3; margin: 2px 0 6px; }
.pb-open { margin-left: 6px; background: #1c2331; border: 1px solid #3b5a86; color: #a9d6ff; border-radius: 6px; padding: 2px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.pb-open:hover { background: #243652; }
.pb-notes li { font-size: 13px; line-height: 1.55; margin-bottom: 4px; }
@media (max-width: 760px) { .pb-grid { grid-template-columns: minmax(0, 1fr); } .pb-ladder-k { width: 100%; } }
:root[data-theme="light"] .pb-step-good { background: #e3f4ea; border-color: #7cc49c; color: #14532d; }
:root[data-theme="light"] .pb-step-fund { background: #e3ecf8; border-color: #8fb0d8; color: #1f3f66; }
:root[data-theme="light"] .pb-step-weak { background: #f1f3f6; border-color: #cfd6de; color: #3a4550; }
:root[data-theme="light"] .pb-step-none { background: #f7f8fa; border-color: #e0e4ea; color: #6b7684; }
:root[data-theme="light"] .pb-screen p, :root[data-theme="light"] .pb-screen li { color: #2f3a45; }
:root[data-theme="light"] .pb-v-good { background: #d7f0df; color: #14532d; }
:root[data-theme="light"] .pb-v-fund { background: #e3ecf8; color: #1f3f66; }
:root[data-theme="light"] .pb-v-weak { background: #fbefd6; color: #7a5a12; }
:root[data-theme="light"] .pb-v-bad { background: #fbe0de; color: #8a1f17; }
:root[data-theme="light"] .pb-open { background: #fff; border-color: #6b8fc2; color: #1f5f99; }
#playbookScreensPane table.rs-table th, #playbookScreensPane table.rs-table td { text-align: left; }

/* Ratio board (see ratioscan.js). The score is the column the eye goes to
   first and alone carries a fill; 2 and 3 share a hue because they measured
   alike, 1 is neutral because it measured just under the median, and 0 is
   the one rung measured well below it. */
#ratioBoardTable td.rotation-name { min-width: 240px; text-align: left; }
#ratioBoardTable td.num { white-space: nowrap; }
#ratioBoardTable tr.ratio-row { cursor: pointer; }
#ratioBoardTable tr.ratio-row.is-open td { border-bottom-color: transparent; }
#ratioBoardTable tr.ratio-detail-row > td { padding: 4px 12px 14px; background: rgba(255, 255, 255, 0.025); text-align: left; }
#ratioBoardTable.ratio-level-sector .ratio-col-ind { display: none; }

.ratio-score {
    display: inline-block;
    min-width: 2.2em;
    text-align: center;
    font-weight: 600;
    border-radius: 3px;
    padding: 0 4px;
}
.ratio-score-of { font-weight: 400; opacity: 0.6; font-size: 0.85em; }
.ratio-score-top { background: #1d4d2b; color: #d6f5de; }
.ratio-score-2 { background: #24402e; color: #bfe8cb; }
.ratio-score-1 { color: #aeb6c1; border: 1px solid #3a4450; }
.ratio-score-0 { background: rgba(242, 113, 106, 0.16); color: #f2a19c; }

.ratio-cellbtn {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.ratio-cellbtn:hover .ratio-state { outline: 1px solid var(--border-bright); }
.ratio-state {
    display: inline-block;
    white-space: nowrap;
    font-size: 11.5px;
    padding: 0 6px;
    border-radius: 3px;
}
.ratio-state-up { background: rgba(95, 211, 154, 0.16); color: #8fe3b8; }
.ratio-state-flat { background: rgba(255, 255, 255, 0.05); color: #aeb6c1; }
.ratio-state-down { background: rgba(242, 113, 106, 0.14); color: #f2a19c; }
.ratio-mark {
    font-size: 10px;
    font-weight: 600;
    padding: 0 3px;
    border-radius: 2px;
}
.ratio-mark-cont { color: #8fe3b8; border: 1px solid rgba(95, 211, 154, 0.4); }
.ratio-mark-reg { color: #8d97a3; border: 1px solid #3a4450; }
.ratio-move { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.ratio-weeks { display: inline-flex; gap: 2px; vertical-align: middle; }
.ratio-wk { width: 7px; height: 14px; border-radius: 1px; }
.ratio-wk-top { background: #3fae6d; }
.ratio-wk-2 { background: #2f6f47; }
.ratio-wk-1 { background: #3a4450; }
.ratio-wk-0 { background: #7a3531; }

.ratio-sib { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.ratio-sib-bar { width: 44px; height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.ratio-sib-bar > span { display: block; height: 100%; background: #3fae6d; }

.ratio-ladder {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    padding: 8px 16px;
    font-size: 12.5px;
}
.ratio-ladder:empty { display: none; }
.ratio-ladder-rung { white-space: nowrap; font-variant-numeric: tabular-nums; }
#ratioBoardExplainer p { margin: 0 0 6px; max-width: 110ch; }

.ratio-detail { display: grid; gap: 8px; }
.ratio-detail-head { font-size: 12px; color: var(--text-muted); }
.ratio-sibgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.ratio-sibbtn { justify-content: flex-start; font-size: 12.5px; text-align: left; white-space: normal; }
.ratio-detail-foot { font-size: 11.5px; }
#ratioBoardSearch { max-width: 180px; }
#ratioBoardSectorFilter { max-width: 220px; }

:root[data-theme="light"] #ratioBoardTable tr.ratio-detail-row > td { background: rgba(0, 0, 0, 0.03); }
:root[data-theme="light"] .ratio-score-top { background: #cdebd6; color: #14532d; }
:root[data-theme="light"] .ratio-score-2 { background: #e2f3e7; color: #1e5a33; }
:root[data-theme="light"] .ratio-score-1 { color: #4a5663; border-color: #c8d0d9; }
:root[data-theme="light"] .ratio-score-0 { background: #fbe0de; color: #8a1f17; }
:root[data-theme="light"] .ratio-state-up { background: #dff3e6; color: #1e5a33; }
:root[data-theme="light"] .ratio-state-flat { background: #eef1f4; color: #4a5663; }
:root[data-theme="light"] .ratio-state-down { background: #fbe0de; color: #8a1f17; }
:root[data-theme="light"] .ratio-mark-cont { color: #1e5a33; border-color: #9fd3b1; }
:root[data-theme="light"] .ratio-mark-reg { color: #5d6875; border-color: #c8d0d9; }
:root[data-theme="light"] .ratio-wk-top { background: #2e9a5b; }
:root[data-theme="light"] .ratio-wk-2 { background: #8fcfa6; }
:root[data-theme="light"] .ratio-wk-1 { background: #d3d9df; }
:root[data-theme="light"] .ratio-wk-0 { background: #e8a39d; }
:root[data-theme="light"] .ratio-sib-bar { background: rgba(0, 0, 0, 0.08); }

/* The industry and stock names are buttons so they are reachable by keyboard;
   stripped to read as the dotted-underline links every other view uses. The
   old "Open" button rendered as a grey block that wrapped its arrow. */
#ratioBoardTable button.ratio-basket,
#ratioMembersTable button.ratio-stock {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: left;
}
#ratioBoardTable button.ratio-basket:hover,
#ratioMembersTable button.ratio-stock:hover { color: var(--accent); }
.ratio-members-btn { white-space: nowrap; font-size: 12px; padding: 2px 8px; }

/* The members popup reuses the constituent dialog's frame. */
.ratio-members-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
#ratioMembersDialog .ratio-members-ladder { padding: 6px 0 2px; }
.ratio-members-note { font-size: 12px; max-width: 110ch; margin: 2px 0 4px; }
#ratioMembersTable td.rotation-name { text-align: left; min-width: 110px; }
#ratioMembersTable td.num { white-space: nowrap; }

/* The Confirmed tick: the board's strongest measured state, so it alone of
   the new marks carries a fill. */
.ratio-confirmed {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 600;
    padding: 0 5px;
    border-radius: 3px;
    background: #1d4d2b;
    color: #d6f5de;
    white-space: nowrap;
}
:root[data-theme="light"] .ratio-confirmed { background: #cdebd6; color: #14532d; }

/* The Stocks level (ratiostocks.js). Chips are buttons that open another
   screen's card, so they read as links, not as badges. */
.ratio-stocks-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 6px; }
#ratioStocksTable td { white-space: nowrap; }
#ratioStocksTable td.rotation-name { text-align: left; min-width: 110px; }
#ratioStocksTable button.rotation-name,
#ratioStocksTable button.ratio-stocks-industry {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
}
#ratioStocksTable button.rotation-name:hover { color: var(--accent); }
#ratioStocksTable td.ratio-stock-ind { text-align: left; }
/* A button truncates as one block, so the ellipsis lives on the button. */
#ratioStocksTable button.ratio-stocks-industry {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
#ratioStocksTable button.ratio-stocks-industry:hover { color: var(--accent); }
.ratio-stock-tier { font-size: 11px; }
.ratio-stock-board { margin-left: 4px; padding: 0 4px; border-radius: 3px; font-size: 10px; font-weight: 600; background: var(--accent-soft, rgba(120,120,200,.15)); color: var(--text-muted, inherit); }
.ratio-stock-leg {
    display: inline-block;
    width: 1.2em;
    text-align: center;
    font-size: 10.5px;
    border: 1px solid #3a4450;
    border-radius: 2px;
    opacity: 0.55;
}
.ratio-stock-leg.is-up { background: #1d4d2b; color: #d6f5de; border-color: #1d4d2b; opacity: 1; }
:root[data-theme="light"] .ratio-stock-leg { border-color: #c4ccd6; }
:root[data-theme="light"] .ratio-stock-leg.is-up { background: #cdebd6; color: #14532d; border-color: #cdebd6; }
.ratio-stock-conf { font-size: 10.5px; font-weight: 600; color: #8fe3b8; }
:root[data-theme="light"] .ratio-stock-conf { color: #14532d; }
.ratio-stock-stretched { color: #f0b35a; }
.ratio-chip {
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 0 4px;
    font: inherit;
    font-size: 12px;
    color: inherit;
    cursor: pointer;
}
.ratio-chip:hover { border-color: var(--accent); }
.ratio-chip.is-good { color: #8fe3b8; font-weight: 600; }
:root[data-theme="light"] .ratio-chip.is-good { color: #14532d; }

/* "How to use" popup (explainer.js, content in howtouse.js). */

dialog.explainer-dialog {
    width: min(860px, 94vw);
    max-height: 86vh;
    box-sizing: border-box;
    padding: 0;
}
dialog.explainer-dialog[open] { display: flex; flex-direction: column; }
.explainer-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--border);
}
.explainer-dialog-head h3 { margin: 0; font-size: 15px; }
.explainer-dialog-x {
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.explainer-dialog-x:hover { color: var(--text-bright); }
.explainer-dialog-body {
    overflow: auto;
    padding: 14px 22px 20px;
    font-size: 13.5px;
    line-height: 1.6;
    text-align: left;
    color: var(--text);
    white-space: normal;
}
.explainer-dialog-body p { margin: 0 0 12px; max-width: none; }
.explainer-dialog-body b,
.explainer-dialog-body strong { color: var(--text-bright); }
.explainer-dialog-body table { border-collapse: collapse; margin: 6px 0 14px; font-size: 12.5px; }
.explainer-dialog-body th,
.explainer-dialog-body td { border-bottom: 1px solid var(--border); padding: 4px 10px; text-align: left; vertical-align: top; }
.explainer-dialog-body ul,
.explainer-dialog-body ol { margin: 0 0 12px; padding-left: 20px; }

/* Track record (trackrecord.js): its own pane on the Scans page. */
#scansTrackPane { overflow-y: auto; padding-bottom: 24px; }
.track-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; }
.track-label { color: var(--text-muted, #888); font-size: 12px; }
.track-table td small { color: var(--text-muted, #888); }
.track-table td { vertical-align: top; }
#trackOverviewTable tr.track-row { cursor: pointer; }
#trackOverviewTable tr.track-row:hover td,
.track-table tr.track-selected td { background: var(--row-hover, rgba(127, 127, 127, 0.12)); }
.track-flag { color: #d9822b; font-size: 12px; }
.track-bucket td:first-child { padding-left: 28px; color: var(--text-muted, #888); }
.track-waiting td { opacity: 0.6; }
.track-expand, .track-picks-btn { cursor: pointer; font-size: 12px; }
.track-expand { border: none; background: none; color: inherit; padding: 0 4px 0 0; }
.track-picks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 16px; }
.track-picks-head { font-weight: 600; margin: 4px 0; }
.track-said { font-size: 12px; margin-top: 2px; max-width: 42ch; }
@media (max-width: 900px) { .track-picks-grid { grid-template-columns: 1fr; } }
.track-thin td { opacity: 0.45; }
/* IPO Base (ipobase.js): its own pane on the Scans page, like Track record. */
#scansIPOPane { overflow-y: auto; padding-bottom: 24px; }
#ipoNote { padding: 0 16px 8px; }
#ipoTableWrap { padding: 0 16px; }
#ipoTable td { vertical-align: top; }
#ipoTable td small { color: var(--text-dim); }
#ipoTable th[data-sort] { cursor: pointer; }
#ipoTable tbody tr { cursor: pointer; }
.ipo-locked { color: var(--warn); font-size: 11.5px; font-weight: 600; }
.ipo-early-tag { color: var(--accent); }
.ratio-stocks-legend { font-size: 12px; margin: 0 0 6px; }
/* The Stocks level's per-column filters: a second header row, compact. */
#ratioStocksTable tr.ratio-stocks-filters td { padding: 2px 4px 6px; }
#ratioStocksTable tr.ratio-stocks-filters select { font-size: 11.5px; max-width: 120px; padding: 1px 2px; }
#ratioStocksTable td.ratio-stock-fresh { color: #8fe3b8; font-weight: 600; }
:root[data-theme="light"] #ratioStocksTable td.ratio-stock-fresh { color: #14532d; }
.ratio-stocks-viewline { margin-top: 3px; font-size: 12px; color: #8fe3b8; }
.ratio-stocks-viewline.is-changed { color: #f0b35a; }
.ratio-stocks-viewline button { font-size: 11.5px; padding: 1px 8px; margin-left: 6px; }
:root[data-theme="light"] .ratio-stocks-viewline { color: #14532d; }
:root[data-theme="light"] .ratio-stocks-viewline.is-changed { color: #8a5300; }
#ratioStocksTable td.ratio-stock-below { color: #f2a19c; }
:root[data-theme="light"] #ratioStocksTable td.ratio-stock-below { color: #9b1c1c; }
/* The Industry column is wide and left-aligned; its filter sits under the
   heading, or it reads as the Stage column's. */
#ratioStocksTable tr.ratio-stocks-filters td.ratio-filter-left { text-align: left; }
#ratioStocksTable tr.ratio-stocks-filters td.ratio-filter-left select { width: 100%; max-width: none; }
.ratio-stocks-viewline.is-search { color: #8ab4f8; }
:root[data-theme="light"] .ratio-stocks-viewline.is-search { color: #1a4f9c; }
/* The "RS & flow" popup (ratiostocks.js). */
#ratioFlowDialog { width: min(1200px, 97vw); }
.ratio-flow-section { font-weight: 600; margin: 10px 0 4px; }
.ratio-flow-grid { display: flex; flex-wrap: wrap; gap: 14px; }
/* max-content: a frame never narrower than its table, so frames wrap onto
   the next line instead of drawing over each other (first build overlapped). */
.ratio-flow-frame { flex: 0 1 auto; min-width: max-content; }
.ratio-flow-head { font-size: 12.5px; margin-bottom: 2px; opacity: 0.85; }
.ratio-flow-frame table { width: auto; }
.ratio-flow-frame td, .ratio-flow-frame th { padding: 2px 6px; font-size: 12.5px; white-space: nowrap; }
.ratio-flow-avg { font-size: 12px; margin-top: 3px; }
.ratio-row-actions { white-space: nowrap; }
/* The Stocks level's early presets: set apart from the measured ones. */
.ratio-stocks-early { margin-left: 8px; }
.ratio-stocks-early-label { font-size: 12px; color: var(--text-muted, #999); margin-right: 4px; align-self: center; }
.rotation-level-btn.is-early { border-style: dashed; }
/* The Stocks level's Score history popup. */
.ratio-hist-btn { background: none; border: 0; padding: 0; cursor: pointer; }
.ratio-hist-btn:hover .ratio-score { outline: 1px solid var(--accent, #6af); }
.ratio-hist-chart { width: 100%; max-width: 760px; height: 190px; display: block; }
.ratio-hist-line { fill: none; stroke: var(--text, #ddd); stroke-width: 1.4; }
.ratio-hist-axis { font-size: 10px; fill: var(--text-muted, #999); }
.ratio-hist-legend { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted, #999); margin: 2px 0 6px 46px; }
.ratio-hist-legend i { display: inline-block; width: 12px; height: 10px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(128,128,128,.4); }
.ratio-hist-summary { margin: 6px 0 10px; }
.ratio-hist-table { min-width: max-content; }
.ratio-hist-flicker td { opacity: .6; }
/* The stock panel (stockpanel.js): slides in from the right over any page. */
.stock-panel { position: fixed; top: 0; right: 0; width: 380px; max-width: 92vw; height: 100vh; z-index: 900;
  background: var(--bg-panel); border-left: 1px solid var(--border-strong); overflow-y: auto;
  transform: translateX(100%); transition: transform .18s ease-out; padding: 14px 16px 24px; box-sizing: border-box; }
.stock-panel.open { transform: translateX(0); }
.stock-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.stock-panel-title { font-size: 18px; font-weight: 600; color: var(--text-brightest); }
.stock-panel-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stock-panel-close { background: none; border: 0; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; }
.stock-panel-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 12px; }
.stock-panel-k { color: var(--text-dim); }
.stock-panel-v { color: var(--text); }
.stock-panel-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.stock-panel-buttons button { font-size: 12px; padding: 4px 9px; }
.stock-panel-chart svg { width: 100%; height: 110px; display: block; border: 1px solid var(--border); }
.stock-panel-note { font-size: 11px; margin-top: 6px; }
/* The chart's card that opens it (app.js updateStockPanelCard). */
.stock-panel-card .mtf-rsi-value { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-panel-card-more { color: var(--accent, #64b5f6); font-size: 11px; font-weight: 600; margin-top: 2px; }
.stock-panel-card:hover { border-color: var(--accent, #64b5f6); }

/* The alert row's note, which is both the confirmation and the server's
   refusal. It must wrap rather than widen the panel: a validation message
   ("a vertical line has no level to cross") is a sentence, not a label, and
   a properties dialog that grows to fit one is a dialog that leaves the
   screen. */
.tool-props-template-row > span.tool-props-note {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    line-height: 1.3;
}

/* A footer action that is present but not available here -- "Add alert..." on
   a basket chart. Shown rather than hidden, because a hidden control reads as
   a feature that never shipped and no amount of reloading says otherwise; its
   title says why. Below the 4.5:1 bar on purpose, which is the one exemption
   the contrast rule allows (see AGENTS.md). */
.tool-props-footer button:disabled {
    color: var(--text-faintest);
    border-color: var(--border);
    cursor: not-allowed;
}

/* "All screens" on the Turnaround card and the Stage history popup: opens the
   side stock panel for the same name. Qualified with the element because
   ".turn-dialog-head button" (same specificity once qualified, earlier in this
   file) otherwise strips the border and colour, and the button read as text.
   margin-left: auto keeps it beside the Close button; the Close button after
   it then sits 8px away instead of taking half the free space with a second
   auto margin. */
button.card-panel-btn {
    margin-left: auto; background: none; border: 1px solid var(--accent);
    color: var(--accent); border-radius: 5px; cursor: pointer;
    padding: 3px 9px; font: inherit; font-size: 12px; white-space: nowrap;
    align-self: center;
}
button.card-panel-btn:hover { background: var(--accent-soft); }
button.card-panel-btn[hidden] { display: none; }
.card-panel-btn + .stage-hist-close { margin-left: 8px; }

/* The Macro page (macro.js). Same shell as Market Breadth: a toolbar, then a
   scrolling column of cards. Every colour is a theme token, so both themes
   follow without a light-theme override. */
#viewMacro { min-height: 0; }
#macroToolbar {
    flex: 0 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
}
#macroToolbar .howto-btn { margin-left: auto; }
#macroContent {
    flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 16px;
}
#macroContent > section { display: flex; flex-direction: column; gap: 16px; }
#macroContent > [hidden] { display: none !important; }
.macro-note { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.macro-footnote { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin-top: 8px; }
.macro-group-title { margin: 4px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-bright); }
.macro-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.macro-tile {
    display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer;
    background: var(--bg-deeper); color: var(--text); font: inherit;
    border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
    border-radius: 8px; padding: 10px 12px;
}
.macro-tile:hover { border-color: var(--border-strong); }
.macro-tile-good { border-left-color: var(--pos); }
.macro-tile-bad { border-left-color: var(--neg); }
.macro-tile-label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.macro-tile-value { font-size: 20px; font-weight: 600; color: var(--text-bright); }
.macro-tile-asof, .macro-tile-pct, .macro-tile-changes { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.macro-tile-pct { color: var(--text); }
.macro-stale { color: var(--warn); }
.macro-spark { width: 100%; height: 34px; margin-top: 4px; }
.macro-spark polyline { fill: none; stroke: var(--text-dim); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.macro-spark-good polyline { stroke: var(--pos); }
.macro-spark-bad polyline { stroke: var(--neg); }
.macro-spark-zero { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.macro-card-head, .macro-detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.macro-card-head .breadth-card-title, .macro-detail-head .breadth-card-title { margin-bottom: 0; }
.macro-card-head { margin-bottom: 10px; }
.macro-controls { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; }
.macro-years { margin-left: auto; }
.macro-controls .macro-years { margin-left: 0; }
.macro-detail-close {
    margin-left: auto; background: transparent; color: var(--text-dim); border: 0;
    font-size: 15px; cursor: pointer; padding: 2px 6px;
}
.macro-legend { font-size: 12px; color: var(--text); margin-top: 4px; }
.macro-val-now { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.macro-group-note { margin: -4px 0 8px; }
.macro-tier-wrap { margin-top: 14px; }
.macro-tier-table td, .macro-tier-table th { white-space: nowrap; }
.macro-tier-table .macro-tier-measure { text-align: left; color: var(--text); }
.macro-tier-cell { cursor: pointer; border-left: 3px solid transparent; }
.macro-tier-good { border-left-color: var(--pos); }
.macro-tier-bad { border-left-color: var(--neg); }
.macro-tier-value { display: block; font-weight: 600; color: var(--text-bright); }
.macro-tier-chg { display: block; font-size: 11.5px; }
.macro-tier-chg:not(.rs-pos):not(.rs-neg) { color: var(--text-dim); }
.macro-tier-empty { color: var(--text-dim); }
.macro-table-wrap { overflow-x: auto; }
.macro-table td, .macro-table th { white-space: nowrap; }
.macro-stock { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.macro-comps { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.macro-comp { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.macro-comp-empty { opacity: 1; border-style: dashed; }
.macro-comp-head { display: flex; align-items: baseline; gap: 10px; }
.macro-comp-val { font-size: 22px; font-weight: 600; color: var(--text-bright); }
.macro-comp-ch { font-size: 12px; }
.macro-members { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.macro-member { font-size: 11.5px; color: var(--text-dim); border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; }
.macro-regime-now { font-size: 15px; font-weight: 600; color: var(--text-bright); margin-bottom: 6px; }
.macro-dim { color: var(--text-dim); font-weight: 400; }
.macro-holds { color: var(--pos); font-weight: 600; }
.macro-now-row td { background: var(--bg-sunken); font-weight: 600; }
.macro-arith { font-size: 13px; color: var(--text); line-height: 1.5; margin-bottom: 8px; }

/* Macro chart frame (macro.js chartFrame): range, zoom and overlays on every
   time-series chart. The selection band and right axis are ChartKit's. */
.ck-select { fill: var(--accent, #6cb8ff); fill-opacity: 0.15; stroke: var(--accent, #6cb8ff); stroke-opacity: 0.5; }
.ck-axis-right { fill: var(--text-dim); }
.macro-frame-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; }
.macro-frame-ym { display: inline-flex; gap: 3px; }
.macro-frame-range .macro-frame-ym select {
    font: inherit; font-size: 12px; color: var(--text); background: var(--bg-deeper);
    border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px; width: auto;
}
.macro-frame-zoom button {
    font: inherit; font-size: 12px; min-width: 26px; padding: 3px 7px; color: var(--text);
    background: var(--bg-deeper); border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.macro-frame-zoom button:hover { border-color: var(--border-strong); }
.macro-frame-overlays { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.macro-frame-add { font: inherit; font-size: 12px; max-width: 200px; }
.macro-chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border-radius: 12px;
    border: 1px solid var(--border-strong); background: var(--bg-deeper); color: var(--text); font-size: 12px;
}
.macro-chip button { font: inherit; font-size: 11px; background: transparent; border: 0; color: var(--text-dim); cursor: pointer; padding: 1px 4px; }
.macro-chip-mode { text-decoration: underline dotted; text-underline-offset: 3px; }
.macro-chip button:hover { color: var(--text-bright); }
.macro-compare-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.macro-compare-form select { font: inherit; font-size: 13px; max-width: 280px; }
.ck-marker { stroke: var(--bg-panel, #1c1f26); stroke-width: 1.5; }
.ck-marker-label { font-size: 10.5px; fill: var(--text); }
/* Event marks (macro.js "Mark…", Rate cycles): the ring is the owner's hand-drawn
   circle, the rule a thin line through the plot so a mark reads at any zoom. */
.ck-marker-ring { pointer-events: none; }
.ck-marker-rule { pointer-events: none; }
.macro-frame-add, .macro-frame-shade, .macro-frame-mark { font: inherit; font-size: 12px; max-width: 200px; }
.macro-sum-row td { font-weight: 600; border-top: 1px solid var(--border-strong); }
.ck-tip-extra { color: var(--text-dim); margin-top: 2px; }

/* Valuation -> Earnings: one chart per metric (2026-10-13). Two columns so
   revenue and profit sit side by side; a narrow window stacks them. */
.ek-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 4px; }
.ek-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin-bottom: 6px; }
.ek-meta .ck-legend { margin: 0; }
.ek-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.ek-panel.ek-wide { grid-column: 1 / -1; }
.ek-title { font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; user-select: none; margin-bottom: 2px; }
.ek-unit { font-weight: 400; color: var(--text-dim); font-size: 11.5px; }
@media (max-width: 900px) { .ek-grid { grid-template-columns: minmax(0, 1fr); } }

/* Macro -> Rate cycles: the plain-words cards over the detail (2026-10-14).
   The owner could not read the tables alone; each card is one verdict, one
   sentence and a small picture of "usually" against "this cycle". */
.macro-story { margin: 4px 0 14px; }
.macro-story-title { font-size: 15px; font-weight: 600; color: var(--text-bright); margin: 0 0 8px; }
.macro-story-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.macro-story-card { background: var(--bg-panel); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 0 8px 8px 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.macro-story-good { border-left-color: var(--pos); }
.macro-story-warn { border-left-color: var(--warn); }
.macro-story-bad { border-left-color: var(--neg); }
.macro-story-note { border-left-color: var(--chart-blue, #6cb8ff); }
.macro-story-head { font-size: 12px; color: var(--text-dim); text-transform: none; }
.macro-story-verdict { font-size: 17px; font-weight: 600; color: var(--text-bright); line-height: 1.25; }
.macro-story-text { font-size: 13px; color: var(--text); line-height: 1.5; }
.macro-story-spark { width: 100%; height: 64px; margin-top: auto; }
.macro-story-key { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.macro-story-dash { display: inline-block; width: 14px; border-top: 2px dashed var(--text-dim); }
.macro-story-solid { display: inline-block; width: 14px; border-top: 3px solid; margin-left: 6px; }

/* Macro -> Snapshot (2026-10-14): seven questions answered in words, each
   reading's place in its own history a dot on a bar instead of a sentence. */
.macro-snap { margin: 2px 0 14px; }
.macro-snap-head { font-size: 18px; font-weight: 600; color: var(--text-bright); line-height: 1.35; margin: 2px 0 4px; }
.macro-snap-sub { font-size: 12px; color: var(--text-dim); margin: 0 0 12px; }
.macro-snap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.macro-snap-card { background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--border-strong); border-radius: 0 0 8px 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.macro-snap-good { border-top-color: var(--pos); }
.macro-snap-warn { border-top-color: var(--warn); }
.macro-snap-bad { border-top-color: var(--neg); }
.macro-snap-q { font-size: 12px; color: var(--text-dim); }
.macro-snap-verdict { font-size: 16px; font-weight: 600; color: var(--text-bright); line-height: 1.3; }
.macro-snap-good .macro-snap-verdict { color: var(--pos); }
.macro-snap-warn .macro-snap-verdict { color: var(--warn); }
.macro-snap-bad .macro-snap-verdict { color: var(--neg); }
.macro-snap-why { font-size: 12.5px; color: var(--text); }
.macro-snap-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.macro-snap-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: center; text-align: left; background: transparent; border: 0; padding: 2px 0; color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.macro-snap-row:hover .macro-snap-label { text-decoration: underline; text-underline-offset: 3px; }
.macro-snap-value { font-weight: 600; color: var(--text-bright); white-space: nowrap; }
.macro-snap-row .macro-pos { grid-column: 1 / 3; }
.macro-snap-extreme { grid-column: 1 / 3; font-size: 11px; color: var(--text-dim); }
.macro-pos { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--bg-sunken); border: 1px solid var(--border-strong); }
.macro-pos-dot { position: absolute; top: -3px; width: 10px; height: 10px; border-radius: 50%; transform: translateX(-50%); }
.macro-pos-tile { margin: 4px 0 2px; }
.macro-snap-note { font-size: 12px; color: var(--text); background: var(--bg-sunken); border-radius: 6px; padding: 6px 8px; }
.macro-snap-link { align-self: flex-start; background: transparent; border: 0; padding: 0; color: var(--chart-blue, #6cb8ff); font: inherit; font-size: 12.5px; cursor: pointer; }
.macro-snap-link:hover { text-decoration: underline; }
.macro-all { margin-top: 8px; }
.macro-all > summary { cursor: pointer; font-size: 13px; color: var(--text-dim); padding: 6px 0; }

/* Macro -> Rate cycles in the Snapshot's shape (2026-10-14): one-click
   questions over the overlay, a one-sentence answer, the evidence folded. */
.macro-cycle-questions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.macro-cycle-q { font: inherit; font-size: 12.5px; padding: 5px 10px; border-radius: 14px; border: 1px solid var(--border-strong); background: transparent; color: var(--text); cursor: pointer; }
.macro-cycle-q:hover { border-color: var(--chart-blue, #6cb8ff); }
.macro-cycle-q.active { border-color: var(--chart-blue, #6cb8ff); color: var(--chart-blue, #6cb8ff); font-weight: 600; box-shadow: inset 0 0 0 1px var(--chart-blue, #6cb8ff); }
.macro-cycle-answer { font-size: 14px; font-weight: 600; color: var(--text-bright); line-height: 1.45; margin: 0 0 8px; }
.macro-fold { margin-top: 10px; }
.macro-fold > summary { cursor: pointer; font-size: 13px; color: var(--text-dim); padding: 6px 0; }
.macro-evidence > .breadth-card { margin-top: 10px; }

/* Macro chart frame: period, vs Nifty and More options (2026-10-14). */
.macro-frame-more-btn { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-dim); cursor: pointer; }
.macro-frame-more-btn:hover { color: var(--text); }
.macro-frame-more { display: contents; }
.macro-frame-more[hidden] { display: none; }

/* Research: the question box and its answer (2026-10-14). */
.macro-ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.macro-ask-line { font-size: 14px; line-height: 2.1; }
.macro-ask-line select { font: inherit; font-size: 13px; max-width: 260px; }
.macro-answer-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.macro-badge { display: inline-block; font-weight: 600; font-size: 13px; padding: 5px 12px; border-radius: 14px; border: 1px solid; }
.macro-badge-held { color: var(--pos); border-color: var(--pos); background: color-mix(in srgb, var(--pos) 10%, transparent); }
.macro-badge-part { color: var(--warn); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.macro-badge-none { color: var(--text-dim); border-color: var(--border-strong); }
.macro-answer-head { font-size: 15px; line-height: 1.5; margin: 12px 0 6px; color: var(--text); }
.macro-answer-key { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.macro-answer-today { margin-top: 10px; padding: 8px 12px; border-left: 3px solid var(--chart-blue, #6cb8ff); background: var(--bg-sunken); font-size: 14px; }
.macro-bars { width: 100%; max-width: 640px; height: auto; display: block; margin: 6px 0; }
.macro-bars-zero { stroke: var(--border-strong); stroke-width: 1; }
.macro-bars-base { stroke: var(--text-dim); stroke-width: 1.5; stroke-dasharray: 5 4; }
.macro-bar-up { fill: var(--pos); }
.macro-bar-down { fill: var(--neg); }
.macro-bar-weak { fill: var(--text-dim); fill-opacity: 0.55; }
.macro-bar-nowband { fill: var(--chart-blue, #6cb8ff); fill-opacity: 0.1; stroke: var(--chart-blue, #6cb8ff); stroke-opacity: 0.5; }
.macro-bar-val { font-size: 13px; font-weight: 600; fill: var(--text); }
.macro-bar-label { font-size: 12.5px; fill: var(--text); }
.macro-bar-sub { font-size: 11.5px; fill: var(--text-dim); }
.macro-bar-today { font-size: 12px; font-weight: 700; fill: var(--chart-blue, #6cb8ff); }
.macro-leads { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.macro-lead { font: inherit; font-size: 13.5px; text-align: left; display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.macro-lead:hover { border-color: var(--chart-blue, #6cb8ff); }
.macro-lead-weaker { color: var(--neg); }
.macro-lead-stronger { color: var(--pos); }
.macro-outlook-fold { margin-top: 14px; }

/* Chains (2026-10-14). */
.macro-idx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 14px; }
.macro-idx-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--bg-raised); display: flex; flex-direction: column; gap: 8px; }
.macro-idx-head { font-size: 15px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.macro-idx-close { color: var(--text-dim); }
.macro-idx-trend { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg-sunken); color: var(--text); }
.macro-idx-verdict { font-weight: 600; font-size: 13.5px; line-height: 1.4; }
.macro-idx-pe { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; font-size: 13px; }
.macro-idx-pe .macro-pos-dot { background: var(--chart-blue, #6cb8ff); }
.macro-idx-ends { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); }
.macro-idx-rec { font-size: 12.5px; line-height: 1.45; }
.macro-idx-links { display: flex; flex-direction: column; gap: 4px; }
.macro-idx-link { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.4; }
.macro-idx-tw > span:first-child { color: var(--pos); font-weight: 700; }
.macro-idx-hw > span:first-child { color: var(--neg); font-weight: 700; }
.macro-idx-off { color: var(--text-dim); }
.macro-idx-link em, .macro-chain-sentence em { color: var(--text-dim); font-style: normal; display: block; font-size: 12px; }
.macro-chain-today { font-size: 14px; line-height: 1.5; padding: 8px 12px; border-left: 3px solid var(--warn); background: var(--bg-sunken); margin: 6px 0 10px; }
.macro-chain-today.macro-chain-quiet { border-left-color: var(--border-strong); color: var(--text-dim); }
.macro-chain-scroll { overflow-x: auto; padding-bottom: 4px; }
.macro-chain-canvas { position: relative; }
.macro-chain-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.macro-node { position: absolute; box-sizing: border-box; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg-raised); padding: 6px 9px; display: flex; flex-direction: column; justify-content: center; gap: 3px; overflow: hidden; }
.macro-node-label { font-size: 12.5px; font-weight: 600; line-height: 1.2; color: var(--text); }
.macro-node-val { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.macro-node-state { color: var(--text); }
.macro-node-extreme { border-color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }
.macro-node-extreme .macro-node-state { color: var(--warn); font-weight: 600; }
.macro-node-index { border-color: var(--chart-blue, #6cb8ff); background: color-mix(in srgb, var(--chart-blue, #6cb8ff) 8%, var(--bg-raised)); }
.macro-arrow-hit { fill: none; stroke: transparent; stroke-width: 14; }
.macro-arrow-line { fill: none; stroke-width: 2.2; }
.macro-arrow-held .macro-arrow-line { stroke: var(--chart-blue, #6cb8ff); }
.macro-arrow-held { cursor: pointer; }
.macro-arrow-held:hover .macro-arrow-line, .macro-arrow-held.active .macro-arrow-line { stroke-width: 3.6; }
.macro-arrow-none .macro-arrow-line { stroke: var(--text-dim); stroke-opacity: 0.6; stroke-dasharray: 5 5; stroke-width: 1.6; }
.macro-arrowhead-held { fill: var(--chart-blue, #6cb8ff); }
.macro-arrowhead-none { fill: var(--text-dim); fill-opacity: 0.6; }
.macro-chain-links { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.macro-chain-link { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); }
.macro-chain-link-held { cursor: pointer; border-left: 3px solid var(--chart-blue, #6cb8ff); }
.macro-chain-link-held:hover, .macro-chain-link-held.active { border-color: var(--chart-blue, #6cb8ff); }
.macro-chain-link-none { color: var(--text-dim); border-style: dashed; }
.macro-chain-pair-names { font-size: 13px; font-weight: 600; }
.macro-chain-to { color: var(--chart-blue, #6cb8ff); }
.macro-chain-link-none .macro-chain-to { color: var(--text-dim); }
.macro-chain-sentence { font-size: 13px; line-height: 1.4; }
.macro-chain-pair { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.macro-chain-pair-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.macro-chain-pair-sentence { font-size: 13.5px; margin: 4px 0 8px; }
.macro-chain-today ul { margin: 4px 0 0; padding-left: 18px; }
.macro-chain-today li { margin: 2px 0; }

/* Flows: bought and sold by month, FPI and NSE categories (2026-10-20). */
.macro-gross-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 4px 0 8px; }
.macro-gross-cats { flex-wrap: wrap; }
.macro-gross-sum { font-size: 13px; line-height: 1.5; margin-top: 6px; }
/* Macro: Build a chart (2026-10-20). */
.macro-build-intro { font-size: 13px; color: var(--text-dim); margin: 2px 0 8px; line-height: 1.5; }
.macro-build-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
/* Chart legends: an entry hides or shows its series (2026-10-20). */
.macro-legend-item { cursor: pointer; }
.macro-legend-off { text-decoration: line-through; color: var(--text-dim); }

/* Macro > Small vs large (macro.js renderSizes): one line per tier, a
   verdict a reader can act on, then the chosen tier's charts and table. */
.macro-size-lines { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; }
.macro-size-line { font: inherit; text-align: left; display: grid; grid-template-columns: 210px 110px 1fr; gap: 4px 12px; align-items: baseline; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.macro-size-line:hover, .macro-size-line.on { border-color: var(--chart-blue, #6cb8ff); }
.macro-size-name { font-weight: 600; }
.macro-size-now { font-size: 13px; }
.macro-size-verdict { grid-column: 1 / -1; font-size: 13px; color: var(--text-dim); }
.macro-size-tag { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); justify-self: start; }
.macro-size-table td { white-space: normal; vertical-align: top; min-width: 170px; }
.macro-size-sub { font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.macro-size-thin, .macro-size-thin b { color: var(--text-dim) !important; }
.macro-size-cur th, .macro-size-cur td { background: color-mix(in srgb, var(--chart-blue, #6cb8ff) 10%, transparent); }
@media (max-width: 760px) { .macro-size-line { grid-template-columns: 1fr; } }
.macro-ret-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-weight: 600; }
.macro-ret-lead { font-size: 13.5px; margin: 4px 0 6px; line-height: 1.5; }

/* Macro > Flows: who bought and sold, by day, week or month. */
.macro-cat-table td:first-child { white-space: nowrap; }
.macro-cat-rare { font-weight: 700; }
.macro-cat-idx, .macro-cat-table td:nth-child(9) { border-left: 1px solid var(--border); }

/* The Buildup Scan's measured table: folded under the positioning read. */
.fno-bu-evidence { margin: 8px 0 4px; font-size: 12.5px; }
.fno-bu-evidence > summary { cursor: pointer; color: var(--text-dim); }
.fno-bu-evidence > .fno-sub { margin: 6px 0; }
.fno-bu-evidence .fno-bt-table { width: auto; margin-top: 4px; }
.fno-bu-evidence .fno-bu-base td { font-weight: 600; }

/* The F&O desk's second design (docs/PLAN-FNO-STRATEGY.md): the regime
   card, the menu cards' status, plan and risk lines, the paper book's risk
   line, the managed table and the Hedge tab. Colours through the theme
   tokens only, so both themes follow. */
#fnoRegime { margin: 8px 0 4px; }
.fno-regime { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); padding: 8px 12px; }
.fno-regime-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.fno-regime-state { font-weight: 700; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border-strong); color: var(--text-bright); }
.fno-state-rich { color: var(--pos); border-color: var(--pos); }
.fno-state-shock, .fno-state-event { color: var(--neg); border-color: var(--neg); }
.fno-state-cheap, .fno-state-mid { color: var(--warn); border-color: var(--warn); }
.fno-regime-summary { color: var(--text); font-size: 13px; }
.fno-regime-gates { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 16px; }
.fno-gate { display: flex; gap: 6px; font-size: 12.5px; align-items: baseline; }
.fno-gate-mark { width: 14px; font-weight: 700; }
.fno-gate-pass .fno-gate-mark { color: var(--pos); }
.fno-gate-fail .fno-gate-mark { color: var(--neg); }
.fno-gate-info .fno-gate-mark { color: var(--text-dim); }
.fno-gate-label { color: var(--text-bright); white-space: nowrap; }
.fno-gate-value { color: var(--text-dim); }
.fno-regime-notes { margin-top: 6px; }
.fno-pick-badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; margin-left: 8px; border: 1px solid; }
.fno-badge-ok { color: var(--pos); border-color: var(--pos); }
.fno-badge-warn { color: var(--warn); border-color: var(--warn); }
.fno-badge-bad { color: var(--neg); border-color: var(--neg); }
.fno-badge-thin { color: var(--text-dim); border-color: var(--border-strong); }
.fno-pick-uncleared { border-style: dashed; }
.fno-pick-warn { color: var(--warn); font-size: 12.5px; margin: 4px 0; }
.fno-pick-plan { font-size: 12.5px; margin: 6px 0; color: var(--text); }
.fno-pick-risk { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.fno-pick-sizewhy { margin-bottom: 4px; }
.fno-paper-btn:disabled { opacity: 1; color: var(--text-dim); cursor: not-allowed; }
.fno-refused { margin: 8px 0; font-size: 12.5px; color: var(--text-dim); }
.fno-refused summary { cursor: pointer; }
.fno-measured-note { margin-top: 6px; }
.fno-paper-risk { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; margin: 4px 0 8px; }
.fno-paper-plan { margin: 2px 0 4px; }
.fno-plan-flag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; border: 1px solid; margin-left: 6px; }
.fno-plan-target { color: var(--pos); border-color: var(--pos); }
.fno-plan-stop { color: var(--neg); border-color: var(--neg); }
.fno-plan-time { color: var(--warn); border-color: var(--warn); }
.fno-managed-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
#fnoManaged, #fnoTrackRecord { margin-bottom: 14px; }
.fno-legacy-boards > summary { cursor: pointer; color: var(--text-dim); margin: 6px 0; }
.fno-hedge-block { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); padding: 8px 12px; margin: 8px 0; font-size: 13px; }
.fno-hedge-block h4 { margin: 0 0 4px; font-size: 13.5px; color: var(--text-bright); }
.fno-hedge-block .fno-sub { margin-top: 4px; }
#fnoHedge { padding: 0 2px; }

/* F&O paper auto-trade panel (2026-11-02) */
.fno-auto { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; }
.fno-auto-state { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-dim); }
.fno-auto-state.fno-auto-on { color: var(--pos); border-color: var(--pos); }
.fno-auto-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 6px 0; font-size: 13px; }
.fno-auto-kind { font-weight: 700; min-width: 70px; }
.fno-auto-chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 8px; margin: 2px 4px 2px 0; border: 1px solid var(--border); border-radius: 10px; font-size: 12px; }
.fno-auto-chip button { border: 0; background: transparent; color: var(--text-dim); cursor: pointer; padding: 0 2px; font-size: 11px; }
.fno-auto-controls input[type="number"] { width: 56px; }
.fno-auto-rule { margin: 4px 0; line-height: 1.45; }
.fno-auto-log td { padding: 2px 8px 2px 0; vertical-align: top; font-size: 12.5px; }
.fno-auto-state.fno-auto-live { color: var(--neg); border-color: var(--neg); font-weight: 600; }
.fno-auto-live-box { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 6px; }
.fno-auto-live-box.fno-auto-live-on { border-left: 3px solid var(--neg); padding-left: 8px; }
.fno-auto-ok { color: var(--pos); }
.fno-auto-warn { color: var(--warn); }
.fno-broker-card { margin: 8px 0; }
.fno-broker-card input[type="text"], .fno-broker-card input[type="password"] { width: 180px; }
.fno-broker-setup code { font-size: 12px; word-break: break-all; }
