/* The look.
 *
 * Loaded AFTER styles.css and layered over it. styles.css says what each
 * screen is laid out as; this file says what it looks like. Nothing here moves
 * a control, adds one or hides one -- delete the <link> and every screen still
 * works, it simply looks the way it did before October 2026.
 *
 * WHY IT IS A SEPARATE FILE. styles.css is 7,600 lines written screen by
 * screen, and a restyle threaded through it would be a diff nobody could read
 * or revert. The owner asked for "the look and feel, not the functions", and a
 * second sheet is the shape of that request.
 *
 * WHAT WAS WRONG. Not any one colour. The dark ground (#1b202c) and the panels
 * on it (#1e222d) were 2% apart, so nothing sat ON anything: tables floated on
 * the page, cards were outlines, and the eye had no hierarchy to follow. Every
 * control was a 4px-cornered grey box with the browser's own select arrow, the
 * nav was a row of folder tabs, and up/down was printed in two muted shades
 * (#279d82 / #c86164) chosen to be quiet. A screen with a great deal of data
 * read as a spreadsheet. The references the owner pointed at (Value Picker,
 * Invesights) and the ones checked alongside them (TradingView, Tickertape,
 * Finviz) all do the same four things: a ground clearly darker than its cards,
 * generous radii, tinted pills for state instead of outlined boxes, and colour
 * spent only where the number moves.
 *
 * BOTH THEMES ARE DESIGNED HERE, from the same token names. The charts, the
 * breadth canvases and the RRG read these tokens with getComputedStyle on every
 * ftt:themechange (chart-app.js applyTheme, breadth.js, rotation.js), so a
 * value set here reaches the canvases too -- keep the NAMES, change the values.
 *
 * SPECIFICITY. Component rules are prefixed :root[data-theme] (two attribute-
 * level selectors) so they beat styles.css's class rules and its
 * :root[data-theme="light"] .x corrections without !important. The toolbars
 * style their buttons through ID selectors (#rotationToolbar button), which no
 * class prefix beats, so those IDs are named below one by one.
 */

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */

/* Dark: a deep navy ground with slate cards. The steps between surfaces are
   now 3-5% in lightness rather than 1-2%, which is what makes a card read as
   raised without needing a border to say so. */
:root[data-theme="dark"],
:root:not([data-theme]) {
    color-scheme: dark;

    --bg-deepest: #070d18;   /* nav band */
    --bg-app:     #0a111e;   /* the ground */
    --bg-deeper:  #101a2b;   /* cards (breadth, playbook) */
    --bg-panel:   #111c2f;   /* panels, dialogs, popovers */
    --bg-raised:  #172439;   /* buttons, hover */
    --bg-sunken:  #0c1524;   /* input wells, segmented-control trays */

    --border:        #1c2940;
    --border-strong: #273752;
    --border-bright: #3a4e70;

    --text-brightest: #f4f7fc;
    --text-bright:    #e6ecf5;
    --text:           #d6dfec;
    --text-soft:      #b9c5d6;
    --text-softer:    #a8b5c8;
    --text-muted:     #a3b0c4;
    --text-dim:       #95a3b9;
    --text-dimmer:    #8a99b0;
    --text-faint:     #8292aa;
    --text-faintest:  #7b8ba3;

    --neg:      #f4646a;
    --good:     #2ecc71;
    --pos:      #34d39a;
    --pos-soft: #6ee7b7;
    --accent:   #4c9dff;
    --link:     #82b8ff;
    --warn:     #f5a524;
    --shadow:   rgba(0, 0, 0, 0.5);

    /* New in this sheet. */
    --accent-strong: #79b6ff;
    --accent-soft:   rgba(76, 157, 255, 0.14);
    --accent-ring:   rgba(76, 157, 255, 0.35);
    --pos-bg:        rgba(52, 211, 154, 0.13);
    --neg-bg:        rgba(244, 100, 106, 0.13);
    --warn-bg:       rgba(245, 165, 36, 0.14);
    --row-line:      rgba(148, 170, 205, 0.08);
    --row-hover:     rgba(76, 157, 255, 0.06);
    --th-bg:         #0e1828;
    --card-shadow:   0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --pop-shadow:    0 24px 60px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.02);
    --nav-bg:        linear-gradient(180deg, #0b1424 0%, #070d18 100%);
    --overlay:       rgba(3, 7, 14, 0.62);

    /* Chart ink. Read by breadth.js palette() and the ChartKit SVG rules;
       the dark values are the literals those charts always drew with. */
    --chart-grid:  #16223a;
    --chart-amber: #e0a33e;
    --chart-up:    #4caf50;
    --chart-blue:  #6cb8ff;

    /* The KLineChart canvas, read by chart-app.js applyTheme. Dark keeps
       what the chart always drew with; light is TradingView's light chart
       (see the light block). */
    --kc-bg:         var(--bg-app);
    --kc-grid:       var(--border);
    --kc-grid-style: dashed;
    --kc-axis:       var(--border-strong);
    --kc-axis-text:  var(--text-dim);
    --kc-cross-line: var(--border-strong);
    --kc-cross-bg:   var(--bg-raised);
    --kc-cross-text: var(--text);
    --select-arrow:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238796ad' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Light: white cards on a cool grey ground, the same arrangement styles.css
   arrived at after its first light theme came out as mud (see the comment on
   its own light block) -- the ground is the grey one and every card is white.
   Text keeps at least 4.5:1 on white all the way down to --text-faintest. */
:root[data-theme="light"],
:root[data-theme] #chartContainerWrap.kc-light {
    color-scheme: light;

    /* Readability, raised on 2026-10-01 at the owner's request: the first
       pass held light text to 3:1 (the floor for LARGE text), and grey labels
       and pale signal colours on white read as washed out. Now body text is
       16:1, every secondary step is 6:1 or better down to --text-faintest,
       and every signal colour is 5:1 or better on white and 4.5:1 on its own
       tinted pill. Hierarchy on light comes from size and weight, not from
       fading the ink -- a faint label on white is a hard one to read. */
    --bg-deepest: #e4e8ef;
    --bg-app:     #eef1f5;
    --bg-deeper:  #ffffff;
    --bg-panel:   #ffffff;
    --bg-raised:  #ffffff;
    --bg-sunken:  #e8ecf2;

    --border:        #d9dfe8;
    --border-strong: #c3ccd9;
    --border-bright: #98a4b6;

    --text-brightest: #070d1a;
    --text-bright:    #0c1424;
    --text:           #121b2d;
    --text-soft:      #222e44;
    --text-softer:    #2c384e;
    --text-muted:     #3b475c;
    --text-dim:       #445066;
    --text-dimmer:    #4a566c;
    --text-faint:     #505c72;
    --text-faintest:  #57637a;

    --neg:      #c01b1b;
    --good:     #13773a;
    --pos:      #13773a;
    --pos-soft: #16803c;
    --accent:   #1d4ed8;
    --link:     #1e40af;
    --warn:     #a64b05;
    --shadow:   rgba(15, 23, 42, 0.14);

    --accent-strong: #1e40af;
    --accent-soft:   rgba(29, 78, 216, 0.09);
    --accent-ring:   rgba(29, 78, 216, 0.30);
    --pos-bg:        rgba(22, 163, 74, 0.12);
    --neg-bg:        rgba(220, 38, 38, 0.10);
    --warn-bg:       rgba(217, 119, 6, 0.12);
    --row-line:      #e6eaf0;
    --row-hover:     rgba(29, 78, 216, 0.05);
    --th-bg:         #f4f6fa;
    --card-shadow:   0 1px 2px rgba(15, 23, 42, 0.06), 0 6px 20px -12px rgba(15, 23, 42, 0.18);
    --pop-shadow:    0 24px 60px -16px rgba(15, 23, 42, 0.30), 0 0 0 1px rgba(15, 23, 42, 0.05);
    --nav-bg:        linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
    --overlay:       rgba(15, 23, 42, 0.38);

    /* Lines at 4.5:1 or better against white, so a 1.4px series reads as a
       line rather than a smudge. */
    --chart-grid:  #e1e6ee;
    --chart-amber: #c2620a;
    --chart-up:    #16a34a;
    --chart-blue:  #1d4ed8;

    /* The chart canvas is TradingView's light chart (owner, 2026-11-04,
       from a screenshot of it): a WHITE plot rather than the app's grey
       ground, grid lines so faint they only guide the eye, axis figures in
       near-black, and the crosshair's price and date on a near-black chip
       with white figures. The grey ground stays everywhere else. */
    --kc-bg:         #ffffff;
    --kc-grid:       #f0f3fa;
    --kc-grid-style: solid;
    --kc-axis:       #e0e3eb;
    --kc-axis-text:  #131722;
    --kc-cross-line: #9598a1;
    --kc-cross-bg:   #131722;
    --kc-cross-text: #ffffff;
    --select-arrow:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23536077' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ */
/* Theme switch                                                        */
/* ------------------------------------------------------------------ */

/* theme.js puts .theme-anim on <html> for the length of the switch and takes
   it off again. A permanent transition on every element would animate every
   hover in the app and make tables feel sluggish; this cross-fades the one
   moment the whole palette changes and nothing else. The canvases repaint on
   ftt:themechange and simply land on the new colours. */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
    transition: background-color 0.32s ease, color 0.32s ease, border-color 0.32s ease,
                fill 0.32s ease, stroke 0.32s ease, box-shadow 0.32s ease !important;
}

@media (prefers-reduced-motion: reduce) {
    html.theme-anim,
    html.theme-anim *,
    html.theme-anim *::before,
    html.theme-anim *::after { transition: none !important; }
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */

/* Inter where it is installed; Segoe UI Variable is Windows 11's own and the
   closest match on the machines this runs on. Not loaded from a font CDN: a
   self-hosted app should not tell Google who opened it. */
:root[data-theme] body {
    font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, system-ui, sans-serif;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg-app);
    color: var(--text);
}

:root[data-theme] * {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

:root[data-theme] ::-webkit-scrollbar { width: 10px; height: 10px; }
:root[data-theme] ::-webkit-scrollbar-track { background: transparent; }
:root[data-theme] ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
:root[data-theme] ::-webkit-scrollbar-thumb:hover { background-color: var(--border-bright); }

:root[data-theme] ::selection { background: var(--accent-ring); }

/* ------------------------------------------------------------------ */
/* App nav                                                             */
/* ------------------------------------------------------------------ */

/* Pills instead of folder tabs. The folder-tab active state joined the tab to
   the page below it, which only works when the page is the same colour as the
   tab -- and the whole point of the new ground is that it is not. */
:root[data-theme] #appNav {
    align-items: center;
    gap: 2px;
    padding: 7px 12px;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
    min-height: 46px;
    box-sizing: border-box;
}

:root[data-theme] #appBrand {
    padding: 0 16px 0 2px;
    margin-right: 6px;
    border-right: 1px solid var(--border);
    height: 26px;
}

:root[data-theme] #appBrandName {
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 0.12em;
    background: linear-gradient(90deg, var(--text-brightest), var(--accent-strong));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

:root[data-theme] .app-nav-btn {
    border: 0;
    border-radius: 8px;
    padding: 7px 12px;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.005em;
    background: transparent;
    transition: background-color 0.12s ease, color 0.12s ease;
}

:root[data-theme] .app-nav-btn:hover {
    color: var(--text-bright);
    background: var(--bg-raised);
}

:root[data-theme="light"] .app-nav-btn:hover { background: var(--bg-sunken); }

:root[data-theme] .app-nav-btn.active {
    color: var(--accent-strong);
    background: var(--accent-soft);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--accent-ring);
}

:root[data-theme] #alertBellButton {
    border-radius: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

:root[data-theme] #alertBellButton:hover {
    background: var(--bg-raised);
    border-color: var(--border-strong);
}

:root[data-theme] .alert-bell-badge {
    background: var(--neg);
    color: #fff;
    box-shadow: 0 0 0 2px var(--bg-deepest);
}

:root[data-theme] .auth-badge {
    color: var(--text-muted);
    font-weight: 500;
}

:root[data-theme] .auth-logout-btn {
    border-radius: 8px;
    border-color: var(--border-strong);
    background: transparent;
    padding: 6px 12px;
    font-weight: 500;
}

:root[data-theme] .auth-logout-btn:hover {
    background: var(--bg-raised);
    border-color: var(--border-bright);
}

/* The theme picker: a tray with a sliding-looking active chip, sun / moon /
   monitor drawn in index.html. The active choice is the one with the accent,
   so which theme is ON is readable at a glance rather than by hovering. */
:root[data-theme] .theme-picker {
    gap: 2px;
    padding: 2px;
    margin: 0 8px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-sunken);
}

:root[data-theme] .theme-choice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
    padding: 0;
    border-radius: 7px;
    color: var(--text-dimmer);
    background: transparent;
}

:root[data-theme] .theme-choice svg { width: 14px; height: 14px; display: block; }

:root[data-theme] .theme-choice:hover {
    color: var(--text-bright);
    background: var(--bg-raised);
}

:root[data-theme] .theme-choice.active {
    color: var(--accent-strong);
    background: var(--bg-panel);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 0 0 1px var(--accent-ring);
}

/* ------------------------------------------------------------------ */
/* Toolbars                                                            */
/* ------------------------------------------------------------------ */

/* Every screen's controls sit in a band of their own, a shade off the ground,
   so the data underneath starts on a clean edge. Matched by id suffix because
   there are sixteen of them and each has its own id rule for layout. */
:root[data-theme] [id$="Toolbar"],
:root[data-theme] #toolbar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

:root[data-theme] #toolbar { padding: 8px 12px; gap: 6px; }

:root[data-theme] [id$="Toolbar"] label,
:root[data-theme] #toolbar label,
:root[data-theme] #chartStockBar label {
    color: var(--text-dim);
    font-weight: 500;
}

/* One button. Named by id because the toolbar rules in styles.css are id
   selectors and would otherwise win every property they set. */
:root[data-theme] #toolbar button,
:root[data-theme] #chartStockBar button,
:root[data-theme] #rotationToolbar button,
:root[data-theme] #watchlistToolbar button,
:root[data-theme] #industryemaToolbar button,
:root[data-theme] #breadthToolbar button,
:root[data-theme] #macroToolbar button,
:root[data-theme] #breadthRangeControls button,
:root[data-theme] #pnlToolbar button,
:root[data-theme] #portfolioToolbar button,
:root[data-theme] #scansToolbar > button,
:root[data-theme] .dialog-buttons button,
:root[data-theme] .app-dialog-actions button,
:root[data-theme] .howto-btn,
:root[data-theme] .stock-panel-buttons button,
:root[data-theme] .fold-btn {
    background: var(--bg-raised);
    color: var(--text-bright);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    cursor: pointer;
}

:root[data-theme] #toolbar button:hover,
:root[data-theme] #chartStockBar button:hover,
:root[data-theme] #rotationToolbar button:hover,
:root[data-theme] #watchlistToolbar button:hover,
:root[data-theme] #industryemaToolbar button:hover,
:root[data-theme] #breadthToolbar button:hover,
:root[data-theme] #macroToolbar button:hover,
:root[data-theme] #breadthRangeControls button:hover:not(:disabled),
:root[data-theme] #pnlToolbar button:hover,
:root[data-theme] #portfolioToolbar button:hover,
:root[data-theme] #scansToolbar > button:hover,
:root[data-theme] .dialog-buttons button:hover,
:root[data-theme] .app-dialog-actions button:hover,
:root[data-theme] .howto-btn:hover,
:root[data-theme] .stock-panel-buttons button:hover,
:root[data-theme] .fold-btn:hover {
    background: var(--bg-sunken);
    border-color: var(--border-bright);
    color: var(--text-brightest);
}

:root[data-theme="light"] #toolbar button:hover,
:root[data-theme="light"] #chartStockBar button:hover,
:root[data-theme="light"] #rotationToolbar button:hover,
:root[data-theme="light"] #watchlistToolbar button:hover,
:root[data-theme="light"] #industryemaToolbar button:hover,
:root[data-theme="light"] #breadthToolbar button:hover,
:root[data-theme="light"] #macroToolbar button:hover,
:root[data-theme="light"] #pnlToolbar button:hover,
:root[data-theme="light"] #portfolioToolbar button:hover,
:root[data-theme="light"] #scansToolbar > button:hover,
:root[data-theme="light"] .howto-btn:hover,
:root[data-theme="light"] .fold-btn:hover { background: #f6f8fb; }

/* "How to use" is help, not an action: quieter than the buttons beside it. */
:root[data-theme] .howto-btn {
    background: transparent;
    color: var(--accent-strong);
    border-color: var(--accent-ring);
    box-shadow: none;
}

:root[data-theme] .howto-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Segmented controls                                                  */
/* ------------------------------------------------------------------ */

/* .rotation-level-btn is the app's most common control (152 of them) and
   almost always lives in a .rotation-level-toggle. As a tray with a raised
   active chip it reads as ONE choice among several, which is what it is; as
   joined outlined boxes it read as a row of separate buttons. */
:root[data-theme] .rotation-level-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 10px;
}

:root[data-theme] .rotation-level-btn,
:root[data-theme] .rotation-level-btn:first-child,
:root[data-theme] .rotation-level-btn:last-child {
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 4px 11px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-dim);
    background: transparent;
    transition: background-color 0.12s ease, color 0.12s ease;
}

/* Outside a tray (a loose one in a toolbar row) it still needs an edge. */
:root[data-theme] :not(.rotation-level-toggle) > .rotation-level-btn {
    border-color: var(--border-strong);
    background: var(--bg-raised);
}

:root[data-theme] .rotation-level-btn:hover {
    color: var(--text-bright);
    background: var(--bg-raised);
}

:root[data-theme] .rotation-level-btn.active {
    background: var(--bg-panel) !important;
    color: var(--accent-strong);
    font-weight: 600;
    border-color: var(--accent-ring) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] .rotation-level-btn.active {
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

:root[data-theme] .rotation-level-btn:disabled,
:root[data-theme] .rotation-level-btn:disabled:hover {
    opacity: 0.4;
    background: transparent;
    color: var(--text-dim);
}

/* A chip inside a tray that sits in a TOOLBAR. The "#xToolbar button" rules
   below are id selectors, so on every property they set they beat the chip
   rules above: each chip came out as a raised, bordered button, and the
   active one -- the same surface with a faint accent border, its colour and
   weight lost to the id rule too -- could not be told from its neighbours.
   The owner found it on Macro's sub-pages, both themes, and it was every
   toolbar (2026-10-25). Only !important beats an id without naming one, so
   these name only the properties that mark the chip; padding and radius are
   left to the toolbar rule, which the phone block below also sets. The
   active chip is an accent wash with accent text rather than a white chip,
   because on light the tray's white-on-grey read as "not highlighted". */
:root[data-theme] .rotation-level-toggle > .rotation-level-btn {
    background: transparent !important;
    border-color: transparent !important;
    color: var(--text-dim) !important;
    font-weight: 500 !important;
    box-shadow: none !important;
}

:root[data-theme] .rotation-level-toggle > .rotation-level-btn:hover {
    background: var(--bg-raised) !important;
    color: var(--text-bright) !important;
}

:root[data-theme] .rotation-level-toggle > .rotation-level-btn.active,
:root[data-theme] .rotation-level-toggle > .rotation-level-btn.active:hover {
    background: var(--accent-soft) !important;
    color: var(--accent-strong) !important;
    font-weight: 600 !important;
    border-color: var(--accent-ring) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18) !important;
}

:root[data-theme] .rotation-level-toggle > .rotation-level-btn:disabled,
:root[data-theme] .rotation-level-toggle > .rotation-level-btn:disabled:hover {
    opacity: 0.4;
    background: transparent !important;
    color: var(--text-dim) !important;
}

/* ------------------------------------------------------------------ */
/* Inputs and selects                                                  */
/* ------------------------------------------------------------------ */

/* The browser's own select arrow was the single most "unfinished"-looking
   thing on every toolbar. Replaced by an SVG chevron held as a token, so it
   changes colour with the theme like everything else. */
:root[data-theme] select,
:root[data-theme] #toolbar select,
:root[data-theme] #fnoToolbar select,
:root[data-theme] .rotation-date-label select {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--bg-sunken);
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 9px center;
    color: var(--text-bright);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 5px 28px 5px 10px;
    font-size: 12.5px;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
}

:root[data-theme] select:hover { border-color: var(--border-bright); }

:root[data-theme] select option {
    background: var(--bg-panel);
    color: var(--text);
}

:root[data-theme] input[type="text"],
:root[data-theme] input[type="search"],
:root[data-theme] input[type="number"],
:root[data-theme] input[type="date"],
:root[data-theme] input[type="password"],
:root[data-theme] input[type="email"],
:root[data-theme] input:not([type]),
:root[data-theme] textarea {
    background-color: var(--bg-sunken);
    color: var(--text-bright);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.4;
}

:root[data-theme] input::placeholder,
:root[data-theme] textarea::placeholder { color: var(--text-faintest); }

:root[data-theme] select:focus,
:root[data-theme] input:focus,
:root[data-theme] textarea:focus,
:root[data-theme] button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

:root[data-theme] input[type="checkbox"],
:root[data-theme] input[type="radio"] { accent-color: var(--accent); }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */

/* The table is a card now: its own surface, a rounded edge and a header band,
   instead of rows ruled straight onto the page. border-collapse has to be
   separate for the corners to round; .rs-table only ever rules the bottom of a
   cell, so there are no shared edges to double up. No overflow:hidden -- it
   would make the table the sticky header's scroll container and the header
   would stop sticking. The corner cells carry the radius instead. */
:root[data-theme] .rs-table {
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

:root[data-theme] .rs-table thead th {
    background: var(--th-bg);
    color: var(--text-dim);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

:root[data-theme] .rs-table thead tr:first-child th:first-child { border-top-left-radius: 11px; }
:root[data-theme] .rs-table thead tr:first-child th:last-child  { border-top-right-radius: 11px; }
:root[data-theme] .rs-table tbody tr:last-child td:first-child  { border-bottom-left-radius: 11px; }
:root[data-theme] .rs-table tbody tr:last-child td:last-child   { border-bottom-right-radius: 11px; }
:root[data-theme] .rs-table tbody tr:last-child td { border-bottom: 0; }

:root[data-theme] .rs-table thead th:hover { color: var(--text-bright); }

:root[data-theme] .rs-table thead th[data-sort] { color: var(--accent-strong); }

:root[data-theme] .rs-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--row-line);
    color: var(--text);
}

:root[data-theme] .rs-table tbody tr:hover td { background: var(--row-hover); }

:root[data-theme] .rotation-name { color: var(--text-bright); font-weight: 500; }
:root[data-theme] .rotation-name.clickable { text-decoration-color: var(--border-bright); }
:root[data-theme] .rotation-name.clickable:hover { color: var(--accent-strong); text-decoration-color: var(--accent); }

/* Up and down: brighter on dark, deeper on light, the same tokens either way. */
:root[data-theme] .rs-pos { color: var(--pos); font-weight: 500; }
:root[data-theme] .rs-neg { color: var(--neg); font-weight: 500; }

:root[data-theme] .rotation-empty-row td { color: var(--text-dimmer); padding: 40px 12px; }

/* The scroll wraps that hold a table get a little air so the card's shadow
   and corners are not cut off at the edge. */
:root[data-theme] #rotationTableWrap { padding: 12px 16px 16px; }

/* ------------------------------------------------------------------ */
/* Cards, panels, popovers, dialogs                                    */
/* ------------------------------------------------------------------ */

:root[data-theme] .breadth-card,
:root[data-theme] .playbook-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
}

:root[data-theme] .breadth-card-title {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

:root[data-theme] dialog.app-dialog,
:root[data-theme] dialog.bt-dialog,
:root[data-theme] dialog.explainer-dialog,
:root[data-theme] dialog.turn-dialog,
:root[data-theme] dialog.accum-detail-dialog,
:root[data-theme] dialog.fno-bt-dialog {
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: var(--pop-shadow);
}

:root[data-theme] dialog::backdrop {
    background: var(--overlay);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

:root[data-theme] dialog.app-dialog h3 {
    font-size: 15px;
    font-weight: 650;
    color: var(--text-brightest);
}

/* The Bottoms dialog was written with literal dark hexes and only partly
   corrected for light; on tokens it is right in both. */
:root[data-theme] .bt-dialog-head { border-bottom-color: var(--border); }
:root[data-theme] .bt-close,
:root[data-theme] .bt-tab {
    background: var(--bg-sunken);
    border-color: var(--border-strong);
    color: var(--text-soft);
    border-radius: 8px;
}
:root[data-theme] .bt-tab:hover,
:root[data-theme] .bt-close:hover { color: var(--text-brightest); border-color: var(--border-bright); }
:root[data-theme] .bt-banner,
:root[data-theme] .bt-rung,
:root[data-theme] .bt-box {
    background: var(--bg-sunken);
    border-color: var(--border);
    color: var(--text-soft);
    border-radius: 10px;
}
:root[data-theme] .bt-hist-cell { background: var(--border-strong); }
:root[data-theme] .bottoms-search {
    background: var(--bg-sunken);
    border-color: var(--border-strong);
    color: var(--text-bright);
    border-radius: 8px;
}
:root[data-theme] .bottoms-market {
    background: var(--bg-panel);
    border-color: var(--border);
    color: var(--text-soft);
    border-radius: 12px;
}

/* Pills that already were pills get the tray treatment's colours. */
:root[data-theme] .bottoms-preset,
:root[data-theme] .fno-scan-chip {
    background: var(--bg-sunken);
    border-color: var(--border-strong);
    color: var(--text-soft);
    border-radius: 999px;
}
:root[data-theme] .bottoms-preset.active,
:root[data-theme] .fno-scan-chip.active,
:root[data-theme] .fno-dir-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

:root[data-theme] .alert-dropdown,
:root[data-theme] .typeahead-menu {
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: var(--pop-shadow);
}

:root[data-theme] .typeahead-item:hover,
:root[data-theme] .typeahead-item.active {
    background: var(--accent-soft);
    color: var(--text-brightest);
}

:root[data-theme] .stock-panel {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-strong);
    box-shadow: -24px 0 60px -20px var(--shadow);
}

:root[data-theme] .stock-panel-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
:root[data-theme] .stock-panel-chart svg { border-radius: 10px; border-color: var(--border); }

:root[data-theme] .stock-chip {
    border-radius: 999px;
}

/* Chart tabs above the chart: pills like the nav, one level quieter. */
:root[data-theme] .chart-tab {
    border-radius: 8px 8px 0 0;
}
:root[data-theme] .chart-tab.active {
    background: var(--bg-panel);
    box-shadow: inset 0 2px 0 var(--accent);
}

/* ------------------------------------------------------------------ */
/* Sign-in                                                             */
/* ------------------------------------------------------------------ */

:root[data-theme] .auth-overlay {
    background:
        radial-gradient(1200px 600px at 15% 10%, rgba(76, 157, 255, 0.16), transparent 60%),
        radial-gradient(900px 500px at 90% 90%, rgba(52, 211, 154, 0.10), transparent 60%),
        var(--overlay);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

:root[data-theme="dark"] .auth-overlay { background-color: rgba(5, 9, 18, 0.88); }
:root[data-theme="light"] .auth-overlay { background-color: rgba(226, 232, 242, 0.88); }

:root[data-theme] .auth-box,
:root[data-theme] .startup-refresh-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    padding: 28px 32px;
    box-shadow: var(--pop-shadow);
}

:root[data-theme] .auth-box h3 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-brightest);
}

:root[data-theme] .auth-box .dialog-buttons button:last-child {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 9px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
}

:root[data-theme] .auth-box .dialog-buttons button:last-child:hover { filter: brightness(1.08); }

/* ------------------------------------------------------------------ */
/* Light-theme legibility                                              */
/* ------------------------------------------------------------------ */

/* Found by auditing the parsed stylesheets in the browser, not by eye: every
   rule whose text colour is a literal under 3:1 against white and that had no
   light counterpart. 48 of them on 2026-10-01 -- greens at 1.9-2.8:1, ambers
   at 1.6-2.5, greys at 2.5-3.0 -- all tuned for the dark ground and never
   revisited, so on light the Fear zone, the Bottoms ladder ticks and the F&O
   short legs were close to invisible. Each maps to the token that means the
   same thing, so it moves with the theme from here on. Dark is untouched:
   these colours were right there. Re-run the audit (AGENTS.md, "The look
   lives in ui.css") after adding a screen with literal colours. */
:root[data-theme="light"] .ema-breadth-panel .mtf-rsi-value .ema-breadth-above,
:root[data-theme="light"] .ew-rev-up,
:root[data-theme="light"] .ew-check-pass .ew-check-mark,
:root[data-theme="light"] .mtf-rsi-value.mtf-rsi-oversold,
:root[data-theme="light"] .mtf-rsi-value.rs-strong,
:root[data-theme="light"] .mtf-rsi-value.ms-up,
:root[data-theme="light"] .breadth-zone-extreme-greed,
:root[data-theme="light"] .paper-pnl-positive,
:root[data-theme="light"] .timing-month-good td,
:root[data-theme="light"] .turn-ledger .is-earned .turn-ledger-mark,
:root[data-theme="light"] .turn-tg-table .is-up,
:root[data-theme="light"] .coiled-up,
:root[data-theme="light"] .bt-rung.is-done .bt-mark { color: var(--pos); }

:root[data-theme="light"] .fib-levels-editor-remove:hover,
:root[data-theme="light"] .fno-oi-chg.neg,
:root[data-theme="light"] .fno-leg.sell,
:root[data-theme="light"] .fno-close-btn,
:root[data-theme="light"] .fno-scan-chip.fno-bu-short b,
:root[data-theme="light"] .fno-neg,
:root[data-theme="light"] .coiled-down { color: var(--neg); }

:root[data-theme="light"] .breadth-zone-fear,
:root[data-theme="light"] .portfolio-flag,
:root[data-theme="light"] .fno-card-warn .fno-card-title,
:root[data-theme="light"] .turn-verdict-pre-turn,
:root[data-theme="light"] .turn-ledger .is-charged .turn-ledger-mark,
:root[data-theme="light"] .coiled-new,
:root[data-theme="light"] .bm-correction,
:root[data-theme="light"] .bt-thin,
:root[data-theme="light"] .ratio-stock-stretched,
:root[data-theme="light"] .track-flag { color: var(--warn); }

:root[data-theme="light"] .mtf-rsi-value.ms-range,
:root[data-theme="light"] .breadth-zone-neutral,
:root[data-theme="light"] .coiled-tier-C,
:root[data-theme="light"] .coiled-muted,
:root[data-theme="light"] .bm-k,
:root[data-theme="light"] .bp-n,
:root[data-theme="light"] .bt-muted,
:root[data-theme="light"] .bt-phase-0,
:root[data-theme="light"] .bt-banner-k,
:root[data-theme="light"] .bt-cols h4,
:root[data-theme="light"] .bt-pane h4,
:root[data-theme="light"] .bt-mark,
:root[data-theme="light"] .bt-note,
:root[data-theme="light"] .bt-hist-year,
:root[data-theme="light"] .pb-ladder-k,
:root[data-theme="light"] details.pb-screen > summary .pb-sum,
:root[data-theme="light"] .pb-screen h4,
:root[data-theme="light"] .pb-src { color: var(--text-dim); }

:root[data-theme="light"] .bottoms-preset.active .bp-n { color: var(--accent-strong); }

:root[data-theme] .stage-hist-back { background: var(--overlay); }

/* ------------------------------------------------------------------ */
/* Fixes from the first review (2026-10-01, Scans in light, 1920 wide) */
/* ------------------------------------------------------------------ */

/* The nav overflowed: fourteen tabs, the bell, the picker and three account
   buttons do not fit at 1920 with 12px tab padding, and the items that DID
   shrink were the picker (its icons crushed together) and Log Out (wrapped
   onto two lines). Nothing in the bar may shrink -- #appNav scrolls instead,
   which styles.css already arranged for narrow windows. */
:root[data-theme] #appNav > * { flex-shrink: 0; }
:root[data-theme] .app-nav-btn { padding: 6px 10px; }
:root[data-theme] .auth-logout-btn { white-space: nowrap; margin: 0 0 0 6px; }
:root[data-theme] .auth-badge { white-space: nowrap; }

/* "99+" sat on top of the bell and hid it. Badge to the corner, bell larger. */
:root[data-theme] #alertBellButton { font-size: 16px; overflow: visible; }
:root[data-theme] .alert-bell-badge {
    top: -4px;
    right: -6px;
    height: 16px;
    min-width: 16px;
    line-height: 16px;
    font-size: 9.5px;
    padding: 0 4px;
}

/* A native date input told color-scheme: dark draws its calendar icon light
   on any theme -- invisible on white. Three rules in styles.css said so
   explicitly; they now follow the page. */
:root[data-theme] .rotation-date-label input[type="date"],
:root[data-theme] .rotation-date-label select,
:root[data-theme] #breadthRangeDate,
:root[data-theme] .breadth-range-date-wrap input[type="date"] {
    color-scheme: inherit;
}

/* On light the input wells (#eaeef4 with a #cdd5e1 edge) read as grey blobs
   with no edge at all. White with a border is what a light field looks like. */
:root[data-theme="light"] select,
:root[data-theme="light"] #toolbar select,
:root[data-theme="light"] #fnoToolbar select,
:root[data-theme="light"] .rotation-date-label select,
:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] input[type="search"],
:root[data-theme="light"] input[type="number"],
:root[data-theme="light"] input[type="date"],
:root[data-theme="light"] input[type="password"],
:root[data-theme="light"] input[type="email"],
:root[data-theme="light"] input:not([type]),
:root[data-theme="light"] textarea {
    background-color: #ffffff;
    border-color: var(--border-strong);
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
}

/* Scans' filter rows and its evidence line are siblings of #scansToolbar,
   not children, and carry no side padding -- so once the toolbar became a
   band they sat flush against the window edge, 16px left of everything
   above and below them. They join the band now. */
:root[data-theme] .scans-pane > .scans-ema-filter:not([hidden]) {
    margin: 0;
    padding: 8px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

:root[data-theme] .scans-odds-line {
    margin: 12px 16px 0;
    padding: 8px 12px;
    color: var(--text-soft);
    background: var(--accent-soft);
    border: 0;
    border-left: 3px solid var(--accent);
    border-radius: 8px;
}

:root[data-theme] .scans-odds-line.scans-odds-warn {
    background: var(--warn-bg);
    border-left-color: var(--warn);
}

:root[data-theme] #scansTableWrap { padding-top: 12px; }

/* Header alignment. styles.css left-aligns th:first-child, but #scansTable's
   first th is a HIDDEN Date column, so Ticker got the right-aligned default
   and sat at the far end of its own column. Name-like columns are left by
   key, wherever they fall. */
:root[data-theme] .rs-table thead th[data-key="ticker"],
:root[data-theme] .rs-table thead th[data-key="name"],
:root[data-theme] .rs-table thead th[data-key="symbol"],
:root[data-theme] .rs-table thead th[data-key="company"],
:root[data-theme] .rs-table thead th[data-key="summary"] {
    text-align: left;
}

/* Commentary was right-aligned: .watchlist-summary-cell says left, but
   `.rs-table td` (right) is the more specific rule and won. A paragraph
   ragged on the left is very hard to read. */
:root[data-theme] .rs-table td.watchlist-summary-cell { text-align: left; }

/* The four-line clamp showed the top of a fifth line. -webkit-line-clamp
   hides the extra lines but they still paint, clipped at the PADDING box, so
   the cell's bottom padding is a window onto line five. The spacing moves
   into a transparent border (outside the clip) and the row rule is painted
   as a 1px background at the bottom of the border box. */
:root[data-theme] #scansTable td.watchlist-summary-cell:not(.expanded) {
    padding-bottom: 0;
    border-bottom: 9px solid transparent;
    background-image: linear-gradient(var(--row-line), var(--row-line));
    background-origin: border-box;
    background-clip: border-box;
    background-repeat: no-repeat;
    background-position: bottom;
    background-size: 100% 1px;
}

/* ------------------------------------------------------------------ */
/* Charts drawn as SVG (Market Breadth, ChartKit)                      */
/* ------------------------------------------------------------------ */

/* The Fear & Greed line was stroked #eef0f2 -- a literal near-white, so on
   the light theme the line vanished and only its dots were left floating over
   the zone bands. It is the foreground, so it takes the brightest text ink. */
:root[data-theme] .breadth-trend-line { stroke: var(--text-brightest); stroke-width: 1.75; }
:root[data-theme] .breadth-trend-dot { stroke: var(--bg-panel); }

/* Both grids used --bg-raised, a card colour -- white on the light theme, so
   the grid drew white on a white card. */
:root[data-theme] .breadth-trend-gridline,
:root[data-theme] .ck-gridline { stroke: var(--chart-grid); }

:root[data-theme] .breadth-trend-axis-label,
:root[data-theme] .ck-axis { fill: var(--text-dim); font-size: 10.5px; }

/* The zone names are written in their band colour (a fill ATTRIBUTE set by
   breadth.js). On light, ui.js recolours them -- same hue, saturated, deep
   enough for 4.5:1 -- see "Inline colours" below. */

:root[data-theme] .ck-tooltip,
:root[data-theme] .breadth-tooltip {
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--pop-shadow);
    color: var(--text);
}

:root[data-theme] .ck-legend { color: var(--text-muted); }

/* styles.css kept this tooltip dark on the light theme and forced its text
   pale to match. It follows the theme now, so its text does too. */
:root[data-theme="light"] .breadth-tooltip { color: var(--text); }
:root[data-theme="light"] .breadth-tooltip .breadth-tooltip-row { color: var(--text-dim); }
:root[data-theme="light"] .breadth-tooltip .breadth-tooltip-row b { color: var(--text-brightest); }

/* The same zone colours written as inline style="color:..." are recoloured
   by ui.js on light; see "Inline colours" below. */

/* Tinted pills: a translucent wash of the signal colour behind text in the
   same colour. On navy the text is bright and the wash dark; on white the
   wash goes pale and the bright text sits at 1.6-2.9:1 on it. The first
   stylesheet audit skipped any rule that set its own background, so these
   were found by a second pass that looked for exactly this shape (27 rules),
   and by checking the rendered pages. Light only: dark was right. */
:root[data-theme="light"] .paper-buy-btn,
:root[data-theme="light"] .pnl-badge-target,
:root[data-theme="light"] .mywl-live-badge,
:root[data-theme="light"] .timing-state.on,
:root[data-theme="light"] .timing-verdict-good,
:root[data-theme="light"] .turn-stage-confirmed,
:root[data-theme="light"] .turn-verdict-candidate,
:root[data-theme="light"] .turn-stage-recovery,
:root[data-theme="light"] .turn-new { color: var(--pos); }

:root[data-theme="light"] .context-badge-partial,
:root[data-theme="light"] .accum-state-chip.is-firing,
:root[data-theme="light"] .new-member-chip,
:root[data-theme="light"] .news-badge,
:root[data-theme="light"] .timing-verdict-weak,
:root[data-theme="light"] .turn-stage-repair,
:root[data-theme="light"] .turn-board,
:root[data-theme="light"] .turn-thin-count,
:root[data-theme="light"] .turn-verdict-verify,
:root[data-theme="light"] .turn-stage-pre-turn,
:root[data-theme="light"] .bt-mkt { color: var(--warn); }

:root[data-theme="light"] .news-source-exchange,
:root[data-theme="light"] .turn-stage-setup,
:root[data-theme="light"] .turn-verdict-watch { color: var(--accent-strong); }

:root[data-theme="light"] .timing-verdict-bad,
:root[data-theme="light"] .bt-neg { color: var(--neg); }

:root[data-theme="light"] .coiled-scan-muted,
:root[data-theme="light"] .bt-shown,
:root[data-theme="light"] .pb-v-none { color: var(--text-dim); }

/* Inline colours. Many screens write a label's colour straight into the
   markup -- style="color:${c}" from a JS map of classification colours, a
   "WORKED" badge, a zone name -- every one picked on navy. On light, ui.js
   recomputes each one: same hue, saturation held at 70%+, darkened only
   until it clears 4.5:1 on white, yellows turned toward amber (a darkened
   yellow is olive). The first version darkened them with a brightness()
   filter: legible, but it turned amber to brown and green to near-black, and
   the owner's side-by-side showed the colour had stopped meaning anything. */

:root[data-theme="light"] .pnl-badge-sl,
:root[data-theme="light"] .pnl-close-btn { color: var(--neg); }

/* #279d82, the old "up" teal, in pills on a teal wash: 2.8:1 on light. */
:root[data-theme="light"] .context-badge-full,
:root[data-theme="light"] .check-chip-done,
:root[data-theme="light"] .classification-badge-bottom,
:root[data-theme="light"] .accum-agree-pin,
:root[data-theme="light"] .breadth-stat-up,
:root[data-theme="light"] .news-source { color: var(--pos); }
:root[data-theme="light"] .turn-stage-wc-release { color: #6d3fc0; }
:root[data-theme="light"] .bt-link { color: var(--link); }
/* An "off" leg is meant to recede, not to disappear: the faintest text ink,
   which still holds 4.5:1 on white. */
:root[data-theme] .mr-leg-off { color: var(--text-faintest); }

/* Illiquid strikes are dimmed on purpose, to the faintest ink rather than a
   literal grey that sat at 2.8:1 on navy and lower on white. */
:root[data-theme] #fnoChainTable td.fno-illiquid,
:root[data-theme] #fnoChainTable td.fno-illiquid * { color: var(--text-faintest); }

/* At 1440 the bar measured 1,524px of content in 1,440 and pushed Log Out
   off the right edge (the bar scrolls, so it was reachable, but nobody looks
   for Log Out by scrolling). Tighter tabs fit 1440; below that the wordmark
   goes (the mark stays) and the user name truncates, which is enough down to
   1280. Narrower still, the bar scrolls as styles.css always arranged. */
:root[data-theme] .app-nav-btn { padding: 6px 9px; font-size: 12.5px; }
:root[data-theme] .theme-choice { width: 26px; }

@media (max-width: 1480px) {
    :root[data-theme] .app-nav-btn { padding: 6px 7px; font-size: 12px; }
    :root[data-theme] #appBrandName { display: none; }
    :root[data-theme] #appBrand { padding-right: 10px; margin-right: 4px; }
    :root[data-theme] .auth-badge {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    :root[data-theme] .auth-logout-btn { padding: 5px 9px; }
}

/* Buttons with no class at all ("Read" on Today, many dialog and table
   actions) fell through to the browser's default grey box. :where() keeps
   the whole selector at ZERO specificity, so any rule that styles a button
   anywhere still wins; this only replaces the browser default. */
:where(:root[data-theme] button:not([class])) {
    background: var(--bg-raised);
    color: var(--text-bright);
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    padding: 3px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

:where(:root[data-theme] button:not([class])):hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

:where(:root[data-theme] button:not([class])):disabled {
    opacity: 0.45;
    cursor: default;
}

/* A tray squeezed by its neighbours wrapped its own options onto two rows,
   and the buttons beside it broke their labels ("Force / Refresh All").
   Neither may shrink; the toolbar wraps as a whole instead. */
:root[data-theme] .rotation-level-toggle { flex-shrink: 0; }
:root[data-theme] [id$="Toolbar"] { flex-wrap: wrap; row-gap: 8px; }
:root[data-theme] [id$="Toolbar"] button,
:root[data-theme] .rotation-subtoolbar button { white-space: nowrap; }

/* Second readability pass (owner, 2026-10-01: "more readable and high
   visible in light theme"). The bar moved from 3:1 to 4.5:1, the normal-
   text standard, and this is everything between the two: mostly the bright
   reds (#ef5350, #f44336, #ff5252, #f85149) that read at 3.2-3.7 on white.
   Found by the stylesheet walk at 4.5, then confirmed on the rendered pages. */
:root[data-theme="light"] #stockSearchExitButton,
:root[data-theme="light"] .ema-breadth-panel .mtf-rsi-value .ema-breadth-below,
:root[data-theme="light"] .ew-rev-down,
:root[data-theme="light"] .ew-check-fail .ew-check-mark,
:root[data-theme="light"] .mtf-rsi-value.mtf-rsi-overbought,
:root[data-theme="light"] .mtf-rsi-value.rs-weak,
:root[data-theme="light"] .mtf-rsi-value.ms-down,
:root[data-theme="light"] .dialog-error,
:root[data-theme="light"] .custom-index-row button,
:root[data-theme="light"] .rsi-level-row button,
:root[data-theme="light"] .fib-levels-editor-remove,
:root[data-theme="light"] .alert-row.alert-failure .alert-row-meta,
:root[data-theme="light"] .breadth-stat-down,
:root[data-theme="light"] .paper-sell-btn,
:root[data-theme="light"] .paper-pnl-negative,
:root[data-theme="light"] .mywl-remove-btn:hover,
:root[data-theme="light"] .price-alert-del-btn:hover,
:root[data-theme="light"] #adminUserDialogError,
:root[data-theme="light"] #adminPasswordError,
:root[data-theme="light"] .timing-month-bad td,
:root[data-theme="light"] .turn-stage-excluded,
:root[data-theme="light"] .turn-verdict-avoid,
:root[data-theme="light"] .turn-stage-dropped,
:root[data-theme="light"] .turn-tg-table .is-dn { color: var(--neg); }

:root[data-theme="light"] .breadth-zone-greed,
:root[data-theme="light"] .ticker-copy-done { color: var(--pos) !important; }

:root[data-theme="light"] .turn-verdict-ignore,
:root[data-theme="light"] .turn-verdict-unread { color: var(--text-dim); }
/* "/3" after a score is secondary, but at 0.6 opacity on the tinted pill it
   fell under 3:1 on light. Smaller and lighter in weight already says
   "secondary"; the fade is kept only on dark, where it still reads. */
:root[data-theme="light"] .ratio-score-of { opacity: 0.85; }

/* Inline fades (style="opacity:.55" on a secondary figure, .4 on a "none"
   mark) were set against navy, where faded ink still reads. On white a
   .55-faded label is 3.9:1 and a .4 one 2.5. Drawn at full opacity on light
   (0.8 was tried and was not enough once ui.js had recoloured the text for
   5.3:1 at full strength). The SPACED form is matched too: when ui.js sets
   style.color the browser re-serialises the attribute as "opacity: 0.8",
   and an unspaced-only selector silently stopped matching. A bare
   "opacity: 0" (a script hiding something) has no dot and is not caught. */
:root[data-theme="light"] [style*="opacity:."],
:root[data-theme="light"] [style*="opacity:0."],
:root[data-theme="light"] [style*="opacity: ."],
:root[data-theme="light"] [style*="opacity: 0."] { opacity: 1 !important; }

/* Stage ribbon (Stage Setups, Turnaround). styles.css's light values read
   3.0-4.5:1 on their own 10% tint, lower on the counts, which are faded. */
:root[data-theme="light"] {
    --stage-1: #1d4ed8;
    --stage-2: #0f6a32;
    --stage-3: #934204;
    --stage-4: #c01b1b;
}

/* ------------------------------------------------------------------ */
/* Tokens used but never defined                                       */
/* ------------------------------------------------------------------ */

/* Eight var() names in styles.css point at tokens no theme defines, so each
   fell back to whatever literal sat beside it -- in both themes. The worst:
   the Earnings delivery grid's sticky name column and header used
   var(--panel-bg, #1c1f26), a dark fallback, so on the light theme the
   industry names were near-black on near-black (1.0:1). Found by listing
   every var() name against every definition; none of the literal audits
   could see it, because each skipped any value written as var(). Defined
   here as aliases of the real tokens, so they follow the theme. --bg and
   --fg had no fallback at all, so the turnaround tabs' hover and the stage
   groups' background silently resolved to nothing. */
:root[data-theme],
:root:not([data-theme]) {
    --panel-bg: var(--bg-panel);
    --bg:       var(--bg-panel);
    --fg:       var(--text-brightest);
    --bg-elev:  var(--bg-sunken);
    --muted:    var(--text-dim);
    --rule:     var(--border-strong);
    --up:       var(--pos);
    --down:     var(--neg);
}

/* Dark, at the same 4.5:1 bar. The grey ladder above was lifted for it (the
   faintest step was 2.9:1 on a card); these are the signal colours that sat
   between 3 and 4.5 on navy: the zone greys and reds Breadth writes inline,
   and the timing chips on their tinted wash. */
:root[data-theme="dark"] .breadth-segment-desc b,
:root[data-theme="dark"] .breadth-zone-chip,
:root[data-theme="dark"] .breadth-tooltip-zone,
:root[data-theme="dark"] .breadth-trend-band-label { filter: brightness(1.4); }
:root[data-theme="dark"] .breadth-stat-down,
:root[data-theme="dark"] .timing-verdict-bad { color: var(--neg); }
:root[data-theme="dark"] .timing-state.on,
:root[data-theme="dark"] .timing-verdict-good { color: var(--pos); }
:root[data-theme] .ratio-score-of { opacity: 0.85; }
:root[data-theme="light"] .stage-zone .zc { opacity: 1; }
/* An "off" leg (I / C / M not up) faded to .55 -- 3.9:1 on white. It reads
   as off by having no fill beside the filled "up" legs; it does not also
   need to be faint. */
:root[data-theme="light"] .ratio-stock-leg { opacity: 0.8; }
:root[data-theme="light"] .ratio-stock-leg.is-up { opacity: 1; }
/* The ratio board's "Surge · laggard" label: a surge in an industry at 0 or 1
   of 3, measured behind the median industry. Warning ink, not the red of a
   loss: it describes a move, it is not a sell. */
.ratio-mark-lag { color: var(--warn); border: 1px solid var(--warn); }

/* ------------------------------------------------------------------ */
/* Tracks, separators and washes that were white on white              */
/* ------------------------------------------------------------------ */

/* Found from the owner's side-by-side of Market Breadth: in dark each
   "% above EMA" bar sits on a track showing the whole 0-100 scale; in light
   the track was --bg-raised -- a card colour, white -- so a 30% bar floated
   with nothing to be 30% OF. Every --bg-raised used as a line, track or hover
   rather than as a card had the same fault, and so did every faint WHITE
   wash (rgba(255,255,255,.02-.12)) written to lift something off navy: on a
   white card it lifts nothing. On light those become a dark wash of the
   same weight. */
:root[data-theme] .breadth-ema-track { background: var(--bg-sunken); }
:root[data-theme="light"] .breadth-ema-track { background: #e3e8f0; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04); }
:root[data-theme] .breadth-ema-fill { background: var(--pos); }
:root[data-theme] .breadth-ema-fill-below { background: var(--neg); }

:root[data-theme] .alert-row,
:root[data-theme] .breadth-segment { border-bottom-color: var(--row-line); }

:root[data-theme="light"] .stage-groups th { background: var(--th-bg); }
:root[data-theme="light"] .stage-group-row:hover td,
:root[data-theme="light"] .stage-group-row.active td { background: var(--row-hover); }

:root[data-theme="light"] #earningsTotalsTable tbody tr:hover,
:root[data-theme="light"] .ema-breadth-panel:hover,
:root[data-theme="light"] .ema-member:hover { background: rgba(15, 23, 42, 0.05); }

:root[data-theme="light"] .ema-members-count,
:root[data-theme="light"] .vd-track-tall,
:root[data-theme="light"] .coiled-scan-muted,
:root[data-theme="light"] .coiled-band-fair,
:root[data-theme="light"] .bt-shown,
:root[data-theme="light"] .pb-v-none,
:root[data-theme="light"] .ratio-state-flat { background: rgba(15, 23, 42, 0.07); }

:root[data-theme="light"] .vd-visuals,
:root[data-theme="light"] .turn-verdict-panel,
:root[data-theme="light"] .turn-replay-card,
:root[data-theme="light"] .pb-step-none,
:root[data-theme="light"] #coiledTable tr.coiled-detail > td,
:root[data-theme="light"] #ratioBoardTable tr.ratio-detail-row > td { background: var(--th-bg); }

:root[data-theme="light"] .vd-tick { background: rgba(15, 23, 42, 0.25); }
:root[data-theme="light"] .ratio-sib-bar { background: rgba(15, 23, 42, 0.10); }
:root[data-theme="light"] .pb-step-none { border-color: var(--border-strong); }

/* ------------------------------------------------------------------ */
/* Light colours that carry their colour                               */
/* ------------------------------------------------------------------ */

/* The owner's side-by-side of Ratio Scan's Stocks level: in dark every
   coloured word reads as its colour; in light the same words read as dark
   text. Contrast was not the problem (all passed 4.5:1) -- lightness was.
   styles.css's light corrections chose #14532d for green (20% lightness),
   #8a1f17 for red and #7a5a12 for amber: legible, and indistinguishable from
   body text at a glance, which is the whole job of a coloured label.

   Each rule below is styles.css's own light correction recomputed, not
   hand-picked: same hue, saturation held at 72%+, and the HIGHEST lightness
   that still clears 5:1 on white (4.6:1 on the rule's own tinted chip), so
   it is as vivid as legibility allows. Yellows turn to amber, because a dark
   yellow is olive. Generated in the browser from the parsed sheets; the
   signal tokens above (--pos #13773a, --neg #c01b1b, --warn #a64b05) follow
   the same principle. */
:root[data-theme="light"] .ratio-save-btn { color: #a85a00; }
:root[data-theme="light"] .pnl-autoclose-note { color: #a85a00; }
:root[data-theme="light"] .mr-leg-rare { color: #a85a00; }
:root[data-theme="light"] .fno-bu-short, :root[data-theme="light"] .fno-ivrank.fno-iv-high { color: #c52042; }
:root[data-theme="light"] .fno-bu-unwind, :root[data-theme="light"] .fno-hz-chip { color: #975b16; }
:root[data-theme="light"] .fno-bu-cover, :root[data-theme="light"] .fno-hz-aligned { color: #1e67b8; }
:root[data-theme="light"] .fno-hz-warning { color: #9a6219; }
:root[data-theme="light"] .fno-hz-warning b { color: #9a6319; }
: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: #a06018; }
:root[data-theme="light"] .mr-setup-4 { color: #137231; }
:root[data-theme="light"] .mr-setup-3 { color: #137630; }
:root[data-theme="light"] .coiled-tier-A { color: #13763b; }
:root[data-theme="light"] .coiled-band-dear { color: #c12b1f; }
:root[data-theme="light"] .coiled-band-cheap { color: #13763b; }
:root[data-theme="light"] .mr-extended { color: #a85a00; }
:root[data-theme="light"] .bottoms-preset.active { color: #245edb; }
:root[data-theme="light"] .bt-ev-good, :root[data-theme="light"] .bt-gate { color: #13763b; }
:root[data-theme="light"] .bt-down { color: #d32c22; }
:root[data-theme="light"] .bt-phase-1, :root[data-theme="light"] .bt-phase-2, :root[data-theme="light"] .bt-phase-3 { color: #1e6fb8; }
:root[data-theme="light"] .bm-split { color: #1e6fb8; }
:root[data-theme="light"] .pb-step-good { color: #147b3d; }
:root[data-theme="light"] .pb-step-fund { color: #1f68c1; }
:root[data-theme="light"] .pb-v-good { color: #13763b; }
:root[data-theme="light"] .pb-v-fund { color: #1f68c1; }
:root[data-theme="light"] .pb-v-weak { color: #975b16; }
:root[data-theme="light"] .pb-v-bad { color: #c12b1f; }
:root[data-theme="light"] .pb-open { color: #1e6fb8; }
:root[data-theme="light"] .ratio-score-top { color: #137238; }
:root[data-theme="light"] .ratio-score-0 { color: #c12b1f; }
:root[data-theme="light"] .ratio-state-down { color: #c12b1f; }
:root[data-theme="light"] .ratio-mark-cont { color: #157f3a; }
:root[data-theme="light"] .ratio-confirmed { color: #137238; }
:root[data-theme="light"] .ratio-stock-leg.is-up { color: #137238; }
:root[data-theme="light"] .ratio-stock-conf { color: #157f3f; }
:root[data-theme="light"] .ratio-chip.is-good { color: #157f3f; }
:root[data-theme="light"] #ratioStocksTable td.ratio-stock-fresh { color: #157f3f; }
:root[data-theme="light"] .ratio-stocks-viewline { color: #13723a; }
:root[data-theme="light"] #ratioStocksTable td.ratio-stock-below { color: #d72323; }
:root[data-theme="light"] .ratio-stocks-viewline.is-search { color: #236cd7; }

/* The score chips and lit legs: a saturated green wash on light, so a 3/3
   reads as a green chip the way it does on navy, not a grey one. */
:root[data-theme="light"] .ratio-score-top,
:root[data-theme="light"] .ratio-stock-leg.is-up { background: #d2f4dd; border-color: #b4e8c5; }
:root[data-theme="light"] .ratio-score-2 { background: #e2f6e8; color: #137238; }
:root[data-theme="light"] .timing-state.on,
:root[data-theme="light"] .timing-verdict-good { background: var(--pos-bg); color: #137033; }
:root[data-theme="light"] .timing-verdict-bad { background: var(--neg-bg); }
:root[data-theme="light"] .timing-verdict-weak { background: var(--warn-bg); color: #a24a07; }
:root[data-theme="light"] .ratio-score-of { opacity: 1; }

/* ------------------------------------------------------------------ */
/* Opacity fades on light                                              */
/* ------------------------------------------------------------------ */

/* Secondary text faded with opacity (0.45-0.75) is a dark-theme habit: on
   navy a faded label is still light-on-dark; on white it greys out to
   1.5-3:1. Found when the popups were checked one by one -- the Turnaround
   card's "not earned" ledger lines measured 1.5:1, Score history's flicker
   rows 2.5:1. Every such rule in styles.css (a walk of the parsed sheets for
   text faded below 0.85, minus disabled/hidden/hover states and the purely
   graphic ones -- .turn-dim-fill, the empty ribbon segments) is drawn at
   full opacity in the dim text ink instead. Holding the fade at 0.85 was
   tried first and failed wherever the faded element holds a COLOURED mark
   (the ledger's ✓ and −, the valuation scale's anchor and "today"): a fade
   dims everything inside it, a text colour dims only the uncoloured text.
   Applied to BOTH themes: dark measured the same fault (Score history's
   flicker rows at 2.8:1 on navy), and the dim ink reads on either ground. */
:root[data-theme] .actionscan-history-item em,
:root[data-theme] .ema-members-sub,
:root[data-theme] .ema-members-empty,
:root[data-theme] .vd-row .vd-note,
:root[data-theme] .vd-label,
:root[data-theme] .vd-unit,
:root[data-theme] .vd-scale,
:root[data-theme] .vd-note,
:root[data-theme] .timing-meaning,
:root[data-theme] .timing-state.off,
:root[data-theme] .timing-verdict-none,
:root[data-theme] .turn-hist-empty,
:root[data-theme] .turn-verdict-total span,
:root[data-theme] .turn-verdict-note,
:root[data-theme] .turn-dim-v span,
:root[data-theme] .turn-dim-n,
:root[data-theme] .turn-ledger .is-missed,
:root[data-theme] .turn-ledger-pts,
:root[data-theme] .turn-target-head span,
:root[data-theme] .turn-tg-inputs,
:root[data-theme] .turn-tg-notes,
:root[data-theme] .turn-tg-foot,
:root[data-theme] .turn-replay-card-label,
:root[data-theme] .turn-replay-card-sub,
:root[data-theme] .ratio-stock-leg,
:root[data-theme] .track-waiting td,
:root[data-theme] .track-thin td,
:root[data-theme] .ratio-hist-flicker td { opacity: 1; color: var(--text-dim); }
:root[data-theme] .ratio-stock-leg.is-up { opacity: 1; }
:root[data-theme] .turn-tg-table .turn-tg-ceiling td { opacity: 1; }

/* The Report page had no layout rules at all: its toolbar, list and notes
   sat flush against the window's left edge, the only page that did. Same
   gutter as every other screen. (#reportListWrap carries an inline margin,
   hence !important.) */
:root[data-theme] #reportToolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}
:root[data-theme] #reportListWrap { margin: 12px 16px !important; }
:root[data-theme] #reportEmptyState { margin: 8px 16px; }

/* P&L and Watchlist put their headings, notes and tables straight into the
   view with no wrapper, so all three sat on the window's left edge (found by
   a walk of every view for visible text under 6px from the edge; Report was
   the third). The view takes the gutter; the toolbar steps back out of it so
   its band still runs edge to edge like every other page's. */
:root[data-theme] #viewPnl,
:root[data-theme] #viewMywatchlist { padding: 0 16px 16px; box-sizing: border-box; overflow-y: auto; }
:root[data-theme] #pnlToolbar,
:root[data-theme] #mywlToolbar { margin: 0 -16px 4px; }
:root[data-theme] #viewPnl > h3,
:root[data-theme] #pnlManualPane > h3,
:root[data-theme] #pnlAutoPane h3,
:root[data-theme] #viewMywatchlist > h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 650; color: var(--text-brightest); }

/* P&L > Momentum auto (pnlauto.js, 2026-11-04). The toolbar carries both
   sub-pages' controls and the view's class says which are shown; !important
   because the toolbar's id rules set display on its buttons. */
:root[data-theme] #viewPnl:not(.pnl-auto-mode) .pnl-auto-ctl,
:root[data-theme] #viewPnl.pnl-auto-mode .pnl-manual-ctl { display: none !important; }
:root[data-theme] #pnlAutoPane .portfolio-tiles { margin-top: 12px; }
:root[data-theme] .pnl-auto-curve { display: block; width: 100%; max-width: 1100px; height: auto; margin: 12px 0 4px; }
:root[data-theme] .pnl-auto-curve .pnl-auto-base { stroke: var(--chart-grid); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
:root[data-theme] .pnl-auto-curve path { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
:root[data-theme] .pnl-auto-curve .pnl-auto-line-up { stroke: var(--pos); }
:root[data-theme] .pnl-auto-curve .pnl-auto-line-down { stroke: var(--neg); }
:root[data-theme] .pnl-auto-curve .pnl-auto-axis { fill: var(--text-dim); font-size: 11px; }
:root[data-theme] .pnl-auto-note { color: var(--text-dim); font-size: 12px; margin: 6px 0 0; }
:root[data-theme] .pnl-auto-banner { margin: 12px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg-raised); color: var(--text); font-size: 13px; line-height: 1.45; }
:root[data-theme] .pnl-auto-empty { color: var(--text-dim); text-align: left !important; }
:root[data-theme] .pnl-auto-skipped { margin-top: 18px; }
:root[data-theme] .pnl-auto-skipped > summary { cursor: pointer; font-size: 14px; font-weight: 650; color: var(--text-brightest); }
:root[data-theme] .pnl-auto-table th[data-key] { cursor: pointer; }
:root[data-theme="dark"] .ratio-stock-leg.is-up { color: #d6f5de; }

/* The alert list opened BEHIND the page. It is positioned inside #appNav,
   and #appNav scrolls sideways (overflow-x: auto, so that all fourteen tabs
   stay reachable on a narrow window) -- and a scrolling box clips anything
   that overflows it, in both directions. The list was cut off at the nav's
   bottom edge and the toolbar showed through where it should have been.
   Fixed positioning takes it out of the nav's box; ui.js places it under the
   bell each time it opens. */
:root[data-theme] #alertDropdown {
    position: fixed;
    z-index: 2000;
    max-height: min(480px, calc(100vh - 80px));
}

/* ------------------------------------------------------------------ */
/* Chart cards: hide / show per chart (chartcards.js)                  */
/* ------------------------------------------------------------------ */

/* The reader's choice, on top of the screen's own style.display. */
:root[data-theme] .chart-top-right-panels .chart-card-hidden { display: none !important; }

/* The cards let the mouse through to the chart (pointer-events: none in
   styles.css, so the chart can be dragged underneath them), which means a
   card cannot be hovered to reveal its button. The button is therefore
   always there, faint, in the corner, and is the one part that takes the
   mouse. Its glyph is CSS so the card's text -- which the screenshot export
   copies -- gains nothing. */
:root[data-theme] .chart-top-right-panels > .mtf-rsi-panel { position: relative; }
:root[data-theme] .chart-card-hide {
    /* A badge on the card's top-left corner, half outside it: inside, it sat
       on the right-aligned values ("41.3x"). */
    position: absolute;
    top: -7px;
    left: -7px;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--bg-panel);
    color: var(--text-dim);
    opacity: 0.55;
    cursor: pointer;
    pointer-events: auto;
    line-height: 13px;
    font-size: 12px;
}
:root[data-theme] .chart-card-hide::before { content: "\00d7"; }
:root[data-theme] .chart-card-hide:hover {
    opacity: 1;
    color: var(--text-brightest);
    background: var(--bg-raised);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* A hidden card leaves a chip to bring it back, in the same corner. */
:root[data-theme] .chart-card-tray {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
:root[data-theme] .chart-card-chip {
    pointer-events: auto;
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 9px 2px 7px;
    border-radius: 999px;
    border: 1px dashed var(--border-bright);
    background: var(--bg-panel);
    color: var(--text-dim);
    cursor: pointer;
    box-shadow: var(--card-shadow);
}
:root[data-theme] .chart-card-chip::before { content: "+ "; color: var(--accent-strong); font-weight: 700; }
:root[data-theme] .chart-card-chip:hover { color: var(--text-brightest); border-style: solid; border-color: var(--accent); }

/* The chart's own right-click menu. */
:root[data-theme] .chart-context-menu {
    display: none;
    position: absolute;
    z-index: 2100;
    min-width: 220px;
    padding: 5px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--pop-shadow);
}
:root[data-theme] .chart-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    padding: 6px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-bright);
    font: inherit;
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
}
:root[data-theme] .chart-menu-item:hover { background: var(--accent-soft); color: var(--text-brightest); }
:root[data-theme] .chart-menu-item.is-check { padding-left: 28px; position: relative; }
:root[data-theme] .chart-menu-item.is-check.checked::before {
    content: "\2713";
    position: absolute;
    left: 10px;
    color: var(--accent-strong);
    font-weight: 700;
}
:root[data-theme] .chart-menu-hint { color: var(--text-dim); font-size: 11px; }
:root[data-theme] .chart-menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }
:root[data-theme] .chart-menu-head {
    padding: 4px 10px 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
}

/* Delete sits apart from Cancel / Ok in the properties footer. */
:root[data-theme] .tool-props-footer .tool-props-delete {
    color: var(--neg);
    border-color: var(--neg-bg);
    background: transparent;
}
:root[data-theme] .tool-props-footer .tool-props-delete:hover { background: var(--neg-bg); border-color: var(--neg); }
:root[data-theme] .tool-props-footer .tool-props-default-label { margin-left: auto; }

/* ---------------------------------------------------------------------------
   Sector & Industry Breadth (groupbreadth.js). Every colour is a token, so
   both themes follow without a redraw.

   Two colour jobs, kept apart:
   - DIVERGING, on the Ranking bars and the Week-by-week cells: a group's share
     against the whole market's share that week. Green above (--pos), red below
     (--neg), grey within two points (--gb-mid, no hue at the midpoint); depth
     is the distance, as --d (0..1) set per element by the script. Heat cells
     mix at most 42% of the hue into the card, which keeps --text at 5:1 or
     better on the deepest cell in both themes (the earlier blue at 55% fell to
     3.8:1 on dark).
   - CATEGORICAL, on the Trend lines: eight fixed slots, the dataviz skill's
     validated palette, each stepped for its theme. A line keeps its slot when
     others are removed (groupbreadth.js togglePick).
   ------------------------------------------------------------------------- */
:root {
    --gb-mid: #4d5b72;
    --gb-c1: #3987e5; --gb-c2: #d95926; --gb-c3: #199e70; --gb-c4: #c98500;
    --gb-c5: #d55181; --gb-c6: #008300; --gb-c7: #9085e9; --gb-c8: #e66767;
}
:root[data-theme="light"] {
    --gb-mid: #b3bccb;
    --gb-c1: #2a78d6; --gb-c2: #eb6834; --gb-c3: #1baf7a; --gb-c4: #eda100;
    --gb-c5: #e87ba4; --gb-c6: #008300; --gb-c7: #4a3aa7; --gb-c8: #e34948;
}

#groupBreadthCard { display: flex; flex-direction: column; gap: 10px; }
.gb-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.gb-controls label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12.5px; font-weight: 500; }
.gb-controls label[hidden] { display: none; }
.gb-summary { color: var(--text); font-size: 13px; line-height: 1.6; }
.gb-summary strong { color: var(--text-bright); }
.gb-refs { color: var(--text-dim); font-size: 12px; }
.gb-up { color: var(--pos); }
.gb-down { color: var(--neg); }
.gb-tabs { align-self: flex-start; }
.gb-pane { min-width: 0; }
/* Only the table scrolls sideways; the key above it stays in view. */
.gb-scroll { overflow-x: auto; }
.gb-pane[hidden] { display: none; }
.gb-empty { color: var(--text-dim); font-size: 12.5px; }

:root[data-theme] .gb-table td.gb-name { text-align: left; min-width: 150px; max-width: 260px; }
.gb-sub { display: block; color: var(--text-dim); font-size: 11px; font-weight: 400; }
.gb-table tbody tr[data-group] { cursor: pointer; }
:root[data-theme] .gb-table tbody tr.gb-open td:not(.gb-cell) { background: var(--accent-soft); }
/* The sticky name cell must stay opaque, or the weeks scrolling under it show through. */
:root[data-theme] .gb-heat tbody tr.gb-open td.gb-name { background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-deeper); }
.gb-table td.num { white-space: nowrap; }

/* The key above each table: what green, red, grey and the two marks mean. */
.gb-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 2px 0 8px; font-size: 12px; color: var(--text); }
.gb-key > span { display: inline-flex; align-items: center; gap: 6px; }
.gb-keynote { color: var(--text-dim); }
.gb-keyswatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.gb-keytick { display: inline-block; width: 2px; height: 12px; background: var(--text-bright); border-radius: 1px; }
.gb-keyline { display: inline-block; height: 12px; border-left: 1px dashed var(--text-dim); }

/* Diverging fills: bars and key swatches. */
.gb-fill.gb-above, .gb-keyswatch.gb-above { background: color-mix(in srgb, var(--pos) calc(40% + var(--d, 0) * 60%), var(--bg-deeper)); }
.gb-fill.gb-below, .gb-keyswatch.gb-below { background: color-mix(in srgb, var(--neg) calc(40% + var(--d, 0) * 60%), var(--bg-deeper)); }
.gb-fill.gb-level, .gb-keyswatch.gb-level { background: var(--gb-mid); }
.gb-fill.gb-na { background: transparent; }
/* On white, the same mix reads as pastel -- the washed-out colour the owner
   flagged -- so light starts deeper. */
:root[data-theme="light"] .gb-fill.gb-above, :root[data-theme="light"] .gb-keyswatch.gb-above { background: color-mix(in srgb, var(--pos) calc(62% + var(--d, 0) * 38%), var(--bg-deeper)); }
:root[data-theme="light"] .gb-fill.gb-below, :root[data-theme="light"] .gb-keyswatch.gb-below { background: color-mix(in srgb, var(--neg) calc(62% + var(--d, 0) * 38%), var(--bg-deeper)); }
/* The table's own cell rule sets every td's colour and outranks a bare class,
   which left the Change column uncoloured in both themes. */
:root[data-theme] .gb-table td.gb-up { color: var(--pos); }
:root[data-theme] .gb-table td.gb-down { color: var(--neg); }

/* Ranking bars: the fill is now, the white mark is the comparison week, the
   dashed line is the whole market's share. */
.gb-barcell { min-width: 140px; width: 30%; }
/* The table right-aligns every header, which put "Share of group" over the
   percentages at the far end of a wide cell instead of over its bars. */
:root[data-theme] .gb-table th.gb-barhead { text-align: left; }
.gb-bar { display: flex; align-items: center; gap: 8px; height: 20px; }
.gb-track { position: relative; flex: 1 1 auto; height: 100%; }
.gb-fill { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 0 4px 4px 0; }
.gb-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text-bright); border-radius: 1px; z-index: 1; }
.gb-mktline { position: absolute; top: -3px; bottom: -3px; border-left: 1px dashed var(--text-dim); z-index: 1; }
.gb-val { flex: 0 0 auto; min-width: 56px; font-variant-numeric: tabular-nums; color: var(--text); font-size: 12px; white-space: nowrap; }

/* Week-by-week heatmap. */
:root[data-theme] .gb-heat td.gb-cell {
    text-align: center;
    min-width: 34px;
    padding: 6px 4px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    border-left: 2px solid var(--bg-deeper, transparent);
}
:root[data-theme] .gb-heat td.gb-cell.gb-above { background: color-mix(in srgb, var(--pos) calc(8% + var(--d, 0) * 34%), transparent); }
:root[data-theme] .gb-heat td.gb-cell.gb-below { background: color-mix(in srgb, var(--neg) calc(8% + var(--d, 0) * 34%), transparent); }
:root[data-theme] .gb-heat td.gb-cell.gb-level { background: color-mix(in srgb, var(--gb-mid) 18%, transparent); }
/* Light needs more of the hue to read as coloured rather than tinted. At the
   deepest (65%) --text still clears 5:1 on both --pos and --neg. */
:root[data-theme="light"] .gb-heat td.gb-cell.gb-above { background: color-mix(in srgb, var(--pos) calc(14% + var(--d, 0) * 51%), transparent); }
:root[data-theme="light"] .gb-heat td.gb-cell.gb-below { background: color-mix(in srgb, var(--neg) calc(14% + var(--d, 0) * 51%), transparent); }
:root[data-theme="light"] .gb-heat td.gb-cell.gb-level { background: color-mix(in srgb, var(--gb-mid) 35%, transparent); }
:root[data-theme] .gb-heat td.gb-now { font-weight: 600; color: var(--text-bright); }
:root[data-theme] .gb-heat tr.gb-mktrow td { border-top: 2px solid var(--border-strong); color: var(--text-dim); font-weight: 600; }
.gb-heat th.gb-wk { font-weight: 500; color: var(--text-dim); }
:root[data-theme] .gb-heat th { padding-left: 4px; padding-right: 4px; text-align: center; }
:root[data-theme] .gb-heat th:first-child { text-align: left; }
/* The name stays put while the weeks scroll under it on a narrow window. */
:root[data-theme] .gb-heat td.gb-name,
:root[data-theme] .gb-heat th:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg-deeper); }
:root[data-theme] .gb-heat thead th:first-child { background: var(--th-bg); }

.gb-pick {
    background: transparent; color: var(--text-dim);
    border: 1px solid var(--border-strong); border-radius: 999px;
    padding: 1px 9px; font-size: 11.5px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.gb-pick:hover { color: var(--text-bright); border-color: var(--border-bright); }
.gb-pick.on { color: var(--text-bright); border-width: 2px; padding: 0 8px; }

/* Trend chart. */
.gb-trend-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.gb-trend-controls select { max-width: 280px; }
.gb-quick {
    background: var(--bg-raised); color: var(--text-bright);
    border: 1px solid var(--border-strong); border-radius: 8px;
    padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.gb-quick:hover { border-color: var(--border-bright); }
.gb-trend-wrap { position: relative; }
.gb-trend-svg { display: block; }
.gb-grid { stroke: var(--chart-grid); stroke-width: 1; }
.gb-axis { fill: var(--text-dim); font-size: 11px; font-family: inherit; }
.gb-endlabel { fill: var(--text); font-size: 11.5px; font-family: inherit; }
.gb-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.gb-dot { stroke: var(--bg-deeper, #000); stroke-width: 2; }
.gb-cross { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.gb-line.gb-mkt { stroke: var(--text-dim); stroke-dasharray: 5 4; }
.gb-dot.gb-mkt, .gb-endmark.gb-mkt { fill: var(--text-dim); }
.gb-swatch.gb-mkt { background: var(--text-dim); }
.gb-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text); margin-bottom: 4px; }
.gb-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.gb-swatch { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.gb-legend .gb-swatch { margin-right: 0; }
.gb-unpick {
    background: transparent; color: var(--text-dim); border: 0; padding: 0 2px;
    font: inherit; font-size: 14px; line-height: 1; cursor: pointer;
}
.gb-unpick:hover { color: var(--text-bright); }
.gb-tip {
    position: absolute; width: 240px; pointer-events: none; z-index: 2;
    background: var(--bg-raised); color: var(--text); border: 1px solid var(--border-strong);
    border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.6; box-shadow: var(--pop-shadow);
}
.gb-tip[hidden] { display: none; }
.gb-tip-date { color: var(--text-dim); }
.gb-note { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.gb-clear, .gb-close {
    background: transparent; color: var(--link); border: 0; padding: 0;
    font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline;
}

/* The eight categorical slots: line, end dot, label mark, legend swatch and
   the "On chart" button's ring all read the same token. */
.gb-c1 { --gb-c: var(--gb-c1); } .gb-c2 { --gb-c: var(--gb-c2); }
.gb-c3 { --gb-c: var(--gb-c3); } .gb-c4 { --gb-c: var(--gb-c4); }
.gb-c5 { --gb-c: var(--gb-c5); } .gb-c6 { --gb-c: var(--gb-c6); }
.gb-c7 { --gb-c: var(--gb-c7); } .gb-c8 { --gb-c: var(--gb-c8); }
.gb-line[class*="gb-c"] { stroke: var(--gb-c); }
.gb-dot[class*="gb-c"], .gb-endmark[class*="gb-c"] { fill: var(--gb-c); }
.gb-swatch[class*="gb-c"] { background: var(--gb-c); }
.gb-pick.on[class*="gb-c"] { border-color: var(--gb-c); }

/* The group popup (groupbreadth.js openGroup). Built on the Turnaround
   card's dialog shell -- head, scrolling body -- and a little wider, for a
   ten-column member table. */
dialog.gb-dialog { width: min(1180px, 96vw); }
.gb-dlg-body { padding: 14px 18px 18px; font-size: 12.5px; color: var(--text); }
.gb-sub-inline { color: var(--text-dim); font-size: 13px; font-weight: 400; margin-left: 6px; }
.gb-dlg-close {
    background: transparent; color: var(--text-dim); border: 0; font-size: 16px; cursor: pointer; padding: 2px 6px;
}
.gb-dlg-close:hover { color: var(--text-bright); }
.gb-dlg-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .gb-dlg-top { grid-template-columns: 1fr; } }
.gb-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gb-tile { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.gb-tile-k { color: var(--text-dim); font-size: 11.5px; }
.gb-tile-v { color: var(--text-bright); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
.gb-tile-v small { color: var(--text-dim); font-size: 12px; font-weight: 400; }
.gb-tile-s { color: var(--text-dim); font-size: 11.5px; }
.gb-dlg-reading p { margin: 0 0 6px; line-height: 1.5; }
.gb-dlg-reading b { color: var(--text-bright); }
.gb-dlg-h { margin: 16px 0 6px; font-size: 13px; color: var(--text-bright); font-weight: 600; }
.gb-dlg-chart { display: block; max-width: 100%; }
.gb-dlg-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 6px; }
.gb-count { color: var(--text-dim); font-variant-numeric: tabular-nums; margin-left: 2px; }
.gb-dlg-search { min-width: 180px; }
:root[data-theme] .gb-dlg-table th { vertical-align: bottom; line-height: 1.25; }
.gb-dlg-table th small { font-weight: 400; color: var(--text-dim); }
:root[data-theme] .gb-dlg-table td.gb-dlg-stock { text-align: left; white-space: nowrap; }
.gb-ticker {
    background: transparent; border: 0; padding: 0; font: inherit; font-weight: 600;
    color: var(--link); cursor: pointer;
}
.gb-ticker:hover { text-decoration: underline; }
.gb-status { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; border: 1px solid var(--border-strong); color: var(--text); }
.gb-st-new { border-color: var(--accent); color: var(--link); font-weight: 600; }
.gb-st-yes { border-color: var(--pos); color: var(--pos); }
.gb-st-dropped { border-color: var(--neg); color: var(--neg); }
.gb-st-no, .gb-st-none { color: var(--text-dim); }
:root[data-theme] .gb-dlg-table td.gb-dlg-emas { text-align: left; white-space: nowrap; }
.gb-ema { display: inline-block; min-width: 34px; margin-right: 3px; font-size: 11px; font-variant-numeric: tabular-nums; }
.gb-ema-up { color: var(--pos); }
.gb-ema-down { color: var(--neg); }
.gb-ema-na { color: var(--text-dim); }
.gb-spark { display: block; }
.gb-spark path { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.gb-spark-up path { stroke: var(--pos); }
.gb-spark-down path { stroke: var(--neg); }

/* Market Breadth's two sub-pages (industryema.js showSub). Only one is ever
   laid out, and the Sectors & Industries one carries its own scroll box, the
   same shape as #breadthContent. The [hidden] rule is needed because
   #breadthToolbar's display:flex is an id rule and would beat the attribute. */
#breadthSubnav { flex: 0 0 auto; padding: 10px 16px 0; }
#viewBreadth > [hidden] { display: none !important; }
#viewBreadth > #viewIndustryema { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#viewBreadth > #viewIndustryema > #industryemaContent {
    flex: 1 1 auto; min-height: 0; overflow: auto;
    padding: 16px; display: flex; flex-direction: column; gap: 16px;
}
.industryema-interval { margin-bottom: 10px; }

/* The row commentary (groupbreadth.js rowStory): a floating card beside the
   pointer, in the theme's popup colours, wide enough for a sentence a line. */
.gb-story {
    position: fixed; z-index: 1000; width: 340px; max-width: calc(100vw - 16px);
    pointer-events: none;
    background: var(--bg-raised); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 10px;
    box-shadow: var(--pop-shadow);
    padding: 10px 12px; font-size: 12.5px; line-height: 1.5;
}
.gb-story[hidden] { display: none; }
.gb-story p { margin: 0 0 6px; }
.gb-story p:last-child { margin-bottom: 0; }
.gb-story b { color: var(--text-bright); }
.gb-story-title { font-weight: 600; color: var(--text-bright); font-size: 13px; margin-bottom: 6px; }
.gb-story-week { padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.gb-story-note { color: var(--text-dim); }

/* The sector combo's industry rows keep their indent inside #toolbar.
   The toolbar button padding above is set through ID selectors, which no
   class-only rule beats -- the same trap this file already records for
   toolbar buttons -- so styles.css's .sector-row-child indent was flattened
   to the shared 12px and every row in the dropdown started at the same x,
   which is how the nesting became invisible. The tick marker in styles.css
   was applying the whole time; only the indent was lost. */
:root[data-theme] #toolbar .sector-combo-menu button.sector-row-child {
    padding-left: 34px;
}

/* One box for sector, industry and stock (2026-11-16): typed text lists
   the matching stocks and indices under the baskets, each section headed
   when both are there. Through #toolbar for the same reason as above. */
:root[data-theme] #toolbar .sector-combo-menu .sector-combo-heading {
    padding: 6px 12px 3px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}
:root[data-theme] #toolbar .sector-combo-menu .sector-combo-heading:first-child { border-top: none; }
:root[data-theme] #toolbar .sector-combo-menu .sector-combo-heading + button.sector-row-total {
    border-top: none;
    margin-top: 0;
}
:root[data-theme] #toolbar .sector-combo-menu button.sector-row-pick-stock {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
/* The company's name between the symbol and the exchange (2026-11-19), as
   the Analysis page's search shows it; cut with an ellipsis, never wrapped. */
:root[data-theme] #toolbar .sector-combo-menu .chart-suggest-sym { font-weight: 600; flex: 0 0 auto; }
:root[data-theme] #toolbar .sector-combo-menu .chart-suggest-name {
    flex: 1 1 auto; min-width: 0; text-align: left; color: var(--text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
:root[data-theme] #toolbar .sector-combo-menu .chart-suggest-name:empty { display: none; }
:root[data-theme] #toolbar .sector-combo-menu button.sector-combo-active {
    background: var(--border);
}

/* The Scans page above the table, compacted (2026-10-03). The owner's
   screenshot had six rows of chrome over one row of data: toolbar, presets,
   filters, odds, board, facets. Now the preset strip flows on the toolbar
   line, the market sentence sits in the odds box, the Board select rides
   in the filter row on VCP (scans.js placeBoardFilter), and the row
   paddings are halved. Scoped to the Scans pane; nothing else moves. */
:root[data-theme] #scansToolbar {
    padding: 6px 16px;
    gap: 8px;
}
:root[data-theme] #vcpPresetStrip:not([hidden]),
:root[data-theme] #wyckoffPresetStrip:not([hidden]),
:root[data-theme] #momentumPresetStrip:not([hidden]),
:root[data-theme] #stagePresetStrip:not([hidden]) {
    display: inline-flex;
    width: auto;
    padding: 0;
    gap: 6px;
}
/* Halved vertically, NOT sideways: the compaction first wrote "3px 0 5px",
   which put every filter row flush against the window edge and clipped its
   first label to "iquidity:", "oard:", "erdict:" in the owner's screenshots
   of 2026-10-13. And they WRAP: the facet row was nowrap and 1,709px wide in
   a 1,100px window, its last controls off-screen to the right -- the "let it
   wrap" a note in styles.css (BUG 3) describes was never written. Folded by
   default since the same day (fold.js), so the extra line costs nothing
   until the reader opens Filters. */
:root[data-theme] .scans-pane > .scans-ema-filter:not([hidden]) {
    padding: 3px 16px 5px;
    flex-wrap: wrap;
    row-gap: 4px;
}
:root[data-theme] #ema40EmaFilter > #scansBoardFilter:not([hidden]) {
    padding: 0;
}
:root[data-theme] .scans-odds-line {
    margin: 4px 16px 0;
    padding: 5px 12px;
    line-height: 1.4;
}

/* ------------------------------------------------------------------ */
/* Filters and Info switches (fold.js)                                 */
/* ------------------------------------------------------------------ */

/* The rows fold by a class on their scope, never by moving: the pages move
   their own controls between rows. !important because several rows carry
   display rules of their own (inline display:block on Momentum's market
   note, inline-flex on the preset strips) that a class would otherwise lose
   to. */
[data-fold-scope].fold-filters-closed [data-fold="filters"],
[data-fold-scope].fold-info-closed [data-fold="info"] {
    display: none !important;
}

.fold-switches {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.fold-switches[hidden],
.fold-switches [hidden] { display: none !important; }

:root[data-theme] .fold-btn[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent-strong);
}
.fold-caret { font-size: 10px; margin-left: 2px; }
.fold-count {
    display: inline-block;
    min-width: 16px;
    padding: 0 5px;
    margin-left: 2px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

/* A folded filter is said, never silent: one chip per narrowing setting.
   Spans with role=button, not buttons -- the toolbars style every button
   inside them by id, and a chip dressed as a toolbar button is a row again. */
.fold-chips {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.fold-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 280px;
    padding: 1px 4px 1px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--bg-panel);
    color: var(--text-bright);
    font-size: 12px;
    line-height: 20px;
    white-space: nowrap;
    cursor: pointer;
}
.fold-chip:hover { border-color: var(--accent); }
.fold-chip-label { color: var(--text-dim); }
.fold-chip-value { overflow: hidden; text-overflow: ellipsis; }
.fold-chip-x {
    padding: 0 5px;
    border-radius: 999px;
    color: var(--text-dim);
    font-size: 11px;
    line-height: 18px;
}
.fold-chip-x:hover { background: var(--neg-bg); color: var(--neg); }
.fold-chip-more { padding-right: 8px; color: var(--accent-strong); }

/* A warning folded under Info stays on screen as one line. */
.fold-warn {
    max-width: 640px;
    padding: 2px 10px;
    border-left: 3px solid var(--neg);
    border-radius: 6px;
    background: var(--neg-bg);
    color: var(--neg);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.fold-warn.is-note {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* ------------------------------------------------------------------ */
/* Chart toolbar: one row, and the stock's controls beside its tab     */
/* ------------------------------------------------------------------ */

/* The owner's screenshot of 2026-10-13: three toolbar lines plus the tab
   strip, 155px over the chart at 1900px wide. The first row used 625px of
   1,876; the second wrapped by 47px, leaving Sell alone on a third line.
   Now the two rows flow as one wrapping row (display: contents keeps their
   ids and children where scripts expect them), and everything that only
   applies to a charted stock -- its industry, Alert, Cycle, quantity, Size,
   Buy, Sell -- sits beside the stock's own tab in #chartSubBar. Ratio mode's
   wide Index A/B pickers, which the two rows were split for, simply wrap. */
:root[data-theme] #toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 6px;
    row-gap: 4px;
    padding: 6px 12px;
}
#toolbar > .toolbar-row { display: contents; }

#chartSubBar {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 4px 8px 0;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
}
/* No tab strip means no stock is open, so nothing here can show. */
#chartSubBar:has(> #chartTabBar:empty) { display: none; }
/* One line, always: the tabs take what is left and scroll sideways when
   full. Two earlier versions failed the owner's nine-tab screenshot of
   2026-10-13. The first let the controls WRAP: Sell dropped to a second
   line, the row doubled and the newest tab was cut off. The second boxed
   the controls in a shrinkable flex item, which shrank below its contents
   and, right-aligned, spilled them LEFT over the tabs. Now #chartStockBar
   is display: contents, so the tabs, the industry note and each button are
   siblings in this one row: the note gives up width first (flex-shrink 50
   against the tabs' 1, down to 90px, ending in an ellipsis), then the tabs
   scroll, and the buttons never shrink -- nothing can overlap. */
#chartSubBar > .chart-tab-bar {
    flex: 1 1 auto;
    min-width: 160px;
    /* End padding so the last tab can scroll fully in: without it the
       strip's sub-pixel width left the newest tab 3px clipped. */
    padding: 0 8px 0 0;
    border-bottom: 0;
    background: transparent;
    scrollbar-width: none;
}
#chartSubBar > .chart-tab-bar::-webkit-scrollbar { display: none; }
#chartStockBar { display: contents; }
#chartStockBar > * { flex: 0 0 auto; margin-bottom: 4px; align-self: center; }
#chartStockBar > #stockSectorInfo { flex: 0 50 auto; min-width: 90px; }

/* Interval switch and the log / magnet toggles (charttoolbar.js). A toggle
   is a toolbar button that stays lit while on; the id in the selector is
   what lets it beat `#toolbar button`, which sets border and colour. */
:root[data-theme] #toolbar button.chart-toggle {
    min-width: 34px;
    font-weight: 600;
}
:root[data-theme] #toolbar button.chart-toggle[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}
:root[data-theme] #toolbar button.chart-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
}
#toolbar button.chart-toggle-icon svg { display: block; }
:root[data-theme] #toolbar .chart-interval-toggle .rotation-level-btn {
    min-width: 30px;
    padding-left: 10px;
    padding-right: 10px;
    font-weight: 600;
}

/* Valuation -> Results (results.js). Theme tokens only, so both themes follow;
   text is drawn at full opacity in the dim ink, never faded (see AGENTS.md). */
#resultsCard .results-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 6px;
}
#resultsCard .results-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
    margin: 8px 0 10px;
}
#resultsCard .results-kpi {
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
}
#resultsCard .results-kpi-label { font-size: 12px; color: var(--text-dim); }
#resultsCard .results-kpi-value { font-size: 18px; font-weight: 600; color: var(--text-bright); }
#resultsCard .results-presets { flex-wrap: wrap; margin-bottom: 8px; }

/* The season at a glance (results.js renderScorecard / renderIndustries,
   2026-11-09): the scorecard is the same tile as the KPIs below it, larger,
   with a line under the value; the industry tiles are buttons that filter
   the table. Every ink is a token, so both themes hold 4.5:1. */
#resultsCard .results-scorecard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
    margin: 8px 0 4px;
}
#resultsCard .results-scorecard .results-kpi-value { font-size: 20px; }
#resultsCard .results-kpi-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
#resultsCard .results-scorecard-prev { grid-column: 1 / -1; font-size: 12px; color: var(--text-dim); }
#resultsCard .results-movers { margin: 4px 0 6px; line-height: 1.7; }
#resultsCard .results-movers button.results-link { margin: 0 2px; }
#resultsCard .results-ind-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 4px; }
#resultsCard .results-ind-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
#resultsCard .results-ind-grid[hidden] { display: none; }
#resultsCard button.results-ind-tile {
    display: block;
    text-align: left;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
#resultsCard button.results-ind-tile:hover { border-color: var(--accent); }
#resultsCard button.results-ind-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
#resultsCard .results-ind-sector { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
#resultsCard .results-ind-name { font-size: 14px; font-weight: 600; color: var(--text-bright); margin: 1px 0 5px; }
#resultsCard .results-ind-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
#resultsCard .results-ind-chip { font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 9px; }
#resultsCard .results-ind-chip.good { color: var(--pos); background: var(--pos-bg); }
#resultsCard .results-ind-chip.mixed { color: var(--warn); background: var(--warn-bg); }
#resultsCard .results-ind-chip.weak { color: var(--neg); background: var(--neg-bg); }
/* On light the tinted wash over the sunken tile took the three inks to
   4.2-4.5:1 (measured 2026-11-09); an outline keeps the colour and leaves the
   text on the tile's own ground, where each clears 4.6. */
:root[data-theme="light"] #resultsCard .results-ind-chip { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
#resultsCard .results-ind-bar { display: flex; height: 4px; border-radius: 2px; overflow: hidden; background: var(--border); margin: 4px 0; }
#resultsCard .results-ind-bar span { display: block; height: 100%; }
#resultsCard .results-ind-bar .good { background: var(--pos); }
#resultsCard .results-ind-bar .mixed { background: var(--warn); }
#resultsCard .results-ind-bar .weak { background: var(--neg); }
#resultsCard .results-ind-meta { font-size: 12px; color: var(--text-dim); }
#resultsCard .results-ind-names { font-size: 12px; color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#resultsCard .results-warn-mark { color: var(--warn); font-weight: 700; margin-left: 3px; cursor: help; }
#resultsCard .results-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-bottom: 8px;
}
#resultsCard .results-count { color: var(--text-dim); font-weight: 400; font-size: 12px; }
#resultsCard .results-table-wrap { overflow-x: auto; }
#resultsCard .results-dim { color: var(--text-dim); }
#resultsCard .results-sub { font-size: 11px; color: var(--text-dim); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#resultsCard .results-mark { color: var(--warn); cursor: help; }
#resultsCard .results-band { font-size: 12px; }
#resultsCard button.results-name {
    background: none;
    border: none;
    padding: 0;
    color: var(--link);
    font-weight: 600;
    cursor: pointer;
}
#resultsCard button.results-name:hover { text-decoration: underline; }
#resultsCard button.results-link {
    background: none;
    border: none;
    padding: 0 0 0 6px;
    color: var(--link);
    cursor: pointer;
    text-decoration: underline;
}
#resultsCard .results-read {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
    border: 1px solid var(--border);
    color: var(--text);
}
#resultsCard .results-read.good { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
#resultsCard .results-read.bad { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.rs-warn { color: var(--warn); }
#resultsCard .results-read.loss { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
#resultsCard .results-dots { display: inline-flex; gap: 2px; vertical-align: middle; }
#resultsCard .results-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    box-sizing: border-box;
}
#resultsCard .results-dot.up { background: var(--pos); }
#resultsCard .results-dot.down { border: 1.5px solid var(--neg); }
#resultsCard .results-dot.none { background: var(--border); height: 2px; border-radius: 1px; align-self: center; }
#resultsCard .results-dot.now { outline: 1px solid var(--text-dim); outline-offset: 1px; }
#resultsCard tbody tr[data-row] { cursor: pointer; }
/* Not a .breadth-card-title on purpose: on the Valuation page that class is
   the collapse toggle, and a collapsed card hides every child but a title
   that is its DIRECT child -- this one sits in a header row, so one click
   folded the whole card away, title and all, and left an empty bar with
   nothing to click (2026-10-14). The tab is the whole page; it does not
   collapse. */
#resultsCard .results-title { font-size: 15px; font-weight: 600; color: var(--text-bright); }
#valuationSubpageToggle { margin-bottom: 8px; }
#resultsCard .results-record { cursor: help; white-space: nowrap; }
#resultsCard .results-record:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
#resultsCard #resultsBoardToggle { margin: 0; }
/* The Record column's hover card (results.js). On body, so the table's
   horizontal scroll cannot clip it; position: fixed, placed by script. */
.results-record-card {
    position: fixed;
    z-index: 2000;
    display: none;
    width: 440px;
    max-width: calc(100vw - 16px);
    background: var(--bg-raised);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--pop-shadow);
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.45;
}
.results-record-card .results-rc-title { font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.results-record-card .results-rc-lead { color: var(--text-dim); margin-bottom: 6px; }
.results-record-card .results-rc-foot { color: var(--text-dim); margin-top: 6px; }
.results-record-card .results-dim { color: var(--text-dim); }
.results-record-card table.results-rc-table { width: 100%; border-collapse: collapse; }
.results-record-card .results-rc-table th,
.results-record-card .results-rc-table td { padding: 2px 6px; text-align: right; border-bottom: 1px solid var(--row-line); white-space: nowrap; }
.results-record-card .results-rc-table th { color: var(--text-dim); font-weight: 500; }
.results-record-card .results-rc-table th:first-child,
.results-record-card .results-rc-table td:first-child { text-align: left; }
.results-record-card tr.results-rc-now td { font-weight: 600; color: var(--text-bright); }
.results-record-card .results-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; box-sizing: border-box; vertical-align: middle; }
.results-record-card .results-dot.up { background: var(--pos); }
.results-record-card .results-dot.down { border: 1.5px solid var(--neg); }
.results-record-card .results-dot.none { background: var(--border); height: 2px; border-radius: 1px; }
#resultsCard .results-flags { margin-top: 2px; }
/* Where the quarter sits in a run of good quarters (results.js runFlag):
   the 2nd and 3rd after a weak patch, the measured ones, in the good ink. */
#resultsCard .results-run { margin-top: 2px; font-size: 11px; color: var(--text-dim); white-space: nowrap; cursor: help; }
#resultsCard .results-run.key { color: var(--pos); font-weight: 600; }
/* Profit level and profit against sales (results.js profitLevelCell,
   profitVsLine; 2026-11-13). The state chip reuses the read pills, so a
   breakout looks like a good read and a fall into loss like a weak one; the
   sparkline draws its line in the accent and the record dashed in faint ink,
   so neither colour competes with the chip. Unmeasured, said in the header. */
#resultsCard .results-level { display: flex; align-items: center; gap: 8px; min-width: 210px; cursor: help; }
#resultsCard .results-spark { flex: 0 0 auto; }
#resultsCard .results-spark .sp-line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
#resultsCard .results-spark .sp-zero { stroke: var(--border-strong); stroke-width: 1; }
#resultsCard .results-spark .sp-rec { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 3 3; }
#resultsCard .results-spark .sp-loss { fill: var(--neg-bg); }
#resultsCard .results-spark .sp-end { fill: var(--accent); stroke: var(--bg-panel); stroke-width: 1.4; }
#resultsCard .results-spark .sp-end.good { fill: var(--pos); }
#resultsCard .results-spark .sp-end.bad { fill: var(--neg); }
#resultsCard .results-spark .sp-end.loss { fill: var(--warn); }
#resultsCard .results-vs { cursor: help; }
#resultsCard .results-vs.up { color: var(--pos); }
#resultsCard .results-vs.down { color: var(--neg); }
#resultsCard .results-vs.warn { color: var(--warn); }
#resultsCard .results-flag.neg { color: var(--neg); background: var(--neg-bg); }
#resultsCard .results-flag {
    display: inline-block;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 11px;
    color: var(--warn);
    background: var(--warn-bg);
    cursor: help;
}
/* Light-theme legibility (the owner, 2026-10-14: "the colors for the text
   not clearly visible"). The inks already clear 5:1; what read faint was
   thin coloured text. Coloured figures are semi-bold, the read pills
   heavier, and the measured line is ink on a tinted box with a coloured
   rule instead of a whole sentence in green or red. */
#resultsCard .rs-pos,
#resultsCard .rs-neg { font-weight: 600; }
#resultsCard td b { font-weight: 600; color: var(--text-bright); }
#resultsCard .results-read { font-weight: 600; }
#resultsCard .results-flag { font-weight: 600; }
#resultsCard .results-measured {
    margin: 0 0 8px;
    color: var(--text);
    background: var(--bg-sunken);
    border-left: 3px solid var(--border-strong);
    border-radius: 0;
    padding: 5px 10px;
}
#resultsCard .results-measured.holds { color: var(--text); border-left-color: var(--pos); background: var(--pos-bg); }
#resultsCard .results-measured.lags { color: var(--text); border-left-color: var(--neg); background: var(--neg-bg); }
/* One line per cell: the bolder figures made Margin, Filed and Multiple
   wrap to three lines and doubled every row. The table scrolls sideways
   in its wrap on a narrow window instead. */
#resultsTable td { white-space: nowrap; }
/* The table tidied (reader, 2026-11-21: "do something about the
   formatting"): figures right-aligned in their columns, the company on two
   lines (name, then size and industry), each row's content aligned to the
   top, the presets in three labelled rows. */
#resultsTable td { vertical-align: top; padding-top: 9px; padding-bottom: 9px; }
#resultsTable th:nth-child(n+4):nth-child(-n+7), #resultsTable td:nth-child(n+4):nth-child(-n+7),
#resultsTable th:nth-child(13), #resultsTable td:nth-child(13) { text-align: right !important; }
#resultsTable td:nth-child(1), #resultsTable td:nth-child(2), #resultsTable td:nth-child(8),
#resultsTable td:nth-child(9), #resultsTable td:nth-child(12) { text-align: left !important; }
#resultsCard button.results-name { font-weight: 700; font-size: 13.5px; }
#resultsCard .results-sub .ratio-stock-tier { color: var(--text); font-weight: 600; }
#resultsCard .results-level .results-run { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
#resultsCard .results-vs { max-width: 170px; margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
#resultsCard #resultsPresets.results-presets { display: flex; flex-direction: column; gap: 6px; align-items: stretch; background: transparent; padding: 0; border: 0; }
#resultsCard .results-preset-group { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 8px; align-items: center; }
#resultsCard .results-preset-label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
#resultsCard .results-preset-label.ahead { color: var(--pos); }
#resultsCard .results-preset-label.behind { color: var(--neg); }
#resultsCard .results-preset-chips { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg-deeper, transparent); border-radius: 8px; padding: 3px; }
@media (max-width: 640px) {
    #resultsCard .results-preset-group { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* Settings > Filing alerts: one switch per category, two or three to a row.
   Each label carries its explanation in a title, not in faded text beside
   it (the 4.5:1 rule). */
.filing-alert-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 4px 14px;
    margin: 6px 0 4px;
}
.filing-alert-categories label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    cursor: pointer;
}
.filing-alert-categories.disabled label { color: var(--text-dim); }

/* Settings > Your Telegram: the heading with its "How to set up" button at
   the right, the same .howto-btn every screen's "How to use" wears. */
.settings-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 2px;
}
.settings-section-head h4 { margin: 0; }

/* Settings > API tokens (apitokens.js): the reader's tokens as a compact
   table, and the once-only token in a read-only box with its Copy button.
   Monospace so a token can be checked by eye against a client's config. */
.api-tokens-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0 8px; }
.api-tokens-table th,
.api-tokens-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); color: var(--text); }
.api-tokens-table th { color: var(--text-dim); font-weight: 600; }
.api-token-created { margin: 4px 0 8px; }
.api-assistants-head { margin: 14px 0 4px; font-size: 13px; font-weight: 600; color: var(--text); }
.api-token-created-row { display: flex; gap: 6px; }
.api-token-created-row input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* Settings > AI filing summaries: a provider's Test button and its last
   outcome, which can run to a sentence (a test's summary or the provider's
   error), so it wraps under the button rather than widening the dialog. */
.ai-provider-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; max-width: 520px; }
.ai-provider-status { color: var(--text-dim); font-size: 12px; line-height: 1.4; }

/* Sector & Industry Breadth > By sector (groupbreadth.js renderStack): one
   stacked bar per week-end. Segments take the Trend tab's colour slots, so
   both themes follow the same tokens; "Other" is the neutral grey. */
.gb-stack-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 6px; }
.gb-stack-controls label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12.5px; font-weight: 500; }
.gb-stack-head { margin: 0 0 6px; font-size: 13px; color: var(--text); }
.gb-stack-head b { color: var(--text-bright); }
.gb-stack-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 6px; }
.gb-stack-key {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; color: var(--text); border: 1px solid var(--border);
    border-radius: 999px; padding: 2px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.gb-stack-key b { color: var(--text-bright); font-variant-numeric: tabular-nums; }
.gb-stack-key:hover { border-color: var(--border-bright); }
.gb-stack-key.on { border-color: var(--accent); background: var(--accent-soft); }
.gb-stack-swatch[class*="gb-c"] { background: var(--gb-c); }
.gb-stack-swatch.gb-other, .gb-swatch.gb-other { background: color-mix(in srgb, var(--gb-mid) 55%, var(--bg-deeper)); }
.gb-stack-svg { display: block; }
.gb-stack-seg { stroke: var(--bg-deeper); stroke-width: 0.5; }
.gb-stack-seg[class*="gb-c"] { fill: var(--gb-c); }
/* Lighter than the coloured sectors, so they read first: Other is often
   the largest slice (38 sectors, eight colours). */
.gb-stack-seg.gb-other { fill: color-mix(in srgb, var(--gb-mid) 55%, var(--bg-deeper)); }
.gb-stack-seg.gb-dim { opacity: 0.18; }

/* Market Breadth > Market, "Stocks above their EMA, by cap tier"
   (breadthtiers.js). Cap tiers are ORDERED, so one hue stepped in
   lightness rather than five categorical colours: darker is larger, in
   both themes. The segment stroke keeps the two palest steps apart. */
:root {
    --bt-t1: #1d4f9c; --bt-t2: #2f6fd0; --bt-t3: #5a93e6; --bt-t4: #8fb6ef; --bt-t5: #c6d9f7;
}
:root[data-theme="light"] {
    --bt-t1: #0e3a7a; --bt-t2: #1f5fc0; --bt-t3: #4c88dc; --bt-t4: #8ab2ea; --bt-t5: #c4d8f5;
}
.bt-seg { stroke: var(--bg-deeper); stroke-width: 0.5; }
.bt-seg.gb-dim { opacity: 0.18; }
.bt-seg.bt-t1, .bt-swatch.bt-t1 { fill: var(--bt-t1); background: var(--bt-t1); }
.bt-seg.bt-t2, .bt-swatch.bt-t2 { fill: var(--bt-t2); background: var(--bt-t2); }
.bt-seg.bt-t3, .bt-swatch.bt-t3 { fill: var(--bt-t3); background: var(--bt-t3); }
.bt-seg.bt-t4, .bt-swatch.bt-t4 { fill: var(--bt-t4); background: var(--bt-t4); }
.bt-seg.bt-t5, .bt-swatch.bt-t5 { fill: var(--bt-t5); background: var(--bt-t5); }
/* Outside every tier (the margin book's ETFs, SME and untracked names on
   Macro > Margin trading): grey, so it does not read as a sixth size. */
.bt-seg.bt-t6, .bt-swatch.bt-t6 { fill: color-mix(in srgb, var(--gb-mid) 55%, var(--bg-deeper)); background: color-mix(in srgb, var(--gb-mid) 55%, var(--bg-deeper)); }
.gb-swatch.bt-swatch { height: 10px; width: 10px; }
.bt-cursor { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
#breadthTiersCard .gb-stack-controls .rotation-level-toggle { margin: 0; }
.bt-thin .bt-seg { stroke: none; shape-rendering: crispEdges; }

/* ---- In-chart legend (chartlegend.js), TradingView's layout: the bar's
   OHLC on the first line, one line per study under it, folding behind a
   chevron. The box ignores the pointer so the chart under it still pans
   and draws; only the rows and buttons take clicks. ---- */
.chart-legend {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 40;
    max-width: calc(100% - 120px);
    font-size: 12px;
    line-height: 18px;
    color: var(--text);
    pointer-events: none;
    user-select: none;
}
.chart-legend-head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
.chart-legend-title { font-weight: 600; font-size: 13px; color: var(--text); }
.chart-legend-ohlc { display: flex; flex-wrap: wrap; column-gap: 8px; font-variant-numeric: tabular-nums; }
.chart-legend-field i { font-style: normal; color: var(--text-dim); margin-right: 3px; }
.chart-legend-field b { font-weight: 500; }
.chart-legend .is-up { color: var(--pos); }
.chart-legend .is-down { color: var(--neg); }
.chart-legend .is-plain { color: var(--text); }
.chart-legend-list { display: flex; flex-direction: column; align-items: flex-start; margin-top: 2px; }
.chart-legend-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
    margin-left: -4px;
    border: 1px solid transparent;
    border-radius: 4px;
    pointer-events: auto;
    font-variant-numeric: tabular-nums;
}
.chart-legend-row:hover { background: var(--bg-panel); border-color: var(--border); }
.chart-legend-name { color: var(--text); cursor: default; }
.chart-legend-values { display: inline-flex; gap: 6px; }
.chart-legend-row.is-hidden .chart-legend-name { color: var(--text-dim); text-decoration: line-through; }
.chart-legend-tools { display: none; gap: 2px; }
.chart-legend-row:hover .chart-legend-tools { display: inline-flex; }
.chart-legend-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}
.chart-legend-btn:hover { color: var(--text); background: var(--border); }
.chart-legend-fold {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
    padding: 0 6px;
    height: 18px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-panel);
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    pointer-events: auto;
}
.chart-legend-fold:hover { color: var(--text); }
.chart-legend-fold[hidden] { display: none; }

/* ---- TradingView-style chart controls (charttv.js, 2026-10-23). The
   menus sit inside #toolbar, whose `#toolbar button` rule sets padding,
   border and colour on every button in it -- so the menu items here are
   named through their menu's id to win (see "Toolbar buttons are styled
   through ID selectors" in AGENTS.md). ---- */
:root[data-theme] #toolbar #chartTypeMenu,
:root[data-theme] #toolbar #chartCompareMenu { min-width: 190px; padding: 4px; }
:root[data-theme] #toolbar #chartTypeMenu button.chart-type-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 6px 10px; border: 0; border-radius: 4px; background: transparent;
    color: var(--text); font-weight: 400; text-align: left;
}
:root[data-theme] #toolbar #chartTypeMenu button.chart-type-item:hover { background: var(--bg-raised); }
:root[data-theme] #toolbar #chartTypeMenu button.chart-type-item.active { color: var(--accent-strong); }
#chartTypeMenu svg { flex: 0 0 auto; }
:root[data-theme] #toolbar #chartCompareMenu { width: 280px; }
#chartCompareInput { width: 100%; box-sizing: border-box; margin-bottom: 4px; }
.chart-compare-results { max-height: 320px; overflow-y: auto; }
:root[data-theme] #toolbar #chartCompareMenu button.chart-compare-item {
    display: flex; justify-content: space-between; gap: 8px; width: 100%;
    padding: 5px 8px; border: 0; border-radius: 4px; background: transparent;
    color: var(--text); font-weight: 400; text-align: left;
}
:root[data-theme] #toolbar #chartCompareMenu button.chart-compare-item:hover { background: var(--bg-raised); }
.chart-compare-item i { font-style: normal; color: var(--text-dim); font-size: 11px; }
.chart-compare-current { display: flex; align-items: center; gap: 6px; padding: 3px 8px; font-size: 12px; }
.chart-compare-current .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.chart-compare-current span:nth-child(2) { flex: 1 1 auto; }
:root[data-theme] #toolbar #chartCompareMenu .chart-compare-current button {
    padding: 0 6px; min-width: 0; border: 0; background: transparent; color: var(--text-dim);
}
.chart-compare-hint { padding: 6px 8px; color: var(--text-dim); font-size: 12px; }
:root[data-theme] #toolbar button.chart-toggle:disabled { opacity: 1; color: var(--text-faintest, var(--text-dim)); cursor: default; }

/* The range bar under the chart: 1M ... All, then Go to date. */
.chart-range-bar {
    flex: 0 0 auto; display: flex; align-items: center; gap: 2px;
    padding: 3px 8px; border-top: 1px solid var(--border); background: var(--bg-app);
    position: relative; font-size: 12px;
}
.chart-range-bar > button {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border: 0; border-radius: 4px; background: transparent;
    color: var(--text-dim); font-size: 12px; font-weight: 600; cursor: pointer;
}
.chart-range-bar > button:hover { background: var(--bg-raised); color: var(--text); }
.chart-range-sep { width: 1px; height: 16px; background: var(--border); margin: 0 6px; }
.chart-goto-popover {
    position: absolute; bottom: 100%; left: 8px; margin-bottom: 6px; z-index: 60;
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
}
.chart-goto-popover[hidden] { display: none; }

/* Bar Replay's controls float over the bottom of the chart. */
.chart-replay-bar {
    position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 55;
    display: flex; align-items: center; gap: 6px; padding: 6px 10px;
    background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 8px;
    box-shadow: 0 4px 16px var(--shadow); font-size: 12px; white-space: nowrap;
}
.chart-replay-bar[hidden] { display: none; }
.chart-replay-note { color: var(--text-dim); margin-right: 4px; font-variant-numeric: tabular-nums; }
.chart-replay-bar button, .chart-replay-bar select { font-size: 12px; }
#chartContainer.replay-selecting { cursor: crosshair; }

/* TradingView's floating drawing toolbars (chartdrawbars.js): the bar over
   a selected drawing and the favourite tools. They follow the APP's theme,
   not the chart's: on TradingView's dark theme with a light chart they stay
   dark, and so do these. Hence tokens of their own, set on the root only,
   which #chartContainerWrap.kc-light does not redefine. */
:root {
    --drawbar-bg: #1e222d; --drawbar-border: #2a2e39; --drawbar-ink: #d1d4dc;
    --drawbar-hover: #2a2e39; --drawbar-on: #2962ff;
    --drawbar-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
:root[data-theme="light"] {
    --drawbar-bg: #ffffff; --drawbar-border: #e0e3eb; --drawbar-ink: #131722;
    --drawbar-hover: #f0f3fa; --drawbar-on: #2962ff;
    --drawbar-shadow: 0 2px 12px rgba(19, 23, 34, 0.18);
}
.chart-drawbar {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 55;
    display: flex; align-items: center; gap: 2px; padding: 3px 4px;
    background: var(--drawbar-bg); color: var(--drawbar-ink);
    border: 1px solid var(--drawbar-border); border-radius: 6px;
    box-shadow: var(--drawbar-shadow); font-size: 12px; user-select: none;
}
.chart-drawbar[hidden] { display: none; }
.chart-favbar { top: 44px; }
.chart-favbar-tools { display: flex; align-items: center; gap: 2px; }
:root[data-theme] .chart-drawbar button {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    min-width: 30px; height: 30px; padding: 0 6px; margin: 0;
    border: 0; border-radius: 4px; background: transparent; color: var(--drawbar-ink);
    font-size: 12px; font-weight: 500; cursor: pointer; box-shadow: none;
}
:root[data-theme] .chart-drawbar button:hover { background: var(--drawbar-hover); }
:root[data-theme] .chart-drawbar button.on { color: var(--drawbar-on); }
:root[data-theme] .chart-drawbar .chart-drawbar-grip { min-width: 14px; padding: 0 3px; cursor: grab; opacity: .7; }
.chart-drawbar-color { position: relative; }
.chart-drawbar-swatch {
    position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border-radius: 2px;
}
.chart-drawbar .draw-ico { width: auto; min-width: 18px; color: inherit; font-size: 15px; }
.chart-drawbar .chart-favbar-tool[data-overlay^="ew"] .draw-ico { font-size: 9px; }
.chart-drawbar svg { display: block; }

.chart-drawbar-pop {
    position: absolute; z-index: 60; min-width: 150px; padding: 4px 0;
    background: var(--drawbar-bg); color: var(--drawbar-ink);
    border: 1px solid var(--drawbar-border); border-radius: 6px; box-shadow: var(--drawbar-shadow);
    font-size: 13px;
}
.chart-drawbar-pop hr { border: 0; border-top: 1px solid var(--drawbar-border); margin: 4px 0; }
:root[data-theme] .chart-drawbar-pop .chart-drawbar-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 14px; margin: 0;
    border: 0; border-radius: 0; background: transparent; color: var(--drawbar-ink);
    font-size: 13px; text-align: left; cursor: pointer; white-space: nowrap; box-shadow: none;
}
:root[data-theme] .chart-drawbar-pop .chart-drawbar-item:hover { background: var(--drawbar-hover); }
:root[data-theme] .chart-drawbar-pop .chart-drawbar-item.on { color: var(--drawbar-on); }
:root[data-theme] .chart-drawbar-pop .chart-drawbar-item.danger { color: #f23645; }
.chart-drawbar-namerow { display: flex; gap: 6px; padding: 6px 10px; }
.chart-drawbar-name { flex: 1; min-width: 140px; }

/* The star on every tool in the rail's flyouts: TradingView's way of
   putting a tool on the favourites bar. Shown on hover, kept lit once on. */
#leftSidebar .draw-flyout button { position: relative; padding-right: 30px; }
.draw-fav {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-size: 14px; line-height: 1; color: var(--text-dim); opacity: 0; cursor: pointer;
}
#leftSidebar .draw-flyout button:hover .draw-fav { opacity: .8; }
.draw-fav:hover { opacity: 1 !important; color: #f7a600; }
.draw-fav.on { opacity: 1; color: #f7a600; }

/* The drawing rail's Lock all / Hide all stay lit while on. */
#leftSidebar button.draw-rail-toggle[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-soft); }
#leftSidebar button svg { display: block; margin: 0 auto; }
.draw-ico.pos-long { color: var(--pos); font-weight: 700; }
.draw-ico.pos-short { color: var(--neg); font-weight: 700; }
:root[data-theme] .chart-range-bar > button.chart-range-help { margin-left: auto; font-weight: 500; }
#indicatorsMenu .dropdown-menu-header {
    padding: 6px 12px 2px; border-top: 1px solid var(--border); margin-top: 4px;
    color: var(--text-dim); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}

/* One line per study, cut with an ellipsis rather than wrapped, and a halo
   in the chart's own ground so the text reads over candles, as TradingView's
   legend does. */
.chart-legend-row, .chart-legend-head { white-space: nowrap; }
.chart-legend-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.chart-legend { text-shadow: 0 0 3px var(--kc-bg), 0 0 3px var(--kc-bg), 0 0 2px var(--kc-bg); }
.chart-legend-head { flex-wrap: nowrap; overflow: hidden; }
.chart-legend-ohlc { flex-wrap: nowrap; }

/* Full screen (charttv.js): the chart page lifted over the app's top bar to
   fill the browser tab. Under the stock panel (900) and every dropdown
   (1000), so those still open over it; dialogs sit in the top layer anyway. */
#viewChart.chart-maximized {
    position: fixed;
    inset: 0;
    z-index: 850;
    background: var(--bg-app);
}

/* Full screen on a phone (charttv.js, owner 2026-11-13). The toolbar's five
   rows took 317px of an 812px screen and left the candles about 150px, so
   in full screen they fold behind #chartFsBar: Controls (the toolbar back in
   the page's flow, still in full screen), D / W / M, and Exit. The stock's
   tab strip folds with them. Above 640px the bar never shows and full screen
   is the toolbar-and-all maximize it always was. */
#chartFsBar { display: none; }
@media (max-width: 640px) {
    #viewChart.chart-maximized { height: 100dvh; }
    #viewChart.chart-maximized > #chartFsBar {
        display: flex;
        flex: none;
        align-items: center;
        gap: 8px;
        padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 4px;
        border-bottom: 1px solid var(--border);
        background: var(--bg-panel);
    }
    #viewChart.chart-maximized:not(.chart-fs-tools) > #toolbar,
    #viewChart.chart-maximized:not(.chart-fs-tools) > #chartSubBar { display: none !important; }
    :root[data-theme] #chartFsBar > button {
        min-height: 34px;
        padding: 4px 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--bg-raised);
        color: var(--text);
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    :root[data-theme] #chartFsBar > button[aria-pressed="true"] {
        border-color: var(--accent);
        color: var(--accent);
    }
    #chartFsExit { margin-left: auto; }
    :root[data-theme] #chartFsBar > button { white-space: nowrap; flex: none; }
    /* The phone rule for every .rotation-level-toggle makes it a full-width
       scrolling row; here it is three chips and must not push Exit off. */
    :root[data-theme] #viewChart #chartFsInterval { flex: none !important; width: auto !important; min-width: 0; max-width: none; overflow: visible; }
}

/* RSI settings (app.js wireRSISettingsDialog): TradingView's sections, one
   column, scrolling inside the dialog when the window is short. */
.rsi-settings-dialog > div { min-width: 320px; }
/* The options scroll, the title and the buttons stay put; chartpanels.js
   caps this to the chart's height while the dialog is open. */
.rsi-settings-scroll { max-height: 70vh; }
.rsi-settings-dialog h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.rsi-settings-dialog .rsi-settings-note { margin: 6px 0 0; font-size: 12px; color: var(--text-dim); }
.rsi-settings-dialog input:disabled, .rsi-settings-dialog select:disabled { opacity: .5; }


/* ------------------------------------------------------------------ */
/* Phones and tablets (2026-10-25)                                     */
/* ------------------------------------------------------------------ */

/* The app was laid out for a desk, and until this block the narrowest rule
   that touched the shell was the 1480px one above. Two widths are handled
   here, and only the SHELL: nav, toolbars, the stock panel and the dialogs.
   The screens themselves -- the tables, the chart's drawing rail, the
   cards -- are each their own change and are not re-laid here.

   Under 1024px (a tablet, or a phone turned sideways) every toolbar wraps and
   gives up its side padding, and a dialog can never be wider than the window.
   Under 640px (a phone) the nav moves to the BOTTOM as a sideways-scrolling
   tab bar with the bell pinned at its right (position: sticky works along
   the scroll axis of a flex row), the stock panel and the dialogs take the
   whole width, and the page's height is the browser's visible area (100dvh)
   rather than 100vh, which on a phone includes the strip behind the address
   bar and leaves the bottom bar hidden under it.

   The toolbars are named by id, every one of them, because styles.css lays
   each out through its id (#rotationToolbar { display: flex }) and an
   attribute selector ([id$="Toolbar"]) loses to an id on every property both
   set -- the trap recorded under "The look lives in ui.css". A new view's
   toolbar joins both lists here, or it keeps the desktop padding and does
   not wrap on a phone.

   Two scripts cooperate: nav.js scrolls the active tab into view when the
   bar scrolls, and ui.js opens the bell's list UPWARD when the bell sits in
   the lower half of the window. Neither changes anything at desk widths. */

@media (max-width: 1024px) {
    /* The body is the outer scroll box and styles.css hides its overflow,
       which still lets a SCRIPT scroll it: on the first phone test a
       scrollIntoView or a focus beside a strip wider than the window (the
       Scans sub-tabs, 1,370px) dragged the whole page, nav included, 65px to
       the left, and nothing could drag it back. clip is not a scroll
       container, so nothing can scroll it. Under 1024px only, because a desk
       window fits every strip and the behaviour there is unchanged. */
    :root[data-theme] body { overflow: clip; }

    :root[data-theme] #toolbar,
    :root[data-theme] #chartSubBar,
    :root[data-theme] #fnoToolbar,
    :root[data-theme] #breadthToolbar,
    :root[data-theme] #macroToolbar,
    :root[data-theme] #industryemaToolbar,
    :root[data-theme] #industryvaluationToolbar,
    :root[data-theme] #rotationToolbar,
    :root[data-theme] #mywlToolbar,
    :root[data-theme] #scansToolbar,
    :root[data-theme] #tickerScanHistoryToolbar,
    :root[data-theme] #watchlistToolbar,
    :root[data-theme] #trackToolbar,
    :root[data-theme] #ipoToolbar,
    :root[data-theme] #ratioScanToolbar,
    :root[data-theme] #actionScanToolbar,
    :root[data-theme] #pnlToolbar,
    :root[data-theme] #portfolioToolbar,
    :root[data-theme] #reportToolbar,
    :root[data-theme] #adminToolbar {
        flex-wrap: wrap;
        row-gap: 6px;
        padding-left: 12px;
        padding-right: 12px;
    }

    /* A control wider than the window pushes the whole page sideways. */
    :root[data-theme] [id$="Toolbar"] select,
    :root[data-theme] [id$="Toolbar"] input,
    :root[data-theme] #toolbar select,
    :root[data-theme] #toolbar input {
        max-width: calc(100vw - 32px);
        min-width: 0;
    }

    :root[data-theme] dialog.app-dialog,
    :root[data-theme] dialog.bt-dialog,
    :root[data-theme] dialog.explainer-dialog,
    :root[data-theme] dialog.turn-dialog,
    :root[data-theme] dialog.accum-detail-dialog,
    :root[data-theme] dialog.fno-bt-dialog {
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - 32px);
        overflow: auto;
        box-sizing: border-box;
    }

    /* Its floor is min(640px, 94vw); on a tablet 94vw is the whole window. */
    :root[data-theme] .constituent-rotation-dialog { min-width: 0; }
}

@media (max-width: 640px) {
    :root[data-theme] #app {
        height: 100vh;
        height: 100dvh;
    }

    /* The nav as a bottom tab bar. order puts it after every .app-view in
       #app's flex column without touching the markup; the safe-area inset is
       the home indicator on a phone with no bottom bezel. */
    :root[data-theme] #appNav {
        order: 1;
        padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
        border-bottom: 0;
        border-top: 1px solid var(--border);
        min-height: 0;
        gap: 2px;
    }

    /* The brand, the account badges and the theme picker are a desk's
       furniture; on a phone the tabs need the width. The theme follows the
       system when nothing was chosen, and the choice can still be made on a
       wider screen in the same browser. */
    :root[data-theme] #appBrand,
    :root[data-theme] #authBadge,
    :root[data-theme] #licenseBadge,
    :root[data-theme] #themePicker { display: none; }

    :root[data-theme] .app-nav-btn {
        padding: 9px 11px;
        font-size: 13px;
    }

    /* The bell stays at the right edge while the tabs scroll under it. The
       shadow is the bar's own colour, so a tab sliding under reads as going
       behind the bell rather than being cut by it. */
    :root[data-theme] #alertBellWrap {
        position: sticky;
        right: 0;
        margin-left: auto;
        padding-left: 6px;
        background: var(--nav-bg);
        box-shadow: -10px 0 10px var(--nav-bg);
    }

    :root[data-theme] .auth-logout-btn { margin: 0 4px; }

    :root[data-theme] #alertDropdown {
        width: min(340px, calc(100vw - 16px));
        max-height: calc(100vh - 90px);
    }

    :root[data-theme] #toolbar,
    :root[data-theme] #chartSubBar,
    :root[data-theme] #fnoToolbar,
    :root[data-theme] #breadthToolbar,
    :root[data-theme] #macroToolbar,
    :root[data-theme] #industryemaToolbar,
    :root[data-theme] #industryvaluationToolbar,
    :root[data-theme] #rotationToolbar,
    :root[data-theme] #mywlToolbar,
    :root[data-theme] #scansToolbar,
    :root[data-theme] #tickerScanHistoryToolbar,
    :root[data-theme] #watchlistToolbar,
    :root[data-theme] #trackToolbar,
    :root[data-theme] #ipoToolbar,
    :root[data-theme] #ratioScanToolbar,
    :root[data-theme] #actionScanToolbar,
    :root[data-theme] #pnlToolbar,
    :root[data-theme] #portfolioToolbar,
    :root[data-theme] #reportToolbar,
    :root[data-theme] #adminToolbar {
        padding-left: 8px;
        padding-right: 8px;
        gap: 6px;
    }

    /* The stock panel is a full-width sheet; it still slides in from the
       right, which is the one transition it has. */
    :root[data-theme] .stock-panel {
        width: 100vw;
        max-width: 100vw;
        border-left: 0;
        padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px));
    }

    :root[data-theme] dialog.app-dialog,
    :root[data-theme] dialog.bt-dialog,
    :root[data-theme] dialog.explainer-dialog,
    :root[data-theme] dialog.turn-dialog,
    :root[data-theme] dialog.accum-detail-dialog,
    :root[data-theme] dialog.fno-bt-dialog {
        min-width: 0;
        max-width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        padding: 12px 14px;
        border-radius: 12px;
    }

    /* The popup table scrolls inside the popup; leave room for its heading,
       toggle and Close on a short screen. */
    :root[data-theme] .constituent-rotation-table-wrap { max-height: 50vh; }
}

/* A finger, not a mouse. Keyed on the pointer rather than the width so a
   touch laptop gets it and a narrow desktop window does not. 36-40px is the
   smallest target a thumb lands on reliably; the desk sizes above are 26px. */
@media (pointer: coarse) {
    :root[data-theme] .app-nav-btn { min-height: 40px; }

    :root[data-theme] #alertBellButton {
        width: 40px;
        height: 40px;
    }

    :root[data-theme] #toolbar button,
    :root[data-theme] #chartStockBar button,
    :root[data-theme] #rotationToolbar button,
    :root[data-theme] #watchlistToolbar button,
    :root[data-theme] #industryemaToolbar button,
    :root[data-theme] #breadthToolbar button,
    :root[data-theme] #macroToolbar button,
    :root[data-theme] #pnlToolbar button,
    :root[data-theme] #portfolioToolbar button,
    :root[data-theme] #scansToolbar > button,
    :root[data-theme] .dialog-buttons button,
    :root[data-theme] .app-dialog-actions button,
    :root[data-theme] .howto-btn,
    :root[data-theme] .stock-panel-buttons button,
    :root[data-theme] .fold-btn {
        min-height: 36px;
        padding: 7px 12px;
    }

    :root[data-theme] [id$="Toolbar"] select,
    :root[data-theme] #toolbar select,
    :root[data-theme] #chartStockBar select {
        min-height: 36px;
    }

    :root[data-theme] .stock-panel-close { padding: 6px 10px; }
}

/* iOS zooms the page in when a field with text under 16px takes focus, and
   does not zoom back out. Only on a phone, and only in the toolbars; the
   desk's 12.5px is right for a desk. */
@media (max-width: 640px) and (pointer: coarse) {
    :root[data-theme] [id$="Toolbar"] select,
    :root[data-theme] [id$="Toolbar"] input[type="text"],
    :root[data-theme] [id$="Toolbar"] input[type="search"],
    :root[data-theme] [id$="Toolbar"] input[type="number"],
    :root[data-theme] #toolbar select,
    :root[data-theme] #toolbar input[type="text"] {
        font-size: 16px;
    }
}

/* ------------------------------------------------------------------ */
/* Phones and tablets: the screens (2026-10-25)                        */
/* ------------------------------------------------------------------ */

/* The block above fits the FRAME; this fits the screens the owner named as
   worth a phone -- Watchlist, Portfolio, the alert list, the stock panel,
   the valuation card, Valuation > Results and read-only charting -- and
   every stock table, since the tables are where the width goes. Every other
   screen keeps its desk layout and scrolls inside its own pane.

   TABLES. Under 1024px every .rs-table is its own sideways scroller
   (display: block; overflow-x: auto): the table is the card and the rows
   scroll inside it, so a 20-column scan never widens the page. Cells stop
   wrapping, or the table squeezes to the window and every figure breaks
   over three lines; the paragraph columns (Commentary, the stage guide)
   keep wrapping at a readable minimum. The NAME column is sticky at the
   left: stocklist.js marks the row's name cell and its header
   (.rs-sticky-col) by the contract it already reads, and a table it does
   not recognise falls back to its first column. Under 640px a column whose
   header carries data-priority="low" is hidden; stocklist.js copies the
   attribute down that column's cells, so a page says it once, in markup.

   display: block makes the table its own scroll container, and that costs
   the header its vertical stick (sticky top now means the top of the
   table, which never scrolls vertically). The tables that sit inside a
   wrapper which already scrolls (the popups' .constituent-rotation-table-
   wrap, Results' .results-table-wrap, the Ratio Scan, Coiled and Bottoms
   panes) therefore stay display: table and let the wrapper scroll both
   ways, which keeps their header stuck and their name column sticky
   against the wrapper. A new wrapper of that kind joins the list below, or
   its table scrolls on its own inside it. */

@media (max-width: 1024px) {
    :root[data-theme] .rs-table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    :root[data-theme] .constituent-rotation-table-wrap .rs-table,
    :root[data-theme] .results-table-wrap .rs-table,
    :root[data-theme] .breadth-history-table-wrap .rs-table,
    :root[data-theme] #ratioBoardWrap .rs-table,
    :root[data-theme] #ratioStocksWrap .rs-table,
    :root[data-theme] #coiledTableWrap .rs-table,
    :root[data-theme] #bottomsIndustriesWrap .rs-table,
    :root[data-theme] #bottomsStocksWrap .rs-table {
        display: table;
        max-width: none;
        overflow: visible;
    }

    :root[data-theme] .rs-table th,
    :root[data-theme] .rs-table td {
        white-space: nowrap;
        padding: 8px 10px;
    }

    /* The paragraph cells keep wrapping; a minimum width or they squeeze
       to one word a line beside the sticky name. */
    :root[data-theme] .rs-table td.watchlist-summary-cell,
    :root[data-theme] .rs-table td.actionscan-summary,
    :root[data-theme] .rs-table td.stage-guide-cell,
    :root[data-theme] .macro-size-table td {
        white-space: normal;
        min-width: 220px;
        max-width: 70vw;
    }

    /* The name column, pinned. An opaque background, or the scrolled
       columns show through it; the header's is the header band's. */
    :root[data-theme] .rs-table .rs-sticky-col,
    :root[data-theme] .rs-table:not(:has(.rs-sticky-col)) tr > :is(th, td):first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--bg-panel);
        box-shadow: 6px 0 8px -6px var(--shadow);
    }
    :root[data-theme] .rs-table thead th.rs-sticky-col,
    :root[data-theme] .rs-table:not(:has(.rs-sticky-col)) thead tr > th:first-child {
        z-index: 3;
        background: var(--th-bg);
    }
    /* The row hover is translucent and would read lighter on the opaque
       sticky cell than on the row; blend it over the panel. */
    :root[data-theme] .rs-table tbody tr:hover td.rs-sticky-col,
    :root[data-theme] .rs-table:not(:has(.rs-sticky-col)) tbody tr:hover > td:first-child {
        background: color-mix(in srgb, var(--row-hover), var(--bg-panel));
    }

    /* P&L and Portfolio padded the TABLE for their gutter; inside a scroll
       box that padding scrolls with the rows. A margin does the same job
       outside it. */
    :root[data-theme] #viewPnl .rs-table,
    :root[data-theme] #viewPortfolio .rs-table {
        padding: 0;
        margin: 0 16px;
        max-width: calc(100% - 32px);
    }
}

@media (max-width: 640px) {
    :root[data-theme] .rs-table [data-priority="low"] { display: none; }

    /* ---- Watchlist ---- */
    :root[data-theme] #viewMywatchlist {
        padding: 0 10px 10px;
        overflow-x: hidden;
    }
    :root[data-theme] #mywlToolbar { margin: 0 -10px 4px; }
    :root[data-theme] #viewMywatchlist .rrg-legend-note { font-size: 12px; }
    :root[data-theme] .mywl-add-combo { max-width: calc(100vw - 110px); }
    :root[data-theme] .mywl-add-menu { max-width: calc(100vw - 20px); }

    /* ---- Portfolio ---- */
    :root[data-theme] #viewPortfolio { overflow-x: hidden; }
    :root[data-theme] .portfolio-tiles { padding: 10px 10px 0; gap: 8px; }
    :root[data-theme] .portfolio-tile {
        flex: 1 1 calc(50% - 4px);
        box-sizing: border-box;
        min-width: 0;
        padding: 8px 10px;
    }
    :root[data-theme] .portfolio-tile-value { font-size: 15px; }
    :root[data-theme] .portfolio-flags { padding: 10px 10px 0; }
    :root[data-theme] #portfolioAllocationSection { padding: 12px 10px; }
    :root[data-theme] #portfolioAllocationBody { justify-content: center; gap: 12px; }
    :root[data-theme] #portfolioDonut { width: 180px; height: 180px; }
    :root[data-theme] #portfolioAllocationLegend { min-width: 0; width: 100%; max-height: 200px; }
    :root[data-theme] #viewPortfolio h3 { margin: 12px 10px 4px; }
    :root[data-theme] #portfolioEmptyState { margin: 12px 10px; }
    :root[data-theme] #viewPortfolio .rs-table,
    :root[data-theme] #viewPnl .rs-table {
        margin: 0 10px;
        max-width: calc(100% - 20px);
    }

    /* ---- The alert list ---- */
    :root[data-theme] #alertDropdown { width: calc(100vw - 16px); }
    /* The bell's wrap is position: sticky (the shell block), which is a
       stacking context of its own at level 0, and the list is INSIDE it:
       the sticky name cells above (z-index 2 and 3) painted over the open
       list on the first phone test. Lift the wrap, and the list with it. */
    :root[data-theme] #alertBellWrap { z-index: 20; }
    :root[data-theme] .alert-row { padding: 10px 12px; font-size: 13px; line-height: 1.4; }

    /* ---- The stock panel ---- */
    :root[data-theme] .stock-panel {
        height: 100vh;
        height: 100dvh;
    }
    /* Label over value, not beside it: a VCP or Multibagger line runs to
       two hundred characters, and a two-column grid gave it 60% of 375px. */
    :root[data-theme] .stock-panel-grid {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }
    :root[data-theme] .stock-panel-k {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-top: 8px;
    }
    :root[data-theme] .stock-panel-grid > .stock-panel-k:first-child { margin-top: 0; }
    :root[data-theme] .stock-panel-v { line-height: 1.45; overflow-wrap: anywhere; }
    :root[data-theme] .stock-panel-buttons button { flex: 1 1 auto; }

    /* ---- The valuation card: a full-screen sheet ----
       The overlay's inner box is laid out by inline style in index.html
       (a 92vw box at 5% from the top), which only !important beats. */
    :root[data-theme] #valuationDetailOverlay > div {
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        height: 100dvh;
        border-radius: 0 !important;
        border: 0 !important;
        padding: 10px 10px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box;
    }
    :root[data-theme] #valuationDetailBody { font-size: 0.92em !important; }
    :root[data-theme] .vd-visuals { padding: 8px 8px; }
    :root[data-theme] .vd-row {
        grid-template-columns: 92px 1fr 54px;
        gap: 6px;
    }
    :root[data-theme] .vd-label { line-height: 1.2; }
    /* The Results section's tables (8 columns in the growth matrix, 11 in
       the re-rating table) scroll inside the section with the row label
       pinned. .rx already clips sideways; making each TABLE the scroller
       keeps the headings above them in place. */
    :root[data-theme] .rx { overflow-x: visible; }
    :root[data-theme] .rx-table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
    }
    :root[data-theme] .rx-table th:first-child,
    :root[data-theme] .rx-table td.rx-name {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--bg-panel);
        padding-left: 4px;
        padding-right: 8px;
        box-shadow: 6px 0 8px -6px var(--shadow);
    }
    :root[data-theme] .rx-strip-q { min-width: 0; flex: 1 1 calc(50% - 3px); }
    :root[data-theme] .gb-card { padding: 7px 8px 6px; }

    /* ---- Valuation > Results ---- */
    :root[data-theme] #viewIndustryvaluation { overflow-x: hidden; }
    :root[data-theme] #resultsCard .results-kpis {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    :root[data-theme] #resultsCard .results-kpi { padding: 5px 8px; }
    :root[data-theme] #resultsCard .results-kpi-value { font-size: 16px; }
    :root[data-theme] #resultsCard .results-kpi-label { font-size: 11px; }
    /* The scorecard two to a row, and the industry tiles a sideways strip:
       a grid of twenty tiles would push the table off a phone's screen. */
    :root[data-theme] #resultsCard .results-scorecard { grid-template-columns: 1fr 1fr; gap: 6px; }
    :root[data-theme] #resultsCard .results-scorecard .results-kpi-value { font-size: 16px; }
    :root[data-theme] #resultsCard .results-ind-grid {
        display: flex;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
    }
    :root[data-theme] #resultsCard button.results-ind-tile { flex: 0 0 200px; }
    :root[data-theme] #resultsCard .results-sub { max-width: 150px; }
    /* The profit-level sparkline gives way first; the chip and its line stay. */
    :root[data-theme] #resultsCard .results-spark { display: none; }
    :root[data-theme] #resultsCard .results-level { min-width: 0; }
    :root[data-theme] #resultsCard .results-head select { max-width: calc(100vw - 110px); }
    :root[data-theme] #resultsCard .results-filters input[type="text"] { width: 100% !important; box-sizing: border-box; }
    :root[data-theme] .results-record-card { max-width: calc(100vw - 16px); }

    /* ---- The Chart page ----
       From 2026-10-25 to 2026-10-31 this hid the drawing rail, the study
       menus (Indicators, chart type, Compare, Replay, undo and redo, the
       magnet, %, settings, screenshot), paper trading, Cycle and the cards
       over the chart's top-right corner, on the reading that a phone chart
       is read-only. The owner opened the page on a phone and asked where
       the menus and the cards had gone, so every control is back: the
       toolbar wraps to as many rows as it needs, each menu drops below the
       WHOLE toolbar at the window's width (the "menus and strips" block at
       the end of this file), and the cards sit in the corner at a smaller
       size. Only the bar count and the refresh status are left out. */
    :root[data-theme] #toolbar .sector-combo,
    :root[data-theme] #toolbar .mywl-add-combo { max-width: calc(100vw - 180px); }
    :root[data-theme] #toolbar #sectorSearchInput,
    :root[data-theme] #toolbar #stockSearchInput { width: 100%; min-width: 0; box-sizing: border-box; }
    :root[data-theme] #toolbar #statusLabel,
    :root[data-theme] #toolbar #refreshStatus { display: none; }
    :root[data-theme] .chart-legend { max-width: calc(100% - 60px); font-size: 11px; line-height: 16px; }
    :root[data-theme] .chart-legend-head,
    :root[data-theme] .chart-legend-ohlc { flex-wrap: wrap; }
    :root[data-theme] .chart-legend-name { max-width: 150px; }
}

/* A finger cannot hover. The copy glyph beside a ticker is drawn by
   tickercopy.js on mouseover and faded in by :hover; on a coarse pointer
   stocklist.js draws it with the tier and it is always visible, a little
   larger. Hover notes (title=) have a tap equivalent in taptip.js, which
   draws them as a .tap-tip under the tapped element. */
@media (pointer: coarse) {
    :root[data-theme] .ticker-copy {
        /* Full ink, never a fade: at 0.75 the glyph measured 4.2:1 on both
           themes, under the 4.5:1 bar every piece of text here clears. */
        opacity: 1;
        color: var(--text-dim);
        font-size: 13px;
        padding: 4px 6px;
        margin-left: 2px;
    }
    :root[data-theme] .th-copy-tickers { padding: 4px 8px; font-size: 1em; }
    :root[data-theme] .mywl-remove-btn { padding: 6px 10px; font-size: 14px; }
}

:root[data-theme] .tap-tip {
    position: fixed;
    z-index: 3000;
    max-width: min(360px, calc(100vw - 24px));
    padding: 8px 10px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--pop-shadow);
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-line;
}

/* Market Breadth > Market, "Share of stocks above their EMA, over time"
   (breadthema.js). One categorical slot per average, from the Trend tab's
   validated palette: amber for 100 and blue for 200, as on the chart the
   owner brought. The fill is a light wash of the line's own colour. */
.be-e20 { --be: var(--gb-c3); }
.be-e50 { --be: var(--gb-c7); }
.be-e100 { --be: var(--gb-c4); }
.be-e200 { --be: var(--gb-c1); }
.be-line { fill: none; stroke: var(--be); stroke-width: 1.5; stroke-linejoin: round; }
.be-area { fill: color-mix(in srgb, var(--be) 16%, transparent); stroke: none; }
.be-swatch { background: var(--be); }
.be-panel + .be-panel { margin-top: 10px; }
.be-head { font-size: 13px; color: var(--text); margin-bottom: 2px; display: flex; align-items: center; gap: 2px; }
.be-head b { color: var(--text-bright); margin: 0 4px; }
.be-svg { display: block; }
.be-low { stroke: var(--neg); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.be-ring { fill: none; stroke: var(--neg); stroke-width: 2; pointer-events: none; }
.be-record { margin-top: 12px; }
.be-record-title { font-size: 13px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.be-table td, .be-table th { white-space: nowrap; }
/* The rebuilt part of the history (counted on today's companies) sits on a
   faint wash with a dashed edge, so it never reads as the same record as the
   readings stored at the time. */
.be-rebuilt { fill: var(--text-dim); opacity: 0.07; }
.be-rebuilt-edge { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.be-rebuilt-label { fill: var(--text-dim); font-size: 11px; }
.be-tag { color: var(--text-dim); font-size: 11px; margin-left: 4px; }


/* ------------------------------------------------------------------ */
/* Phones and tablets: the strips and the menus (2026-10-31)          */
/* ------------------------------------------------------------------ */

/* The owner opened the app on a phone six days after the two blocks above
   shipped and found "some menu and screens not fully visible" and the chart's
   cards gone. Measured at 375px: every segmented sub-tab strip
   (.rotation-level-toggle: Scans 1,370px, Macro 978, Sector Rotation 913,
   Ratio Scan 594, Market Breadth 504) ran off the right edge, and since the
   body is overflow: clip there was no way to reach the tabs past it. The
   strip is inline-flex with flex-wrap: wrap already, but ui.css also gives
   it flex-shrink: 0 inside the toolbar's flex row, so it is never narrower
   than its chips laid out on one line and never wraps. Under 1024px it may
   shrink to the toolbar's width, and then its own wrap takes over.

   The second half is the menus. A .dropdown-menu is positioned under its
   own button (position: absolute; left: 0), so one opened from a button at
   the right of a phone's toolbar ran past the edge. Inside the chart's
   toolbar the dropdown's own box is static under 640px, so the menu is
   placed against #toolbar instead: directly under the whole toolbar, at the
   window's width, which is where a phone puts a menu. The sector, ratio and
   watchlist pickers keep their own anchor because their list is typed into
   and scrolls. Everywhere else ui.js shifts an open menu, flyout or popover
   back inside the window after each click (translateX, reset when it
   closes), since a menu's width is only known once it is open. */

@media (max-width: 1024px) {
    :root[data-theme] .rotation-level-toggle {
        flex-shrink: 1;
        min-width: 0;
        max-width: 100%;
    }

    :root[data-theme] .dropdown-menu,
    :root[data-theme] .draw-flyout,
    :root[data-theme] .paper-size-popover {
        max-width: calc(100vw - 16px);
        box-sizing: border-box;
    }

    :root[data-theme] .dropdown-menu {
        max-height: 70vh;
        overflow: auto;
    }
}

@media (max-width: 640px) {
    /* The range buttons and Go to date wrapped onto the How to use button,
       which sat 7px past the edge. */
    :root[data-theme] .chart-range-bar { flex-wrap: wrap; }

    /* The cards over the chart: in the corner, smaller, never wider than
       two thirds of the chart. They let the mouse through (styles.css), so
       the chart under them still pans. */
    :root[data-theme] .chart-top-right-panels {
        top: 6px;
        right: 6px;
        gap: 4px;
        max-width: 68%;
        font-size: 11px;
    }

    :root[data-theme] #toolbar { position: relative; }
    :root[data-theme] #toolbar .dropdown:not(.sector-combo):not(.mywl-add-combo) { position: static; }
    :root[data-theme] #toolbar .dropdown:not(.sector-combo):not(.mywl-add-combo) > .dropdown-menu {
        left: 8px;
        right: 8px;
        width: auto;
        min-width: 0;
    }
}

/* The second pass, every sub-tab clicked at 375px: the preset strips on the
   Scans tabs (.scans-ema-filter: VCP 858px, EMA+RSI40 899, Momentum 859,
   Multibagger 781, Wyckoff 600) are flex rows with no wrap; the status line
   (#scansStatus, "9 of 10 matches shown (Monthly RSI) (stored ...)") is
   nowrap and ran to 687px on Multibagger; the Filters / Info switches and
   their chips (.fold-switches, 662px on Bottoms) wrap only when something
   makes them narrower than their chips; Macro > Rate cycles' control row
   (.macro-controls, 644px) does not wrap; and F&O > Paper Book's table is
   not an .rs-table, so it kept the desk width. Each wraps or scrolls now. */
@media (max-width: 1024px) {
    :root[data-theme] .scans-ema-filter,
    :root[data-theme] .macro-controls {
        flex-wrap: wrap;
        min-width: 0;
        max-width: 100%;
        row-gap: 6px;
    }

    :root[data-theme] .fold-switches,
    :root[data-theme] [data-fold-slot] {
        flex-wrap: wrap;
        min-width: 0;
        max-width: 100%;
        white-space: normal;
    }

    :root[data-theme] .rotation-status {
        white-space: normal;
        min-width: 0;
        max-width: 100%;
    }

    :root[data-theme] #viewFno table:not(.rs-table) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
}

/* ===================================================================
 * The Journal (journal.js, docs/PLAN-JOURNAL.md, 2026-11-03).
 *
 * Tokens only, so both themes follow; no text is faded with opacity (the
 * 4.5:1 rule at the top of this file). The page has a phone layout from day
 * one: the owner posts readings from a phone, so the grid, the timeline, the
 * viewer and the add dialog all read at 375px (the last block below).
 * =================================================================== */
#viewJournal.active { display: flex; flex-direction: column; min-height: 0; }
#journalToolbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 8px 16px; border-bottom: 1px solid var(--border);
}
#journalToolbar #journalFind { width: 240px; }
.jr-spacer { flex: 1 1 auto; }
.jr-usage { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.jr-count {
    display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
    border-radius: 9px; background: var(--warn-bg); color: var(--warn);
    font-size: 11px; font-weight: 700; text-align: center;
}
.jr-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 28px; }
.jr-notices { padding: 0 16px; }
/* Dim ink at full opacity, never a faded opacity (the contrast rule). */
.jr-disclaimer { flex: 0 0 auto; margin: 0; padding: 6px 16px 8px; border-top: 1px solid var(--border); font-size: 11.5px; line-height: 1.45; color: var(--text-dim); }
.jr-disclaimer b { color: var(--text); }
.jr-disclaimer-viewer { padding: 8px 0 0; margin-top: 8px; }
.jr-notices:empty { display: none; }
.jr-notice, .jr-flash {
    margin-top: 10px; padding: 8px 12px; border-radius: 8px;
    background: var(--accent-soft); color: var(--text-bright); font-size: 13px;
}
.jr-notice ul { margin: 6px 0; padding-left: 18px; }
.jr-notice-warn { background: var(--warn-bg); }
.jr-notice-error, .jr-flash-error { background: var(--neg-bg); color: var(--text-brightest); }
.jr-muted { color: var(--text-dim); }
.jr-small { font-size: 12px; }
.jr-up { color: var(--pos); }
.jr-down { color: var(--neg); }
.jr-empty {
    margin: 40px auto; max-width: 560px; padding: 24px; text-align: center;
    border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--text-dim); line-height: 1.6;
}
.jr-section { margin: 22px 0 10px; font-size: 14px; color: var(--text-bright); }
.jr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.jr-footnote { margin-top: 18px; font-size: 12px; }

.jr-btn {
    background: var(--bg-raised); color: var(--text-bright);
    border: 1px solid var(--border-strong); border-radius: 8px;
    padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 500; line-height: 1.4;
    cursor: pointer; white-space: nowrap;
}
.jr-btn:hover:not(:disabled) { background: var(--bg-sunken); border-color: var(--border-bright); color: var(--text-brightest); }
.jr-btn:disabled { cursor: default; color: var(--text-faintest); }
.jr-btn.on { border-color: var(--accent); color: var(--accent-strong); }
.jr-btn.jr-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.jr-btn.jr-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
:root[data-theme="light"] .jr-btn.jr-primary:hover:not(:disabled) { background: #1f6fd1; border-color: #1f6fd1; }
.jr-btn.jr-primary:disabled { opacity: 1; background: var(--bg-raised); border-color: var(--border-strong); color: var(--text-faintest); }
.jr-danger { color: var(--neg); }
.jr-link {
    background: none; border: 0; padding: 0; font: inherit; font-size: 12.5px;
    color: var(--link); cursor: pointer;
}
.jr-link:hover { text-decoration: underline; }
.jr-link.jr-danger { color: var(--neg); }
.jr-file { position: relative; overflow: hidden; }
/* Positioned for the same reason as .pl-switch (2026-11-19): an input hidden
 * with position:absolute and no positioned ancestor is laid out against the
 * document and can make it scroll. */
.jr-file-inline { position: relative; }
.jr-file input, .jr-file-inline input { position: absolute; left: -9999px; }
.jr-input {
    background: var(--bg-sunken); color: var(--text-bright);
    border: 1px solid var(--border-strong); border-radius: 7px;
    padding: 6px 9px; font: inherit; font-size: 13px; min-width: 0;
}
textarea.jr-input { resize: vertical; width: 100%; box-sizing: border-box; line-height: 1.45; }
.jr-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }

.jr-chip {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    background: var(--bg-sunken); color: var(--text-soft); border: 1px solid var(--border);
}
.jr-tier { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.jr-untracked, .jr-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.jr-bull { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
.jr-bear { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.jr-neutral { color: var(--text-soft); }
.jr-saved { color: var(--accent-strong); }
.jr-tag { color: var(--text-dim); font-weight: 500; }
button.jr-tag-link { cursor: pointer; font-family: inherit; line-height: inherit; }
button.jr-tag-link:hover { color: var(--accent-strong); border-color: var(--accent); }
button.jr-asset-chip { cursor: pointer; color: var(--text-bright); font-family: inherit; }
.jr-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.jr-pill {
    background: transparent; color: var(--text-soft);
    border: 1px solid var(--border-strong); border-radius: 999px;
    padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.jr-pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.jr-pill.on.jr-b-bullish { background: var(--pos-bg); border-color: var(--pos); color: var(--pos); }
.jr-pill.on.jr-b-bearish { background: var(--neg-bg); border-color: var(--neg); color: var(--neg); }
.jr-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.jr-facets { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 10px 0 14px; }
.jr-facet { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Assets, collections and Unfiled tiles. */
.jr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.jr-tile {
    display: flex; flex-direction: column; gap: 6px; text-align: left;
    background: var(--bg-deeper); color: var(--text); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px; font: inherit; cursor: pointer; position: relative;
    box-shadow: var(--card-shadow);
}
.jr-tile:hover { border-color: var(--border-bright); }
.jr-tile-img {
    display: block; height: 140px; border-radius: 8px; overflow: hidden;
    background: var(--bg-sunken); border: 1px solid var(--border); padding: 0; width: 100%;
}
.jr-tile-img img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.jr-tile-noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-dim); font-size: 12px; }
.jr-tile-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.jr-tile-name { font-weight: 700; font-size: 14px; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jr-tile-meta { font-size: 12px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.jr-tile-caption { font-size: 12.5px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.jr-unfiled-tile { cursor: default; }
.jr-unfiled-tile .jr-tile-img { cursor: zoom-in; }
.jr-tile-check { position: absolute; top: 16px; left: 16px; z-index: 1; background: var(--bg-panel); border-radius: 6px; padding: 2px 6px; }
.jr-picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.jr-bulk {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-deeper);
}
.jr-bulk .jr-asset-input { width: 220px; }

/* One asset's timeline. */
.jr-asset-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 6px; }
.jr-asset-head h2 { margin: 0; font-size: 20px; color: var(--text-brightest); }
.jr-cards { display: flex; flex-direction: column; gap: 12px; }
.jr-card {
    display: grid; grid-template-columns: 96px auto minmax(0, 1fr); gap: 16px;
    background: var(--bg-deeper); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
    box-shadow: var(--card-shadow);
}
.jr-card.jr-picking { cursor: copy; }
.jr-card-date { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-dim); }
.jr-card-date b { font-size: 15px; color: var(--text-bright); }
.jr-card-pics { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; max-width: 480px; }
.jr-thumb {
    width: 230px; height: 128px; padding: 0; border-radius: 8px; overflow: hidden;
    border: 1px solid var(--border); background: var(--bg-sunken); cursor: zoom-in;
}
.jr-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.jr-more { align-self: center; color: var(--text-dim); font-size: 12px; }
.jr-card-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.jr-note { white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; }
.jr-col-note { margin: 4px 0 12px; }
.jr-price { font-size: 12.5px; color: var(--text-dim); }
.jr-price b { color: var(--text-bright); }
.jr-actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* By date. */
.jr-months { display: flex; flex-direction: column; gap: 6px; }
.jr-year { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.jr-year-label { width: 44px; font-weight: 700; color: var(--text-bright); font-size: 13px; }

/* Dialogs. */
dialog.jr-dialog { padding: 14px 18px; max-height: 92vh; overflow-y: auto; }
dialog.jr-viewer { width: min(1320px, 96vw); }
dialog.jr-editor { width: min(720px, 96vw); }
dialog.jr-compare { width: min(1400px, 96vw); }
dialog.jr-small { width: min(560px, 94vw); }

/* The administrators' new readings: the pop-up and the Journal tab's count. */
dialog.jr-notices { width: min(640px, 96vw); }
.jr-notice-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; }
.jr-notice { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); color: var(--text); cursor: pointer; font: inherit; }
.jr-notice:hover { border-color: var(--accent); background: var(--accent-soft); }
.jr-notice img, .jr-notice-blank { width: 96px; height: 60px; flex: none; object-fit: cover; border-radius: 4px; background: var(--bg-sunken); }
.jr-notice-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.jr-notice-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.jr-notice-note { font-size: 13px; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.jr-notice-tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.jr-notice-tag.jr-notice-upd { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.jr-notice-section { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
/* An asset's discussion: comments and questions under its readings. */
.jr-discuss { margin-top: 22px; padding-top: 6px; border-top: 1px solid var(--border); max-width: 900px; }
.jr-comments { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.jr-comment { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); }
.jr-comment-owner { border-left: 3px solid var(--accent); }
.jr-comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.jr-comment-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.jr-comment-form { display: flex; flex-direction: column; gap: 6px; }
.jr-comment-form textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 64px; padding: 8px; font: inherit; color: var(--text); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; }
.jr-tile-talk { font-size: 11px; color: var(--accent); white-space: nowrap; }
.jr-tile-new { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 9px; color: var(--bg-panel); background: var(--accent); white-space: nowrap; }
.app-nav-btn .jr-nav-badge { cursor: pointer; }
/* An owner's comment already carries the accent edge, so new is a wash. */
.jr-comment.jr-comment-new { background: var(--accent-soft); border-color: var(--accent); }
.app-nav-btn .jr-nav-badge { display: inline-block; min-width: 16px; margin-left: 5px; padding: 0 5px; border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; color: var(--bg-panel); background: var(--accent); vertical-align: middle; }
.jr-viewer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.jr-viewer-head h3 { margin: 0; font-size: 16px; }
.jr-viewer-main { display: flex; flex-wrap: wrap; gap: 18px; }
.jr-viewer-pic { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.jr-viewer-form { flex: 1 1 300px; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.jr-stage {
    background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; min-height: 240px;
    max-height: 66vh; overflow: auto; cursor: zoom-in;
}
.jr-stage img { max-width: 100%; max-height: 66vh; display: block; }
.jr-stage.jr-actual { cursor: zoom-out; align-items: flex-start; justify-content: flex-start; }
.jr-stage.jr-actual img { max-width: none; max-height: none; }
.jr-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.jr-strip-item { position: relative; }
.jr-strip-item > button:first-child {
    width: 92px; height: 54px; padding: 0; border-radius: 6px; overflow: hidden;
    border: 1px solid var(--border); background: var(--bg-sunken); cursor: pointer;
}
.jr-strip-item.on > button:first-child { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.jr-strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jr-strip-del {
    position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; padding: 0;
    border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg-panel);
    color: var(--neg); font-size: 11px; cursor: pointer;
}
.jr-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* Side by side only inside a row: in the dialogs' column a flex basis is a
   height, and 140px of it opened a gap under every field. */
.jr-row > .jr-field { flex: 1 1 140px; }
.jr-field > span { font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px; color: var(--text-dim); text-transform: uppercase; }
.jr-resolve { font-size: 12px; color: var(--warn); }
.jr-resolve.jr-resolved { color: var(--pos); }
.jr-editor-form { display: flex; flex-direction: column; gap: 12px; }
.jr-capture { display: flex; flex-direction: column; gap: 6px; }
.jr-capture img { width: 100%; max-height: 300px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-sunken); }
.jr-drop {
    border: 2px dashed var(--border-strong); border-radius: 12px; padding: 14px;
    display: flex; flex-direction: column; gap: 10px; outline: none;
}
.jr-drop.jr-over { border-color: var(--accent); background: var(--accent-soft); }
.jr-drop-hint { color: var(--text-dim); font-size: 13px; text-align: center; }
.jr-drop.jr-has .jr-drop-hint { text-align: left; }
.jr-file-inline { position: relative; cursor: pointer; }
.jr-previews { display: flex; flex-wrap: wrap; gap: 10px; }
.jr-previews:empty { display: none; }
.jr-preview { position: relative; display: flex; flex-direction: column; gap: 2px; }
.jr-preview img { width: 150px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.jr-preview small { color: var(--text-dim); font-size: 11px; }
.jr-preview button {
    position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0;
    border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg-panel); color: var(--neg); cursor: pointer;
}
.jr-compare-body { display: flex; flex-wrap: wrap; gap: 16px; }
.jr-compare-side { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.jr-compare-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.jr-compare-pic img { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
.jr-pick-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; max-height: 50vh; overflow-y: auto; }
.jr-pick-row {
    display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-deeper); color: var(--text-bright); font: inherit; cursor: pointer;
}
.jr-pick-row:hover { border-color: var(--accent); }
.jr-pre {
    background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; font-size: 12px; overflow-x: auto; color: var(--text-bright);
}

/* The stock panel's line. */
.jr-panel-line { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 13px; }
.jr-panel-line img { width: 96px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

@media (max-width: 1024px) {
    :root[data-theme] #journalToolbar { padding-left: 12px; padding-right: 12px; row-gap: 6px; }
    .jr-card { grid-template-columns: 80px minmax(0, 1fr); }
    .jr-card-body { grid-column: 1 / -1; }
}

/* Phones: two tiles a row, the timeline in one column, the viewer and the
   add dialog as full-width sheets, every touch target at least 36px. */
@media (max-width: 640px) {
    :root[data-theme] #journalToolbar { padding-left: 8px; padding-right: 8px; gap: 6px; }
    #journalToolbar #journalFind { width: 100%; order: 5; }
    #journalToolbar .jr-usage { order: 6; width: 100%; white-space: normal; }
    .jr-body { padding: 10px 8px 24px; }
    .jr-disclaimer { padding: 4px 8px 5px; font-size: 10.5px; line-height: 1.35; }
    .jr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .jr-tile { padding: 7px; border-radius: 10px; }
    .jr-tile-img { height: 96px; }
    .jr-card { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px; }
    .jr-card-date { flex-direction: row; gap: 8px; align-items: baseline; }
    .jr-card-pics { max-width: none; }
    .jr-thumb { width: calc(50% - 4px); height: 96px; }
    .jr-card-pics .jr-thumb:only-child { width: 100%; height: 170px; }
    dialog.jr-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: 10px 12px; }
    .jr-viewer-form { max-width: none; }
    .jr-stage, .jr-stage img { max-height: 48vh; }
    .jr-bulk .jr-asset-input { width: 100%; }
    .jr-btn, .jr-pill { min-height: 36px; }
    .jr-actions { gap: 16px; }
    .jr-actions .jr-link { padding: 6px 0; }
}
@media (max-width: 640px) and (pointer: coarse) {
    .jr-input { font-size: 16px; }
}

/* The Journal's Telegram dialog and post status (migration 78). */
.jr-h4 { margin: 14px 0 6px; font-size: 13px; color: var(--text-bright); }
.jr-targets { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.jr-target {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--bg-deeper);
}
.jr-target-name { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.jr-posted { background: var(--pos-bg); color: var(--pos); border-color: transparent; }

/* The chart's plot is the canvas's own colour (--kc-bg), which on the light
   theme and on a light chart is TradingView's white rather than the app's
   grey ground. */
:root[data-theme] #chartContainer { background: var(--kc-bg); }

/* Ctrl held flips the magnet (chart-app.js installMagnetFlip): the button
   says so while it lasts, so a point that did or did not snap is never a
   surprise. */
:root[data-theme] #chartMagnetToggle.magnet-flipped { outline: 1px dashed var(--accent); outline-offset: -3px; }

/* Chart Settings laid out as TradingView's (chartsettings.js): tabs down the
   left, one tab's options on the right, Reset at the foot. The panes scroll,
   the dialog keeps its height while tabs change. */
:root[data-theme] #chartSettingsDialog.chart-settings-dialog { width: min(980px, 96vw); }
.cs-shell > h3 { margin: 0 0 12px; font-size: 18px; }
.cs-body { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; height: min(560px, 70vh); }
.cs-nav { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); padding-right: 10px; }
:root[data-theme] .cs-nav button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin: 0;
    border: 0; border-radius: 6px; background: transparent; color: var(--text-soft);
    font-size: 14px; text-align: left; cursor: pointer; box-shadow: none;
}
:root[data-theme] .cs-nav button:hover { background: var(--row-hover); color: var(--text); }
:root[data-theme] .cs-nav button.active { background: var(--accent-soft); color: var(--text-bright); font-weight: 600; }
.cs-nav svg { flex: 0 0 auto; }
.cs-panes { overflow-y: auto; padding-right: 6px; }
.cs-pane[hidden] { display: none; }
.cs-head {
    margin: 14px 0 6px; color: var(--text-dim); font-size: 11px; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase;
}
.cs-pane > .cs-head:first-child { margin-top: 0; }
.cs-row { display: flex; align-items: center; gap: 12px; min-height: 34px; }
.cs-row .cs-label { flex: 0 0 210px; color: var(--text); }
.cs-check { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.cs-indent { padding-left: 24px; }
.cs-controls { display: inline-flex; align-items: center; gap: 8px; color: var(--text-dim); }
.cs-controls input[type="color"] { width: 34px; height: 26px; padding: 0 2px; }
.cs-controls input[type="number"] { width: 72px; }
.cs-note { color: var(--text-dim); font-size: 12px; margin: 10px 0 0; }
.chart-settings-dialog .dialog-buttons { display: flex; gap: 8px; }
.chart-settings-dialog .cs-reset { margin-right: auto; }
/* Chart dialogs on a phone (Chart Settings, RSI, indicator settings;
   chartpanels.js stands down for them under 640px). A full-screen sheet:
   the title, then the options scrolling, then the buttons on their own row
   at the foot, which is the only layout where nothing hides behind them.
   The first phone layout capped .cs-body while its panes did the scrolling,
   and the Canvas tab's Floating toolbars sat under Reset and OK (owner's
   screenshot, 2026-11-13). The tabs wrap to two rows rather than scroll:
   five labels, every one in sight. */
@media (max-width: 640px) {
    :root[data-theme] dialog.chart-fit-dialog[open] {
        position: fixed;
        inset: 0 !important;
        margin: 0 !important;
        width: 100vw !important;
        min-width: 0 !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border: 0;
        border-radius: 0;
        padding: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    dialog.chart-fit-dialog[open] > div {
        flex: 1 1 auto;
        min-height: 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        padding: calc(10px + env(safe-area-inset-top, 0px)) 14px calc(10px + env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }
    dialog.chart-fit-dialog[open] > div > h3 { flex: none; margin: 0 0 8px; }
    dialog.chart-fit-dialog .rsi-settings-scroll,
    dialog.chart-fit-dialog #indicatorDialogFields {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
    }
    dialog.chart-fit-dialog .dialog-buttons {
        flex: none;
        margin: 0;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }
    .cs-body {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .cs-nav {
        flex: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 0 0 8px;
    }
    :root[data-theme] .cs-nav button { width: auto; white-space: nowrap; padding: 7px 10px; font-size: 13px; gap: 6px; }
    .cs-nav svg { width: 15px; height: 15px; }
    .cs-panes { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 0; }
    .cs-row { flex-wrap: wrap; row-gap: 4px; }
    .cs-row .cs-label { flex-basis: 140px; }
}

/* Status line switches (chartlegend.js setOptions). */
.chart-legend.no-title .chart-legend-title { display: none; }
.chart-legend.with-background { background: color-mix(in srgb, var(--kc-bg) 85%, transparent); border-radius: 4px; padding: 2px 6px; }
.cs-hint { color: var(--text-dim); font-size: 12px; margin-left: 6px; }

/* The screenshot button's confirmation (app.js screenshotToast). */
.chart-shot-toast {
    position: fixed; z-index: 1200; padding: 8px 12px; border-radius: 6px;
    background: var(--drawbar-bg); color: var(--drawbar-ink); border: 1px solid var(--drawbar-border);
    box-shadow: var(--drawbar-shadow); font-size: 13px; pointer-events: none;
    opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s;
}
.chart-shot-toast.show { opacity: 1; transform: none; }

/* ===================================================================
 * The Analysis page (analysis.js, 2026-11-04): one stock read across every
 * screen. Tokens only, so both themes follow; no text is faded with opacity
 * (the 4.5:1 rule at the top of this file). Buttons are styled by class, not
 * through the toolbar id rules, which is why #analysisToolbar is in neither
 * list above. Its phone layout is the last block here.
 * =================================================================== */
#viewReport.active { display: flex; flex-direction: column; min-height: 0; }
#analysisToolbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 8px 16px; border-bottom: 1px solid var(--border);
}
.an-search { position: relative; flex: 0 1 380px; min-width: 220px; }
.an-search input {
    width: 100%; box-sizing: border-box; padding: 7px 10px; font-size: 14px;
    background: var(--bg-sunken); color: var(--text-bright);
    border: 1px solid var(--border-strong); border-radius: 8px;
}
.an-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.an-menu {
    display: none; position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
    max-height: 360px; overflow-y: auto; padding: 4px;
    background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--pop-shadow);
}
.an-menu.open { display: block; }
.an-opt {
    display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 6px 8px; text-align: left;
    background: transparent; color: var(--text); border: 0; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.an-opt.active, .an-opt:hover { background: var(--accent-soft); }
.an-opt-sym { font-weight: 700; color: var(--text-bright); white-space: nowrap; }
.an-opt-name { flex: 1 1 auto; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-opt-x { color: var(--text-dim); font-size: 11px; }
.an-btn {
    padding: 6px 12px; font-size: 13px; cursor: pointer; border-radius: 8px;
    background: var(--bg-raised); color: var(--text-bright); border: 1px solid var(--border-strong);
}
.an-btn:hover { border-color: var(--accent); }
.an-btn:disabled { cursor: progress; }
.an-btn.an-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.an-status { color: var(--text-dim); font-size: 12px; }
.an-spacer { flex: 1 1 auto; }
.an-recent { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.an-recent-label { color: var(--text-dim); font-size: 12px; margin-right: 2px; }
.an-chip {
    display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; line-height: 18px;
    background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap;
}
button.an-chip { cursor: pointer; }
button.an-chip:hover { border-color: var(--accent); color: var(--text-bright); }
.an-chip-x { font-weight: 600; }
.an-chip-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.an-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 40px; scroll-padding-top: 52px; }
.an-empty { max-width: 640px; margin: 48px auto; text-align: center; color: var(--text-muted); }
.an-empty h3 { color: var(--text-bright); margin: 0 0 8px; }
.an-loading { color: var(--text-dim); font-size: 13px; padding: 8px 0; }
.an-muted { color: var(--text-dim); font-size: 12.5px; }
.an-note { color: var(--text); font-size: 13px; margin: 6px 0 0; }
.an-foot { color: var(--text-dim); font-size: 12px; margin: 24px 0 0; max-width: 900px; }
.an-good { color: var(--pos); }
.an-bad { color: var(--neg); }
.an-warn { color: var(--warn); }

/* Hero: name, price, the 52-week range and the key figures. */
.an-hero {
    padding: 16px 18px; border-radius: 12px; border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--bg-raised), var(--bg-panel));
}
.an-hero:empty { display: none; }
.an-hero-main { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.an-hero-name { font-size: 22px; font-weight: 700; color: var(--text-brightest); line-height: 1.2; }
.an-hero-sym { margin-top: 4px; color: var(--text-muted); font-weight: 600; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.an-hero-where { margin-top: 6px; color: var(--text-muted); font-size: 13px; }
.an-hero-price { text-align: right; min-width: 240px; }
.an-price { font-size: 28px; font-weight: 700; color: var(--text-brightest); line-height: 1.1; }
.an-change { font-size: 14px; font-weight: 700; margin-top: 2px; }
.an-range { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-muted); justify-content: flex-end; }
.an-range-bar { position: relative; width: 160px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--neg-bg), var(--pos-bg)); border: 1px solid var(--border); }
.an-range-bar i { position: absolute; top: -4px; width: 4px; height: 14px; margin-left: -2px; border-radius: 2px; background: var(--text-brightest); }
.an-range-cap { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.an-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.an-stat { padding: 6px 10px; border-radius: 8px; background: var(--bg-sunken); border: 1px solid var(--border); min-width: 110px; }
.an-stat span { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
.an-stat b { font-size: 14px; color: var(--text-bright); }
.an-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Section index: sticks under the toolbar while the page scrolls. */
.an-toc {
    position: sticky; top: -14px; z-index: 5; display: flex; gap: 4px; flex-wrap: wrap;
    margin: 12px -16px 0; padding: 8px 16px; background: var(--bg-app); border-bottom: 1px solid var(--border);
}
.an-toc button {
    padding: 4px 10px; font-size: 12.5px; border-radius: 14px; cursor: pointer;
    background: transparent; color: var(--text-muted); border: 1px solid var(--border);
}
.an-toc button:hover { color: var(--text-bright); border-color: var(--accent); }
.an-section { margin-top: 22px; }
.an-h2 { font-size: 16px; margin: 0 0 10px; color: var(--text-bright); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.an-sub { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.an-card { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-panel); margin-top: 10px; }
.an-card-warn { border-color: var(--warn); }
.an-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 10px; }
.an-big { font-size: 26px; font-weight: 700; color: var(--text-bright); }

/* At a glance: one tile per screen's reading. */
.an-lead { grid-column: 1 / -1; font-size: 15px; color: var(--text-bright); padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--border); }
.an-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.an-tile { padding: 10px 12px; border-radius: 10px; background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--border-strong); }
.an-tile.an-good { border-top-color: var(--pos); color: inherit; }
.an-tile.an-bad { border-top-color: var(--neg); color: inherit; }
.an-tile.an-warn { border-top-color: var(--warn); color: inherit; }
.an-tile-k { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
.an-tile-v { font-size: 17px; font-weight: 700; margin-top: 4px; color: var(--text-bright); }
.an-tile.an-good .an-tile-v { color: var(--pos); }
.an-tile.an-bad .an-tile-v { color: var(--neg); }
.an-tile.an-warn .an-tile-v { color: var(--warn); }
.an-tile-s { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.an-measured { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 6px; font-size: 10px; text-transform: none; letter-spacing: 0; background: var(--pos-bg); color: var(--pos); }
.an-new { font-size: 11px; padding: 0 5px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); }
.an-leg { display: inline-block; margin: 2px 4px 0 0; padding: 0 6px; border-radius: 6px; font-size: 11px; background: var(--bg-sunken); color: var(--text-dim); border: 1px solid var(--border); }
.an-leg.on { background: var(--pos-bg); color: var(--pos); border-color: transparent; }

/* Price & trend. */
.an-chart-card { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-panel); }
.an-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.an-chart-wrap { position: relative; }
.an-svg { display: block; width: 100%; }
.an-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--bg-sunken); border: 1px solid var(--border); }
.an-seg button { padding: 3px 10px; font-size: 12.5px; border: 0; border-radius: 6px; cursor: pointer; background: transparent; color: var(--text-muted); }
.an-seg button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.an-legend { font-size: 12px; }
.an-ret { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.an-ret-k { width: 32px; color: var(--text-muted); font-weight: 600; }
.an-ret-k.an-wide { width: 150px; font-weight: 500; }
.an-ret-track { position: relative; flex: 1 1 auto; height: 10px; background: var(--bg-sunken); border-radius: 5px; }
.an-ret-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border-strong); }
.an-ret-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.an-ret-track i.pos { background: var(--pos); }
.an-ret-track i.neg { background: var(--neg); }
.an-ret-track i.warn { background: var(--warn); }
.an-ret-v { width: 64px; text-align: right; font-weight: 600; }
.an-ret-from { width: 150px; }
.an-emas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.an-ema { padding: 8px; border-radius: 8px; background: var(--bg-sunken); border: 1px solid var(--border); }
.an-ema span { display: block; font-size: 11.5px; color: var(--text-dim); }
.an-ema b { display: block; color: var(--text-bright); }
.an-ema em { font-style: normal; font-size: 12px; }
.an-tfs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.an-tf { padding: 10px; border-radius: 8px; background: var(--bg-sunken); border: 1px solid var(--border); }
.an-tf-k { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
.an-tf-trend { font-size: 18px; font-weight: 700; margin: 2px 0; color: var(--text-bright); }
.an-tf-trend.an-good { color: var(--pos); }
.an-tf-trend.an-bad { color: var(--neg); }
.an-tf-ev { font-size: 12px; color: var(--text-muted); min-height: 16px; }
.an-rsi { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.an-rsi-track { position: relative; flex: 1 1 auto; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--neg-bg), var(--bg-panel) 50%, var(--pos-bg)); border: 1px solid var(--border); }
.an-rsi-track i { position: absolute; top: -4px; width: 4px; height: 12px; margin-left: -2px; border-radius: 2px; background: var(--text-brightest); }
.an-rsi-track b { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-strong); }
.an-wave { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.an-levels .an-level { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--row-line); font-size: 13px; }
.an-level span { width: 90px; font-weight: 600; }
.an-level.sup span { color: var(--pos); }
.an-level.res span { color: var(--neg); }
.an-level b { width: 110px; color: var(--text-bright); }
.an-level em { font-style: normal; color: var(--text-dim); }

/* Technical screens. */
.an-scrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.an-scr { padding: 10px 12px; border-radius: 10px; background: var(--bg-panel); border: 1px solid var(--border); border-left: 3px solid var(--border-strong); font-size: 13px; }
.an-scr.an-good { border-left-color: var(--pos); color: inherit; }
.an-scr-t { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.an-scr-b { color: var(--text); line-height: 1.5; }
.an-scr-b b { color: var(--text-bright); }
.an-scr-f { margin-top: 6px; font-size: 11.5px; color: var(--text-dim); }
.an-row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.an-score-svg { display: block; width: 100%; height: 140px; border-radius: 6px; border: 1px solid var(--border); }
.an-score-line { fill: none; stroke: var(--text-bright); stroke-width: 1.5; }

/* Business. */
.an-about { margin: 0; color: var(--text); font-size: 13.5px; line-height: 1.55; white-space: pre-line; }
.an-details summary { cursor: pointer; color: var(--link); font-size: 13px; margin-top: 8px; }
.an-events .an-event { padding: 6px 0; border-bottom: 1px solid var(--row-line); font-size: 13px; }
.an-events .an-event b { margin-left: 6px; color: var(--text-bright); }
.an-quote { margin-top: 2px; font-style: italic; }

/* Valuation & results: the valuation card embedded whole. */
.an-vcard { padding: 4px 2px; }

/* Accounts health. */
.an-gauge-card { text-align: center; }
.an-gauge { position: relative; width: 200px; margin: 0 auto; }
.an-gauge svg { width: 100%; display: block; }
.an-gauge-bg { fill: none; stroke: var(--bg-sunken); stroke-width: 12; stroke-linecap: round; }
.an-gauge-fg { fill: none; stroke-width: 12; stroke-linecap: round; }
.an-gauge.good .an-gauge-fg { stroke: var(--pos); }
.an-gauge.bad .an-gauge-fg { stroke: var(--neg); }
.an-gauge.warn .an-gauge-fg { stroke: var(--warn); }
/* Too little filed to judge (research.ForensicScore.Thin): no verdict colour. */
.an-gauge.thin .an-gauge-fg { stroke: var(--text-dim); }
.an-gauge-v { position: absolute; left: 0; right: 0; bottom: 4px; font-size: 30px; font-weight: 700; color: var(--text-brightest); }
.an-gauge-v span { font-size: 14px; color: var(--text-dim); font-weight: 500; }
.an-gauge-band { font-weight: 700; color: var(--text-bright); margin-top: 4px; }
.an-factor { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr 64px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.an-factor.na span, .an-factor.na em { color: var(--text-dim); }
/* What the accounts read covered (analysis.js, research.Coverage); amber
   when the store is missing filings the company must have made. */
.an-coverage { margin: 0 0 10px; font-size: 12.5px; color: var(--text-dim); }
.an-coverage-gap { color: var(--warn); }
/* Why each unscored factor is unscored (analysis.js gapList), folded. */
.an-gaps { margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.an-gaps summary { cursor: pointer; }
.an-gaps ul { margin: 6px 0 0; padding-left: 18px; }
.an-gaps li { margin: 2px 0; }
.an-gaps b { color: var(--text); font-weight: 600; }
.an-factor-track { height: 8px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; }
.an-factor-track i { display: block; height: 100%; }
.an-factor-track i.good { background: var(--pos); }
.an-factor-track i.bad { background: var(--neg); }
.an-factor-track i.warn { background: var(--warn); }
.an-factor em { font-style: normal; text-align: right; color: var(--text-muted); }
.an-flag { padding: 6px 0; border-bottom: 1px solid var(--row-line); font-size: 13px; }
.an-flag b { margin: 0 6px; color: var(--text-bright); }
.an-flag div { color: var(--text); margin-top: 2px; }
.an-pill { display: inline-block; padding: 0 7px; border-radius: 8px; font-size: 11px; font-weight: 700; line-height: 18px; }
.an-pill.good { background: var(--pos-bg); color: var(--pos); }
.an-pill.bad { background: var(--neg-bg); color: var(--neg); }
.an-pill.warn { background: var(--warn-bg); color: var(--warn); }
.an-pill.neutral { background: var(--bg-sunken); color: var(--text-muted); }
.an-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.an-table th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.an-table td { padding: 4px 6px; border-bottom: 1px solid var(--row-line); color: var(--text); }
.an-table td.an-good { color: var(--pos); }
.an-table td.an-bad { color: var(--neg); }
.an-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.an-kv > div { padding: 6px 8px; border-radius: 8px; background: var(--bg-sunken); }
.an-kv span { display: block; font-size: 11.5px; color: var(--text-dim); }
.an-kv b { color: var(--text-bright); font-size: 14px; }
.an-timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.an-timeline li { position: relative; padding: 4px 0 10px 10px; font-size: 13px; }
.an-timeline li::before { content: ""; position: absolute; left: -21px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg-panel); border: 2px solid var(--border-strong); }
.an-timeline li.mat::before { background: var(--accent); border-color: var(--accent); }
.an-timeline b { margin-left: 6px; color: var(--text-bright); }
.an-tl-when { font-weight: 700; color: var(--text-muted); margin-right: 6px; }
.an-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.an-list li { margin-bottom: 4px; }

/* Filings & news. */
.an-news { list-style: none; margin: 0; padding: 0; }
.an-news li { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--row-line); font-size: 13px; }
.an-news-when { width: 92px; flex: 0 0 auto; color: var(--text-dim); font-size: 12px; }
.an-news a { color: var(--link); text-decoration: none; }
.an-news a:hover { text-decoration: underline; }

/* Phones: one column, the price block under the name, the toolbar and the
   section index wrapped (a screen with a phone layout reads at 375px with
   every control). */
@media (max-width: 640px) {
    #analysisToolbar { padding: 8px; }
    .an-search { flex: 1 1 100%; min-width: 0; }
    .an-search input { font-size: 16px; }
    .an-recent { display: none; }
    .an-body { padding: 10px 8px 32px; }
    .an-hero { padding: 12px; }
    .an-hero-price { text-align: left; min-width: 0; }
    .an-range { justify-content: flex-start; }
    .an-range-bar { width: 120px; }
    .an-toc { margin: 10px -8px 0; padding: 6px 8px; flex-wrap: nowrap; overflow-x: auto; }
    .an-toc button { flex: 0 0 auto; }
    .an-grid2 { grid-template-columns: minmax(0, 1fr); }
    .an-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .an-tfs, .an-emas { grid-template-columns: minmax(0, 1fr); }
    .an-ret-k.an-wide, .an-ret-from { width: 96px; }
    .an-factor { grid-template-columns: minmax(0, 1fr) 1fr 52px; }
    .an-news li { flex-wrap: wrap; }
    .an-table { display: block; overflow-x: auto; }
}

/* ---- Analysis, New layout (analysis.js, 2026-11-19) ----
 * The answer first, the full evidence after it
 * (docs/PLAN-ANALYSIS-READABILITY.md). Every rule here is .an2-*; the
 * Classic layout's .an-* rules above are untouched. Marks pair a colour with
 * a shape (round for good and neutral, square for warn and bad), so tone
 * never rests on colour alone. */
#analysisLayout { flex: 0 0 auto; }
.an2-hero {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px 26px;
    padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--bg-raised), var(--bg-panel));
}
.an2-hero:empty { display: none; }
.an2-id { flex: 1 1 320px; min-width: 0; }
.an2-name { font-size: 21px; font-weight: 700; color: var(--text-brightest); line-height: 1.2; }
.an2-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--text-muted); font-size: 12.5px; }
.an2-meta b { color: var(--text-bright); }
.an2-about { margin-top: 4px; color: var(--text-dim); font-size: 12.5px; max-width: 70ch; }
.an2-px { flex: 0 1 auto; }
.an2-price { font-size: 25px; font-weight: 700; color: var(--text-brightest); }
.an2-chg { font-weight: 700; }
.an2-range { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.an2-range em { font-style: normal; color: var(--text-dim); }
.an2-size { display: flex; gap: 20px; }
.an2-size span { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.an2-size b { font-size: 14px; color: var(--text-bright); }
.an2-acts { display: flex; gap: 8px; flex-wrap: wrap; }

.an2-qwrap { margin-top: 16px; }
.an2-qhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 8px; }
.an2-h { font-size: 15px; margin: 0; color: var(--text-bright); }
.an2-h3 { font-size: 13px; margin: 14px 0 6px; color: var(--text-bright); }
.an2-part:first-child > .an2-h3 { margin-top: 0; }
.an2-qs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.an2-qp {
    display: flex; flex-direction: column; gap: 8px; padding: 13px 14px; border-radius: 12px;
    background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--border-strong);
}
.an2-q-good { border-top-color: var(--pos); }
.an2-q-bad { border-top-color: var(--neg); }
.an2-q-warn { border-top-color: var(--warn); }
.an2-qk { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.an2-qh { font-size: 18px; font-weight: 700; line-height: 1.25; color: var(--text-bright); }
.an2-qsub { font-size: 12.5px; color: var(--text-dim); }
.an2-qsub b { color: var(--text); font-weight: 600; }
.an2-qf { margin: 0; padding-left: 17px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text); }
.an2-qf li.an-good, .an2-qf li.an-bad, .an2-qf li.an-warn { font-weight: 500; }
.an2-qchips { display: flex; flex-wrap: wrap; gap: 6px; }
.an2-qchips span { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--pos-bg); color: var(--pos); }
.an2-qgo {
    margin-top: auto; align-self: flex-start; background: none; border: 0; padding: 2px 0; cursor: pointer;
    color: var(--link); font-size: 12.5px;
}
.an2-qgo:hover { text-decoration: underline; }
.an2-badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-sunken); color: var(--text-bright); }
.an2-badge.an2-good { background: var(--pos-bg); color: var(--pos); }
.an2-badge.an2-bad { background: var(--neg-bg); color: var(--neg); }
.an2-badge.an2-warn { background: var(--warn-bg); color: var(--warn); }
.an2-strip { display: flex; gap: 3px; }
.an2-strip i { flex: 1 1 0; height: 8px; border-radius: 2px; background: var(--border-strong); }
.an2-strip i.good { background: var(--pos); }
.an2-strip i.bad { background: var(--neg); }
.an2-strip-cap { font-size: 11.5px; color: var(--text-dim); margin-top: -4px; }
.an2-zone { position: relative; padding-top: 4px; }
.an2-zone-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; }
.an2-zone-bar .c { background: var(--pos); opacity: .55; }
.an2-zone-bar .f { background: var(--border-strong); }
.an2-zone-bar .e { flex: 1 1 auto; background: var(--neg); opacity: .55; }
.an2-zone > i { position: absolute; top: 0; width: 3px; height: 17px; margin-left: -1px; border-radius: 2px; background: var(--text-brightest); }
.an2-zone-cap { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--text-dim); margin-top: -2px; }
.an2-tfs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.an2-tf { padding: 6px 8px; border-radius: 8px; background: var(--bg-sunken); }
.an2-tf span { display: block; font-size: 11px; color: var(--text-dim); }
.an2-tf b { color: var(--text-bright); }
.an2-tf.up { background: var(--pos-bg); }
.an2-tf.up b { color: var(--pos); }
.an2-tf.down { background: var(--neg-bg); }
.an2-tf.down b { color: var(--neg); }

#an2GB { margin-top: 14px; }
#an2GB:empty { display: none; }

/* The section bar: sticks while the page scrolls, says which stock and
 * where the reader is. */
.an2-nav {
    position: sticky; top: -14px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    margin: 14px -16px 0; padding: 8px 16px; background: var(--bg-app); border-bottom: 1px solid var(--border);
}
.an2-nav-id { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.an2-nav-id b { color: var(--text-bright); }
.an2-nav-links { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.an2-nav-links button, .an2-nav-folds button {
    padding: 4px 10px; font-size: 12.5px; border-radius: 14px; cursor: pointer;
    background: transparent; color: var(--text-muted); border: 1px solid var(--border);
}
.an2-nav-links button:hover, .an2-nav-folds button:hover { color: var(--text-bright); border-color: var(--accent); }
.an2-nav-links button.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.an2-nav-folds { display: flex; gap: 4px; }

.an2-secs { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.an2-sec { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel); }
.an2-sec[hidden] { display: none; }
.an2-sum {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 12px 16px; cursor: pointer;
    list-style: none;
}
.an2-sum::-webkit-details-marker { display: none; }
.an2-sum::before {
    content: ""; flex: 0 0 auto; width: 7px; height: 7px; margin-right: 2px;
    border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim);
    transform: rotate(-45deg); transition: transform .15s;
}
.an2-sec[open] > .an2-sum::before { transform: rotate(45deg); }
.an2-sec[open] > .an2-sum { border-bottom: 1px solid var(--border); }
.an2-t { flex: 0 0 230px; font-weight: 700; font-size: 14.5px; color: var(--text-bright); }
.an2-s { flex: 1 1 320px; min-width: 0; color: var(--text); font-size: 13px; }
.an2-mark { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.an2-mark.an2-good { background: var(--pos); }
.an2-mark.an2-warn { background: var(--warn); border-radius: 2px; }
.an2-mark.an2-bad { background: var(--neg); border-radius: 2px; }
.an2-body { padding: 4px 16px 16px; min-width: 0; }
.an2-body > .an-card:first-child, .an2-body > .an-grid2:first-child > .an-card { margin-top: 10px; }
.an2-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; align-items: start; }
.an2-grid > .an-card { margin-top: 10px; }
.an2-price-grid { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.an2-price-grid .an-chart-card { margin-top: 10px; }
.an2-side { padding-top: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.an2-tfrow { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-sunken); font-size: 13px; }
.an2-tfrow > div:first-child span { display: block; font-size: 11px; color: var(--text-dim); }
.an2-tfrow > div:first-child b { color: var(--text-bright); }
.an2-tfrow.up { background: var(--pos-bg); }
.an2-tfrow.up > div:first-child b { color: var(--pos); }
.an2-tfrow.down { background: var(--neg-bg); }
.an2-tfrow.down > div:first-child b { color: var(--neg); }
.an2-figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.an2-figs > div { padding: 6px 8px; border-radius: 8px; background: var(--bg-sunken); }
.an2-figs span { display: block; font-size: 11px; color: var(--text-dim); }
.an2-figs b { font-size: 15px; color: var(--text-bright); }
.an2-figs b.an-good { color: var(--pos); }
.an2-figs b.an-bad { color: var(--neg); }
.an2-emas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.an2-emas > div { padding: 6px 8px; border-radius: 8px; background: var(--bg-sunken); }
.an2-emas span { display: block; font-size: 11px; color: var(--text-dim); }
.an2-emas b { display: block; color: var(--text-bright); }
.an2-emas em { font-style: normal; font-size: 12px; }
.an2-extras { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.an2-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text); margin-left: auto; cursor: pointer; }
.an2-why { margin: 8px 0 0; }
/* Profit, sales and margin: the card's Profit level chart with Profit
 * against sales beside it once the window has room for both at full size. */
.an2-profit { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 22px; }
@media (min-width: 1500px) {
    .an2-profit { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
}
.an2-key {
    display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 12px; padding: 10px 12px; border-radius: 8px;
    background: var(--bg-sunken); font-size: 12.5px; color: var(--text);
}
.an2-key > b { flex: 1 1 100%; font-weight: 600; color: var(--text-bright); }
.an2-key em { flex: 1 1 100%; font-style: normal; color: var(--text-dim); }
.an2-how { margin-top: 6px; }
.an2-how > summary { cursor: pointer; color: var(--link); font-size: 12.5px; }
.an2-how > p { margin-top: 6px; }

@media (max-width: 640px) {
    /* The toolbar took 215px of a 375px phone: Export PDF goes (printing
     * from a phone is the browser's own menu) and the layout switch shares
     * the Analyze row. */
    #analysisExport { display: none; }
    #analysisLayout .rotation-level-btn { padding: 6px 10px; }
    .an2-hero { padding: 12px; gap: 10px; }
    .an2-px { flex: 1 1 100%; }
    .an2-size { flex: 1 1 100%; }
    .an2-acts { flex: 1 1 100%; }
    .an2-acts .an-btn { flex: 1 1 0; min-height: 40px; }
    .an2-qs { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .an2-qh { font-size: 16px; }
    .an2-nav { margin: 12px -8px 0; padding: 6px 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .an2-nav::-webkit-scrollbar { display: none; }
    .an2-nav-id { display: none; }
    .an2-nav-links { flex-wrap: nowrap; }
    .an2-nav-links button, .an2-nav-folds button { flex: 0 0 auto; white-space: nowrap; }
    .an2-sum { padding: 10px 12px; }
    .an2-t { flex: 1 1 auto; }
    .an2-s { flex: 1 1 100%; order: 3; font-size: 12.5px; color: var(--text-dim); }
    .an2-body { padding: 4px 10px 12px; }
    .an2-grid, .an2-price-grid { grid-template-columns: minmax(0, 1fr); }
    .an2-emas { grid-template-columns: minmax(0, 1fr); }
    .an2-tfrow { grid-template-columns: 64px minmax(0, 1fr); }
}

/* Export PDF (analysis.js): the Analysis page alone, every section open, in
 * the light palette whatever the theme, through the browser's Save as PDF.
 * Printed where it stands, as the card is: the app's own layout (the fixed
 * 100dvh shell, the scroller) is undone here, so nothing is clipped. */
@media print {
    html.an-printing body, html.an-printing #app { height: auto !important; overflow: visible !important; background: #fff !important; }
    html.an-printing #appNav, html.an-printing #analysisToolbar, html.an-printing .app-view:not(#viewReport),
    html.an-printing .an2-nav, html.an-printing .an2-acts, html.an-printing .an-chart-head .an-seg,
    html.an-printing .an2-check, html.an-printing .an-row-btns, html.an-printing .vn-bar,
    html.an-printing .stock-panel, html.an-printing #alertDropdown { display: none !important; }
    html.an-printing #viewReport { display: block !important; height: auto !important; overflow: visible !important; }
    html.an-printing #analysisBody {
        overflow: visible !important; height: auto !important; padding: 0 !important; color: #111;
        --text: #1f2937; --text-bright: #0b1220; --text-brightest: #0b1220; --text-dim: #4b5563; --text-muted: #4b5563;
        --border: #d1d5db; --border-strong: #9ca3af; --bg-panel: #fff; --bg-sunken: #f3f4f6; --bg-raised: #fff; --bg-deeper: #f8fafc; --bg-deepest: #f3f4f6; --bg-elev: #fff; --bg: #fff; --bg-hover: #f3f4f6; --border-bright: #6b7280; --bg-app: #fff;
        --pos: #13773a; --neg: #c01b1b; --warn: #a64b05; --accent: #1d4ed8; --link: #1d4ed8;
        --pos-bg: rgba(22, 163, 74, 0.10); --neg-bg: rgba(220, 38, 38, 0.10); --warn-bg: rgba(217, 119, 6, 0.12);
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    html.an-printing .an2-sec, html.an-printing .an-card, html.an-printing .an2-qp { break-inside: avoid; }
    html.an-printing .an2-sec { break-inside: auto; }
    html.an-printing .an2-sum::before { display: none; }
    /* Every Profit / Sales / Margin pane prints, as on the card's own PDF:
     * a saved copy is read away from the switch. */
    html.an-printing .pl-switch > .pl-pane { display: block !important; }
    html.an-printing .pl-switch > label { display: none !important; }
}

/* The FDTD.IN watermark on every PDF export (owner, 2026-11-19): the
 * Analysis page, the valuation card and Compare. A fixed element repeats on
 * every printed page in Chrome; it is faint enough that a table under it
 * still reads, and it is never shown on screen. Its body-level siblings are
 * hidden by the card's and Compare's print rules, which let it through by
 * id. */
#pdfWatermark { display: none; }
@media print {
    html.an-printing #pdfWatermark, html.vd-printing #pdfWatermark, html.cmp-printing #pdfWatermark {
        display: flex !important; position: fixed; inset: 0; z-index: 2147483000;
        align-items: center; justify-content: center; pointer-events: none;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    #pdfWatermark span {
        transform: rotate(-32deg); font: 800 120px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
        letter-spacing: .08em; color: rgba(15, 23, 42, 0.08); white-space: nowrap;
    }
}

/* ---- Market Breadth: index and breadth moving apart (breadthdiv.js) ---- */
.bd-neg { color: var(--neg); }
.bd-pos { color: var(--pos); }
.bd-dim { color: var(--text-dim); }
.bd-fresh { font-weight: 600; }
.bd-strip { width: 100%; border-collapse: collapse; margin: 0 0 10px; font-size: 12.5px; }
.bd-strip th { text-align: left; font-weight: 500; color: var(--text-dim); padding: 3px 8px; border-bottom: 1px solid var(--border); }
.bd-strip td { padding: 4px 8px; border-bottom: 1px solid var(--border); cursor: pointer; }
.bd-strip tr.bd-on td { background: var(--bg-raised); }
.bd-strip tr:hover td { background: var(--bg-raised); }
.bd-svg { display: block; max-width: 100%; }
.bd-index { fill: none; stroke: var(--chart-blue); stroke-width: 1.6; }
.bd-e20 { fill: none; stroke: var(--chart-amber); stroke-width: 1.4; }
.bd-e50 { fill: none; stroke: var(--chart-amber); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: 0.8; }
.bd-mid { stroke-dasharray: 3 3; }
.bd-band { stroke-width: 1; opacity: 0.35; }
.bd-band.bd-neg { stroke: var(--neg); }
.bd-band.bd-pos { stroke: var(--pos); }
.bd-mark.bd-neg { fill: var(--neg); }
.bd-mark.bd-pos { fill: var(--pos); }
.bd-summary { margin: 8px 0 4px; padding-left: 18px; font-size: 12.5px; }
.bd-summary li { margin: 2px 0; }
.bd-table-wrap { max-height: 260px; overflow: auto; margin-top: 6px; }
.bd-events { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.bd-events th { position: sticky; top: 0; background: var(--bg-panel); text-align: left; font-weight: 500; color: var(--text-dim); padding: 3px 8px; border-bottom: 1px solid var(--border); }
.bd-events td { padding: 3px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
#breadthDivCard .gb-stack-controls .rotation-level-toggle { margin: 0; }
@media (max-width: 640px) {
    .bd-strip, .bd-events { display: block; overflow-x: auto; }
}

/* ===================================================================
 * Analysis > Screen (screener.js, 2026-11-09): the fundamentals screener
 * in the Analysis page's own toolbar and body. #viewReport.an-screen-mode
 * hides the one-stock search and body. Tokens only; no faded text.
 * =================================================================== */
#viewReport.an-screen-mode .an-stock-only,
#viewReport.an-screen-mode #analysisBody { display: none; }
.sc-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.sc-field-l { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12.5px; }
.sc-bar select, .sc-bar input, #scFind, .sc-rule select, .sc-rule input {
    padding: 5px 8px; font-size: 13px; border-radius: 6px;
    background: var(--bg-sunken); color: var(--text-bright); border: 1px solid var(--border-strong);
}
.sc-bar select:focus, .sc-bar input:focus, #scFind:focus, .sc-rule select:focus, .sc-rule input:focus { outline: none; border-color: var(--accent); }
#scStart { max-width: 340px; }
#scFind { width: 200px; }
.sc-danger:hover { border-color: var(--neg); color: var(--neg); }
.sc-about { font-size: 13px; color: var(--text); max-width: 1100px; }
.sc-about p { margin: 4px 0; }
.sc-verdict { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; margin-right: 4px; }
.sc-held { background: var(--pos-bg); color: var(--pos); }
.sc-lagged { background: var(--neg-bg); color: var(--neg); }
.sc-mixed { background: var(--warn-bg); color: var(--warn); }
.sc-measured { margin: 4px 0 8px; font-size: 12.5px; }
.sc-measured summary { cursor: pointer; color: var(--link); }
.sc-measured .an-table { max-width: 900px; margin: 6px 0; }
.sc-muted { color: var(--text-dim); font-size: 12.5px; }
.sc-rules { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 6px; }
.sc-rule { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sc-fieldsel { max-width: 320px; }
.sc-val-num { width: 96px; }
.sc-val-text { width: 200px; }
.sc-unit, .sc-op-fixed { color: var(--text-dim); font-size: 12.5px; }
.sc-count { color: var(--text-dim); font-size: 12px; }
.sc-del {
    padding: 2px 8px; font-size: 12px; cursor: pointer; border-radius: 6px;
    background: transparent; color: var(--text-dim); border: 1px solid var(--border);
}
.sc-del:hover { color: var(--neg); border-color: var(--neg); }
.sc-rule-actions, .sc-table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.sc-textbox { margin: 6px 0; max-width: 900px; }
.sc-textbox textarea {
    width: 100%; box-sizing: border-box; padding: 8px; font: 13px/1.5 ui-monospace, Consolas, monospace;
    background: var(--bg-sunken); color: var(--text-bright); border: 1px solid var(--border-strong); border-radius: 8px;
}
.sc-text-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 6px; }
.sc-hint { color: var(--text-dim); font-size: 12px; }
.sc-hint code { color: var(--text-bright); }
.sc-error { margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: var(--neg-bg); color: var(--neg); font-size: 13px; }
.sc-status { color: var(--text); font-size: 13px; margin: 8px 0 4px; }
.sc-note { color: var(--text-dim); font-size: 12.5px; }
.sc-table-wrap { overflow-x: auto; }
.sc-table { width: 100%; }
.sc-table th[data-sort] { cursor: pointer; white-space: normal; min-width: 64px; vertical-align: bottom; }
.sc-table tbody tr[data-row] { cursor: pointer; }
.sc-table tbody tr[data-row]:hover td { background: var(--accent-soft); }
.sc-name { font-weight: 600; color: var(--text-bright); white-space: nowrap; }
.sc-ind { color: var(--text); max-width: 220px; }
.sc-num { text-align: right; white-space: nowrap; }
.sc-dash { color: var(--text-dim); }
.sc-tag { font-size: 10.5px; padding: 0 5px; border-radius: 6px; background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border); font-weight: 400; }
.sc-flags { max-width: 280px; }
.sc-flag { display: inline-block; margin: 1px 4px 1px 0; padding: 0 6px; border-radius: 8px; font-size: 11.5px; background: var(--warn-bg); color: var(--warn); }
.sc-panel {
    padding: 2px 8px; font-size: 12px; cursor: pointer; border-radius: 6px;
    background: var(--bg-raised); color: var(--text-bright); border: 1px solid var(--border-strong);
}
.sc-panel:hover { border-color: var(--accent); }
/* The Board switch and the folded line (2026-11-13). Folded, each rule is a
   chip and a template's verdict its pill, on one wrapping line under the bar;
   display:flex would beat the hidden attribute, so it is said. */
:root[data-theme] .sc-board-ruled { border-style: dashed; }
.sc-chipline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.sc-chipline[hidden] { display: none; }
.sc-chipline .fold-chip { max-width: 360px; }
.sc-verdict-mini { cursor: pointer; margin-right: 0; }
@media (max-width: 640px) {
    #scStart, #scFind, .sc-fieldsel { max-width: 100%; width: 100%; }
    /* Two buttons: the phone block's sideways-scrolling fold row would let
       the bar squeeze them to "Fil". */
    :root[data-theme] .sc-bar .fold-switches { flex: none; }
    .sc-bar select, .sc-bar input, #scFind, .sc-rule select, .sc-rule input { font-size: 16px; }
    .sc-text-row { flex-direction: column; }
}

/* ------------------------------------------------------------------ */
/* Phones: the data gets the screen (2026-11-12)                      */
/* ------------------------------------------------------------------ */

/* The owner, on a phone a fortnight after the strips block above: "the
   filters and other buttons are occupied more spaces and not able to see
   the data", and sideways scrolling left the data "completely not
   readable". Measured on Scans > Multibagger at 375 x 812: the tab strip
   wrapped to five rows (146px), the toolbar to eight (337px: three
   buttons, the preset strip on three rows, Find, the Filters / Info chips
   on three rows, two status lines), the ticker-history row under the table
   took 110px, and the table was left 171px -- two rows of data. In that
   table the pinned name cell was 209px of the 343px (ticker, tier, the
   "also in" mark and the copy glyph on one line) and every cell was
   nowrap, the industry column 380px, so a sideways swipe showed 130px of
   one column at a time beside the name. And the table was its own sideways
   scroller INSIDE #scansTableWrap, which scrolls too: two nested
   scrollers, the inner one swallowing the swipe meant for the outer.

   So, under 640px:
   - Every segmented strip (.rotation-level-toggle) and every preset strip
     is ONE row that scrolls sideways. The strips block above wrapped them,
     which reached every chip at the cost of the screen; ui.js scrolls the
     active chip into view, so the tab in use is never past the edge.
   - The Filters / Info switches and their chips are one sideways row too.
   - A status line is at most two lines; Find takes the rest of its row.
   - Scans' ticker-history row is one row ("Ticker history", the box, Look up).
   - #scansTableWrap is the table's one scroller, both ways (it joins the
     list of wrappers whose table stays display: table), so the header
     sticks and the name column is pinned against it.
   - The pinned name column is narrow and wraps: the ticker, then the tier on
     its own line. Word columns wrap at about nine characters' width, a rule
     ui.js writes per table because only it knows which columns are words;
     headers wrap at their spaces, so a long header no longer sets a figure
     column's width. Figures stay on one line.
   On a tablet the earlier blocks stand: a wrapped strip costs one or two
   rows at 768px, not five. */

/* The other wrappers that scroll both ways round a table, found by walking
   every .rs-table's parents at 375px. */
@media (max-width: 1024px) {
    :root[data-theme] #scansTableWrap .rs-table,
    :root[data-theme] #rotationTableWrap > .rs-table,
    :root[data-theme] #bottomingWrap > .rs-table,
    :root[data-theme] #volumeFlowWrap > .rs-table,
    :root[data-theme] #rsVolumeFlowWrap > .rs-table,
    :root[data-theme] #accumWrap > .rs-table,
    :root[data-theme] #tickerScanHistoryWrap > .rs-table,
    :root[data-theme] #adminPermissionsWrap > .rs-table,
    :root[data-theme] div[style*="overflow:auto"] > .rs-table {
        display: table;
        max-width: none;
        overflow: visible;
    }
}
@media (max-width: 640px) {
    :root[data-theme] :is(#rotationTableWrap, #bottomingWrap, #volumeFlowWrap, #rsVolumeFlowWrap, #accumWrap, #adminPermissionsWrap) {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (max-width: 640px) {
    :root[data-theme] .rotation-level-toggle,
    :root[data-theme] .scans-ema-filter:not([id$="MarketNote"]),
    :root[data-theme] .fold-switches,
    :root[data-theme] .fold-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }
    :root[data-theme] .rotation-level-toggle::-webkit-scrollbar,
    :root[data-theme] .scans-ema-filter::-webkit-scrollbar,
    :root[data-theme] .fold-switches::-webkit-scrollbar,
    :root[data-theme] .fold-chips::-webkit-scrollbar { display: none; }
    :root[data-theme] .rotation-level-toggle > *,
    :root[data-theme] .scans-ema-filter:not([id$="MarketNote"]) > *,
    :root[data-theme] .fold-switches > *,
    :root[data-theme] .fold-chips > * {
        flex-shrink: 0;
        white-space: nowrap;
    }
    /* The strip is the toolbar's whole width, so its row is its own. */
    :root[data-theme] .rotation-level-toggle,
    :root[data-theme] .scans-ema-filter:not([id$="MarketNote"]) {
        flex: 1 1 100%;
        width: 100%;
    }
    :root[data-theme] .fold-switches { flex: 1 1 0; }

    :root[data-theme] .rotation-status,
    :root[data-theme] #scansToolbar #scansStatus,
    :root[data-theme] .rotation-latest-date-note {
        white-space: normal;
        flex: 1 1 100%;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        font-size: 11.5px;
        line-height: 1.35;
    }
    :root[data-theme] .rotation-status:empty,
    :root[data-theme] .rotation-latest-date-note:empty { display: none; }

    /* ---- Scans ---- */
    /* No side padding on the scroller: a sticky cell sticks at the inside
       of the padding, and the columns scrolled past it showed through the
       16px beside the name. */
    :root[data-theme] #scansTableWrap { padding-left: 0; padding-right: 0; }
    :root[data-theme] #scansModeBar { padding-top: 4px; padding-bottom: 4px; }
    :root[data-theme] #scansToolbar { row-gap: 6px; }
    :root[data-theme] #scansFind {
        flex: 1 1 120px;
        min-width: 0;
        width: auto;
    }
    :root[data-theme] #tickerScanHistoryToolbar {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        padding-top: 4px;
        padding-bottom: 4px;
    }
    :root[data-theme] #tickerScanHistoryToolbar label {
        display: flex;
        align-items: center;
        gap: 6px;
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0;
    }
    :root[data-theme] #tickerScanHistoryToolbar label::before {
        content: "Ticker history";
        font-size: 12px;
        white-space: nowrap;
        color: var(--text-dim);
    }
    :root[data-theme] #tickerScanHistoryInput {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
        font-size: 14px;
    }

    /* ---- Every stock table ---- */
    :root[data-theme] .rs-table thead th { white-space: normal; }
    :root[data-theme] .rs-table th,
    :root[data-theme] .rs-table td { padding: 6px 8px; }
    :root[data-theme] .rs-table .rs-sticky-col,
    :root[data-theme] .rs-table:not(:has(.rs-sticky-col)) tr > :is(th, td):first-child {
        white-space: normal;
        width: 5.5em;
    }
    /* The tier falls under the ticker by wrapping, not by display: block,
       so the "also in" mark and the copy glyph share its line. A ticker is
       never broken: the column is as wide as the longest one. */
    :root[data-theme] .rs-table .rs-sticky-col .ratio-stock-tier {
        font-size: 10.5px;
        line-height: 1.2;
    }
    :root[data-theme] .rs-table td.watchlist-summary-cell,
    :root[data-theme] .rs-table td.actionscan-summary,
    :root[data-theme] .rs-table td.stage-guide-cell {
        min-width: 15rem;
    }
    /* The Ratio Scan's industry names held 240px of the 343px (styles.css)
       and left the score columns past the edge. */
    :root[data-theme] #ratioBoardTable td.rotation-name {
        min-width: 0;
        width: 9.5em;
    }
}

/* The grip on the chart's floating toolbars is dragged by a finger too
   (chartdrawbars.js, pointer events). touch-action: none, or the browser
   reads the drag as a scroll and cancels it. Under 640px the favourites bar
   is no wider than the chart: its tools scroll sideways inside it, and the
   grip stays where a thumb can reach it. */
:root[data-theme] .chart-drawbar .chart-drawbar-grip { touch-action: none; }
@media (pointer: coarse) {
    :root[data-theme] .chart-drawbar .chart-drawbar-grip { min-width: 26px; height: 34px; }
}
@media (max-width: 640px) {
    :root[data-theme] .chart-drawbar { max-width: calc(100% - 16px); box-sizing: border-box; }
    :root[data-theme] .chart-favbar-tools {
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }
    :root[data-theme] .chart-favbar-tools::-webkit-scrollbar { display: none; }
    :root[data-theme] .chart-favbar-tools > * { flex-shrink: 0; }
}
/* Exchange surveillance (docs/PLAN-SURVEILLANCE.md, 2026-11-12): the chip
   stocklist.js puts after the cap tier on every stock table, and the stock
   panel's line. Warning ink for ASM, ESM 1 and trade-for-trade; red for
   GSM 1+, insolvency, ESM 2 and suspension. Text, not a filled pill, so it
   clears 4.5:1 in both themes on the row's own ground. */
.surv-chip {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 600;
    line-height: 14px;
    border: 1px solid currentColor;
    border-radius: 3px;
    color: var(--warn);
    white-space: nowrap;
    vertical-align: 1px;
}
.surv-chip.is-severe { color: var(--neg); }
.surv-warn { color: var(--warn); }

/* Price band (docs/PLAN-PRICE-BANDS.md, 2026-11-13): the UC/LC chip after the
   surveillance chip on every stock table, drawn like it, green for a close at
   the upper band and red for the lower. */
.circ-chip {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 600;
    line-height: 14px;
    border: 1px solid currentColor;
    border-radius: 3px;
    white-space: nowrap;
    vertical-align: 1px;
}
.circ-chip.is-up { color: var(--pos); }
.circ-chip.is-down { color: var(--neg); }

/* The surveillance filter (stocklist.js): a switch in the name column's
   header of every stock table. Lit in warning ink while it hides or keeps
   rows, so a shorter table always says why. */
tr.surv-filtered { display: none; }
.surv-filter-btn {
    font-size: 0.85em;
    padding: 0 5px;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--text-dim);
}
.surv-filter-btn.is-on { color: var(--warn); border-color: currentColor; font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Valuation card: profit level and profit against sales               */
/* (valuationdetail.js profitSection, 2026-11-13). The numbered markers */
/* on the chart are listed under it in the same colours; the two charts */
/* of Profit against sales sit side by side and stack on a phone.       */
/* ------------------------------------------------------------------ */
.pl-lead { margin: 4px 0 6px; font-size: 0.9em; color: var(--text); line-height: 1.5; }
.pl-lead .rx-read { margin-right: 6px; }
.pl-key { margin: 2px 0 4px; }
.pl-events { list-style: none; margin: 4px 0 2px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 16px; font-size: 0.85em; color: var(--text-dim); }
.pl-events li { display: flex; gap: 8px; align-items: flex-start; }
.pl-events strong { color: var(--text); font-weight: 600; }
.pl-n { flex: 0 0 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: var(--bg-panel); }
.pl-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 24px; align-items: start; max-width: 760px; }
.pl-two > div { min-width: 0; }

/* The Profit level section's Profit / Sales / Margin switch (2026-11-17).
 * Radios rather than buttons with a click handler: the card is injected as
 * innerHTML and re-rendered whole, so a handler would have to be re-bound or
 * delegated, while :checked needs nothing and survives every re-render. The
 * inputs stay in the accessibility tree (a screen reader reads a radio group,
 * which is what this is) and are moved out of sight rather than hidden with
 * display:none, which would take them out of it.
 *
 * The switch itself must be positioned (2026-11-19). Without it the inputs
 * are placed against the DOCUMENT, not the page's scroller: on the Analysis
 * page, scrolled 5,000 px down, they sat 5,000 px below the window and made
 * the document 5,617 px tall where it should be the window's height. A click
 * on Sales focuses its radio, the browser scrolls the focused input into
 * view, and the only thing it can scroll is the document, so the whole app
 * slid up out of sight with `html { overflow: hidden }` keeping it there.
 * The same over-tall document pushed the app up 184-562 px on every section
 * jump (scrollIntoView scrolls every scrollable ancestor). The pop-up card
 * never showed it because its box is positioned. */
.pl-switch { position: relative; }
.pl-switch > input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pl-switch > label {
    display: inline-block; padding: 3px 11px; margin: 0 4px 6px 0; cursor: pointer;
    border-radius: 999px; font-size: 0.82em; font-weight: 600; color: var(--text-dim);
    background: transparent; border: 1px solid transparent; user-select: none;
}
.pl-switch > label:hover { color: var(--text-bright); background: var(--bg-raised); }
/* The active chip is the app's own segmented-control chip
   (.rotation-level-btn.active): raised panel, accent ink, accent ring. Its
   tokens, not an invented one -- an undefined var falls back to nothing and
   reads as near-black on near-black in light (the Earnings grid, 2026-10-01). */
.pl-switch > input:checked + label {
    background: var(--bg-panel); color: var(--accent-strong); border-color: var(--accent-ring);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}
:root[data-theme="light"] .pl-switch > input:checked + label { background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }
.pl-switch > input:focus-visible + label { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
/* Two radio groups: the measure (pl-m1 Profit, pl-m2 Sales, pl-m3 Margin)
 * and the grain (pl-g1 Last 12 months, pl-g2 Each quarter, which opens first since 2026-11-21). A pane
 * carries one class of each and shows when both its radios are checked. The
 * measure radios must come before the grain radios, and both before the
 * panes: the sibling combinator only looks forward. A fourth measure or a
 * third grain is one more line of each here. */
.pl-switch > .pl-pane { display: none; }
.pl-switch > .pl-gap { display: inline-block; width: 0; height: 14px; border-left: 1px solid var(--border-strong); vertical-align: middle; margin: 0 10px 6px 4px; }
.pl-switch > input.pl-m1:checked ~ input.pl-g1:checked ~ .pl-pane.pl-m1.pl-g1,
.pl-switch > input.pl-m1:checked ~ input.pl-g2:checked ~ .pl-pane.pl-m1.pl-g2,
.pl-switch > input.pl-m2:checked ~ input.pl-g1:checked ~ .pl-pane.pl-m2.pl-g1,
.pl-switch > input.pl-m2:checked ~ input.pl-g2:checked ~ .pl-pane.pl-m2.pl-g2,
.pl-switch > input.pl-m3:checked ~ input.pl-g1:checked ~ .pl-pane.pl-m3.pl-g1,
.pl-switch > input.pl-m3:checked ~ input.pl-g2:checked ~ .pl-pane.pl-m3.pl-g2 { display: block; }

/* ===================================================================
 * The valuation card's New view (valuationdetail.js newHTML, 2026-11-17,
 * docs/PLAN-EXCHANGE-FIRST.md Part D): a bar with the New / Classic switch
 * and Expand / Collapse all, a strip of verdict tiles, the last eight
 * results, then sections as <details> opened by default. Tokens only, so
 * both themes and the chart's light canvas follow; no faded text (the
 * secondary ink is --text-dim). */
.vn-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.vn-switch, .vn-folds { display: inline-flex; gap: 4px; }
.vn-bar button {
    font-size: 0.82em; padding: 3px 11px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border); background: transparent; color: var(--text-dim);
}
.vn-bar button:hover { color: var(--text-bright); background: var(--bg-raised); }
.vn-switch button.on { background: var(--bg-panel); color: var(--accent-strong); border-color: var(--accent-ring); font-weight: 600; }
:root[data-theme="light"] .vn-switch button.on { background: #fff; }
.vn-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 10px 0 12px; }
.vn-tile {
    display: flex; flex-direction: column; align-items: stretch; gap: 1px; min-width: 0; text-align: left;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-raised);
    color: var(--text); cursor: pointer; font: inherit;
}
.vn-tile:hover { border-color: var(--border-strong); }
.vn-tile:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.vn-tile-label { font-size: 0.78em; color: var(--text-dim); }
.vn-tile-word { font-size: 1.02em; font-weight: 600; line-height: 1.25; }
.vn-tile-sub { font-size: 0.78em; color: var(--text-dim); line-height: 1.3; }
.vn-good { color: var(--pos); } .vn-bad { color: var(--neg); } .vn-warn { color: var(--warn); } .vn-plain { color: var(--text); }
.vn-spark { width: 100%; height: 22px; margin-top: 5px; display: block; }
.vn-zone { position: relative; height: 14px; margin-top: 7px; }
.vn-zone i { position: absolute; left: 0; right: 0; top: 5px; height: 4px; border-radius: 2px; background: var(--border); }
.vn-zone b { position: absolute; top: 5px; height: 4px; background: var(--text-dim); }
.vn-zone u { position: absolute; top: 2px; width: 1px; height: 10px; background: var(--text); }
.vn-zone s { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--accent-strong); border: 2px solid var(--bg-raised); box-sizing: border-box; }
.vn-sec { border-top: 1px solid var(--border); }
.vn-sec > summary {
    display: flex; gap: 10px; align-items: baseline; padding: 9px 2px; cursor: pointer; list-style: none;
}
.vn-sec > summary::-webkit-details-marker { display: none; }
.vn-sec > summary::before { content: '\25B8'; color: var(--text-dim); width: 12px; flex: none; }
.vn-sec[open] > summary::before { content: '\25BE'; }
.vn-sec-title { font-weight: 600; flex: none; min-width: 170px; }
.vn-sec-sum { color: var(--text-dim); font-size: 0.92em; }
.vn-sec-body { padding: 0 0 12px 22px; }
/* The popup went from 860px to 1180px wide (2026-11-18). A chart drawn on a
 * 720px viewBox may grow a quarter (its 11px labels become about 14px);
 * past that the labels outgrow the card's text. Prose keeps a readable
 * line however wide the box is; tables and tiles take the full width. The
 * charts set their own max-width inline, hence !important. */
#valuationDetailBody svg[viewBox^="0 0 720 "] { max-width: 900px !important; }
#valuationDetailBody p, #valuationDetailBody li, #valuationDetailBody .vd-note { max-width: 110ch; }

/* "Is the price keeping up with the earnings?" (valueTrackChart, 2026-11-18):
 * four numbered steps. Tokens only; the sum is three boxes joined by the
 * operators, wrapping to a column on a phone. */
.vt-verdict { margin: 2px 0 10px; font-size: 1.02em; line-height: 1.45; }
.vt-step { margin: 14px 0 6px; font-size: 0.86em; font-weight: 600; color: var(--text-dim); }
.vt-step > span { display: inline-block; min-width: 1.5em; height: 1.5em; line-height: 1.5em; margin-right: 7px; border-radius: 50%; text-align: center; background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); }
.vt-step small { font-weight: 400; margin-left: 6px; }
.vt-sum { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: stretch; max-width: var(--vt-w, 900px); }
.vt-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; max-width: var(--vt-w, 900px); }
.vt-op { align-self: center; color: var(--text-dim); font-size: 1.15em; }
.vt-box { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-raised); min-width: 0; }
.vt-k { font-size: 0.78em; color: var(--text-dim); }
.vt-v { font-size: 1.18em; font-weight: 600; color: var(--text-bright); overflow-wrap: anywhere; }
.vt-v small { font-size: 0.68em; font-weight: 400; color: var(--text-dim); }
.vt-s { font-size: 0.78em; color: var(--text-dim); }
.vt-worth { border-color: var(--warn); background: var(--warn-bg); }
.vt-worth .vt-k, .vt-worth .vt-v, .vt-worth .vt-s { color: var(--warn); }
#valuationDetailBody .vt-after, .vt-after { margin: 6px 0 2px; opacity: 1; color: var(--text-dim); }
.vt-ifs { max-width: var(--vt-w, 900px); }
.vt-if { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) minmax(120px, auto); gap: 12px; align-items: center; padding: 4px 0; font-size: 0.9em; }
.vt-bar { position: relative; height: 14px; border-radius: 4px; background: var(--bg-raised); border: 1px solid var(--border); }
.vt-bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--warn); opacity: 0.75; }
.vt-bar > b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); }
.vt-if-v { text-align: right; font-weight: 600; white-space: nowrap; }
.vt-if-v small { font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.vt-more { margin: 6px 0 2px; font-size: 0.9em; }
.vt-more > summary { cursor: pointer; color: var(--text-dim); }
@media (max-width: 640px) {
    .vt-sum { grid-template-columns: minmax(0, 1fr); }
    .vt-op { justify-self: center; }
    .vt-if { grid-template-columns: minmax(0, 1fr) auto; }
    .vt-if > .vt-bar { grid-column: 1 / -1; order: 3; }
}
.vn-sec-body > .vd-visuals:first-child, .vn-sec-body > h4:first-child { margin-top: 0; }
.vn-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.78em; color: var(--text-dim); margin: 6px 0; }
.vn-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.vn-key-was { background: var(--text-dim); border-radius: 50% !important; }
.vn-key-now { background: var(--pos); border-radius: 50% !important; }
.vn-key-clean, .vn-key-p { background: var(--pos); }
.vn-key-cut { background: var(--text-dim); }
.vn-key-o { background: var(--accent); }
.vn-key-w { background: var(--warn); }
.vn-key-neg { background: var(--neg); }
.vn-dot-row, .vn-rc-row, .vn-cash-row, .vn-hold-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(150px, auto); gap: 10px; align-items: center; margin: 3px 0; }
.vn-dot-name { font-size: 0.88em; }
.vn-dot-val { font-size: 0.85em; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
.vn-dot-track { position: relative; height: 16px; }
.vn-dot-track i { position: absolute; top: 7px; height: 2px; background: var(--border-strong); }
.vn-dot-track s { position: absolute; top: 3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; }
.vn-dot-track s.vn-dot-was { background: var(--text-dim); }
.vn-rc-bar, .vn-cash-bars { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vn-rc-bar { flex-direction: row; gap: 2px; height: 14px; }
.vn-rc-bar i, .vn-cash-bars i { display: block; height: 12px; border-radius: 0 3px 3px 0; min-width: 1px; }
.vn-rc-bar i { height: 14px; }
.vn-rc-clean { background: var(--pos); }
.vn-rc-cut { background: var(--text-dim); }
.vn-rc-loss { background: var(--neg); }
.vn-cash-p { background: var(--pos); }
.vn-cash-o { background: var(--accent); }
.vn-cash-neg { background: var(--neg); }
.vn-hold-row .vn-spark { margin: 0; height: 18px; }
.vn-years { width: 100%; max-width: 680px; height: auto; display: block; }
.vn-svg-val { font-size: 11px; fill: var(--text); }
.vn-svg-lab { font-size: 11px; fill: var(--text-dim); }
.vn-svg-foot { font-size: 11px; fill: var(--text-dim); }
.vn-note { font-size: 0.82em; color: var(--text-dim); margin: 6px 0 0; }
/* A quarter whose profit was larger than its sales (profitOverSalesNote):
   warning ink, both layouts. */
.pos-note { margin: 6px 0 10px; padding: 7px 11px; border-left: 3px solid var(--warn); border-radius: 0; background: var(--warn-bg); color: var(--text); font-size: 0.92em; line-height: 1.45; }
.pos-note strong { color: var(--warn); }
/* The events card (eventscard.js) inside the New view's Projects and deals
   section: its verdict is already the section's summary line. */
.vn-sec-body > .ev > .ev-verdict { display: none; }
@media (max-width: 640px) {
    .vn-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .vn-sec > summary { flex-wrap: wrap; }
    .vn-sec-title { min-width: 0; }
    .vn-sec-body { padding-left: 0; }
    .vn-dot-row, .vn-rc-row, .vn-cash-row, .vn-hold-row { grid-template-columns: 90px minmax(0, 1fr); }
    .vn-dot-val { grid-column: 1 / -1; text-align: left; }
}

/* ===================================================================
 * Analysis > Compare (compare.js, docs/PLAN-STOCK-COMPARE.md, 2026-11-14):
 * two to six stocks side by side. #viewReport.an-compare-mode hides the
 * one-stock search and body, as Screen mode does. Tokens only; no faded
 * text. The print block at the end is the app's first: Export PDF builds
 * #cmpPrint under <body> and prints only it.
 * =================================================================== */
#viewReport.an-compare-mode .an-stock-only,
#viewReport.an-compare-mode #analysisBody { display: none; }
.cmp-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 14px;
    font-size: 12.5px; font-weight: 600; color: var(--text-bright); background: var(--bg-sunken); border: 1px solid var(--border-strong);
}
.cmp-chip-x, .cmp-x {
    border: 0; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px;
}
.cmp-chip-x:hover, .cmp-x:hover { color: var(--neg); }
.cmp-search { flex: 0 1 260px; min-width: 180px; }
.cmp-switch { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
/* The industry picker (2026-11-15): a panel between the bar and the table. */
.cmp-ind {
    margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel);
}
.cmp-ind-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.cmp-ind-search { flex: 0 1 300px; min-width: 200px; }
.cmp-ind-close { padding: 4px 10px; font-size: 12.5px; }
/* Folded with an industry chosen, the button names it, in accent ink so it
   reads as a filter in force rather than a plain action. */
#cmpIndBtn.cmp-ind-btn-on { color: var(--accent); border-color: var(--accent); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-ind-head { margin: 8px 0 6px; font-size: 13px; color: var(--text); line-height: 1.5; }
.cmp-ind-top { margin-left: 6px; padding: 3px 10px; font-size: 12.5px; }
.cmp-ind-list { max-height: 300px; overflow: auto; border-top: 1px solid var(--border); }
.cmp-ind-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp-ind-table th {
    position: sticky; top: 0; z-index: 1; background: var(--bg-panel); text-align: left; font-weight: 600;
    color: var(--text-dim); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.cmp-ind-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); color: var(--text); }
.cmp-ind-table tbody tr { cursor: pointer; }
.cmp-ind-table tbody tr:hover { background: var(--accent-soft); }
.cmp-ind-table tr.cmp-ind-on td { background: var(--accent-soft); }
.cmp-ind-table .num { text-align: right; white-space: nowrap; }
.cmp-ind-table td:first-child, .cmp-ind-table th:first-child { width: 28px; }
.cmp-ind-table b { color: var(--text-bright); }
.cmp-ind-name { color: var(--text-dim); }
.cmp-ind-sme { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: 11px; background: var(--bg-sunken); color: var(--text-dim); border: 1px solid var(--border); }
.cmp-ind-empty { padding: 8px 0; margin: 0; }
@media (max-width: 640px) {
    .cmp-ind-search { flex: 1 1 100%; }
    .cmp-ind-tiers { max-width: 100%; }
}

.cmp-grid {
    display: grid; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
    background: var(--bg-panel); font-size: 13px;
}
.cmp-grid > div { padding: 8px 10px; border-top: 1px solid var(--border); min-width: 0; }
.cmp-corner, .cmp-head { border-top: 0 !important; }
.cmp-head { position: relative; padding-right: 26px !important; }
.cmp-x { position: absolute; top: 6px; right: 4px; }
.cmp-sym {
    font-weight: 700; font-size: 14px; color: var(--text-bright); background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
}
button.cmp-sym:hover { color: var(--accent); text-decoration: underline; }
.cmp-name { color: var(--text); font-size: 12.5px; }
.cmp-price { color: var(--text-bright); font-weight: 600; margin-top: 2px; }
.cmp-flag { display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 6px; font-size: 11px; background: var(--warn-bg); color: var(--warn); }
.cmp-block {
    grid-column: 1 / -1; background: var(--bg-sunken); color: var(--text-dim); font-size: 11.5px;
    font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 5px 10px !important;
}
.cmp-label { color: var(--text-dim); font-size: 12.5px; }
.cmp-cell { color: var(--text); }
.cmp-sub { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }
.cmp-sub-i { color: var(--text-dim); font-size: 11.5px; }
.cmp-none { color: var(--text-dim); font-size: 12px; }
.cmp-pill { display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; background: var(--bg-sunken); color: var(--text-bright); border: 1px solid var(--border); }
.cmp-good-bg { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
.cmp-bad-bg { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.cmp-warn-bg { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
/* The squares shrink with the column: at six stocks or on a phone twelve
   fixed 8px squares ran into the next stock's cell. */
.cmp-qs { display: flex; gap: 2px; max-width: 100%; }
.cmp-q { display: block; box-sizing: border-box; flex: 0 1 9px; min-width: 3px; height: 13px; border-radius: 2px; border: 1px solid transparent; }
.cmp-q-up { background: var(--pos); }
.cmp-q-dn { background: transparent; border-color: var(--neg); }
.cmp-q-na { background: var(--border); }
.cmp-zone { position: relative; height: 8px; border-radius: 4px; background: var(--neg-bg); margin: 6px 0 2px; }
.cmp-zone-cheap { position: absolute; left: 0; top: 0; bottom: 0; background: var(--pos-bg); border-radius: 4px 0 0 4px; }
.cmp-zone-usual { position: absolute; top: 0; bottom: 0; background: var(--border-strong); }
.cmp-zone-dot { position: absolute; top: -3px; width: 3px; height: 14px; margin-left: -1px; border-radius: 2px; background: var(--text-bright); }
.cmp-chart { height: 112px; cursor: pointer; overflow: hidden; }
.cmp-chart svg { display: block; }
.cmp-ax { fill: var(--text-dim); font-size: 10px; }
/* Lists of quotes and events in a cell: the column is narrow, so smaller
   type and a hairline between items rather than bullets. */
.cmp-list { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.4; }
.cmp-list li + li { margin-top: 4px; padding-top: 4px; border-top: 1px dotted var(--border); }
.cmp-quotes li { color: var(--text); }
.cmp-doc + .cmp-doc { margin-top: 8px; }
.cmp-doc a, .cmp-cell a { color: var(--accent); }
.cmp-topic { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); margin-right: 2px; }
.cmp-label-good { color: var(--pos) !important; font-weight: 600; }
.cmp-label-bad { color: var(--neg) !important; font-weight: 600; }
/* EMA 50, 100 and 200: blue, amber and violet, the order a chart reader
   expects fast to slow. Violet has no token; it is set per theme here, and
   the print view takes the light value. */
.cmp-e50 { stroke: var(--chart-blue, var(--accent)); }
.cmp-e100 { stroke: var(--chart-amber, #d08a1a); }
.cmp-e200 { stroke: #b48cf2; }
:root[data-theme="light"] .cmp-e200, #cmpPrint .cmp-e200 { stroke: #7c3aed; }
.cmp-emakey { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 10px; color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.cmp-emakey i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin: 0 4px 0 8px; }
.cmp-emakey i.cmp-e50 { border-color: var(--chart-blue, var(--accent)); }
.cmp-emakey i.cmp-e100 { border-color: var(--chart-amber, #d08a1a); }
.cmp-emakey i.cmp-e200 { border-color: #b48cf2; }
:root[data-theme="light"] .cmp-emakey i.cmp-e200, #cmpPrint .cmp-emakey i.cmp-e200 { border-color: #7c3aed; }
#cmpPrint { display: none; }
/* The card's charts in a column (2026-11-16): profit level and the CWIP and
   fixed-asset bars, drawn from GET /valuation/stock. Colours are the card's:
   CWIP warn, fixed assets accent. */
.cmp-mini { margin-top: 4px; }
.cmp-mini svg { display: block; }
.cmp-ax-acc { fill: var(--accent); font-weight: 600; }
.cmp-cwip { fill: var(--warn); }
.cmp-fixed { fill: var(--accent); }
.cmp-reads li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cmp-q-lab { font-size: 11px; color: var(--text-dim); min-width: 52px; }
.cmp-card-btn {
    margin-top: 4px; padding: 2px 8px; font-size: 11px; border-radius: 6px; cursor: pointer;
    background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-ring);
}
.cmp-card-btn:hover { background: var(--accent-ring); }
.cmp-capkey { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 10px; color: var(--text-dim); font-size: 11px; }
.cmp-capkey i { display: inline-block; width: 9px; height: 9px; vertical-align: middle; margin: 0 4px 0 8px; border-radius: 1px; }
.cmp-capkey i.cmp-cwip { background: var(--warn); }
.cmp-capkey i.cmp-fixed { background: var(--accent); }

@media (max-width: 1024px) {
    /* The grid scrolls sideways with the label column pinned. */
    #cmpTable { overflow-x: auto; }
    .cmp-grid { min-width: 640px; }
    .cmp-label, .cmp-corner, .cmp-block { position: sticky; left: 0; z-index: 2; background: var(--bg-panel); }
    .cmp-block { background: var(--bg-sunken); }
}
@media (max-width: 640px) {
    /* At a fixed 640px six stocks got 95px each beside a 170px label, and a
       company name broke a word a line; each stock keeps 9.5em instead. */
    .cmp-grid { --cmp-lab-min: 92px; --cmp-lab-max: 104px; min-width: calc(104px + var(--cmp-n, 3) * 9.5em); }
    .cmp-grid > div { padding: 6px 8px; }
    .cmp-head { padding-right: 22px !important; }
}

@media print {
    @page { size: A4 landscape; margin: 10mm 10mm 14mm; }
    html.cmp-printing body > *:not(#cmpPrint):not(#pdfWatermark) { display: none !important; }
    html.cmp-printing, html.cmp-printing body { background: #fff !important; height: auto !important; overflow: visible !important; }
    /* The light palette whatever theme is on: everything here is drawn with
       tokens, so redefining them is the whole theme. Tones use ink and a
       border, so a reader who leaves "Background graphics" off still gets a
       readable file. */
    html.cmp-printing #cmpPrint {
        display: block !important; color: #111;
        --text: #1f2937; --text-bright: #0b1220; --text-dim: #4b5563; --text-muted: #4b5563;
        --border: #d1d5db; --border-strong: #9ca3af; --bg-panel: #fff; --bg-sunken: #f3f4f6; --bg-raised: #fff; --bg-deeper: #f8fafc; --bg-deepest: #f3f4f6; --bg-elev: #fff; --bg-app: #fff; --bg: #fff; --bg-hover: #f3f4f6; --border-bright: #6b7280;
        --pos: #13773a; --neg: #c01b1b; --warn: #a64b05; --accent: #1d4ed8;
        --pos-bg: rgba(22, 163, 74, 0.10); --neg-bg: rgba(220, 38, 38, 0.10); --warn-bg: rgba(217, 119, 6, 0.12);
        font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    #cmpPrint .cmp-print-title { font-size: 18px; margin: 0 0 2px; color: #0b1220; }
    #cmpPrint .cmp-print-meta { font-size: 11px; color: #4b5563; margin-bottom: 8px; }
    #cmpPrint .cmp-grid { font-size: 10.5px; border-radius: 6px; }
    #cmpPrint .cmp-grid > div { padding: 4px 6px; break-inside: avoid; }
    #cmpPrint .cmp-good-bg, #cmpPrint .cmp-bad-bg, #cmpPrint .cmp-warn-bg { border: 1px solid currentColor; }
    #cmpPrint .cmp-q-up { border-color: var(--pos); }
    #cmpPrint .cmp-print-notes { font-size: 9.5px; color: #374151; margin: 8px 0 0; padding-left: 0; list-style: none; }
    #cmpPrint .cmp-print-notes li { margin: 2px 0; }
    #cmpPrint .cmp-print-page + .cmp-print-page { break-before: page; }
    #cmpPrint .cmp-print-stock { break-inside: avoid; margin-bottom: 10mm; }
    #cmpPrint .cmp-print-stock-h { font-size: 13px; margin-bottom: 4px; }
    #cmpPrint .cmp-print-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
    #cmpPrint .cmp-chart-big { height: auto; width: 100%; cursor: default; }
    #cmpPrint .cmp-print-foot {
        position: fixed; bottom: 0; left: 0; right: 0; font-size: 8.5px; color: #4b5563; text-align: center;
    }

    /* The valuation card's Export PDF (valuationdetail.js, 2026-11-17).
     * Portrait, because the card is one column of prose and tables where
     * Compare is a wide grid. The card is printed where it stands rather
     * than copied into a print view, so the rules here undo the overlay's
     * own inline layout -- the fixed backdrop, the 88vh scroller and the
     * translateX centring, each set inline in index.html and so each needing
     * !important. Anything new added to the card prints without a rule; only
     * its own box needs one.
     *
     * It inherits the @page above: A4 landscape, which the card wants anyway
     * -- its year-by-year table is twelve columns and its shareholding table
     * nine, and both are cut off in portrait. @page cannot be conditioned on
     * a class, so giving the card its own orientation means naming a page for
     * Compare's too; not worth it while both want landscape. */
    html.vd-printing body > *:not(#valuationDetailOverlay):not(#pdfWatermark) { display: none !important; }
    html.vd-printing, html.vd-printing body { background: #fff !important; height: auto !important; overflow: visible !important; }
    html.vd-printing #valuationDetailOverlay {
        display: block !important; position: static !important; background: none !important;
        inset: auto !important; z-index: auto !important;
    }
    html.vd-printing #valuationDetailOverlay > div {
        position: static !important; transform: none !important; top: auto !important; left: auto !important;
        width: 100% !important; max-width: none !important; max-height: none !important;
        overflow: visible !important; border: 0 !important; box-shadow: none !important;
        border-radius: 0 !important; padding: 0 !important;
        color: #111;
        --text: #1f2937; --text-bright: #0b1220; --text-dim: #4b5563; --text-muted: #4b5563;
        --text-faint: #6b7280; --text-faintest: #6b7280;
        --border: #d1d5db; --border-strong: #9ca3af; --bg-panel: #fff; --bg-sunken: #f3f4f6; --bg-raised: #fff; --bg-deeper: #f8fafc; --bg-deepest: #f3f4f6; --bg-elev: #fff; --bg-app: #fff; --bg: #fff; --bg-hover: #f3f4f6; --border-bright: #6b7280;
        --pos: #13773a; --neg: #c01b1b; --warn: #a64b05; --accent: #1d4ed8; --chart-grid: #e5e7eb;
        --chart-amber: #a64b05; --chart-up: #13773a; --chart-blue: #1d4ed8;
        --pos-bg: rgba(22, 163, 74, 0.10); --neg-bg: rgba(220, 38, 38, 0.10); --warn-bg: rgba(217, 119, 6, 0.12);
        font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    /* The header's buttons are the reader's controls, not part of the read. */
    html.vd-printing #valuationDetailExport,
    html.vd-printing #valuationDetailClose,
    html.vd-printing #valuationDetailOverlay .howto-btn { display: none !important; }
    /* A chart or a table split across a page break is unreadable. */
    html.vd-printing #valuationDetailOverlay svg,
    html.vd-printing #valuationDetailOverlay table,
    html.vd-printing #valuationDetailOverlay .gb-card,
    html.vd-printing #valuationDetailOverlay .pl-pane { break-inside: avoid; }
    html.vd-printing #valuationDetailOverlay h3 { break-after: avoid; }
    /* Print every measure, not only the one on screen: a saved copy is read
       away from the switch, so a hidden panel would simply be missing. */
    html.vd-printing #valuationDetailOverlay .pl-switch > .pl-pane { display: block !important; }
    html.vd-printing #valuationDetailOverlay .pl-switch > label { display: none !important; }
    /* The New view: the bar is a control, not content; the tiles keep their
       grid; each section starts on its summary line. */
    html.vd-printing #valuationDetailOverlay .vn-bar { display: none !important; }
    html.vd-printing #valuationDetailOverlay .vn-tile,
    html.vd-printing #valuationDetailOverlay .vn-sec > summary { break-inside: avoid; }
    html.vd-printing #valuationDetailOverlay .vn-sec > summary { break-after: avoid; }
}

/* ---------------------------------------------------------------------
   Valuation card: Projects and deals (eventscard.js, 2026-11-15). Inks and
   washes are the theme's tokens, so both themes and the light chart follow.
   --------------------------------------------------------------------- */
.ev .ev-verdict { margin: 0 0 10px; color: var(--text-bright); font-size: 0.95em; line-height: 1.45; }
.ev .ev-list { display: flex; flex-direction: column; }
.ev .ev-row { display: grid; gap: 4px 14px; padding: 9px 0; border-top: 1px solid var(--border); align-items: center; }
.ev .ev-proj { grid-template-columns: minmax(0, 1.3fr) minmax(170px, 1.4fr) minmax(0, 1fr); }
.ev .ev-proj .ev-quote { grid-column: 1 / -1; }
.ev .ev-deal { grid-template-columns: 70px minmax(0, 1fr) auto; align-items: start; }
.ev .ev-name strong { color: var(--text-bright); font-weight: 600; }
.ev .ev-kind { font-size: 0.78em; color: var(--text-dim); text-transform: none; }
.ev .ev-when { color: var(--text-dim); font-size: 0.85em; padding-top: 1px; font-variant-numeric: tabular-nums; }
.ev .ev-side { text-align: right; }
.ev .ev-sub { color: var(--text-dim); font-size: 0.82em; }
.ev .ev-quote { color: var(--text-soft); font-size: 0.84em; line-height: 1.45; margin-top: 2px; }
.ev .ev-disc { margin-top: 2px; }
.ev .ev-link { font-size: 0.92em; white-space: nowrap; }
.ev .ev-pill { display: inline-block; font-size: 0.78em; padding: 1px 8px; border-radius: 10px; border: 1px solid currentColor; white-space: nowrap; }
.ev .ev-pill.pos { color: var(--pos); background: var(--pos-bg); }
.ev .ev-pill.warn { color: var(--warn); background: var(--warn-bg); }
.ev .ev-pill.acc { color: var(--accent); background: var(--accent-soft); }
.ev .ev-pill.dim { color: var(--text-dim); }
.ev .ev-track { display: flex; align-items: center; }
.ev .ev-mark { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--border-bright); flex: none; cursor: help; }
.ev .ev-mark.on { background: var(--accent); border-color: var(--accent); }
.ev .ev-mark.cur { box-shadow: 0 0 0 3px var(--accent-soft); }
.ev .ev-seg { height: 2px; flex: 1; background: var(--border-strong); }
.ev .ev-seg.on { background: var(--accent); }
.ev .ev-track-labels { display: flex; justify-content: space-between; font-size: 0.72em; color: var(--text-dim); margin-top: 3px; }
.ev .ev-track-labels .cur { color: var(--text-bright); font-weight: 600; }
.ev .ev-quotes { margin: 2px 0 6px; padding-left: 18px; font-size: 0.86em; line-height: 1.5; color: var(--text-soft); }
.ev .ev-quotes li { margin: 3px 0; }
.ev .ev-building { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.ev .ev-chart { display: flex; gap: 14px; align-items: flex-end; height: 92px; }
.ev .ev-bargroup { text-align: center; cursor: help; }
.ev .ev-bars { display: flex; gap: 3px; align-items: flex-end; height: 72px; justify-content: center; }
.ev .ev-bar { display: inline-block; width: 11px; border-radius: 2px 2px 0 0; }
.ev .ev-bar.cwip { background: var(--warn); }
.ev .ev-bar.fixed { background: var(--accent); }
.ev .ev-legend { flex: 1; min-width: 220px; font-size: 0.84em; color: var(--text-soft); }
.ev .ev-legend span { margin-right: 14px; white-space: nowrap; color: var(--text-dim); }
.ev .ev-legend i.ev-bar { height: 10px; width: 10px; vertical-align: -1px; border-radius: 2px; }
.ev .ev-legend p { margin: 6px 0 0; line-height: 1.45; }
.ev .ev-other { margin: 8px 0 4px; }
.ev .ev-other summary { cursor: pointer; color: var(--accent); font-size: 0.88em; }
.ev .ev-foot { margin: 10px 0 0; font-size: 0.8em; color: var(--text-dim); line-height: 1.45; }
@media (max-width: 640px) {
    .ev .ev-proj { grid-template-columns: 1fr; }
    .ev .ev-proj .ev-side { text-align: left; }
    .ev .ev-deal { grid-template-columns: 1fr; }
    .ev .ev-deal .ev-side { text-align: left; }
}

/* Events tab (actionscan.js, 2026-11-15): a due date passed, and the reason a
   row would be hidden when "Hide noise and old history" is off. */
#actionScanTable .actionscan-due-passed { color: var(--warn); font-weight: 600; white-space: nowrap; }
#actionScanTable .actionscan-flag { display: inline-block; margin-left: 4px; font-size: 0.78em; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border-strong); color: var(--text-dim); white-space: nowrap; cursor: help; }
#actionScanTable .actionscan-flag-noise { color: var(--warn); border-color: currentColor; }

/* ---- Portfolio: Health view, Needs a look, value chart (portfolio.js,
   2026-11-18). Tokens only, so both themes follow; the tones are text and
   borders on a light wash of the same hue, held to the 4.5:1 bar. ---- */
#viewPortfolio .pf-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    min-width: 0;
}
#viewPortfolio .pf-attention {
    margin: 12px 16px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
#viewPortfolio .pf-att-title { font-weight: 600; margin-right: 4px; color: var(--text); }
:root[data-theme] #viewPortfolio .pf-chip {
    min-height: 30px;
    padding: 3px 12px;
    border-radius: 15px;
    border: 1px solid var(--border-strong, var(--border));
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}
:root[data-theme] #viewPortfolio .pf-chip b { margin-left: 4px; }
:root[data-theme] #viewPortfolio .pf-chip:hover:not(:disabled) { border-color: var(--accent); }
:root[data-theme] #viewPortfolio .pf-chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme] #viewPortfolio .pf-chip.is-zero { color: var(--text-dim); cursor: default; opacity: 1; }
#viewPortfolio .pf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 12px;
    padding: 12px 16px 0;
}
#viewPortfolio .pf-grid #portfolioAllocationSection { padding: 12px 14px; }
#viewPortfolio .pf-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#viewPortfolio .pf-card-title { font-weight: 600; color: var(--text); }
#viewPortfolio .pf-alloc-tabs { flex-wrap: wrap; }
#viewPortfolio .pf-history-chart { position: relative; min-height: 220px; }
#viewPortfolio .pf-hover-tip {
    position: absolute; top: 6px; z-index: 5; width: 210px;
    background: var(--bg-raised); border: 1px solid var(--border); border-radius: 6px;
    padding: 6px 8px; font-size: 12px; color: var(--text); pointer-events: none;
}
#viewPortfolio .pf-note { color: var(--text-dim); font-size: 12px; line-height: 1.45; }
#viewPortfolio .pf-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text); margin: 4px 0; }
#viewPortfolio .pf-key { display: inline-block; width: 18px; height: 0; vertical-align: middle; margin-right: 6px; }
#viewPortfolio .pf-key-line { border-top: 2px solid var(--chart-blue); }
#viewPortfolio .pf-key-dash { border-top: 2px dashed var(--text-dim); }
#viewPortfolio .pf-key-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); }
#viewPortfolio .pf-holdings-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 16px 16px 6px; }
#viewPortfolio .pf-holdings-head h3 { margin: 0; }
#viewPortfolio .pf-foot { padding: 8px 16px 20px; margin: 0; }
#viewPortfolio .pf-digest-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); cursor: pointer; }

#portfolioHoldingsTable td { vertical-align: top; }
#portfolioHoldingsTable tbody tr { cursor: pointer; }
#portfolioHoldingsTable .pf-num { text-align: right; font-variant-numeric: tabular-nums; }
#portfolioHoldingsTable td.pf-name { font-weight: 600; }
#portfolioHoldingsTable td.pf-name > * { font-weight: 400; }
#portfolioHoldingsTable td.pf-name:hover { text-decoration: underline; }
#portfolioHoldingsTable td.pf-name:hover > * { text-decoration: none; }
#viewPortfolio .pf-dim { color: var(--text-dim); }
#viewPortfolio .pf-small { font-size: 11.5px; }
/* The broker's initial follows the cap-tier label stocklist.js inserts after
   the name; without a gap of its own the two read as one word ("SmallcapZ"). */
#viewPortfolio .pf-broker { margin-left: 6px; }
#portfolioHoldingsTable td > .pf-small,
#portfolioHoldingsTable td > div.pf-small { margin-top: 3px; }

#viewPortfolio .pf-pill,
#viewPortfolio .pf-flag {
    display: inline-block; border-radius: 5px; padding: 0 7px; font-size: 12px; line-height: 20px;
    border: 1px solid currentColor; white-space: nowrap;
}
#viewPortfolio .pf-pill { font-weight: 600; margin-right: 6px; }
#viewPortfolio .pf-exit { color: #fff; background: #b23a2f; border-color: #b23a2f; }
#viewPortfolio .pf-tone-good { color: var(--pos); }
#viewPortfolio .pf-tone-bad { color: var(--neg); }
#viewPortfolio .pf-tone-warn { color: var(--warn); }
#viewPortfolio .pf-tone-plain { color: var(--text-dim); }
#viewPortfolio .pf-val { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
#viewPortfolio .pf-range { display: flex; align-items: center; gap: 8px; margin-top: 5px; white-space: nowrap; }
#viewPortfolio .pf-range-bar { position: relative; display: inline-flex; gap: 1px; width: 96px; height: 6px; flex: 0 0 auto; }
#viewPortfolio .pf-zone { height: 6px; }
#viewPortfolio .pf-zone-lo { width: 20%; background: var(--pos); opacity: 0.45; border-radius: 3px 0 0 3px; }
#viewPortfolio .pf-zone-mid { width: 60%; background: var(--text-dim); opacity: 0.3; }
#viewPortfolio .pf-zone-hi { width: 20%; background: var(--neg); opacity: 0.45; border-radius: 0 3px 3px 0; }
#viewPortfolio .pf-mark { position: absolute; top: -4px; width: 3px; height: 14px; margin-left: -1px; border-radius: 2px; background: var(--text); }

#viewPortfolio .pf-trail { display: flex; flex-wrap: wrap; gap: 4px; }
:root[data-theme] #viewPortfolio .pf-q {
    display: inline-flex; align-items: baseline; gap: 4px;
    border: 1px solid currentColor; border-radius: 5px; background: transparent;
    padding: 0 7px; font: inherit; font-size: 12px; line-height: 20px; cursor: pointer; white-space: nowrap;
}
:root[data-theme] #viewPortfolio .pf-q .pf-q-m { color: var(--text-dim); font-size: 10.5px; }
:root[data-theme] #viewPortfolio .pf-q.is-latest { font-weight: 700; border-width: 2px; line-height: 18px; }
#viewPortfolio .pf-trend { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#viewPortfolio .pf-trend b { margin-left: 4px; font-weight: 600; }
#viewPortfolio .pf-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--accent); box-sizing: border-box; }
#viewPortfolio .pf-dot.is-on { background: var(--accent); }
#viewPortfolio .pf-flags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }

@media (max-width: 640px) {
    #viewPortfolio .pf-attention { margin: 10px 10px 0; }
    #viewPortfolio .pf-grid { grid-template-columns: minmax(0, 1fr); padding: 10px 10px 0; }
    #viewPortfolio .pf-holdings-head { padding: 12px 10px 6px; }
    #viewPortfolio .pf-foot { padding: 8px 10px 16px; }
}

/* ---- Portfolio: demo banner, benchmark picker, returns table (2026-11-18) ---- */
#viewPortfolio .pf-demo-banner {
    margin: 12px 16px 0;
    padding: 10px 14px;
    border: 1px dashed var(--warn);
    border-radius: 8px;
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.45;
}
#viewPortfolio .pf-demo-banner strong { color: var(--warn); }
:root[data-theme] #portfolioToolbar #portfolioDemoButton.active { border-color: var(--warn); color: var(--warn); }
#viewPortfolio .pf-off { opacity: 1; color: var(--text-dim); cursor: default; }
#viewPortfolio .pf-compare { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 8px; }
:root[data-theme] #viewPortfolio .pf-chip-sm { min-height: 26px; padding: 2px 10px; font-size: 12px; }
:root[data-theme] #viewPortfolio .pf-chip.is-sel { color: var(--text); font-weight: 600; }
:root[data-theme] #viewPortfolio .pf-chip-x {
    border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: 11px;
    margin-left: 6px; padding: 0 2px; cursor: pointer;
}
:root[data-theme] #viewPortfolio .pf-chip-x:hover { color: var(--neg); }
#viewPortfolio .pf-cmp-add { position: relative; display: inline-block; }
#viewPortfolio .pf-cmp-pop {
    position: absolute; top: 32px; left: 0; z-index: 30; width: 300px;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
#viewPortfolio .pf-cmp-pop[hidden] { display: none; }
:root[data-theme] #viewPortfolio .pf-cmp-input {
    width: 100%; box-sizing: border-box; min-height: 30px; padding: 4px 8px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit;
}
#viewPortfolio .pf-cmp-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; margin-top: 6px; }
:root[data-theme] #viewPortfolio .pf-cmp-opt {
    text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 12.5px;
    padding: 5px 6px; border-radius: 5px; cursor: pointer;
}
:root[data-theme] #viewPortfolio .pf-cmp-opt:hover,
:root[data-theme] #viewPortfolio .pf-cmp-opt:focus { background: var(--bg-raised); outline: 1px solid var(--accent); }
#viewPortfolio .pf-cmp-none { padding: 6px; }
#viewPortfolio .pf-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
#viewPortfolio .pf-returns { margin: 8px 0 6px; overflow-x: auto; }
#viewPortfolio .pf-returns-table { border-collapse: collapse; font-size: 12.5px; width: 100%; margin-bottom: 4px; }
#viewPortfolio .pf-returns-table th,
#viewPortfolio .pf-returns-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text); }
#viewPortfolio .pf-returns-table th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; }
#viewPortfolio .pf-returns-table td:first-child { text-align: left; }
#viewPortfolio .pf-returns-table .pf-small { font-size: 10.5px; }
@media (max-width: 640px) {
    #viewPortfolio .pf-demo-banner { margin: 10px 10px 0; }
    #viewPortfolio .pf-cmp-pop { width: min(300px, calc(100vw - 40px)); }
}
/* The demo note on the other screens that show holdings (Today, F&O > Hedge). */
.pf-demo-note {
    border: 1px dashed var(--warn); border-radius: 6px; padding: 6px 10px; margin: 6px 0;
    color: var(--text); font-size: 12.5px;
}
.pf-demo-note strong { color: var(--warn); }
/* Click-to-filter on the make-up chart (2026-11-18). */
#viewPortfolio .pf-slice { cursor: pointer; }
:root[data-theme] #viewPortfolio .pf-legend-btn {
    width: 100%; text-align: left; border: 1px solid transparent; border-radius: 5px; background: transparent;
    font: inherit; color: var(--text); padding: 2px 6px; cursor: pointer;
}
:root[data-theme] #viewPortfolio .pf-legend-btn:hover { border-color: var(--border); }
:root[data-theme] #viewPortfolio .pf-legend-btn.is-on { border-color: var(--accent); background: var(--bg-raised); font-weight: 600; }
#viewPortfolio .pf-slice-chip { margin-left: 6px; }

/* Macro > Flows: foreign investors by sector (macro.js renderFpiSectors).
   Bars diverge from the middle, so a sale and a purchase of the same size
   are the same length; the value column is ink, never a faded colour. */
.fpis-lead { font-size: 13.5px; line-height: 1.5; margin: 0 0 10px; color: var(--text); }
.fpis-bars { display: flex; flex-direction: column; gap: 3px; }
.fpis-row { display: grid; grid-template-columns: minmax(120px, 230px) 1fr 86px; gap: 10px; align-items: center; font-size: 12.5px; }
.fpis-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpis-track { position: relative; height: 14px; background: linear-gradient(to right, transparent calc(50% - 0.5px), var(--border) calc(50% - 0.5px), var(--border) calc(50% + 0.5px), transparent calc(50% + 0.5px)); }
.fpis-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; }
.fpis-bar.pos { background: var(--pos); }
.fpis-bar.neg { background: var(--neg); }
.fpis-val { text-align: right; font-variant-numeric: tabular-nums; }
.fpis-table td.fpis-heat { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.fpis-table .fpis-was { color: var(--text-dim); font-size: 11px; }
.fpis-table tr.fpis-total td { font-weight: 600; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
    .fpis-row { grid-template-columns: 110px 1fr 70px; gap: 6px; font-size: 12px; }
}

/* Macro > Valuation: where today stands in the record, in words. */
.macro-val-read { list-style: none; margin: 0 0 10px; padding: 0; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.macro-val-read li::before { content: "\2022"; color: var(--text-dim); margin-right: 8px; }

/* TradingView's colour picker (colorpicker.js), for every colour input.
   The swatch of a colour input is drawn at the opacity its value carries
   (--cp-alpha), over a checkerboard so a translucent colour reads as one. */
input[type="color"]::-webkit-color-swatch { opacity: var(--cp-alpha, 1); }
input[type="color"]::-moz-color-swatch { opacity: var(--cp-alpha, 1); }
input[type="color"].cp-translucent::-webkit-color-swatch-wrapper {
    background: repeating-conic-gradient(#9aa0aa 0% 25%, #ffffff 0% 50%) 50% / 8px 8px;
}
input[type="color"] { cursor: pointer; }
.tv-cp {
    position: fixed; z-index: 3000; width: 282px; box-sizing: border-box;
    padding: 12px; border-radius: 6px;
    background: var(--bg-panel); border: 1px solid var(--border-strong, var(--border));
    box-shadow: 0 8px 24px var(--shadow); color: var(--text); font-size: 13px;
    user-select: none;
}
.tv-cp[hidden], .tv-cp-view[hidden] { display: none; }
.tv-cp-grid { display: grid; grid-template-columns: repeat(10, 22px); gap: 3px; justify-content: space-between; }
.tv-cp-gap { grid-column: 1 / -1; height: 6px; }
.tv-cp-sw {
    width: 22px; height: 22px; padding: 0; margin: 0; border: 0; border-radius: 3px;
    background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.25);
}
.tv-cp-sw:hover { transform: scale(1.12); }
.tv-cp-sw.on { box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 3.5px var(--text); }
.tv-cp-rule { height: 1px; background: var(--border-strong, var(--border)); margin: 12px 0 10px; }
.tv-cp-custom { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; min-height: 24px; }
.tv-cp-add {
    width: 22px; height: 22px; padding: 0; border: 0; border-radius: 3px; background: transparent;
    color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.tv-cp-add:hover { background: var(--bg-raised); }
.tv-cp-opacity { margin-top: 12px; }
.tv-cp-label { color: var(--text-dim); margin-bottom: 8px; }
.tv-cp-orow { display: flex; align-items: center; gap: 12px; }
.tv-cp-slider {
    position: relative; flex: 1; height: 10px; border-radius: 5px; cursor: pointer; touch-action: none;
    background:
        linear-gradient(to right, transparent, var(--cp-solid, #2962ff)),
        repeating-conic-gradient(#808080 0% 25%, #2a2e39 0% 50%) 0 0 / 8px 8px;
}
.tv-cp-slider-thumb {
    position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
    background: #ffffff; border: 2px solid #131722; box-sizing: border-box;
    transform: translate(-50%, -50%); pointer-events: none;
}
.tv-cp-pct {
    width: 58px; box-sizing: border-box; padding: 6px 8px; text-align: right;
    background: var(--bg-deeper, var(--bg-raised)); color: var(--text);
    border: 1px solid var(--border-strong, var(--border)); border-radius: 4px; font: inherit;
}
.tv-cp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tv-cp-preview { width: 28px; height: 28px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35); }
.tv-cp-hex {
    flex: 1; min-width: 0; padding: 5px 8px; font: inherit;
    background: var(--bg-deeper, var(--bg-raised)); color: var(--text);
    border: 1px solid var(--accent); border-radius: 4px;
}
.tv-cp-addbtn {
    padding: 6px 12px; border: 0; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600;
    background: var(--text); color: var(--bg-panel);
}
.tv-cp-pickbody { display: flex; gap: 10px; }
.tv-cp-sv {
    position: relative; flex: 1; height: 200px; border-radius: 3px; cursor: crosshair; touch-action: none;
    background:
        linear-gradient(to top, #000, transparent),
        linear-gradient(to right, #fff, var(--cp-hue, #ff0000));
}
.tv-cp-sv-thumb {
    position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); box-sizing: border-box;
    transform: translate(-50%, -50%); pointer-events: none;
}
.tv-cp-hue {
    position: relative; width: 14px; border-radius: 3px; cursor: pointer; touch-action: none;
    background: linear-gradient(to bottom, #ff0000, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000);
}
.tv-cp-hue-thumb {
    position: absolute; left: -2px; right: -2px; height: 6px; border-radius: 2px;
    background: #fff; border: 1px solid #131722; transform: translateY(-50%); pointer-events: none;
}
@media (max-width: 640px) {
    .tv-cp { width: min(282px, calc(100vw - 16px)); }
    .tv-cp-grid { grid-template-columns: repeat(10, 1fr); }
    .tv-cp-sw { width: 100%; }
}

/* ---- Macro: the seven tabs and the Market read (2026-11-20,
   docs/PLAN-MACRO-READ.md). Each .macro-tab holds the tab's new cards and
   today's views whole; the sections inside keep the layout they had when
   they sat directly in #macroContent. */
.macro-tab { display: flex; flex-direction: column; gap: 16px; }
.macro-tab > section { display: flex; flex-direction: column; gap: 16px; }
.macro-tab > [hidden] { display: none !important; }
.macro-part { margin: 8px 0 -4px; font-size: 15px; font-weight: 700; color: var(--text-bright); border-top: 1px solid var(--border); padding-top: 14px; }
.macro-tab > .macro-part:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.macro-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; vertical-align: middle;
    background: color-mix(in srgb, var(--text-dim) 14%, transparent); color: var(--text); }
.macro-tag-measured { background: color-mix(in srgb, var(--pos) 18%, transparent); }
.macro-sub { font-weight: 600; margin: 12px 0 6px; color: var(--text-bright); }
.macro-dim { color: var(--text-dim); }
.macro-small { font-size: 11.5px; }
.macro-strong { font-weight: 700; }
.macro-tone-good { color: var(--pos); }
.macro-tone-bad { color: var(--neg); }
.macro-tone-mixed { color: var(--text-bright); }
.macro-word { font-weight: 700; padding: 1px 8px; border-radius: 6px; font-size: 12px; }
.macro-word.macro-tone-good { background: color-mix(in srgb, var(--pos) 16%, transparent); }
.macro-word.macro-tone-bad { background: color-mix(in srgb, var(--neg) 14%, transparent); }
.macro-word.macro-tone-mixed { background: color-mix(in srgb, var(--text-dim) 14%, transparent); }
.macro-link { background: none; border: 0; padding: 4px 0; color: var(--accent, var(--chart-blue)); cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; }
.macro-link:hover { text-decoration: underline; }

.macro-read-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; padding: 0 4px; font-size: 13px; }
.macro-read-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-bright); }
/* A desk read by size: figure now in bold, a year ago under it. */
.macro-desk-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.macro-desk-table th, .macro-desk-table td { padding: 5px 4px; border-top: 1px solid var(--border); vertical-align: top; }
.macro-desk-table tr:first-child th { border-top: 0; font-size: 11px; font-weight: 600; color: var(--text-dim); text-align: right; padding-bottom: 2px; }
.macro-desk-table tr:first-child th:first-child { text-align: left; }
.macro-desk-table th[scope=row] { text-align: left; font-weight: 600; color: var(--text-bright); }
.macro-desk-table th[scope=row] > span { display: block; }
.macro-desk-rword { font-size: 11px; font-weight: 600; margin-top: 1px; }
.macro-desk-rword.macro-tone-mixed { color: var(--text-dim); }
.macro-desk-table td { text-align: right; }
.macro-desk-table td strong { display: block; font-size: 14px; color: var(--text-bright); }
.macro-desk-table td .macro-dim { display: block; font-size: 11px; }
.macro-desk-total th, .macro-desk-total td strong { font-weight: 500 !important; }
.macro-desk-total th[scope=row] { color: var(--text) !important; }
.macro-desk-spark { color: var(--neg); }
.macro-desk-spark svg { display: block; width: 100%; height: 50px; }
.macro-desk-spark text { fill: var(--text-dim); }
.macro-desk-good .macro-desk-spark { color: var(--pos); }
/* What to watch: one row a reading, chip coloured by what followed. */
.macro-watch-table td { vertical-align: top; text-align: left !important; white-space: normal; }
.macro-watch-table th { text-align: left !important; }
.macro-watch-table td:nth-child(2) { min-width: 220px; }
.macro-watch-table td:nth-child(5) { white-space: nowrap; }
.macro-watch-row { cursor: pointer; }
.macro-watch-row:hover > td, .macro-watch-open > td { background: color-mix(in srgb, var(--chart-blue) 8%, transparent); }
.macro-watch-more > td { font-size: 12.5px; line-height: 1.5; padding-bottom: 12px !important; background: color-mix(in srgb, var(--chart-blue) 5%, transparent); }
.macro-watch-chip { display: inline-block; min-width: 38px; text-align: center; font-weight: 700; font-size: 12px; border-radius: 6px; padding: 2px 8px; }
.macro-watch-off { background: color-mix(in srgb, var(--text-dim) 14%, transparent); color: var(--text-dim); }
.macro-watch-bad { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.macro-watch-good { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
/* Institutions and Economy: figures right-aligned in one unit; the
   Economy groups are heading rows of one table. */
.macro-who td:nth-child(n+4), .macro-who th:nth-child(n+4) { text-align: right; }
.macro-who td:last-child, .macro-who th:last-child { text-align: left; }
.macro-who-src { white-space: normal !important; max-width: 220px; }
.macro-eco td:nth-child(2), .macro-eco td:nth-child(3), .macro-eco th:nth-child(2), .macro-eco th:nth-child(3) { text-align: right; }
.macro-eco td:nth-child(1), .macro-eco td:nth-child(4), .macro-eco th:nth-child(1), .macro-eco th:nth-child(4) { text-align: left; }
.macro-eco-ghead th { text-align: left !important; padding-top: 14px !important; font-size: 13.5px; color: var(--text-bright); background: transparent; border-bottom: 1px solid var(--border); }
.macro-eco-bar { min-width: 180px; width: 24%; }
.macro-eco-range { display: flex; justify-content: space-between; gap: 8px; }
/* Lines / Bars switch on the earnings charts (Macro and Valuation). */
.macro-shape-row { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.ek-shape-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px; }
.macro-shape .rotation-level-btn, .ek-shape .rotation-level-btn { min-width: 64px; }
/* Rally readiness: Essentials hides the score's parts and the price moves. */
#rallyReadyTable.rr-essentials [data-col="more"] { display: none; }
#rallyReadyTable .rr-sub { font-size: 11.5px; color: var(--text-dim); font-weight: 400; margin-top: 2px; white-space: nowrap; }
.rr-cols { margin-left: 8px; }
.macro-desks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.macro-desks-one { grid-template-columns: minmax(0, 720px); }
.macro-desk { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; border-top: 4px solid var(--text-dim); }
.macro-desk-good { border-top-color: var(--pos); }
.macro-desk-bad { border-top-color: var(--neg); }
.macro-desk-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.macro-desk-word { font-size: 16px; font-weight: 700; line-height: 1.3; }
.macro-desk-say { font-size: 12.5px; color: var(--text); line-height: 1.45; }
.macro-desk-figs { margin: 4px 0 0; display: flex; flex-direction: column; gap: 4px; }
.macro-desk-figs > div { display: flex; flex-direction: column; }
.macro-desk-figs dt { font-size: 11.5px; color: var(--text-dim); }
.macro-desk-figs dd { margin: 0; font-size: 13px; }
.macro-desk-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11.5px; }

.macro-watch { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.45; }
.macro-watch-state { flex: 0 0 44px; text-align: center; font-weight: 700; font-size: 12px; border-radius: 6px; padding: 2px 0; align-self: flex-start;
    background: color-mix(in srgb, var(--text-dim) 14%, transparent); color: var(--text-dim); }
.macro-watch-on .macro-watch-state { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--text-bright); }

.macro-table-wrap { overflow-x: auto; }
.macro-num td, .macro-num th, .macro-ladder td, .macro-ladder th { white-space: nowrap; font-variant-numeric: tabular-nums; }
.macro-ladder td:nth-child(5) { min-width: 180px; width: 30%; }
.macro-indent { padding-left: 22px !important; font-weight: 400; }
.macro-rbar { position: relative; display: block; height: 16px; min-width: 120px; }
.macro-rbar-track { position: absolute; left: 0; right: 0; top: 6px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text-dim) 30%, transparent); }
.macro-rbar-was { position: absolute; top: 3px; width: 2px; height: 10px; background: var(--text-dim); }
.macro-rbar-now { position: absolute; top: 0; width: 6px; height: 16px; margin-left: -3px; border-radius: 2px; background: currentColor; }
.macro-spark { display: block; width: 90px; height: 22px; color: var(--chart-blue); }
.macro-spark-cell .macro-spark { color: inherit; }
.macro-spark-cell { color: var(--chart-blue); }
.macro-spark-cell.macro-tone-good { color: var(--pos); }
.macro-spark-cell.macro-tone-bad { color: var(--neg); }
.macro-bar-cell { min-width: 140px; }
.macro-heat-0 { background: color-mix(in srgb, var(--text-dim) 6%, transparent); }
.macro-heat-p1 { background: color-mix(in srgb, var(--pos) 12%, transparent); }
.macro-heat-p2 { background: color-mix(in srgb, var(--pos) 22%, transparent); }
.macro-heat-p3 { background: color-mix(in srgb, var(--pos) 34%, transparent); }
.macro-heat-n1 { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.macro-heat-n2 { background: color-mix(in srgb, var(--neg) 22%, transparent); }
.macro-heat-n3 { background: color-mix(in srgb, var(--neg) 34%, transparent); }
.macro-heat-na { background: transparent; }
.macro-cal td { text-align: center; padding: 4px 6px; }

.macro-pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.macro-pair-title { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.macro-tiergrids { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 8px 18px; }
.macro-eco-words { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 18px; }
.macro-eco-gname { font-weight: 600; margin-bottom: 4px; }

/* A row that opens its detail: a ladder row loads the full-history
   valuation chart, any other opens that series under the row. */
.macro-drillable { cursor: pointer; }
.macro-drillable:hover > td { background: color-mix(in srgb, var(--chart-blue) 8%, transparent); }
.macro-drill-open > td { background: color-mix(in srgb, var(--chart-blue) 10%, transparent); }
.macro-drill > td { white-space: normal !important; padding: 8px 4px 14px !important; background: var(--bg-panel); }
.macro-drill-hint { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
@media (max-width: 640px) {
    .macro-tiergrids { grid-template-columns: minmax(0, 1fr); }
}

/* The story from the calls (storycard.js, 2026-11-21; docs/PLAN-CONCALL-BUILD.md
 * part A). Each heading is a <details>, closed, showing its newest line in its
 * summary; Show full story opens them all. */
.st { display: flex; flex-direction: column; gap: 8px; }
.st-calls { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
.st-dot { border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; color: var(--text); }
.st-dot-new { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.st-tile { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--bg-raised); min-width: 0; }
.st-tile-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.st-tile-word { font-size: 15px; font-weight: 600; color: var(--text-bright); margin-top: 2px; }
.st-tile-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.st-neg { color: var(--neg); } .st-warn { color: var(--warn); }
.st-brief { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 8px 12px; background: var(--bg-raised); }
.st-brief-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.st-brief-title { font-weight: 700; color: var(--text-bright); }
.st-brief-by { font-size: 12px; color: var(--text-dim); }
.st-brief ol { margin: 6px 0 2px; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; max-width: 110ch; }
.st-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.st-full { font: inherit; font-size: 12.5px; cursor: pointer; padding: 3px 11px; border-radius: 6px; border: 1px solid var(--border-strong, var(--border)); background: var(--bg-panel); color: var(--accent); }
.st-bar-note { font-size: 12.5px; color: var(--text-dim); }
.st-h { border-top: 1px solid var(--border); }
.st-h > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; padding: 7px 0; list-style: none; }
.st-h > summary::-webkit-details-marker { display: none; }
.st-num { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--bg-raised); border: 1px solid var(--border); font-size: 11.5px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-dim); }
.st-title { font-weight: 600; color: var(--text-bright); }
.st-count { font-size: 12.5px; color: var(--text-dim); }
.st-prev { flex: 1 1 100%; font-size: 13px; color: var(--text-dim); padding-left: 30px; }
.st-prev b { color: var(--text); font-weight: 600; }
.st-h[open] > summary .st-prev { display: none; }
.st-body { padding: 2px 0 10px 30px; display: flex; flex-direction: column; gap: 8px; }
.st-tl { display: flex; flex-direction: column; gap: 6px; }
.st-row { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 2px 10px; }
.st-when { color: var(--text-dim); font-size: 12.5px; padding-top: 2px; }
.st-newest .st-when { color: var(--accent); font-weight: 600; }
.st-row .st-q { grid-column: 2; margin: 0; max-width: 110ch; line-height: 1.5; }
.st-who { color: var(--text-dim); font-size: 12px; margin-left: 4px; }
.st-tag { font-size: 11px; border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 6px; color: var(--text-dim); }
.st-sub { margin: 0 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.st-two { display: flex; flex-direction: column; gap: 10px; }
.st-lead { margin: 0; } .st-lead b { color: var(--text-bright); }
.st-note, .st-none, .st-foot { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.st-empty { margin: 0; }
@media (max-width: 640px) {
    .st-row { grid-template-columns: minmax(0, 1fr); }
    .st-row .st-q { grid-column: 1; }
    .st-prev, .st-body { padding-left: 0; }
}
@media print {
    .st-h > summary .st-prev { display: none; }
    .st-full { display: none; }
}

/* The stock panel's Calls line opens the card (storycard.js). */
.stock-panel-v .link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
