/* =========================================================
   StockSage — V3 Design System (Phase A)
   Mono numerics: JetBrains Mono / IBM Plex Mono / ui-monospace
   Base palette: dark charcoal #1a1d23, cyan accent #22d3ee
========================================================= */

/* ─── CSS CUSTOM PROPERTIES ─────────────────────────────────── */
:root {
    --bg:         #1a1d23;
    --bg1:        #16181d;
    --bg2:        #21242d;
    --bg3:        #1e2230;
    --border:     #1e2230;
    --border2:    #2a2f3d;
    --border3:    #3d4455;
    --text:       #94a3b8;
    --text-bright:#e2e8f0;
    --text-muted: #475569;
    --text-dim:   #334155;
    --accent:     #22d3ee;
    --green:      #4ade80;
    --green2:     #86efac;
    --red:        #f87171;
    --red2:       #ef4444;
    --amber:      #fbbf24;
    --orange:     #fb923c;
    --blue:       #60a5fa;
    --purple:     #a78bfa;
    --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;

    /* action accent colors */
    --action-strong-sell-primary: #ef4444;
    --action-strong-sell-bg:      rgba(153,27,27,0.15);
    --action-sell-primary:        #f87171;
    --action-sell-bg:             rgba(153,27,27,0.10);
    --action-hold-primary:        #60a5fa;
    --action-hold-bg:             rgba(30,58,95,0.15);
    --action-wait-primary:        #fbbf24;
    --action-wait-bg:             rgba(113,63,18,0.12);
    --action-take-profits-primary:#fb923c;
    --action-take-profits-bg:     rgba(146,64,14,0.10);
    --action-buy-primary:         #86efac;
    --action-buy-bg:              rgba(22,101,52,0.10);
    --action-strong-buy-primary:  #4ade80;
    --action-strong-buy-bg:       rgba(22,101,52,0.15);
}

/* ─── LIGHT THEME VARIABLES ─────────────────────────────────── */
/* Warm stone palette — no blue/slate tint. */
[data-theme="light"] {
    --bg:         #f7f5f2;
    --bg1:        #edeae5;
    --bg2:        #ffffff;
    --bg3:        #faf8f6;
    --border:     #e4dfd8;
    --border2:    #d0c9c0;
    --border3:    #a89f95;
    --text:       #5a5248;
    --text-bright:#1c1917;
    --text-muted: #78706a;
    --text-dim:   #a89f95;
    --accent:     #2563eb;
    --green:      #16a34a;
    --green2:     #22c55e;
    --red:        #dc2626;
    --red2:       #b91c1c;
    --amber:      #d97706;
    --orange:     #ea580c;
    --blue:       #2563eb;
    --purple:     #7c3aed;

    --action-strong-sell-primary: #dc2626;
    --action-strong-sell-bg:      rgba(220,38,38,0.08);
    --action-sell-primary:        #ef4444;
    --action-sell-bg:             rgba(220,38,38,0.06);
    --action-hold-primary:        #2563eb;
    --action-hold-bg:             rgba(37,99,235,0.08);
    --action-wait-primary:        #d97706;
    --action-wait-bg:             rgba(217,119,6,0.08);
    --action-take-profits-primary:#ea580c;
    --action-take-profits-bg:     rgba(234,88,12,0.06);
    --action-buy-primary:         #16a34a;
    --action-buy-bg:              rgba(22,163,74,0.08);
    --action-strong-buy-primary:  #15803d;
    --action-strong-buy-bg:       rgba(21,128,61,0.10);
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100%;
    overflow: hidden;
}
body {
    display: flex;
    flex-direction: column;
}
#dashboard-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border3); }

.mono { font-family: var(--mono); }
.positive { color: var(--green); }
.negative { color: var(--red); }
.up       { color: var(--green); }
.dn       { color: var(--red); }
.total    { color: var(--text-bright); }

/* ─── TOP NAV ────────────────────────────────────────────────── */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 46px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo {
    width: 26px; height: 26px;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #fff;
}
.nav-brand-name { font-size: 15px; font-weight: 600; color: var(--text-bright); }
.nav-brand-name span { color: var(--accent); }
.nav-divider { width: 1px; height: 18px; background: var(--border2); margin: 0 12px; }
.nav-tag {
    font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--accent);
    background: rgba(34,211,238,0.08);
    border: 1px solid rgba(34,211,238,0.2);
    padding: 2px 7px; border-radius: 3px;
}
.nav-center { display: flex; align-items: center; gap: 3px; }
.nav-tab {
    padding: 6px 14px; border-radius: 5px;
    font-size: 12px; font-weight: 500; color: var(--text-muted);
    cursor: pointer; border: none; background: none; font-family: inherit;
    transition: all 0.15s;
}
.nav-tab:hover { color: var(--text); background: var(--bg3); }
.nav-tab.active { color: var(--accent); background: rgba(34,211,238,0.08); }
.nav-tab.disabled { color: var(--text-dim); cursor: not-allowed; }

/* ─── MAIN TAB PANELS ────────────────────────────────────────── */
.main-tab-panel { display: none; }
.main-tab-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--green); }
.status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px rgba(74,222,128,0.5);
    animation: pulse-dot 2s ease infinite;
}
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
.nav-icon-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 10px; border-radius: 5px;
    font-size: 11px; font-weight: 500;
    color: var(--text-muted); border: 1px solid var(--border2);
    background: none; cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.nav-icon-btn:hover { color: var(--text); border-color: var(--border3); background: var(--bg2); }

/* ─── TICKER STRIP (V1 borrow) ───────────────────────────────── */
.ticker-strip {
    display: flex;
    align-items: center;
    background: var(--bg1);
    border-bottom: 2px solid var(--accent);
    height: 30px;
    flex-shrink: 0;
    overflow: hidden;
}
.ticker-live-label {
    background: var(--accent);
    color: var(--bg);
    font-family: var(--mono);
    font-size: 9px; font-weight: 800; letter-spacing: 1.5px;
    padding: 0 10px;
    align-self: stretch;
    display: flex; align-items: center;
    flex-shrink: 0;
}
.ticker-inner {
    display: flex; gap: 0; align-items: center;
    overflow: hidden; flex: 1; padding: 0 8px; flex-wrap: wrap;
}
.tick-item {
    display: flex; align-items: center; gap: 5px;
    padding: 0 10px;
    border-right: 1px solid var(--border);
    white-space: nowrap; font-size: 11px;
}
.tick-sym { color: var(--text-bright); font-weight: 700; }
.tick-price { color: var(--text); }
.tick-chg { font-size: 10px; }
.tick-chg.up { color: var(--green); }
.tick-chg.dn { color: var(--red); }

/* ─── STATS BAR ──────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    gap: 2px;
    flex-shrink: 0;
    height: 64px;
    overflow-x: auto;
}
.stat-card {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 0 20px;
    min-width: 80px;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.15s;
    border-bottom: 2px solid transparent;
    position: relative;
}
.stat-card:hover { background: rgba(255,255,255,0.03); }
.stat-card.active { border-bottom-color: currentColor; }
.stat-value {
    font-size: 20px; font-weight: 700; line-height: 1; margin-bottom: 3px;
}
.stat-label {
    font-size: 9px; font-weight: 600; letter-spacing: 0.07em;
    text-transform: uppercase; color: var(--text-muted);
    white-space: nowrap;
}
.stats-sep { width: 1px; background: var(--border); margin: 12px 4px; flex-shrink: 0; }

/* action-color mapping for stat tiles */
.stat-card.strong-sell .stat-value { color: var(--action-strong-sell-primary); }
.stat-card.strong-sell { background: var(--action-strong-sell-bg); }
.stat-card.sell .stat-value        { color: var(--action-sell-primary); }
.stat-card.sell                    { background: var(--action-sell-bg); }
.stat-card.strong-buy .stat-value  { color: var(--action-strong-buy-primary); }
.stat-card.strong-buy              { background: var(--action-strong-buy-bg); }
.stat-card.buy .stat-value         { color: var(--action-buy-primary); }
.stat-card.buy                     { background: var(--action-buy-bg); }
.stat-card.take-profits .stat-value{ color: var(--action-take-profits-primary); }
.stat-card.take-profits            { background: var(--action-take-profits-bg); }
.stat-card.wait .stat-value        { color: var(--action-wait-primary); }
.stat-card.wait                    { background: var(--action-wait-bg); }
.stat-card.hold .stat-value        { color: var(--action-hold-primary); }
.stat-card.hold                    { background: var(--action-hold-bg); }

/* ─── MARKET CONTEXT (sector + SPY) in stats bar ────────────── */
.stats-market-ctx {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    flex-shrink: 0;
}
.stats-spy {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    min-width: 60px;
}
.stats-spy-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.stats-spy-value {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}
.stats-sectors {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 340px;
}
.stats-sector-chip {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--bg2);
    border: 1px solid var(--border);
    font-size: 9px;
    line-height: 1.2;
}
.stats-sector-name {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 8px;
}
.stats-sector-val {
    font-weight: 700;
    font-size: 9px;
}

/* ─── NYSE LIVE CLOCK (right of the sector chips) ───────────── */
.stats-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    min-width: 86px;
}
.stats-clock-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
}
.stats-clock.open  .stats-clock-label { color: var(--action-buy-primary); }
.stats-clock.open  { border-color: var(--action-buy-primary); }
.stats-clock-value {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stats-sector-val.up { color: var(--green); }
.stats-sector-val.dn { color: var(--red); }
.stats-spy-value.up { color: var(--green); }
.stats-spy-value.dn { color: var(--red); }

/* ─── MAIN LAYOUT ────────────────────────────────────────────── */
.main-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ─── LEFT SIDEBAR ───────────────────────────────────────────── */
.sidebar {
    width: 480px;
    flex-shrink: 0;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.sidebar-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}
.sidebar-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}
.sidebar-col {
    display: flex; flex-direction: column;
    overflow-y: auto;
    padding: 10px 0 8px;
    border-right: 1px solid var(--border);
}
.sidebar-col:last-child { border-right: none; }
/* monitoring-tabs sits at the top of the watchlist column — remove the divider meant for single-column layout */
.sidebar-col .monitoring-tabs { border-top: none; margin-top: 0; }
.sidebar-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px 4px;
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--accent);
}
.sidebar-timestamp { font-family: var(--mono); font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* ─── PORTFOLIO TILES ────────────────────────────────────────── */
.pos-tile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 16px;
    cursor: pointer;
    transition: background 0.12s;
    border-left: 2px solid transparent;
    position: relative;
}
.pos-tile:hover  { background: rgba(255,255,255,0.03); }
.pos-tile.selected {
    background: rgba(34,211,238,0.06);
    border-left-color: var(--accent);
}
.pos-tile.toxic-tile {
    background: rgba(153,27,27,0.07);
    border-left-color: rgba(248,113,113,0.35);
}
.pos-tile.toxic-tile:hover { background: rgba(153,27,27,0.12); }
.pos-tile.low-quality-tile { border-left-color: rgba(251,191,36,0.3); }

.pos-tile-left { flex: 1; min-width: 0; }
.pos-tile-top-row { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.pos-symbol { font-size: 13px; font-weight: 700; color: var(--text-bright); }
.toxic-badge {
    font-size: 8px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--red); background: rgba(153,27,27,0.2);
    border: 1px solid rgba(248,113,113,0.3);
    padding: 1px 4px; border-radius: 3px;
}
.pos-tile-bot-row { display: flex; align-items: center; gap: 4px; }
.pos-avg  { font-size: 10px; color: var(--text-muted); }
.pos-chg  { font-size: 10px; }
.pos-chg.up { color: var(--green); }
.pos-chg.dn { color: var(--red); }

.pos-tile-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pos-price { font-size: 12px; font-weight: 700; color: var(--text-bright); }

/* Quality rings (small, in sidebar) */
.quality-ring { position: relative; width: 34px; height: 34px; }
.quality-ring svg { transform: rotate(-90deg); }
.ring-bg   { stroke: var(--border2); stroke-width: 2.5; fill: none; }
.ring-fill { stroke-width: 2.5; fill: none; stroke-linecap: round; transition: stroke-dashoffset 0.3s ease; }
.ring-fill.low   { stroke: var(--red); }
.ring-fill.mid   { stroke: var(--amber); }
.ring-fill.good  { stroke: var(--green); }
.ring-fill.great { stroke: var(--accent); }
.quality-num {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--mono); font-size: 11px; font-weight: 700;
}
.quality-num.low   { color: var(--red); }
.quality-num.mid   { color: var(--amber); }
.quality-num.good  { color: var(--green); }
.quality-num.great { color: var(--accent); }

/* info icon — flows in .pos-tile-top-row flex; margin-left:auto pushes it to the right */
.pos-info-icon {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: rgba(34,211,238,0.1);
    border: 1px solid rgba(34,211,238,0.25);
    color: var(--accent);
    font-size: 9px; font-weight: 700; font-style: normal;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.15s;
    flex-shrink: 0;
    margin-left: auto;
}
.pos-info-icon:hover { background: rgba(34,211,238,0.2); }
/* scanner-row icon: cancel the auto-margin so it leads the td-symbol flex cell */
.inline-info-icon { margin-left: 0; margin-right: 4px; }

.no-pos-compact {
    padding: 12px 16px; color: var(--text-dim); font-size: 11px;
}

/* ─── MONITORING TABS ────────────────────────────────────────── */
.monitoring-tabs {
    display: flex; gap: 2px;
    padding: 8px 12px 4px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.tab-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 10px; font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border2);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.tab-btn:hover { color: var(--text); border-color: var(--border3); }
.tab-btn.active-tab.healthy-tab { color: var(--green); border-color: rgba(74,222,128,0.35); background: rgba(74,222,128,0.06); }
.tab-btn.active-tab.toxic-tab   { color: var(--red);   border-color: rgba(248,113,113,0.35); background: rgba(153,27,27,0.06); }
.tab-count {
    font-family: var(--mono); font-size: 10px; font-weight: 700;
    min-width: 14px; text-align: center;
}
.position-grid-container { padding: 4px 8px; }

/* ─── CENTER ALERTS PANE ─────────────────────────────────────── */
.alerts-pane {
    flex: 1;
    display: flex; flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.alerts-section {
    flex: 1;
    display: flex; flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.section-header {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg1);
}
.section-title-text {
    font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--accent);
}
.alert-count-badge {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    background: var(--bg3);
    border: 1px solid var(--border2);
    padding: 1px 7px; border-radius: 10px;
}

/* ─── ALERT TYPE FILTER (Intraday / Daily) ───────────────────── */
.alert-type-filter {
    display: flex; gap: 4px;
    margin-left: auto;
}
.alert-type-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px;
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border2);
    border-radius: 3px;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.alert-type-btn:hover { color: var(--text); border-color: var(--border3); }
.alert-type-btn .alert-type-count { font-weight: 700; }
.alert-type-btn.active { color: var(--text-bright); border-color: var(--border3); background: var(--bg3); }
.alert-type-btn.type-intraday.active { color: var(--accent); background: rgba(34,211,238,0.08); border-color: rgba(34,211,238,0.25); }
.alert-type-btn.type-daily.active    { color: var(--blue);   background: rgba(96,165,250,0.08); border-color: rgba(96,165,250,0.25); }
.alerts-list { flex: 1; overflow-y: auto; }

/* ─── SCANNER TABLE (Daily Setup Alerts) ─────────────────────── */
.scanner-table {
    width: 100%;
    border-collapse: collapse;
}
.scanner-table thead th {
    position: sticky; top: 0;
    background: var(--bg);
    padding: 7px 14px;
    text-align: left;
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    z-index: 10;
}
.scanner-table thead th.th-right { text-align: right; }
.scanner-table tbody tr { border-bottom: 1px solid rgba(30,34,48,0.6); cursor: pointer; transition: background 0.1s; }
.scanner-table tbody tr:nth-child(even) { background: rgba(33,36,45,0.3); }
.scanner-table tbody tr:hover { background: rgba(34,211,238,0.04); }
.scanner-table tbody tr.alert-card td:first-child { border-left: 2px solid transparent; }
.scanner-table tbody tr.action-strong-buy   td:first-child { border-left-color: var(--action-strong-buy-primary); }
.scanner-table tbody tr.action-buy          td:first-child { border-left-color: var(--action-buy-primary); }
.scanner-table tbody tr.action-hold         td:first-child { border-left-color: var(--action-hold-primary); }
.scanner-table tbody tr.action-wait         td:first-child { border-left-color: var(--action-wait-primary); }
.scanner-table tbody tr.action-take-profits td:first-child { border-left-color: var(--action-take-profits-primary); }
.scanner-table tbody tr.action-sell         td:first-child { border-left-color: var(--action-sell-primary); }
.scanner-table tbody tr.action-strong-sell  td:first-child { border-left-color: var(--action-strong-sell-primary); }
.scanner-table td { padding: 8px 14px; vertical-align: middle; }
.scanner-table td.td-stub { color: var(--text-dim); font-size: 11px; }
.scanner-table td.td-time { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.scanner-table td.td-right { text-align: right; }
.td-symbol { display: flex; align-items: center; gap: 6px; }
.td-sym-name { font-size: 13px; font-weight: 700; color: var(--text-bright); }
.td-company { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.td-price { font-size: 12px; font-weight: 600; color: var(--text-bright); }

/* ─── ACTION BADGE ────────────────────────────────────────────── */
.action-badge {
    display: inline-flex; align-items: center;
    padding: 2px 7px; border-radius: 3px;
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase;
    border-left: 2px solid; background: rgba(0,0,0,0.2);
    white-space: nowrap;
}
.action-badge.action-strong-buy  { border-color: var(--action-strong-buy-primary); color: var(--action-strong-buy-primary); background: var(--action-strong-buy-bg); }
.action-badge.action-buy         { border-color: var(--action-buy-primary); color: var(--action-buy-primary); background: var(--action-buy-bg); }
.action-badge.action-hold        { border-color: var(--action-hold-primary); color: var(--action-hold-primary); background: var(--action-hold-bg); }
.action-badge.action-wait        { border-color: var(--action-wait-primary); color: var(--action-wait-primary); background: var(--action-wait-bg); }
.action-badge.action-take-profits{ border-color: var(--action-take-profits-primary); color: var(--action-take-profits-primary); background: var(--action-take-profits-bg); }
.action-badge.action-sell        { border-color: var(--action-sell-primary); color: var(--action-sell-primary); background: var(--action-sell-bg); }
.action-badge.action-strong-sell { border-color: var(--action-strong-sell-primary); color: var(--action-strong-sell-primary); background: var(--action-strong-sell-bg); }

/* ─── ALERT TYPE BADGE (Intraday / Daily) ────────────────────── */
.type-badge {
    display: inline-flex; align-items: center;
    padding: 2px 7px; border-radius: 3px;
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase;
    white-space: nowrap;
}
.type-badge.type-intraday { color: var(--accent); background: rgba(34,211,238,0.08); border: 1px solid rgba(34,211,238,0.25); }
.type-badge.type-daily    { color: var(--blue);   background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.25); }

/* ─── AI CONTROLS (inline in scanner rows / trading alert rows) ─ */
.td-ai-col { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.ai-provider-checklist { display: flex; gap: 4px; }
.provider-checkbox { display: flex; align-items: center; gap: 3px; cursor: pointer; }
.provider-checkbox input[type="checkbox"] { width: 11px; height: 11px; cursor: pointer; accent-color: var(--accent); }
.provider-label { font-size: 9px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; }
.ai-analyze-btn {
    background: rgba(34,211,238,0.07);
    border: 1px solid rgba(34,211,238,0.25);
    color: var(--accent);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 6px;
    transition: all 0.15s;
    line-height: 1;
}
.ai-analyze-btn:hover { background: rgba(34,211,238,0.14); border-color: rgba(34,211,238,0.5); }

/* ─── NO ALERTS / EMPTY STATES ──────────────────────────────── */
.no-alerts { padding: 24px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* ─── STATS FOOTER (V1 borrow) ───────────────────────────────── */
.stats-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg1);
    border-top: 1px solid var(--border);
    padding: 0 20px;
    height: 36px;
    flex-shrink: 0;
}
.footer-account { display: flex; align-items: center; gap: 4px; }
.footer-account-item { display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.footer-label {
    font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted);
}
.footer-value { font-size: 12px; font-weight: 700; }
.footer-value.positive { color: var(--green); }
.footer-value.negative { color: var(--red); }
.footer-value.total    { color: var(--text-bright); }
.footer-sep { width: 1px; height: 14px; background: var(--border2); }
.footer-timestamp { font-size: 10px; color: var(--text-muted); }

/* ─── V3 MODALS ──────────────────────────────────────────────── */
.v3-modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    align-items: center; justify-content: center;
}
.v3-modal-content {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 10px;
    width: 90%; max-width: 680px;
    max-height: 80vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.v3-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.v3-modal-title { font-size: 14px; font-weight: 600; color: var(--text-bright); }
.v3-modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.v3-icon-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border2);
    color: var(--text-muted);
    width: 28px; height: 28px;
    border-radius: 5px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.v3-icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.v3-close-btn {
    background: none;
    border: 1px solid var(--border2);
    color: var(--text-muted);
    width: 28px; height: 28px;
    border-radius: 5px; font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.v3-close-btn:hover { color: var(--text-bright); border-color: var(--border3); background: var(--bg3); }

/* ─── DAILY DETAILS MODAL ────────────────────────────────────── */
.daily-modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    overflow-y: auto;
    padding: 20px;
}
.daily-modal-content {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
body.daily-modal-open { overflow: hidden; }
body.modal-open       { overflow: hidden; }

/* ─── ALERT DETAIL DRAWER ────────────────────────────────────── */
.alert-detail-drawer {
    position: fixed;
    top: 0; right: 0;
    width: 320px;
    height: 100vh;
    background: var(--bg2);
    border-left: 1px solid var(--border2);
    z-index: 160;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: -10px 0 40px rgba(0,0,0,0.4);
}
.alert-detail-drawer.visible { transform: translateX(0); }
body.alert-drawer-open { overflow: hidden; }

.add-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg1);
    flex-shrink: 0;
}
.add-title-group { flex: 1; min-width: 0; }
.add-symbol-line { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.add-symbol { font-size: 18px; font-weight: 800; color: var(--text-bright); }
.add-action-badge { font-size: 9px; }
.add-company { font-size: 11px; color: var(--text-muted); }

.add-body { flex: 1; overflow-y: auto; }
.add-section {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.add-section-title {
    font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--accent);
    margin-bottom: 10px;
}
.add-price-row { display: flex; gap: 16px; }
.add-price-item { display: flex; flex-direction: column; gap: 2px; }
.add-price-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.add-price-value { font-size: 16px; font-weight: 700; color: var(--text-bright); }
.add-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-detail-full { grid-column: 1 / -1; }
.add-detail-item { display: flex; flex-direction: column; gap: 2px; }
.add-detail-label { font-size: 9px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.add-detail-value { font-size: 11px; color: var(--text-bright); }
.add-message { font-size: 11px; line-height: 1.6; color: var(--text); }

/* Alert message segment cards */
.add-message-segments { display: flex; flex-direction: column; gap: 4px; }
.add-msg-seg {
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 11px; line-height: 1.5;
    border-left: 2px solid transparent;
}
.add-msg-seg-default  { background: rgba(255,255,255,0.03); border-left-color: var(--border2); color: var(--text-bright); }
.add-msg-seg-critical { background: rgba(239,68,68,0.12);   border-left-color: var(--red);   color: var(--red);    font-weight: 700; }
.add-msg-seg-warning  { background: rgba(251,191,36,0.08);  border-left-color: var(--amber); color: var(--amber); }
.add-msg-seg-volume   { background: rgba(34,211,238,0.06);  border-left-color: rgba(34,211,238,0.4); color: var(--text); font-family: var(--mono); font-size: 10.5px; }
.add-msg-seg-score    { background: rgba(255,255,255,0.03); border-left-color: var(--border3); color: var(--text-muted); font-family: var(--mono); font-size: 10.5px; }
.add-msg-seg-candle   { background: rgba(255,255,255,0.03); border-left-color: var(--border3); color: var(--text); font-family: var(--mono); font-size: 10.5px; }
.add-msg-seg-levels   { background: transparent; border-left-color: var(--border); color: var(--text-muted); font-family: var(--mono); font-size: 10px; }
.add-msg-seg-gate     { background: rgba(251,191,36,0.06);  border-left-color: rgba(251,191,36,0.3); color: var(--amber); font-family: var(--mono); font-size: 10.5px; }
.add-msg-seg-positive { background: rgba(74,222,128,0.08);  border-left-color: var(--green); color: var(--green); font-weight: 600; }

.add-ai-controls { display: flex; flex-direction: column; gap: 10px; }
.add-provider-list { display: flex; gap: 12px; }
.add-provider-check { display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: 11px; color: var(--text); }
.add-provider-check input { accent-color: var(--accent); }
.add-analyze-btn {
    background: rgba(34,211,238,0.08);
    border: 1px solid rgba(34,211,238,0.3);
    color: var(--accent);
    border-radius: 5px;
    padding: 7px 14px;
    font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
    font-family: inherit;
    align-self: flex-start;
}
.add-analyze-btn:hover { background: rgba(34,211,238,0.14); border-color: rgba(34,211,238,0.6); }

/* ─── TOASTS ─────────────────────────────────────────────────── */
.v3-toast {
    position: fixed;
    bottom: 32px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #10b981;
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600; font-size: 11px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
    z-index: 300; pointer-events: none;
}
.v3-toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.v3-toast.v3-toast-blue { background: #3b82f6; }

/* ─── LOADING ─────────────────────────────────────────────────── */
.v3-loading {
    text-align: center; padding: 32px;
    color: var(--text-muted); font-size: 12px;
}

/* ─── AI MODAL BODY CARDS ────────────────────────────────────── */
.analysis-card {
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
}
.analysis-header {
    padding: 8px 14px;
    font-size: 11px; font-weight: 700; color: white;
    display: flex; justify-content: space-between;
}
.analysis-body {
    padding: 12px 14px;
    font-size: 11px; line-height: 1.7; color: var(--text);
}
.loading-spinner {
    text-align: center; padding: 32px;
    color: var(--text-muted); font-size: 12px;
}
.error-message { color: var(--red); font-size: 12px; padding: 12px; }

/* ─── MSG SEGMENTS (formatMessage) ───────────────────────────── */
.msg-segment { display: inline; font-size: 11px; }
.msg-primary { font-weight: 600; color: var(--text-bright); }
.msg-rr      { color: var(--amber); font-family: var(--mono); }
.msg-vol     { color: var(--blue); }
.msg-sector  { color: var(--purple); }
.msg-15m     { color: var(--green); }

/* ─── THEME TOGGLE BUTTON ────────────────────────────────────── */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    padding: 0;
    border-radius: 5px;
    font-size: 14px;
    color: var(--text-muted);
    border: 1px solid var(--border2);
    background: none;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border3); background: var(--bg2); }

/* ─── LIGHT THEME OVERRIDES ──────────────────────────────────── */
/* These override hardcoded rgba values that were tuned for dark backgrounds. */

/* Nav accent tag */
[data-theme="light"] .nav-tag {
    background: rgba(37,99,235,0.09);
    border-color: rgba(37,99,235,0.22);
}
/* Nav active tab — base CSS hardcodes a cyan rgba */
[data-theme="light"] .nav-tab.active { background: rgba(37,99,235,0.08); }
/* Ticker live label — text must stay white on blue strip */
[data-theme="light"] .ticker-live-label { color: #ffffff; }
/* Nav logo — warmer blue gradient */
[data-theme="light"] .nav-logo { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
/* Hover / selection states need contrast on light surfaces */
[data-theme="light"] .pos-tile:hover              { background: rgba(0,0,0,0.04); }
[data-theme="light"] .pos-tile.selected           { background: rgba(37,99,235,0.07); }
[data-theme="light"] .pos-tile.toxic-tile         { background: rgba(220,38,38,0.05); }
[data-theme="light"] .pos-tile.toxic-tile:hover   { background: rgba(220,38,38,0.09); }
[data-theme="light"] .stat-card:hover             { background: rgba(0,0,0,0.04); }
[data-theme="light"] .stats-spy               { background: rgba(0,0,0,0.03); border-color: var(--border2); }
[data-theme="light"] .stats-sector-chip       { background: rgba(0,0,0,0.03); border-color: var(--border); }
[data-theme="light"] .stats-spy-value.up      { color: #16a34a; }
[data-theme="light"] .stats-spy-value.dn      { color: #dc2626; }
[data-theme="light"] .stats-sector-val.up     { color: #16a34a; }
[data-theme="light"] .stats-sector-val.dn     { color: #dc2626; }
[data-theme="light"] .alert-card.mini:hover       { background: rgba(37,99,235,0.04); }
[data-theme="light"] .scanner-table tbody tr:hover{ background: rgba(37,99,235,0.05); }
/* Scanner rows — dark rgba border/stripe is invisible on light */
[data-theme="light"] .scanner-table tbody tr              { border-bottom-color: rgba(0,0,0,0.07); }
[data-theme="light"] .scanner-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.022); }
/* Message segment cards that use rgba-white (invisible on white) */
[data-theme="light"] .add-msg-seg-default { background: rgba(0,0,0,0.03); border-left-color: var(--border2); }
[data-theme="light"] .add-msg-seg-score   { background: rgba(0,0,0,0.03); }
[data-theme="light"] .add-msg-seg-candle  { background: rgba(0,0,0,0.03); }
/* Icon buttons */
[data-theme="light"] .v3-icon-btn       { background: rgba(0,0,0,0.05); }
[data-theme="light"] .v3-icon-btn:hover { background: rgba(0,0,0,0.10); }
/* Active monitoring tabs */
[data-theme="light"] .tab-btn.active-tab.healthy-tab { background: rgba(22,163,74,0.10); }
[data-theme="light"] .tab-btn.active-tab.toxic-tab   { background: rgba(220,38,38,0.10); }
/* AI buttons */
[data-theme="light"] .ai-analyze-btn       { background: rgba(37,99,235,0.08); border-color: rgba(37,99,235,0.28); }
[data-theme="light"] .ai-analyze-btn:hover { background: rgba(37,99,235,0.14); border-color: rgba(37,99,235,0.48); }
[data-theme="light"] .add-analyze-btn       { background: rgba(37,99,235,0.08); border-color: rgba(37,99,235,0.28); }
[data-theme="light"] .add-analyze-btn:hover { background: rgba(37,99,235,0.14); border-color: rgba(37,99,235,0.55); }
/* Info icon */
[data-theme="light"] .pos-info-icon       { background: rgba(37,99,235,0.09); border-color: rgba(37,99,235,0.24); }
[data-theme="light"] .pos-info-icon:hover { background: rgba(37,99,235,0.18); }
/* Status dot glow */
[data-theme="light"] .status-dot { box-shadow: 0 0 6px rgba(22,163,74,0.5); }
/* Shadows — lighter on light backgrounds */
[data-theme="light"] .alert-detail-drawer  { box-shadow: -10px 0 30px rgba(0,0,0,0.10); }
[data-theme="light"] .v3-modal-content     { box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
[data-theme="light"] .daily-modal-content  { box-shadow: 0 20px 60px rgba(0,0,0,0.15); }

/* ─── Pre-market readiness banner ─────────────────────────────────────── */
.readiness-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    background: var(--action-wait-bg);
    color: var(--amber);
    border-bottom: 1px solid var(--border2);
}
.readiness-banner.is-running    { background: var(--action-hold-bg); color: var(--blue); }
.readiness-banner.is-incomplete { background: var(--action-sell-bg); color: var(--red); }
.readiness-icon   { font-size: 14px; line-height: 1; }
.readiness-detail { color: var(--text); font-weight: 400; }

/* ─── Market regime banner (SPY+VIX shadow signal, display-only) ───────── */
.regime-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    padding: 8px 18px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    background: var(--action-wait-bg);
    border-bottom: 1px solid var(--border2);
}
.regime-label   { font-weight: 700; letter-spacing: 0.03em; }
.regime-since   { color: var(--text); font-weight: 400; }
.regime-asof    { color: var(--text-muted); font-weight: 400; }
.regime-inputs  { color: var(--text); font-weight: 400; font-size: 12px; }
.regime-caption { color: var(--text-muted); font-weight: 400; font-size: 11px; font-style: italic; margin-left: auto; }
/* Color cue per regime — green RISK_ON, amber FRAGILE, orange SLOW_BLEED, red RISK_OFF */
.regime-banner.regime-risk-on    { background: var(--action-buy-bg);  }
.regime-banner.regime-risk-on    .regime-label { color: var(--green); }
.regime-banner.regime-fragile    { background: var(--action-wait-bg); }
.regime-banner.regime-fragile    .regime-label { color: var(--amber); }
.regime-banner.regime-slow-bleed { background: var(--action-wait-bg); }
.regime-banner.regime-slow-bleed .regime-label { color: var(--orange); }
.regime-banner.regime-risk-off   { background: var(--action-sell-bg); }
.regime-banner.regime-risk-off   .regime-label { color: var(--red); }
.regime-banner.regime-unknown    .regime-label { color: var(--text); }
