:root {
    --bg: #ffffff;
    --panel: #f6f7f9;
    --surface: #ffffff;
    --border: #e1e4ea;
    --text: #2b3240;
    --text-bright: #10131a;
    --muted: #6b7688;
    --accent: #2563eb;
    --accent-bright: #1d4ed8;
    --accent-bg: #eaf1ff;
    --accent-border: #bcd2fb;
    --hover-bg: #eef2f8;
    --green: #15803d;
    --green-bg: #e9f9ef;
    --green-border: #b7ebc6;
    --red: #b91c1c;
    --red-bg: #fdecec;
    --red-border: #f3bcbc;
    --amber-bg: #fef3c7;
    --amber-text: #92400e;
    --shadow-color: rgba(20, 25, 35, 0.18);
}

/* Admin-selected theme: 'auto' follows the OS/browser preference; 'dark' and
   'light' are explicit overrides applied via data-theme on <html> (see
   settings_theme() / lib/settings.php) so every visitor sees the same choice
   regardless of their device setting. */
:root[data-theme="dark"] {
    --bg: #0f1420;
    --panel: #171d2c;
    --surface: #1b2333;
    --border: #2b3345;
    --text: #c7cddb;
    --text-bright: #f2f4f8;
    --muted: #8b93a7;
    --accent: #4f8cff;
    --accent-bright: #7aa8ff;
    --accent-bg: #1c2c4a;
    --accent-border: #35507f;
    --hover-bg: #232c40;
    --green: #4ade80;
    --green-bg: #113322;
    --green-border: #1f5c3a;
    --red: #f87171;
    --red-bg: #3a1414;
    --red-border: #6b2323;
    --amber-bg: #3a2c0f;
    --amber-text: #f2c14e;
    --shadow-color: rgba(0, 0, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        --bg: #0f1420;
        --panel: #171d2c;
        --surface: #1b2333;
        --border: #2b3345;
        --text: #c7cddb;
        --text-bright: #f2f4f8;
        --muted: #8b93a7;
        --accent: #4f8cff;
        --accent-bright: #7aa8ff;
        --accent-bg: #1c2c4a;
        --accent-border: #35507f;
        --hover-bg: #232c40;
        --green: #4ade80;
        --green-bg: #113322;
        --green-border: #1f5c3a;
        --red: #f87171;
        --red-bg: #3a1414;
        --red-border: #6b2323;
        --amber-bg: #3a2c0f;
        --amber-text: #f2c14e;
        --shadow-color: rgba(0, 0, 0, 0.45);
    }
}

* { box-sizing: border-box; }

/* overflow-x:hidden here (not on body) blocks any page-level horizontal scroll
   without body establishing its own scroll container — that would silently
   break position:sticky for every descendant (nav bar, chart header, etc.). */
html { overflow-x: hidden; width: 100%; }
body {
    /* iOS Safari has ignored the viewport meta's user-scalable=no/maximum-scale
       since iOS 10 (an Apple accessibility decision) — touch-action is the actual
       reliable way to stop page-wide pinch/double-tap zoom on modern mobile
       browsers. pan-x pan-y (NOT "manipulation", which still allows native pinch)
       permits normal single-finger scrolling but disables browser pinch-zoom
       entirely. Chart containers override this back to their own gesture
       handling — see .chart-wrap #*Chart rules below. */
    touch-action: pan-x pan-y;
    transition: background-color 0.15s ease, color 0.15s ease;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0 1.5rem 3rem;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.header {
    padding: 1.5rem 0 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
}
.header-slim { padding: 0.8rem 0; margin-bottom: 1rem; }
.header h1 { font-size: 1.8rem; font-weight: 800; color: var(--text-bright); letter-spacing: -0.01em; margin: 0; }
.header .sub { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; margin-top: 0.3rem; }

.lang-toggle a {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--muted);
    margin-left: 4px;
}
.lang-toggle a.active { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-bg); }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.5rem;
}

.pulse-banner { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.pulse-badge { font-size: 1.1rem; font-weight: 700; padding: 6px 14px; border-radius: 8px; letter-spacing: 0.01em; }
.pulse-badge.bullish { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.pulse-badge.bearish { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.pulse-badge.neutral { background: var(--accent-bg); color: var(--accent-bright); border: 1px solid var(--accent-border); }
.pulse-metrics { display: flex; gap: 1.8rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.pulse-metrics b { color: var(--text-bright); font-size: 0.95rem; }
.pulse-desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.6rem; line-height: 1.5; }

h2, h3, h4 { font-weight: 700; color: var(--text-bright); letter-spacing: -0.005em; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.8rem; color: var(--muted); }
.collapsible-h2 {
    cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    user-select: none;
}
.collapse-chevron { font-size: 0.8rem; transition: transform 0.15s ease; }
.collapse-chevron.collapsed { transform: rotate(-90deg); }

/* Same toggle look as .collapsible-h2, but on a real <button> (not an <h2>) for
   the chart's indicator/tool checkboxes — a <button> doesn't inherit the bare
   h2 tag-selector rules above, so its base look is spelled out here instead. */
.chart-filters-toggle {
    width: 100%; background: none; border: none; padding: 0; margin: 0 0 0.6rem;
    font-family: inherit; font-size: 1rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted);
}
.chart-filters-toggle:hover { color: var(--accent-bright); }

table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
thead th {
    text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer;
    white-space: nowrap;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:hover { background: var(--hover-bg); }
.sym { font-weight: 700; color: var(--text-bright); }
.name { color: var(--muted); font-size: 0.75rem; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--muted); }
.badge { font-size: 0.68rem; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); }
.badge.high { color: var(--green); border-color: var(--green-border); background: var(--green-bg); }
.badge.low { color: var(--red); border-color: var(--red-border); background: var(--red-bg); }
.badge.bullish { color: var(--green); border-color: var(--green-border); background: var(--green-bg); }
.badge.bearish { color: var(--red); border-color: var(--red-border); background: var(--red-bg); }
.badge.neutral { color: var(--muted); }

.th-info {
    cursor: pointer; color: var(--muted); font-size: 0.68rem; margin-left: 2px;
    text-transform: none; letter-spacing: normal;
}
.th-info:hover { color: var(--accent-bright); }
.col-popover {
    position: fixed; z-index: 100;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
    font-size: 0.72rem; font-weight: 400; text-transform: none; letter-spacing: normal;
    color: var(--text); box-shadow: 0 6px 18px var(--shadow-color); white-space: normal; line-height: 1.45;
    cursor: default;
}

.count-line { font-size: 0.72rem; color: var(--muted); margin: 0.6rem 0 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin-bottom: 1.2rem; }
/* Purely informational — never a link/button, so no hover/press highlight
   (that would falsely suggest they're interactive/clickable). */
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem 1.1rem; }
.stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--text-bright); }
.stat-explain { font-size: 0.72rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.chart-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin-bottom: 1.5rem; position: relative; }
/* Custom fullscreen-style zoom for mobile charts — a fixed-position overlay rather
   than the native Fullscreen API, since iOS Safari doesn't support requestFullscreen()
   on arbitrary elements (only <video>). Works identically everywhere this way. */
.chart-wrap.chart-zoomed {
    position: fixed; inset: 0; z-index: 500; margin: 0; border-radius: 0;
    background: var(--bg); overflow-y: auto; display: flex; flex-direction: column;
}
.chart-zoom-close-btn {
    display: none; position: sticky; top: 0; align-self: flex-end; z-index: 501;
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 1rem; line-height: 1;
    cursor: pointer; margin-bottom: 0.4rem; align-items: center; justify-content: center;
}
.chart-wrap.chart-zoomed .chart-zoom-close-btn { display: flex; }
/* Period-return row + its caption just eat vertical space while zoomed — the whole
   point of zooming in is to give the actual chart panes more room. */
.chart-wrap.chart-zoomed .period-tabs, .chart-wrap.chart-zoomed .period-explain { display: none; }
.period-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 0.4rem; flex-wrap: wrap; }

.period-tabs a.ptab {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 14px;
    text-decoration: none; min-width: 64px; border-radius: 8px; border: none;
}
.period-tabs a.ptab:hover { text-decoration: none; background: var(--panel); }
.period-tabs a.ptab.active { background: var(--panel); }
.ptab-label { font-size: 0.78rem; font-weight: 500; color: var(--text-bright); }
.ptab-return { font-size: 0.78rem; font-weight: 500; }
.ptab-return.positive { color: var(--green); }
.ptab-return.negative { color: var(--red); }
.ptab-return.neutral { color: var(--muted); }
.period-explain { font-size: 0.72rem; color: var(--muted); margin: -0.1rem 0 0.8rem; }

.signal-line { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.83rem; }
.signal-line:last-child { border-bottom: none; }
.signal-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.signal-dot.positive { background: var(--green); }
.signal-dot.negative { background: var(--red); }
.signal-dot.neutral { background: var(--muted); }

.alert { background: var(--panel); border-left: 3px solid var(--accent); font-size: 0.83rem; padding: 0.9rem 1.1rem; border-radius: 6px; line-height: 1.6; margin-bottom: 1.5rem; }
.disclaimer { font-size: 0.72rem; color: var(--muted); text-align: center; margin-top: 2rem; line-height: 1.6; }

.back-link { font-size: 0.78rem; margin-bottom: 1rem; display: inline-block; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.toolbar-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.ind-check { font-size: 0.75rem; color: var(--text); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; white-space: nowrap; }
.ind-check input { accent-color: var(--accent); }

.tool-btn {
    font-family: inherit; font-size: 0.75rem; padding: 5px 12px;
    border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent-bright); }
.tool-btn.active { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-bg); }

.zoom-group { display: flex; gap: 0.5rem; margin-left: auto; }

.hint { font-size: 0.7rem; color: var(--accent-bright); }

.chip {
    display: inline-block; font-size: 0.72rem; padding: 3px 10px; border-radius: 12px;
    border: 1px solid var(--border); color: var(--accent-bright); background: var(--accent-bg);
}
.chip:hover { border-color: var(--red); color: var(--red); text-decoration: none; }

/* touch-action: none hands pinch/pan entirely to the chart library's own touch
   handling — without this, the body-level touch-action: pan-x pan-y above would
   also block the library's pinch-to-zoom gesture on these elements specifically. */
#mainChart, #rsiChart, #macdChart, #dMainChart, #dRsiChart, #dMacdChart { width: 100%; margin-bottom: 4px; touch-action: none; }
.chart-pane-label {
    font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
    font-weight: 700; margin: 10px 0 2px;
}

.draw-popover {
    position: fixed; z-index: 120; display: flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px;
    box-shadow: 0 6px 18px var(--shadow-color);
}
.draw-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); cursor: pointer; padding: 0; }
.draw-swatch:hover { transform: scale(1.15); }
.draw-delete-btn {
    border: 1px solid var(--border); background: var(--surface); border-radius: 6px; cursor: pointer;
    font-size: 0.8rem; padding: 2px 7px; margin-left: 4px; color: var(--red);
}
.draw-delete-btn:hover { background: var(--red-bg); }

/* Fixed bar above the chart (not a box floating over the candles near the cursor —
   that used to cover whatever part of the chart you were pointing at). Lays out
   horizontally so O/H/L/C and each indicator read as compact inline chips. */
.chart-tooltip-bar {
    display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; column-gap: 14px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 10px; margin-bottom: 6px; font-size: 0.7rem; color: var(--text); line-height: 1.3;
    /* Reserved even when empty (no hover yet) so the chart below doesn't jump
       down the moment the first crosshair-move fills it in. */
    min-height: 26px; box-sizing: border-box;
}
.tt-date { font-weight: 700; color: var(--text-bright); }
.tt-interval { font-weight: 400; color: var(--muted); }
.tt-row { display: flex; align-items: center; gap: 5px; }
.tt-key { color: var(--muted); display: flex; align-items: center; gap: 5px; }
.tt-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* Sticky on every screen size (not just narrow phones) so it stays put while
   scrolling on iPad too, including landscape widths above the 900px mobile
   breakpoint. z-index must beat the All-Stocks drawer (200) so its toggle
   stays reachable while that drawer is open. */
.site-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.8rem 0; border-bottom: 1px solid var(--border); margin-bottom: 0.5rem; flex-wrap: wrap;
    position: sticky; top: 0; z-index: 210; background: var(--bg);
}
.site-nav-left { display: flex; align-items: center; gap: 1.4rem; }
.site-nav-link { font-size: 0.85rem; font-weight: 600; color: var(--muted); padding: 4px 2px; border-bottom: 2px solid transparent; }
.site-nav-link:hover { text-decoration: none; color: var(--accent-bright); }
.site-nav-link.active { color: var(--text-bright); border-bottom-color: var(--accent); }

/* Mobile-only "More" dropdown (Admin/Logout tucked behind a toggle instead of
   sitting inline) — hidden entirely on desktop, where .user-menu below covers it. */
.nav-more-wrap { display: none; position: relative; }
.nav-more-chevron { font-size: 0.7rem; display: inline-block; transition: transform 0.15s ease; }
.nav-more-wrap.open .nav-more-chevron { transform: rotate(180deg); }
.nav-more-dropdown {
    display: none; flex-direction: column; align-items: flex-start; gap: 8px;
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 220; min-width: 150px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; box-shadow: 0 6px 18px var(--shadow-color);
}
.nav-more-wrap.open .nav-more-dropdown { display: flex; }
.nav-more-user { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.nav-more-user img { width: 24px; height: 24px; border-radius: 50%; }
.nav-more-dropdown .nav-more-lang { display: flex; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border); width: 100%; box-sizing: border-box; }

.main-tabs { display: flex; gap: 6px; margin-bottom: 1.2rem; }
.main-tab {
    font-size: 0.85rem; font-weight: 600; padding: 8px 18px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; text-decoration: none;
    display: inline-block;
}
.main-tab:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-bright); }
.main-tab.active { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-bg); }

.view-tabs { display: flex; gap: 6px; margin-bottom: 1.2rem; }
.view-tab {
    font-size: 0.8rem; font-weight: 600; padding: 8px 16px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.view-tab.active { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-bg); }

.cause-text { font-size: 0.78rem; color: var(--text); white-space: normal; max-width: 320px; }
.cause-none { font-size: 0.78rem; color: var(--muted); font-style: italic; }
.cause-publisher { font-size: 0.68rem; color: var(--muted); }

.movers-watch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
.sym.sym-overlap { color: var(--accent-bright); font-weight: 800; }

@media (max-width: 1000px) {
    .movers-watch-grid { grid-template-columns: 1fr; }
}

.fav-star {
    background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--border);
    padding: 0; line-height: 1;
}
.fav-star.active { color: #f59e0b; }
.fav-star:hover { color: #f59e0b; }

.tv-layout { display: flex; gap: 1rem; align-items: flex-start; }
.tv-main { flex: 1; min-width: 0; }
.tv-sidebar { width: 340px; flex-shrink: 0; }
.sidebar-panel { position: sticky; top: 1rem; margin-bottom: 0; }
.sidebar-panel input[type="text"] {
    width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
    font-family: inherit; font-size: 0.82rem; border-radius: 6px; padding: 8px 10px;
}
/* Pinned to the top of whichever ancestor actually scrolls — the mobile
   full-screen drawer, or the desktop sidebar's own internal scroll above
   901px — so the search box never scrolls out of reach while browsing the
   list beneath it, on any device. */
.sidebar-search-sticky {
    position: sticky; top: 0; z-index: 5; background: var(--panel);
    padding-bottom: 0.6rem; margin-bottom: -0.2rem;
}
.search-box { position: relative; }
.search-box input[type="text"] { padding-right: 28px; }
.search-clear-btn {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: none; background: none; color: var(--muted); font-size: 0.85rem;
    cursor: pointer; padding: 4px 6px; line-height: 1; border-radius: 50%;
}
.search-clear-btn:hover { color: var(--text-bright); background: var(--panel); }

/* TradingView-style compact interval row: short single-line codes (1m/5m/.../D/W/M),
   plain text with a soft highlight on the active one — no dropdown, no borders. */
.tv-interval-row { display: flex; align-items: center; gap: 2px; margin-bottom: 0.5rem; flex-wrap: wrap; }
.tv-interval-btn {
    padding: 4px 9px; border-radius: 6px; font-size: 0.74rem; font-weight: 600;
    color: var(--muted); text-decoration: none;
}
.tv-interval-btn:hover { text-decoration: none; background: var(--panel); color: var(--text-bright); }
.tv-interval-btn.active { background: var(--panel); color: var(--text-bright); }

.watch-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.watch-list-tall { max-height: 520px; }
.watch-row { display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-radius: 6px; }
.watch-row:hover { background: var(--hover-bg); }
.watch-row.dragging { opacity: 0.5; background: var(--hover-bg); }
.drag-handle {
    cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
    color: var(--muted); font-size: 0.95rem; padding: 0 2px; flex-shrink: 0; line-height: 1;
}
.drag-handle:active { cursor: grabbing; }
.watch-link { display: flex; align-items: center; flex: 1; gap: 6px; min-width: 0; }
.watch-link:hover { text-decoration: none; }
.watch-sym {
    display: flex; flex-direction: column; gap: 0; width: 92px; flex-shrink: 0; min-width: 0;
}
.watch-sym-code { font-size: 0.78rem; font-weight: 700; color: var(--text-bright); }
.watch-sym-name {
    font-size: 0.6rem; color: var(--muted); white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 100%;
}
.watch-price-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 0; flex: 1; min-width: 0; }
.watch-price { font-size: 0.75rem; color: var(--text); text-align: right; }
.watch-ext { font-size: 0.6rem; color: var(--muted); text-align: right; white-space: nowrap; }
.watch-chg { font-size: 0.72rem; width: 64px; text-align: right; flex-shrink: 0; }
.watch-empty { font-size: 0.72rem; color: var(--muted); padding: 0.4rem 0; }
.watch-divider {
    font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
    font-weight: 700; padding: 6px 2px 4px; margin-top: 2px;
}
.watch-divider:first-child { padding-top: 0; margin-top: 0; }
.watch-list-header {
    display: flex; align-items: center; gap: 6px; padding: 0 2px 6px;
    font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
    border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.watch-list-header .wh-star { width: 16px; flex-shrink: 0; }
.watch-list-header .wh-sym { width: 92px; flex-shrink: 0; }
.watch-list-header .wh-price { flex: 1; text-align: right; }
.watch-list-header .wh-chg { width: 64px; text-align: right; }

.stock-view-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }

@media (min-width: 901px) {
    .stock-view-sticky {
        position: sticky; top: 0; z-index: 15; background: var(--bg);
        padding-top: 0.8rem; margin-top: -0.8rem;
        border-bottom: 1px solid var(--border); margin-bottom: 1rem;
    }
    .sidebar-panel { max-height: calc(100vh - 2rem); overflow-y: auto; }
}

.ext-hours { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.kpi-strip { display: flex; gap: 1.6rem; flex-wrap: wrap; padding: 0.8rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: 0.8rem; }
.kpi-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 3px; }
.kpi-value { font-size: 0.85rem; font-weight: 600; color: var(--text-bright); }
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
/* Read + Cause grouped so they wrap onto a new line together (as a pair) instead
   of each landing on its own separate line once the strip runs out of width. */
/* flex-wrap: nowrap (not wrap) — Read and Cause must always stay side by side as
   a pair; kpi-cause's max-width below is what actually gives them room to fit,
   not letting this wrap internally (that just put them back on separate lines). */
.kpi-cell-pair { display: flex; gap: 1rem; flex-wrap: nowrap; align-items: flex-start; }
.kpi-cause { max-width: 200px; min-width: 0; }
.kpi-cause .kpi-value { font-weight: 400; }
@media (min-width: 901px) {
    .kpi-cause { max-width: 340px; }
}

.snapshot-card { padding: 1.4rem 1.6rem; }
.snapshot-header { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem; }
.snapshot-badge {
    width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 0.85rem; flex-shrink: 0;
}
.snapshot-badge.up { background: var(--green); }
.snapshot-badge.down { background: var(--red); }
.snapshot-title { font-size: 1.15rem; font-weight: 700; color: var(--text-bright); }
.snapshot-ticker {
    font-size: 0.68rem; color: var(--muted); background: var(--panel); border: 1px solid var(--border);
    border-radius: 6px; padding: 1px 7px; margin-left: 6px; vertical-align: middle;
}
.snapshot-price { font-size: 2.4rem; font-weight: 800; color: var(--text-bright); line-height: 1.1; }
.snapshot-point { font-size: 0.6rem; color: var(--muted); font-weight: 600; margin-left: 4px; }
.snapshot-change { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
#snapshotChart { width: 100%; touch-action: none; }

.mobile-only-tab { display: none; }

@media (max-width: 900px) {
    .tv-layout { flex-direction: column; }
    .tv-sidebar { display: none; width: 100%; }
    .sidebar-panel { position: static; }
    .mobile-only-tab { display: inline-block; }

    /* Admin/Logout move from the plain inline .user-menu (desktop) into the
       "More" dropdown (.nav-more-wrap) — no room to show them plainly on mobile.
       (Actual display:none for .user-menu lives after its base rule further down,
       so it wins the cascade at equal specificity — see note there.) */
    .nav-more-wrap { display: inline-flex; align-items: center; }
    /* Language selector moves into the "More" dropdown too, same reasoning. Direct-
       child selector so this doesn't also hide the copy nested inside
       .nav-more-dropdown (.nav-more-lang), which reuses the .lang-toggle class
       for its link styling. No ordering gotcha here (unlike .user-menu) —
       .lang-toggle itself has no competing base `display` rule elsewhere. */
    .site-nav > .lang-toggle { display: none; }

    /* Only the top nav bar stays fixed on mobile — the search box, favorites,
       and All Stocks list all scroll away together beneath it, normally. */
    .tv-sidebar.mobile-open .sidebar-search-sticky { position: static; }

    .tv-sidebar.mobile-open {
        /* top is set inline by JS (favorites.js) to the nav's actual live height;
           this 56px is only a fallback in case JS hasn't run yet. */
        display: block; position: fixed; top: 56px; right: 0; bottom: 0; left: 0; z-index: 200;
        width: 100%; max-width: 100vw; box-sizing: border-box;
        background: var(--bg); overflow-y: auto; overflow-x: hidden; padding: 1rem;
    }
    .tv-sidebar.mobile-open .sidebar-panel { margin-bottom: 2rem; }

    /* iOS Safari auto-zooms the whole page on focus of any text input styled
       under 16px — this is what looked like "the window getting bigger" when
       tapping search. 16px is the minimum that avoids it. Matches (and thus
       overrides) .sidebar-panel input[type="text"]'s specificity, which was
       silently winning over a plain `input[type="text"]` rule here before. */
    input[type="text"], input[type="number"], input[type="email"], select,
    .sidebar-panel input[type="text"], .search-box input[type="text"] {
        font-size: 16px;
    }
}

.col-toggle-btn { display: none; }

@media (max-width: 600px) {
    body { padding: 0 1rem 2rem; }
    .panel, .chart-wrap, .sidebar-panel { padding: 1rem; }
    .header { padding: 1.2rem 0 0.8rem; }
    .header h1 { font-size: 1.4rem; }
    .snapshot-card { padding: 1.1rem 1.2rem; }
    .snapshot-price { font-size: 1.9rem; }
    .snapshot-title { font-size: 1rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem; }
    .movers-watch-grid { gap: 1.2rem; }
    .controls input { min-width: 0; }
    .pulse-metrics { gap: 1rem; }
    .toolbar-row { gap: 0.6rem; }
    .watch-sym { width: 84px; }
    .watch-list-header .wh-sym { width: 84px; }

    .movers-watch-grid table .collapsible-col { display: none; }
    .movers-watch-grid table.show-details .collapsible-col { display: table-cell; }
    .col-toggle-btn { display: inline-block; }
}

.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 2rem 1.8rem; text-align: center;
}
.auth-card h1 { font-size: 1.3rem; margin: 0 0 0.6rem; color: var(--text-bright); }
.google-btn {
    display: inline-flex; align-items: center; gap: 10px; justify-content: center;
    width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 16px; font-size: 0.88rem; font-weight: 600; color: var(--text-bright);
    text-decoration: none; box-sizing: border-box;
}
.google-btn:hover { text-decoration: none; border-color: var(--accent); }

.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu img { width: 24px; height: 24px; border-radius: 50%; }
.user-menu .site-nav-link { font-size: 0.8rem; }
/* Placed after the base rule above (same specificity) so it actually wins on
   mobile — Admin/Logout live in the "More" dropdown there instead (see .nav-more-wrap). */
@media (max-width: 900px) {
    .user-menu { display: none; }
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.admin-table th { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.admin-badge { font-size: 0.68rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.admin-badge.pending { background: var(--amber-bg); color: var(--amber-text); }
.admin-badge.approved { background: var(--green-bg); color: var(--green); }
.admin-badge.rejected { background: var(--red-bg); color: var(--red); }
.admin-actions { display: flex; gap: 6px; }
.admin-actions button { font-size: 0.72rem; padding: 4px 10px; }

.admin-add-range-form { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.admin-add-range-form input[type="text"], .admin-add-range-form select {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    font-family: inherit; font-size: 0.85rem; border-radius: 6px; padding: 8px 10px;
}
.admin-add-range-form input[type="text"] { width: 150px; }
