/* interactive_screeners — calm dense Deepvue-style palette. CLAUDE.md §11.2.
   Dark is default. Light theme activates via [data-theme="light"] on <html>,
   set by main.js from localStorage or prefers-color-scheme. */

:root {
    --bg: #0a0e14;
    --bg-elev: #0f1521;
    --fg: #e6ebf3;
    --fg-muted: #8b94a3;
    --accent: #e6b450;
    --accent-cyan: #39bae6;
    --row-stripe: #11161e;
    --row-hover: #1a2030;
    --border: #1f2937;
    --pass: #10b981;
    --fail: #ef4444;
    --neutral: #4b5563;
}

[data-theme="light"] {
    --bg: #ffffff;
    --bg-elev: #f8fafc;
    --fg: #1f2937;
    --fg-muted: #64748b;
    --accent: #b45309;          /* darker amber — readable on white */
    --accent-cyan: #0e7490;     /* darker cyan */
    --row-stripe: #f3f4f6;
    --row-hover: #e5e7eb;
    --border: #d1d5db;
    --pass: #047857;
    --fail: #b91c1c;
    --neutral: #9ca3af;
}

* { box-sizing: border-box; }

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

body {
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Noto Sans TC", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;          /* never overflow horizontally — controls
                                 reflow to a new line instead of forcing a
                                 page-wide horizontal scrollbar at 100% */
    gap: 0.5rem 1rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    text-decoration: none;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 16px;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
}
.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}
.brand-slogan {
    font-size: 10px;
    font-weight: 400;
    color: var(--fg-muted);
    letter-spacing: 0.03em;
    line-height: 1.25;
    max-width: 16rem;        /* wrap under the logo (≈ lockup width) rather
                                than stretching the topbar row wide */
}
.brand-logo {
    height: 36px;
    width: auto;
    display: block;
}
/* The logo SVG ships in "yellow-on-transparent" form for the dark theme.
   Under the light theme we re-tint via filter so the logomark stays
   readable on a white background. */
[data-theme="light"] .brand-logo {
    filter: brightness(0.6) saturate(1.3);
}
.brand-sub { color: var(--fg-muted); font-weight: 400; }

.intro-banner {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.intro-subhead {
    margin: 0;
    color: var(--fg-muted);
    font-size: 12.5px;
    line-height: 1.55;
    max-width: 70rem;
}

.market-badge,
.market-selector {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--accent-cyan);
    background: var(--bg);
    font-family: "JetBrains Mono", "SFMono-Regular", monospace;
    font-size: 13px;
    cursor: pointer;
}

.market-selector option { background: var(--bg-elev); color: var(--accent-cyan); }
.market-selector:focus { outline: 1px solid var(--accent); }
.market-selector option[data-access="preview"]::after { content: " · preview"; }

.meta-asof {
    color: var(--fg-muted);
    font-family: "JetBrains Mono", "SFMono-Regular", monospace;
    font-size: 13px;
}

.plan-badge {
    padding: 0.2rem 0.55rem;
    border-radius: 3px;
    font-family: "JetBrains Mono", monospace;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--neutral);
    color: #f3f4f6;
}
.plan-badge.plan-demo { background: var(--neutral); }
.plan-badge.plan-lite { background: #1d4ed8; color: #f3f4f6; }
.plan-badge.plan-pro  { background: var(--accent); color: #042619; }

.signin-link {
    color: var(--accent-cyan);
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.25rem 0.7rem;
    border-radius: 3px;
    font-size: 12.5px;
    cursor: pointer;
    font-family: inherit;
}
.signin-link:hover { color: var(--accent); border-color: var(--accent); }

.theme-toggle {
    margin-left: auto;
    background: transparent;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    padding: 0.2rem 0.55rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
    font-family: inherit;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

.lang-toggle {
    display: flex;
    gap: 0.25rem;
}

.lang-toggle button {
    background: transparent;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    padding: 0.25rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
}

.lang-toggle button:hover { color: var(--fg); }
.lang-toggle button.active { color: var(--accent); border-color: var(--accent); }

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    align-items: flex-end;
    background: var(--bg-elev);
}

.control {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.control label {
    color: var(--fg-muted);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control select,
.control input[type="number"],
.control input[type="text"] {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.4rem 0.6rem;
    font-size: 14px;
    font-family: inherit;
    min-width: 10rem;
}

.control input[type="text"]:focus { outline: 1px solid var(--accent); outline-offset: 0; }
.control input[type="number"] { width: 7rem; min-width: 0; }
#ticker-search { font-family: "JetBrains Mono", monospace; letter-spacing: 0.05em; text-transform: uppercase; }

/* Preset dropdown — capped width so the long combo/Raschke labels (e.g.
 * "VVT — ボラティリティ・出来高スラスト セットアップ (AlpharvestPro)")
 * don't blow out the controls row width and push the second toggle column
 * onto a new line. The capped width applies to the CLOSED <select>; native
 * browsers expand the open dropdown body beyond this max-width so the full
 * option text is still readable when picking. Text-overflow:ellipsis adds
 * "…" to the selected-option label when it exceeds the cap (Chrome/Edge;
 * Firefox shows truncated text without the ellipsis glyph but the option
 * is still selectable). Bit the layout on the JA locale 2026-05-25 — full-
 * width chars made Part-2 toggles wrap to a new row. */
#preset-select {
    max-width: 14rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.control .hint {
    color: var(--fg-muted);
    font-size: 12px;
    line-height: 1.35;
    max-width: 16rem;
    text-transform: none;
    letter-spacing: 0;
    margin-top: 2px;
}

/* Description + attribution block that appears under the preset
   dropdown when a preset is selected. The footnote (Raschke entries
   only) MUST be visible — per memory feedback_raschke_attribution_footnote.md
   it is NOT hover-only. Italic + muted so it doesn't compete with the
   active controls, but readable enough that the Linda Bradford Raschke
   credit and Street Smarts (1996) citation are easy to spot. */
.preset-info {
    margin-top: 0.5rem;
    padding: 0.5rem 0.7rem;
    max-width: 28rem;
    background: rgba(57, 186, 230, 0.05);
    border-left: 3px solid var(--accent-cyan, #39bae6);
    border-radius: 2px;
    font-size: 12.5px;
    line-height: 1.5;
}
.preset-info-description {
    margin: 0 0 0.3rem;
    color: var(--text);
}
.preset-info-description:last-child { margin-bottom: 0; }
.preset-info-footnote {
    margin: 0;
    font-style: italic;
    color: var(--fg-muted, var(--muted));
    font-size: 11.5px;
}

.toggles { gap: 0.4rem; }
.toggles label {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    text-transform: none;
    color: var(--fg);
    font-size: 13.5px;
    letter-spacing: 0;
}
.toggles input[type="checkbox"] { accent-color: var(--accent); }

.control-meta { margin-left: auto; }
.result-count { color: var(--fg-muted); font-family: "JetBrains Mono", monospace; }

main {
    padding: 0.5rem 1rem 1rem;
}

#result-table {
    width: 100%;
    border-collapse: collapse;
    font-family: "JetBrains Mono", "SFMono-Regular", monospace;
    font-size: 13.5px;
}

#result-table th,
#result-table td {
    text-align: left;
    /* 0.65->0.5rem horizontal: absorbs the 3 extra RS columns (rs_1m/3m/6m)
       added to the default view so the table fits >=1280px without a
       page-level horizontal scrollbar. Sticky header is preserved (no
       overflow wrapper introduced). */
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
}

#result-table th {
    background: var(--bg-elev);
    color: var(--fg-muted);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    /* Two-word headers (RS 52w-high, Price 52w-high, Perf 12M, RS 1M…) get
       their first space turned into a newline in table.js; pre-line honors
       that break so they render on two lines, halving column width to make
       room for the extra RS horizons. Data cells keep nowrap (line 246). */
    white-space: pre-line;
    line-height: 1.15;
    vertical-align: bottom;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 41px;
    z-index: 5;
}

#result-table th.sorted-asc::after { content: " ▲"; color: var(--accent); }
#result-table th.sorted-desc::after { content: " ▼"; color: var(--accent); }

#result-table tbody tr:nth-child(odd) { background: var(--row-stripe); }
#result-table tbody tr:hover { background: var(--row-hover); }

td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
td.ticker { color: var(--accent); font-weight: 600; font-size: 14px; }
td.ticker .ticker-link { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
td.ticker .ticker-link:hover { color: #ffd97a; border-bottom-style: solid; }
td.company { color: var(--fg); font-size: 12.5px; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.sector { color: var(--fg-muted); font-size: 12.5px; }
.perf-up { color: var(--pass); }
.perf-down { color: var(--fail); }

/* Stale-row marker: rows whose data is older than today get a tiny suffix
   after the ticker. The full row stays at full opacity but the suffix flags
   the freshness. Hover the suffix to see exact data_date. */
.stale-badge {
    color: var(--fg-muted);
    font-size: 11px;
    font-weight: 400;
    margin-left: 0.35em;
    padding: 0.05em 0.35em;
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: help;
    text-transform: lowercase;
    letter-spacing: 0;
    vertical-align: 1px;
}
.stale-mild  .stale-badge { color: var(--fg-muted); border-color: var(--border); }
.stale-medium .stale-badge { color: #ca8a04; border-color: #ca8a04; }
.stale-severe .stale-badge { color: var(--fail); border-color: var(--fail); }
.stale-medium td.ticker, .stale-severe td.ticker { opacity: 0.85; }

/* Locked-cell marker: the column header still renders for every tier, but
   when the DTO row omits the value (server stripped it for non-full
   access — see sql.py::FULL_ONLY_COLUMNS), the cell shows a muted 🔒 with
   an "Upgrade to unlock" tooltip. Mirrors the existing "—" null fallback,
   just with a paywall hint instead of a missing-data hint. */
.cell-locked {
    opacity: 0.4;
    font-size: 0.9em;
    cursor: help;
}

/* VCP Footprint column (2026-05-29) — monospace + tabular-nums so the
   `XW-Y/Z-NT` codes line up at the digit slots (e.g. `12W-25/5-5T` vs
   `7W-15/3-4T`). nowrap because the code is one compound token. */
.col-vcp-footprint {
    font-family: "JetBrains Mono", "SFMono-Regular", monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.85em;
    white-space: nowrap;
}

.chip {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    line-height: 1.1em;
    border-radius: 50%;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
}
.chip-pass { background: var(--pass); color: #042619; }
.chip-fail { background: var(--neutral); color: #d1d5db; }

/* O / X indicator glyphs (es2/vcp/bbu/pp/u_and_r columns). Larger + bolder
 * than the legacy .chip pill so users can scan pass/fail at a glance.
 * Pass = green; fail = default body text color (follows light/dark theme). */
.ox-chip {
    display: inline-block;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}
.ox-chip-pass { color: var(--pass); }
.ox-chip-fail { color: var(--fg); }

/* VCP 60D / Early-S2 60D Breakout Tracker inline badges, appended to the
 * ticker cell when a row has an active tracker entry. Color encodes the
 * indicator + status; tooltip carries qualified-date + status + days. */
.tracker-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    line-height: 14px;
    vertical-align: middle;
    cursor: help;
}
.tracker-vcp.tracker-waiting    { color: #39bae6; }   /* VCP coiling — cyan */
.tracker-vcp.tracker-broke_out  { color: var(--pass); } /* VCP graduate — green */
.tracker-es2.tracker-waiting    { color: #ca8a04; }   /* ES2 waiting — amber */
.tracker-es2.tracker-broke_out  { color: var(--pass); } /* ES2 graduate — green */

/* ANTS (David Ryan) MVP badge — colored circle emoji + ant. The colored
 * circles (🟢 / 🟡) are true colors on every modern platform; no CSS hack
 * needed. Tooltip carries the raw Momentum/Volume/Price numbers. */
.ants-badge {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    line-height: 1;
    vertical-align: middle;
    cursor: help;
}

.score {
    display: inline-block;
    min-width: 1.3em;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    text-align: center;
    color: #042619;
    font-weight: 700;
    background: var(--pass);
    font-size: 11px;
}
.score-low { background: var(--neutral); color: #f3f4f6; }
.score-mid { background: #ca8a04; color: #1a1a00; }

.sparkline { display: inline-block; vertical-align: middle; }

.pager {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    color: var(--fg-muted);
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
}

.pager button {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 0.3rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { color: var(--neutral); cursor: not-allowed; }

.pager-show {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.5rem;
    color: var(--fg-muted);
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
}
.pager-show select {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.25rem 0.45rem;
    font-size: 12px;
    font-family: inherit;
}
.pager-show select:focus { outline: 1px solid var(--accent); }

.loading {
    text-align: center;
    color: var(--fg-muted);
    font-style: italic;
    padding: 2rem !important;
}

.error {
    text-align: center;
    color: var(--fail);
    padding: 2rem !important;
}

.page-footer {
    padding: 1rem;
    color: var(--fg-muted);
    border-top: 1px solid var(--border);
    font-size: 11px;
    line-height: 1.5;
    max-width: 60rem;
}

/* Bilingual visibility — body class drives which lang attr is shown. */
body.lang-en [lang="ja"], body.lang-en [lang="zh"] { display: none; }
body.lang-ja [lang="en"], body.lang-ja [lang="zh"] { display: none; }
body.lang-zh [lang="en"], body.lang-zh [lang="ja"] { display: none; }

/* Chart panel — Phase C. Mounted below the pager on demand. */
.chart-panel {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elev);
    padding: 0.75rem 0.85rem 0.85rem;
}
.chart-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.6rem;
}
.chart-header-meta {
    display: inline-flex;
    align-items: baseline;
    gap: 0.6rem;
    font-family: "JetBrains Mono", monospace;
}
.chart-ticker {
    color: var(--accent);
    font-size: 16px;
    letter-spacing: 0.04em;
}
.chart-market {
    color: var(--accent-cyan);
    font-size: 11.5px;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    text-transform: uppercase;
}
.chart-asof {
    color: var(--fg-muted);
    font-size: 12px;
}
.chart-period-toggle {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}
.chart-period-toggle button {
    background: transparent;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    padding: 0.25rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12.5px;
    font-family: inherit;
}
.chart-period-toggle button:hover { color: var(--fg); }
.chart-period-toggle button.active { color: var(--accent); border-color: var(--accent); }
.chart-close {
    background: transparent;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    padding: 0 0.55rem;
    border-radius: 3px;
    font-size: 16px;
    line-height: 1.1;
    cursor: pointer;
    font-family: inherit;
}
.chart-close:hover { color: var(--fail); border-color: var(--fail); }
.chart-container {
    width: 100%;
    min-height: 270px;
    background: var(--bg);
    border-radius: 3px;
}
/* Pro/Ultra-tier 10-cell readout strip — single horizontal row of
   label+value pairs above the reference chart. Wraps on narrow viewports.
   Demo / lite users never see this; the API returns no `readouts` block.
   Font: 14px (bumped from 12px per user feedback 2026-05-23) so the
   strip reads at a glance without leaning in. Pipe separators between
   cells make the boundaries crisp without adding visual weight. */
.chart-readouts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: rgba(230, 180, 80, 0.05);
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
    line-height: 1.45;
}
.chart-readout-cell {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0 0.85rem;
    white-space: nowrap;
    border-right: 1px solid var(--border);
}
.chart-readout-cell:last-child {
    border-right: none;
}
.chart-readout-label {
    color: var(--fg-muted, var(--muted));
    font-size: 13px;
    letter-spacing: 0.01em;
}
/* Visual colon-separator between label and value without adding a glyph
   to the i18n strings (keeps localized labels clean of EN-style ":"). */
.chart-readout-label::after {
    content: " :";
    color: var(--border);
    margin-left: 0.05rem;
}
.chart-readout-value {
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
}
.chart-readout-value.ok {
    color: var(--accent-positive, var(--accent-cyan, #39bae6));
}
.chart-readout-value.no {
    color: var(--fg-muted, var(--muted));
    font-weight: 400;
}

/* Always-visible attribution under the readout strip. Italic + muted so
   it doesn't compete with the cells, but readable enough that the Linda
   Bradford Raschke + Street Smarts (1996) credit is easy to spot.
   Matches the preset-info footnote pattern (visible, not hover-only) per
   memory feedback_raschke_attribution_footnote.md. */
.chart-readouts-footnote {
    margin: -0.3rem 0 0.7rem;
    padding: 0.25rem 0.85rem 0.5rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 11.5px;
    font-style: italic;
    color: var(--fg-muted, var(--muted));
    line-height: 1.4;
    max-width: 100%;
}

/* Per-market reference index — full-width Lightweight Charts line series
   above the main candlestick. Time scale is hidden on the reference but
   zoom/scroll syncs both ways with the main chart, so panning the main
   chart pans the reference and vice versa. */
.chart-reference {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: rgba(57, 186, 230, 0.03);
    overflow: hidden;
}
.chart-reference-header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.4rem 0.7rem 0.3rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    border-bottom: 1px dashed var(--border);
}
.chart-reference-canvas {
    width: 100%;
    height: 100px;  /* compact: proportional with main + RS so all 3 fit one viewport */
    background: var(--bg);
    position: relative;  /* anchor for the absolute-positioned hover tooltip */
}
.chart-ref-label {
    color: var(--accent-cyan);
    font-weight: 600;
    letter-spacing: 0.04em;
}
.chart-ref-ticker {
    color: var(--fg-muted);
    font-size: 10.5px;
    padding: 0.05rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 2px;
}
.chart-ref-last { color: var(--fg); font-variant-numeric: tabular-nums; }
.chart-ref-pct { font-variant-numeric: tabular-nums; margin-left: auto; }
.chart-loading, .chart-error {
    text-align: center;
    color: var(--fg-muted);
    font-style: italic;
    padding: 2rem 1rem;
}
.chart-error { color: var(--fail); font-style: normal; }
/* In-chart overlay legend — sits in the top-left corner of the chart
   container so the labels don't crowd the latest candles on the right
   edge. The chart-panel is the positioning ancestor. */
.chart-panel { position: relative; }
.chart-legend {
    position: absolute;
    top: 6px;
    left: 10px;
    z-index: 10;
    margin: 0;
    padding: 4px 8px;
    display: flex;
    gap: 0.85rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 11.5px;
    color: var(--fg-muted);
    background: rgba(13, 17, 23, 0.72);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
    backdrop-filter: blur(2px);
    pointer-events: none;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.chart-legend span::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 2px;
}
.legend-sma50::before { background: #39bae6; }
.legend-sma200::before { background: var(--accent); }
.legend-vma50::before { background: var(--fg-muted); }

/* RS Rating sub-chart — sits below the main candlestick, shows our
   screener-computed 0-99 IBD-style rank for the ticker over time, with
   horizontal threshold lines at 70 (leadership cut), 80 (strong), 90
   (elite). Time scale is hidden; the user's main chart time scale
   drives both via zoom-sync. */
.chart-rs-history {
    margin-top: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: rgba(167, 139, 250, 0.04);  /* very faint violet wash */
    overflow: hidden;
}
.chart-rs-header {
    padding: 0.35rem 0.7rem 0.25rem;
    border-bottom: 1px dashed var(--border);
    color: #a78bfa;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.chart-rs-canvas {
    width: 100%;
    height: 110px;
    background: var(--bg);
    position: relative;  /* anchor for the absolute-positioned hover tooltip */
}

/* Hover tooltip shared by both sub-charts (reference + RS history) since
   their time-axes are hidden for vertical compactness. Shows date + value
   in a small floating chip anchored to the top-left of the canvas. */
.chart-subchart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--bg-elev);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.15rem 0.5rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 5;
}

/* Mode toggle — Screener vs Watchlist. Sits in the topbar. */
.mode-toggle {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.4rem;
}
.mode-toggle button {
    background: transparent;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    padding: 0.25rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12.5px;
    font-family: inherit;
}
.mode-toggle button:hover { color: var(--fg); }
.mode-toggle button.active { color: var(--accent); border-color: var(--accent); }
.mode-count {
    display: inline-block;
    background: var(--accent-cyan);
    color: var(--bg);
    border-radius: 9px;
    padding: 0 0.4rem;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.4;
    vertical-align: 1px;
    font-family: "JetBrains Mono", monospace;
}
.mode-toggle button.active .mode-count { background: var(--accent); }

.csv-export {
    background: transparent;
    color: var(--accent-cyan);
    border: 1px solid var(--border);
    padding: 0.25rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12.5px;
    font-family: inherit;
}
.csv-export:hover { color: var(--accent); border-color: var(--accent); }

/* Toast — inline notification for watchlist cap warnings, etc. */
.toast {
    position: fixed;
    top: 60px;
    right: 1rem;
    z-index: 50;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elev);
    color: var(--fg);
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    max-width: 28rem;
}
.toast-warn { border-color: #ca8a04; color: #fde68a; }
.toast-info { border-color: var(--accent-cyan); color: var(--fg); }

/* Watchlist split view — left list, right chart. Stacks on mobile. */
.watchlist-view {
    display: grid;
    grid-template-columns: minmax(220px, 28%) 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
    align-items: start;
    position: relative;
}
.watchlist-sidebar {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elev);
    padding: 0.6rem 0.75rem 0.85rem;
    min-height: 320px;
}
.watchlist-title {
    margin: 0 0 0.25rem;
    color: var(--accent);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.watchlist-meta {
    margin: 0 0 0.5rem;
    color: var(--fg-muted);
    font-family: "JetBrains Mono", monospace;
    font-size: 11.5px;
}
.watchlist-export-btn {
    display: block;
    width: 100%;
    margin-bottom: 0.6rem;
    background: transparent;
    color: var(--accent-cyan);
    border: 1px solid var(--border);
    padding: 0.35rem 0.6rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    text-align: center;
}
.watchlist-export-btn:hover { color: var(--accent); border-color: var(--accent); }
.watchlist-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.watchlist-empty {
    color: var(--fg-muted);
    font-style: italic;
    font-size: 12.5px;
    padding: 0.75rem 0.25rem;
}
.watchlist-item {
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 3px;
}
.watchlist-item.selected {
    border-color: var(--accent);
    background: var(--row-stripe);
}
.watchlist-pick {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    background: transparent;
    border: none;
    color: var(--fg);
    text-align: left;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    border-radius: 3px;
}
.watchlist-pick:hover { background: var(--row-hover); }
.watchlist-ticker { color: var(--accent); font-weight: 600; }
.watchlist-market { color: var(--fg-muted); font-size: 11px; text-transform: uppercase; }
.watchlist-remove {
    background: transparent;
    color: var(--fg-muted);
    border: none;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.watchlist-remove:hover { color: var(--fail); }
.watchlist-chart-panel { margin-top: 0; }
.watchlist-empty-hint {
    color: var(--fg-muted);
    font-style: italic;
    grid-column: 2 / 3;
    text-align: center;
    padding: 4rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 4px;
    margin: 0;
}

/* Star column — toggles filled/hollow on click. */
.col-watchlist-star { width: 2.4rem; text-align: center; padding-left: 0.4rem !important; padding-right: 0.4rem !important; }
.star-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
}
.star-btn:hover { color: var(--accent); border-color: var(--border); }
.star-btn.starred { color: var(--accent); }
#result-table th.col-watchlist-star { cursor: default; }

/* Chart-button column — narrow leftmost column with a single emoji button. */
.col-chart-btn { width: 2.4rem; text-align: center; padding-left: 0.4rem !important; padding-right: 0.4rem !important; }
.chart-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    line-height: 1;
}
.chart-btn:hover { color: var(--accent); border-color: var(--border); }
#result-table th.col-chart-btn { cursor: default; }

.col-diag { width: 2.4rem; text-align: center; padding-left: 0.4rem !important; padding-right: 0.4rem !important; }
.diag-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    line-height: 1;
    font-family: inherit;
}
.diag-btn:hover { color: var(--accent); border-color: var(--border); }
#result-table th.col-diag { cursor: default; }

/* In-screener compact diagnostic modal (diagnostic.js). Fixed overlay —
   never affects table width / the one-page constraint. Theme-aware via
   CSS vars so it tracks the dark/light toggle. */
.diag-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 2rem;
    z-index: 1000;
    overflow-y: auto;
}
.diag-modal {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
    max-width: 30rem;
    max-height: 82vh;
    overflow-y: auto;
    padding: 0.9rem 1rem 1rem;
    font-family: "JetBrains Mono", "SFMono-Regular", monospace;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.diag-head { display: flex; align-items: center; gap: 0.6rem; }
.diag-tk { color: var(--accent); font-size: 17px; letter-spacing: 0.04em; }
.diag-mk {
    color: var(--accent-cyan); font-size: 11px; text-transform: uppercase;
    border: 1px solid var(--border); border-radius: 3px; padding: 0.05rem 0.4rem;
}
.diag-x {
    margin-left: auto; background: transparent; color: var(--fg-muted);
    border: 1px solid var(--border); border-radius: 3px; cursor: pointer;
    font-size: 16px; line-height: 1; padding: 0.1rem 0.5rem; font-family: inherit;
}
.diag-x:hover { color: var(--fail); border-color: var(--fail); }
.diag-x-solo { margin-left: 0; }
.diag-sub { color: var(--fg-muted); font-size: 12px; margin: 0.45rem 0 0.7rem; }
.diag-body { display: flex; flex-direction: column; gap: 0.05rem; }
.diag-row {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: 0.32rem 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.diag-row-label { color: var(--fg-muted); }
.diag-row-value { color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }
.diag-flag-on { color: var(--pass); font-weight: 600; }
.diag-flag-off { color: var(--fg-muted); }
.diag-peers-head {
    color: var(--accent); font-size: 12px; margin: 0.85rem 0 0.4rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.diag-peers { list-style: none; margin: 0; padding: 0; }
.diag-peers li {
    display: flex; gap: 0.6rem; align-items: baseline;
    padding: 0.25rem 0; font-size: 12.5px; border-bottom: 1px solid var(--border);
}
.diag-peer-tk { color: var(--accent); min-width: 4rem; }
.diag-peer-nm { color: var(--fg-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diag-peer-rs { color: var(--fg); font-variant-numeric: tabular-nums; }
.diag-loading, .diag-empty {
    color: var(--fg-muted); font-style: italic; text-align: center; padding: 1.5rem 1rem;
}
.diag-empty { font-style: normal; }

/* Responsive: at narrow widths, hide low-priority columns. */
@media (max-width: 800px) {
    .col-perf, .col-sector, .col-rs-historical { display: none; }
    .controls { padding: 0.5rem; gap: 0.5rem; }
    .watchlist-view {
        grid-template-columns: 1fr;  /* stack list above chart on mobile */
    }
    .watchlist-empty-hint { grid-column: 1 / -1; }
}
