/* ============================================================================
 * light-theme.css — Editorial light mode for Quantum Trading Bot
 * ---------------------------------------------------------------------------
 * MUST load AFTER dashboard.css, side_nav.css, settings.css, premium.css.
 * Activated by  <html class="light-theme">  set BEFORE first paint by the
 * tiny inline script in _INJECTED_HEAD_TAGS (dashboard_app.py).
 *
 * Design intent (per CLAUDE.md / open-codesign reference):
 *   - warm off-white canvas (#f7f6f1) — never pure #fff
 *   - near-black text (#0d1117) — never pure #000
 *   - DARKENED accent (#047857 / #065f46 press) — WCAG AA on light
 *   - subtle 0,0,0 borders + soft warm shadows — no harsh boxes
 *   - editorial restraint — keep dark-mode's bold rhythm
 *
 * Dark mode is UNTOUCHED. This file only emits CSS inside `.light-theme`.
 * ========================================================================= */


/* ===== 1. CORE VARIABLE REMAP (overrides every dark token set elsewhere) */

html.light-theme {
    color-scheme: light;

    /* dashboard.css tokens */
    --bg: #f7f6f1;
    --card-bg: rgba(255, 255, 255, 0.78);
    --text: #0d1117;
    --accent: #047857;
    --accent-glow: rgba(4, 120, 87, 0.22);
    --danger: #b91c1c;
    --danger-glow: rgba(185, 28, 28, 0.20);
    --warn: #b45309;
    --dim: #6b7280;

    /* side_nav.css tokens */
    --qt-sn-bg-start: #ffffff;
    --qt-sn-bg-end: #f3f1ea;
    --qt-sn-edge: rgba(4, 120, 87, 0.18);
    --qt-sn-inset: rgba(4, 120, 87, 0.04);
    --qt-sn-text: #2a2f3a;
    --qt-sn-muted: #6b7280;
    --qt-sn-accent: #047857;
    --qt-sn-accent-soft: rgba(4, 120, 87, 0.08);
    --qt-sn-accent-glow: rgba(4, 120, 87, 0.35);
    --qt-sn-hover: rgba(0, 0, 0, 0.035);

    /* premium.css tokens */
    --bg-canvas: #f7f6f1;
    --bg-elevated: #ffffff;
    --bg-elevated-2: #fbfaf5;
    --bg-inset: #f0eee7;
    --bg-tinted: rgba(0, 0, 0, 0.025);
    --bg-glass: rgba(255, 255, 255, 0.82);
    --border-subtle: rgba(15, 17, 25, 0.06);
    --border-default: rgba(15, 17, 25, 0.10);
    --border-strong: rgba(15, 17, 25, 0.18);
    --border-accent: rgba(4, 120, 87, 0.40);
    --border-danger: rgba(185, 28, 28, 0.35);
    --text-primary: #0d1117;
    --text-secondary: #3d434f;
    --text-tertiary: #5d6470;
    --text-quaternary: #828995;
    --text-disabled: #b6bcc6;
    --accent-primary: #047857;
    --accent-press: #007a4a;
    --accent-soft: rgba(4, 120, 87, 0.10);
    --accent-haze: rgba(4, 120, 87, 0.03);
    --success: #047857;
    --success-soft: rgba(4, 120, 87, 0.10);
    --danger-fg: #b91c1c;
    --danger-soft: rgba(185, 28, 28, 0.08);
    --warning-fg: #b45309;
    --warning-soft: rgba(178, 92, 0, 0.10);
    --info-fg: #1f6feb;
    --info-soft: rgba(31, 111, 235, 0.08);
    --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.7) inset,
                   0 12px 28px -18px rgba(15, 17, 25, 0.18),
                   0 2px 6px -3px rgba(15, 17, 25, 0.08);
    --shadow-hover: 0 1px 0 0 rgba(255, 255, 255, 0.8) inset,
                    0 24px 48px -22px rgba(15, 17, 25, 0.28),
                    0 4px 10px -4px rgba(15, 17, 25, 0.14);
    --glow-accent: 0 0 0 1px rgba(4, 120, 87, 0.20),
                   0 8px 24px -10px rgba(4, 120, 87, 0.30);

    /* settings.css scoped tokens — re-stated globally since #view-settings owns them */
    --st-page-bg: #f7f6f1;
    --st-card-bg: #ffffff;
    --st-card-bg-2: #fbfaf5;
    --st-border: #e3e1d8;
    --st-border-strong: #c8c6bb;
    --st-text: #0d1117;
    --st-text-muted: #4b5159;
    --st-text-faint: #767c87;
    --st-danger: #b91c1c;
    --st-warn: #b45309;
    --st-ok: #047857;
}

html.light-theme #view-settings {
    --st-page-bg: #f7f6f1;
    --st-card-bg: #ffffff;
    --st-card-bg-2: #fbfaf5;
    --st-border: #e3e1d8;
    --st-border-strong: #c8c6bb;
    --st-text: #0d1117;
    --st-text-muted: #4b5159;
    --st-text-faint: #767c87;
    --st-danger: #b91c1c;
    --st-warn: #b45309;
    --st-ok: #047857;
}


/* ===== 2. BODY CANVAS (overrides the rgba(0,255,136,0.03) radial glow) ==== */

html.light-theme body {
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(4, 120, 87, 0.035) 0%, transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(31, 111, 235, 0.025) 0%, transparent 30%);
    color: var(--text);
}

html.light-theme body[data-app="true"] {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
}

/* Replace premium.css top ambient glow which was tuned for dark */
html.light-theme body[data-app="true"]::before {
    background: radial-gradient(ellipse 80% 50% at 50% -10%,
                                rgba(4, 120, 87, 0.06) 0%,
                                transparent 70%);
}


/* ===== 3. CARDS — softer warm shadow, true 1px border, white surface ===== */

html.light-theme .card {
    background: var(--card-bg);
    border-color: rgba(15, 17, 25, 0.08);
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.7) inset,
                0 10px 28px -16px rgba(15, 17, 25, 0.18),
                0 2px 4px -2px rgba(15, 17, 25, 0.06);
}

html.light-theme .inner-card {
    background: rgba(15, 17, 25, 0.04);
}

html.light-theme .kpi,
html.light-theme .market-status-card {
    background: #ffffff;
    border-color: rgba(15, 17, 25, 0.08);
}

html.light-theme .kpi-lbl {
    color: var(--text-tertiary);
}

html.light-theme .agent-box {
    background: rgba(15, 17, 25, 0.025);
    border-color: rgba(15, 17, 25, 0.10);
}

html.light-theme .agent-box .status-dot {
    background: rgba(15, 17, 25, 0.18);
}


/* ===== 4. HEADER + NAV (legacy top-nav, kept for marketing pages) ======== */

html.light-theme .header-top {
    border-bottom-color: rgba(15, 17, 25, 0.08);
}

html.light-theme .brand-name {
    color: #0d1117;
}

html.light-theme .brand-sub {
    color: #6b7280;
}

html.light-theme .brand-logo {
    color: #fff;
    background: var(--accent);
}

html.light-theme .header-nav {
    border-bottom-color: rgba(15, 17, 25, 0.08);
}

html.light-theme .nav-tab {
    color: #6b7280;
}

html.light-theme .nav-tab:hover {
    color: #0d1117;
    background: rgba(15, 17, 25, 0.04);
}

html.light-theme .menu-toggle {
    border-color: rgba(15, 17, 25, 0.18);
}

html.light-theme .menu-toggle span {
    background: var(--accent);
}

html.light-theme .btn-logout {
    color: var(--danger);
    border-color: rgba(185, 28, 28, 0.35);
}

html.light-theme .btn-logout:hover {
    background: rgba(185, 28, 28, 0.06);
}


/* ===== 5. SIDEBAR (qt-sidenav) — light editorial surface =============== */

html.light-theme .qt-sidenav {
    background: linear-gradient(180deg,
                #ffffff 0%,
                #f5f3ec 100%);
    border-right: 1px solid rgba(15, 17, 25, 0.08);
    box-shadow: inset -1px 0 0 rgba(4, 120, 87, 0.04),
                4px 0 24px -16px rgba(15, 17, 25, 0.12);
    color: var(--qt-sn-text);
}

html.light-theme .qt-sidenav-brand {
    border-bottom-color: rgba(15, 17, 25, 0.06);
}

html.light-theme .qt-sidenav-brand-logo {
    background: linear-gradient(135deg, #047857 0%, #007a4a 100%);
    color: #ffffff;
    box-shadow: 0 0 16px rgba(4, 120, 87, 0.22);
}

html.light-theme .qt-sidenav-brand-name {
    color: #0d1117;
}

html.light-theme .qt-sidenav-toggle {
    background: rgba(15, 17, 25, 0.04);
    border-color: rgba(15, 17, 25, 0.10);
    color: var(--qt-sn-muted);
}

html.light-theme .qt-sidenav-toggle:hover {
    background: var(--qt-sn-accent-soft);
    border-color: var(--qt-sn-edge);
    color: var(--qt-sn-accent);
}

html.light-theme .qt-sidenav-link {
    color: #1a1f2a;
}

html.light-theme .qt-sidenav-link:hover {
    background: rgba(15, 17, 25, 0.045);
    color: #0d1117;
}

html.light-theme .qt-sidenav-link.is-active {
    background: var(--qt-sn-accent-soft);
    color: #0d1117;
}

html.light-theme .qt-sidenav-link.is-active .qt-sidenav-label {
    text-shadow: none;     /* glow halo is for dark — looks muddy on light */
}

html.light-theme .qt-sidenav-icon {
    color: #6b7280;
}

html.light-theme .qt-sidenav-list::-webkit-scrollbar-thumb {
    background: rgba(15, 17, 25, 0.12);
}

html.light-theme .qt-sidenav.is-collapsed .qt-sidenav-link[data-label]:hover::after {
    background: #0d1117;
    color: #ffffff;
    border-color: rgba(15, 17, 25, 0.08);
    box-shadow: 0 8px 20px rgba(15, 17, 25, 0.18);
}

html.light-theme .qt-sidenav-footer {
    border-top-color: rgba(15, 17, 25, 0.06);
}

html.light-theme .qt-sidenav-user {
    background: rgba(15, 17, 25, 0.035);
}

html.light-theme .qt-sidenav-user-avatar {
    background: linear-gradient(135deg, #ffffff 0%, #f0eee7 100%);
    border-color: rgba(4, 120, 87, 0.30);
}

html.light-theme .qt-sidenav-user-email {
    color: #0d1117;
}

html.light-theme .qt-sidenav-logout {
    color: var(--danger);
}

html.light-theme .qt-sidenav-logout:hover {
    background: rgba(185, 28, 28, 0.06);
}

/* Scan-line shimmer on the right edge — kill on light, it reads as a stripe */
html.light-theme .qt-sidenav::after {
    opacity: 0;
}

/* Mobile hamburger + backdrop */
html.light-theme .qt-sidenav-hamburger {
    background: #ffffff;
    border-color: rgba(15, 17, 25, 0.12);
    color: #0d1117;
    box-shadow: 0 4px 14px -6px rgba(15, 17, 25, 0.18);
}

html.light-theme .qt-sidenav-backdrop {
    background: rgba(15, 17, 25, 0.32);
}


/* ===== 6. THEME TOGGLE PILL (sidebar bottom — light variant) =========== */

html.light-theme .qt-theme-toggle {
    background: rgba(15, 17, 25, 0.04);
    border-color: rgba(15, 17, 25, 0.10);
}

html.light-theme .qt-theme-toggle::after {
    background: #0d1117;
    box-shadow: 0 2px 6px rgba(15, 17, 25, 0.20);
}

html.light-theme .qt-theme-toggle:hover {
    border-color: var(--qt-sn-edge);
    background: rgba(4, 120, 87, 0.05);
}


/* ===== 7. SETTINGS PAGE (st-* tokens) =================================== */

html.light-theme .st-input,
html.light-theme .st-select,
html.light-theme .st-textarea {
    background: #ffffff;
    border-color: var(--st-border);
    color: var(--st-text);
}

html.light-theme .st-input:focus,
html.light-theme .st-select:focus,
html.light-theme .st-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.14);
}

html.light-theme .st-btn {
    background: #ffffff;
    border-color: var(--st-border);
    color: var(--st-text);
}

html.light-theme .st-btn:hover {
    background: #f5f3ec;
    border-color: var(--st-border-strong);
}

html.light-theme .st-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

html.light-theme .st-btn-primary:hover {
    background: #007a4a;
    border-color: #007a4a;
}

html.light-theme .st-btn-warn {
    background: var(--warn);
    border-color: var(--warn);
    color: #ffffff;
}

html.light-theme .st-btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

html.light-theme .st-toggle {
    background: #fbfaf5;
    border-color: var(--st-border);
}

html.light-theme .st-banner.is-info    { background: rgba(31,111,235,0.08); color: #1248a1; border-color: rgba(31,111,235,0.30); }
html.light-theme .st-banner.is-warn    { background: rgba(178,92,0,0.08);   color: #7a3e00; border-color: rgba(178,92,0,0.32); }
html.light-theme .st-banner.is-danger  { background: rgba(194,38,26,0.06);  color: #8a1610; border-color: rgba(194,38,26,0.32); }
html.light-theme .st-banner.is-success { background: rgba(0,149,90,0.08);   color: #006039; border-color: rgba(0,149,90,0.32); }


/* ===== 8. LOGS / CODE / TERMINAL SURFACES — keep readable on light ====== */

html.light-theme .logs-tail {
    background: #0d1117;
    color: #d7ffd7;
    border-color: rgba(15, 17, 25, 0.18);
}

html.light-theme .logs-toolbar button {
    background: var(--accent);
    color: #ffffff;
}

html.light-theme .logs-toolbar button.secondary {
    background: #ffffff;
    color: var(--text);
    border: 1px solid rgba(15, 17, 25, 0.16);
}

html.light-theme .logs-status,
html.light-theme .logs-toolbar label {
    color: var(--text-tertiary);
}


/* ===== 9. MODALS / OVERLAYS ============================================ */

html.light-theme .demo-stats-modal {
    background: rgba(15, 17, 25, 0.55);
}

html.light-theme .demo-stats-content {
    background: #ffffff;
    color: var(--text);
}


/* ===== 10. PREMIUM.CSS specifics: ambient stripes, dividers, etc ======== */

html.light-theme #view-dashboard,
html.light-theme #view-strategies,
html.light-theme #view-analytics {
    color: var(--text-primary);
}

html.light-theme #view-dashboard *::-webkit-scrollbar-thumb,
html.light-theme #view-strategies *::-webkit-scrollbar-thumb,
html.light-theme #view-analytics *::-webkit-scrollbar-thumb {
    background: rgba(15, 17, 25, 0.16);
}


/* ===== 11. AUTH PAGES (login/signup) — they skip premium.css so leave dark
   feel UNLESS html.light-theme is present at load. ===== */

html.light-theme input,
html.light-theme select,
html.light-theme textarea {
    color-scheme: light;
}


/* ===== 12. UNIVERSAL TEXT FALLBACKS for inline-styled cards ============= */
/* The dashboard has many inline `style="color:#aaa; background:#111"` blocks
   that we don't tokenize here (would risk dark-mode regression). Instead, we
   raise the wrapper contrast so even white-on-near-white inline text remains
   legible. Override is scoped to body[data-app="true"] which is the SPA. */

html.light-theme body[data-app="true"] {
    /* Native form controls (button/input/select) get a sensible default
       so any un-themed legacy <button style="background:#1a1f2a"> reads */
    color-scheme: light;
}


/* ===== 13. DEMO MODE — keep the warning chroma but match light surfaces == */

html.light-theme body.demo-mode {
    background-image:
        radial-gradient(circle at 15% 50%, rgba(255, 152, 0, 0.06) 0%, transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(255, 87, 34, 0.05) 0%, transparent 30%);
}


/* ===== 14. THEME-SWITCHING TRANSITION (subtle ~220ms cross-fade) ======== */
/* Cuts the harsh snap when toggling. Scoped so it only triggers ONCE per
   click (CSS class toggled by JS — see side_nav.js). */

html.theme-transitioning,
html.theme-transitioning body,
html.theme-transitioning .card,
html.theme-transitioning .kpi,
html.theme-transitioning .qt-sidenav,
html.theme-transitioning .qt-sidenav-link {
    transition: background-color 240ms cubic-bezier(0.16, 1, 0.3, 1),
                color 240ms cubic-bezier(0.16, 1, 0.3, 1),
                border-color 240ms cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 240ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}


/* ===== 15. DASHBOARD — System Logs, Bot Logs, Analytics =================== */
/* The dashboard template (templates/index.html) was hand-coded in 2024 with
   ~85 inline `style="background:#0a0a0a"` / `#111` / `#000` / `#222` blocks +
   the System Logs / Bot Logs blocks use a black <pre> with grey text that
   becomes invisible on the warm canvas. Class selectors alone CANNOT beat
   inline styles, so this section uses two devices:
     (a) ID + class targeted overrides with `!important` for the named widgets
     (b) attribute-substring selectors `[style*="background:#0a0a0a"]` etc.
         to catch the 30+ scattered chip/tile/canvas-wrapper divs.
   Each rule below is rooted under `html.light-theme` so dark mode is intact. */

/* --- 15.1 System Logs viewer (id="log-viewer", inline bg:#000 color:#aaa) - */
html.light-theme #log-viewer {
    background: #0d1117 !important;        /* keep terminal feel — readable on dark */
    color: #d7e7d7 !important;
    border: 1px solid rgba(13, 17, 23, 0.18) !important;
    box-shadow: 0 1px 2px rgba(15, 17, 25, 0.05),
                0 8px 24px -12px rgba(15, 17, 25, 0.18);
    border-radius: 8px;
}

/* --- 15.2 Log source selector (id="log-bot-selector", bg:#222 border:#444) */
html.light-theme #log-bot-selector,
html.light-theme #botlog-selector,
html.light-theme #botlog-lines {
    background: #ffffff !important;
    color: #0d1117 !important;
    border: 1px solid rgba(13, 17, 23, 0.18) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* --- 15.3 Bot Logs toolbar + tail (.logs-toolbar, .logs-tail, .logs-status) */
html.light-theme .logs-toolbar {
    background: #ffffff !important;
    border-color: rgba(13, 17, 23, 0.10) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset,
                0 1px 4px rgba(15, 17, 25, 0.04);
}
html.light-theme .logs-toolbar select,
html.light-theme .logs-toolbar input[type="number"] {
    background: #ffffff !important;
    color: #0d1117 !important;
    border-color: rgba(13, 17, 23, 0.18) !important;
}
html.light-theme .logs-toolbar button {
    background: #047857 !important;
    color: #ffffff !important;
}
html.light-theme .logs-toolbar button.secondary {
    background: transparent !important;
    color: #0d1117 !important;
    border: 1px solid rgba(13, 17, 23, 0.20) !important;
}
html.light-theme .logs-toolbar label {
    color: #3d434f !important;
}
html.light-theme .logs-tail,
html.light-theme #botlog-tail {
    background: #0d1117 !important;
    color: #d7e7d7 !important;                /* terminal green, readable */
    border: 1px solid rgba(13, 17, 23, 0.18) !important;
    box-shadow: 0 1px 2px rgba(15, 17, 25, 0.05),
                0 8px 24px -12px rgba(15, 17, 25, 0.18);
    border-radius: 8px;
}
html.light-theme .logs-status {
    color: #6b7280 !important;
}

/* --- 15.4 Inline dark backgrounds scattered across the dashboard ---------- */
/* These hit chart cards, mini-stat tiles, table headers, daily-analytics
   panels, profit/profile widgets — anywhere a div was inline-styled
   `background:#0a0a0a` / `#111` / `#1a1a1a` / `#0b0f14`. The substring match
   works because the template uses no spaces around the colon. */
html.light-theme [style*="background:#0a0a0a"],
html.light-theme [style*="background: #0a0a0a"],
html.light-theme [style*="background:#0a0e14"],
html.light-theme [style*="background:#0b0f14"],
html.light-theme [style*="background:#0d1218"],
html.light-theme [style*="background:#11161e"] {
    background: #ffffff !important;
    border: 1px solid rgba(13, 17, 23, 0.08) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset,
                0 2px 6px -3px rgba(15, 17, 25, 0.06);
    border-radius: 8px;
}
html.light-theme [style*="background:#111"],
html.light-theme [style*="background: #111"],
html.light-theme [style*="background:#1a1a1a"],
html.light-theme [style*="background:#1f2937"] {
    background: #faf9f5 !important;
    border: 1px solid rgba(13, 17, 23, 0.06) !important;
    color: #0d1117 !important;
}
html.light-theme [style*="background:#222"],
html.light-theme [style*="background: #222"] {
    background: #f3f2ed !important;
    border-color: rgba(13, 17, 23, 0.12) !important;
    color: #0d1117 !important;
}

/* Form inputs that hardcoded `background:#000; color:var(--accent)` or
   `color:#fff` — needs explicit attr targeting so the placeholder + value
   stay readable. */
html.light-theme select[style*="background:#000"],
html.light-theme input[style*="background:#000"],
html.light-theme textarea[style*="background:#000"],
html.light-theme button[style*="background:#000"],
html.light-theme select[style*="background:#0a0a0a"],
html.light-theme input[style*="background:#0a0a0a"] {
    background: #ffffff !important;
    color: #0d1117 !important;
    border: 1px solid rgba(13, 17, 23, 0.18) !important;
}
html.light-theme select[style*="background:#000"] option,
html.light-theme select[style*="background:#0a0a0a"] option {
    background: #ffffff !important;
    color: #0d1117 !important;
}

/* Inline text-color overrides used for muted helpers (color:#888 / #aaa /
   #bbb / #ccc) — these are unreadable on the warm canvas. */
html.light-theme [style*="color:#888"],
html.light-theme [style*="color: #888"],
html.light-theme [style*="color:#999"],
html.light-theme [style*="color:#aaa"],
html.light-theme [style*="color: #aaa"],
html.light-theme [style*="color:#bbb"],
html.light-theme [style*="color:#ccc"],
html.light-theme [style*="color:#666"] {
    color: #5d6470 !important;
}
html.light-theme [style*="color:#fff"]:not([style*="background"]),
html.light-theme [style*="color: #fff"]:not([style*="background"]),
html.light-theme [style*="color:#ffffff"]:not([style*="background"]) {
    color: #0d1117 !important;
}

/* Inline border #333 / #444 — these are dark-mode subtle borders that turn
   to harsh near-black lines on a warm canvas. */
html.light-theme [style*="border:1px solid #333"],
html.light-theme [style*="border: 1px solid #333"],
html.light-theme [style*="border:1px solid #444"],
html.light-theme [style*="border: 1px solid #444"] {
    border-color: rgba(13, 17, 23, 0.18) !important;
}

/* --- 15.5 Table rows inline-styled with dark backgrounds ------------------ */
html.light-theme tr[style*="background:#0a0a0a"],
html.light-theme tr[style*="background:#111"] {
    background: #faf9f5 !important;
    border-bottom-color: rgba(4, 120, 87, 0.30) !important;
}

/* --- 15.6 Canvas wrappers — chart container divs should stay visible ----- */
/* Chart.js draws on the canvas, but the wrapper div bg needs to switch so
   the chart area frames cleanly on the warm canvas. */
html.light-theme .card div[style*="background"][style*="canvas"],
html.light-theme div[style*="height:300px"][style*="background:#0a0a0a"],
html.light-theme div[style*="height:250px"][style*="background:#0a0a0a"] {
    background: #ffffff !important;
}

/* --- 15.7 Daily Performance Analytics outer panel (border:2px var(--accent)
       background:#0a0a0a) — keep the accent border but lift the surface. */
html.light-theme div[style*="border:2px solid var(--accent)"][style*="background:#0a0a0a"] {
    background: #ffffff !important;
    border-color: rgba(4, 120, 87, 0.40) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset,
                0 12px 28px -18px rgba(15, 17, 25, 0.18);
}


/* ===== 16. TYPOGRAPHY + BUTTON CONTRAST FIXES ============================ */
/* The dashboard's base typography + button styles were written ONLY for dark
   mode: h1/h2 use #fff/#e2e8f0, generic <button> uses `color:#000` on
   `background:var(--accent)` which lands as black-on-dark-emerald in light
   (~3:1 contrast, well below WCAG-AA). Tab/period/timeframe/history/pagination
   buttons all use the same template (#888 on #222/rgba(40,40,40), and .active
   = #000 on accent). Patch them here with explicit selectors.  Dark mode is
   untouched. */

/* --- 16.1 Headings — were white/near-white on dark, invisible on light ---- */
html.light-theme h1 {
    color: #0d1117;
}
html.light-theme h2 {
    color: #0d1117;
    border-bottom-color: rgba(15, 17, 25, 0.10);
}
html.light-theme h3 {
    color: #0d1117;
}
/* h2 + h3 with inline `color:var(--warn)` etc keep their explicit color */
html.light-theme h2[style*="color"],
html.light-theme h3[style*="color"] {
    /* inline color wins — don't override */
}

/* --- 16.2 Generic <button> — was black text on accent (dark green in light)
       Switch to white text so the button reads. --- */
html.light-theme button {
    color: #ffffff;
}
html.light-theme button.danger {
    color: #ffffff;
}
html.light-theme button.secondary {
    background: #ffffff;
    color: #0d1117;
    border: 1px solid rgba(15, 17, 25, 0.18);
}
html.light-theme button.secondary:hover {
    background: #faf9f5;
    border-color: rgba(15, 17, 25, 0.28);
}

/* --- 16.3 Period / Timeframe / History / Pagination buttons (same template) */
html.light-theme .period-btn,
html.light-theme .timeframe-btn,
html.light-theme .history-tab,
html.light-theme .pagination-btn {
    background: #ffffff;
    border: 1px solid rgba(15, 17, 25, 0.14);
    color: #3d434f;
}
html.light-theme .period-btn:hover,
html.light-theme .timeframe-btn:hover,
html.light-theme .history-tab:hover,
html.light-theme .pagination-btn:hover:not(:disabled) {
    background: #f3f2ed;
    border-color: rgba(15, 17, 25, 0.24);
    color: #0d1117;
}
html.light-theme .period-btn.active,
html.light-theme .timeframe-btn.active,
html.light-theme .history-tab.active,
html.light-theme .pagination-btn.active {
    background: #047857;
    color: #ffffff;
    border-color: #047857;
}

/* --- 16.4 History table — dark-on-dark header + light-grey rows ----------- */
html.light-theme .history-table th {
    background: #f3f2ed;
    color: #3d434f;
    border-bottom-color: rgba(15, 17, 25, 0.12);
}
html.light-theme .history-table td {
    color: #0d1117;
    border-bottom-color: rgba(15, 17, 25, 0.06);
}
html.light-theme .history-table tr:hover {
    background: rgba(4, 120, 87, 0.05);
}
/* The accent-coded PnL classes are bright on dark; tone for light. */
html.light-theme .pnl-positive {
    color: #047857;
}
html.light-theme .pnl-negative {
    color: #b91c1c;
}

/* --- 16.5 Filter input — was bg:#111 color:#fff on light = white on white -- */
html.light-theme .filter-input {
    background: #ffffff;
    color: #0d1117;
    border: 1px solid rgba(15, 17, 25, 0.18);
}
html.light-theme .filter-input:focus {
    border-color: #047857;
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

/* --- 16.6 KPI value — was inheriting white text in dark; explicit dark now -- */
html.light-theme .kpi-val {
    color: #0d1117;
}

/* --- 16.7 Nav buttons (.nav-btn) — class used in sidebar legacy + page nav -- */
html.light-theme .nav-btn {
    color: #3d434f;
}
html.light-theme .nav-btn:hover {
    color: #0d1117;
    background: rgba(15, 17, 25, 0.04);
}
html.light-theme .nav-btn.active {
    background: rgba(4, 120, 87, 0.10);
    color: #0d1117;
}

/* --- 16.8 Strategy control bar (.ctrl-btn) — inherits generic <button> so
       its text gets the white treatment from 16.2; nothing else needed. */

/* --- 16.9 Common chip / pill / badge text fallbacks for low-contrast pairs */
html.light-theme .role-badge,
html.light-theme .notif-badge,
html.light-theme .demo-badge {
    color: #ffffff;
}

/* --- 16.10 Safety net: any element with explicit white text on a class-
       defined dark background still wins via specificity. This is a final
       catch for cards that use `.card-header { color: #fff }` style rules. */
html.light-theme .card h1,
html.light-theme .card h2,
html.light-theme .card h3,
html.light-theme .card h4,
html.light-theme .card h5,
html.light-theme .card h6,
html.light-theme .card p,
html.light-theme .card label,
html.light-theme .card span:not([style*="color"]):not(.pnl-positive):not(.pnl-negative):not(.kpi-val):not(.regime-badge):not(.role-badge):not(.notif-badge):not(.demo-badge) {
    color: inherit;
}
html.light-theme .card {
    color: #0d1117;
}


/* ===== 17. SAFETY NET — text-on-background contrast for inline styles ===== */
/* The dashboard template has 384+ inline `color:` attributes paired with
   inline `background:` colors. After flipping the canvas to light, two
   failure modes appeared:
     (A) Buttons with dark inline bg (e.g. `background:#555; color:#ccc`)
         — section 15's muted-color override rewrote #ccc -> #5d6470 (medium
         grey), which on #555 becomes invisible.
     (B) Mid-grey info chips (`<span background:#333 color:#aaa>i</span>`)
         — same root cause: text turned to mid-grey on mid-dark bg.

   The fix has two halves:
     1. TIGHTEN section 15's muted-color rule so it no longer fires when the
        same inline style also defines a DARK background (#0xxxxx -> #5xxxxx).
        This preserves the original light text on dark backgrounds.
     2. EXPLICITLY force white text on any element whose inline background is
        a dark grey we DON'T convert to light surface (#333, #444, #555,
        #666). Section 15.4 already flips #111/#222/#0a0a0a/etc to light
        cards, so this rule only targets the ones that stay dark. */

/* --- 17.1 Tightened muted-text overrides (re-declared with bg guards) ---- */
/* The original (section 15.4) rules are kept for backwards compatibility,
   but these later rules win on equal specificity by source order — meaning
   any element with a dark inline bg falls through to the white-text rule
   in 17.2 below. */
html.light-theme [style*="color:#888"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color: #888"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#999"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#aaa"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color: #aaa"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#bbb"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#ccc"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#ddd"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#eee"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#666"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]),
html.light-theme [style*="color:#777"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]) {
    color: #3d434f !important;
}

/* --- 17.2 Dark inline bg we DON'T flip -> force white text on the element
       and its descendants. Targets #333, #444, #555, #666 grey buttons /
       info chips / pills that keep their dark feel in light mode. */
html.light-theme [style*="background:#333"],
html.light-theme [style*="background: #333"],
html.light-theme [style*="background:#444"],
html.light-theme [style*="background: #444"],
html.light-theme [style*="background:#555"],
html.light-theme [style*="background: #555"],
html.light-theme [style*="background:#666"],
html.light-theme [style*="background: #666"] {
    color: #ffffff !important;
}
html.light-theme [style*="background:#333"] *:not([style*="color"]):not(.pnl-positive):not(.pnl-negative),
html.light-theme [style*="background:#444"] *:not([style*="color"]):not(.pnl-positive):not(.pnl-negative),
html.light-theme [style*="background:#555"] *:not([style*="color"]):not(.pnl-positive):not(.pnl-negative),
html.light-theme [style*="background:#666"] *:not([style*="color"]):not(.pnl-positive):not(.pnl-negative) {
    color: #ffffff !important;
}

/* --- 17.3 White / light inline text on (now) WHITE light-mode surfaces ---- */
/* The base rule in 15.4 already handles `color:#fff` without bg. This
   adds coverage for the other near-white tokens (#f0f0f0 / #efefef / #eee)
   when they sit on light, and `color:white` (literal). */
html.light-theme [style*="color:#fefefe"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]):not([style*="background:#7"]):not([style*="background:#8"]),
html.light-theme [style*="color:#f0f0f0"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]):not([style*="background:#7"]):not([style*="background:#8"]),
html.light-theme [style*="color:white"]:not([style*="background:#0"]):not([style*="background:#1"]):not([style*="background:#2"]):not([style*="background:#3"]):not([style*="background:#4"]):not([style*="background:#5"]):not([style*="background:#6"]):not([style*="background:#7"]):not([style*="background:#8"]):not([style*="background:var(--accent)"]):not([style*="background:var(--danger)"]):not([style*="background:var(--warn)"]) {
    color: #0d1117 !important;
}

/* --- 17.4 var(--accent)/var(--danger)/var(--warn) inline backgrounds with
       color:#000 — invisible in light because the var is now dark. ---- */
html.light-theme button[style*="background:var(--accent)"],
html.light-theme [style*="background:var(--accent)"][style*="color:#000"],
html.light-theme [style*="background: var(--accent)"][style*="color:#000"],
html.light-theme [style*="background:var(--accent)"][style*="color: #000"],
html.light-theme [style*="background:var(--danger)"],
html.light-theme [style*="background: var(--danger)"],
html.light-theme [style*="background:var(--warn)"],
html.light-theme [style*="background: var(--warn)"] {
    color: #ffffff !important;
}

/* --- 17.5 Pure black inline bg on small chips/labels (NOT log viewers) --- */
/* `background:#000` is currently handled per-tag by section 15.4 for form
   controls, and explicitly for #log-viewer/.logs-tail (kept dark). Catch the
   remaining spans/divs that use #000 inline with light text. */
html.light-theme span[style*="background:#000"],
html.light-theme div[style*="background:#000"]:not(#log-viewer):not(.logs-tail):not(#botlog-tail) {
    color: #ffffff !important;
}

/* --- 17.6 Border-on-light fallback: inline borders #222/#333 turn to
       harsh dark lines on warm canvas — soften to subtle rgba. */
html.light-theme [style*="border:1px solid #222"],
html.light-theme [style*="border: 1px solid #222"] {
    border-color: rgba(15, 17, 25, 0.16) !important;
}

/* --- 17.7 Class-defined buttons that flipped to LIGHT surface but kept
       legacy `color:#000` on an accent-coloured base (now dark green).
       This is a safety duplicate of section 16.2 for any  `class="cta"` /
       `class="quick-action"` style buttons that may exist outside the
       generic <button> selector. */
html.light-theme .cta,
html.light-theme .quick-action,
html.light-theme .action-btn,
html.light-theme .primary-action {
    color: #ffffff;
}

/* --- 17.8 Inline `background-color:` (with the -color suffix) catches the
       handful of templates that use the longhand. */
html.light-theme [style*="background-color:#333"],
html.light-theme [style*="background-color: #333"],
html.light-theme [style*="background-color:#444"],
html.light-theme [style*="background-color: #444"],
html.light-theme [style*="background-color:#555"],
html.light-theme [style*="background-color: #555"],
html.light-theme [style*="background-color:#666"],
html.light-theme [style*="background-color: #666"] {
    color: #ffffff !important;
}


/* ===== 18. CLASS-DEFINED LOW-CONTRAST FIXES ============================== */
/* These are classes in dashboard.css with hardcoded color: #aaa/#888/#ccc/#eee
   that were tuned for dark surfaces and become unreadable when section 3
   flips the underlying card / panel to white. */

/* --- 18.1 Profile selector top-right ------------------------------------- */
html.light-theme .profile-select {
    background: #ffffff;
    border-color: rgba(15, 17, 25, 0.18);
    color: #0d1117;
}
html.light-theme .profile-select option {
    background: #ffffff;
    color: #0d1117;
}

/* --- 18.2 Status pill (.status-stopped) — keep "off" feel but readable --- */
html.light-theme .status-stopped {
    background: #ebe9e2;
    color: #3d434f;
}

/* --- 18.3 Health score / token balance / coin autocomplete subtext ------- */
html.light-theme .health-score,
html.light-theme .token-balance,
html.light-theme .coin-autocomplete-item .coin-price {
    color: #5d6470;
}

/* --- 18.4 Market status card subtext -------------------------------------- */
html.light-theme .market-status-card .regime-confidence,
html.light-theme .market-status-card .fg-label,
html.light-theme .market-status-card .mult-label,
html.light-theme .market-status-card .btc-lbl,
html.light-theme .market-status-card .msc-offline {
    color: #5d6470;
}
html.light-theme .market-status-card .fg-bar-track {
    background: rgba(15, 17, 25, 0.10);
}
/* regime-badge has `color:#000` — invisible on dark accent in light mode */
html.light-theme .market-status-card .regime-badge {
    color: #ffffff;
}

/* --- 18.5 Settings labels + inputs --------------------------------------- */
html.light-theme #view-settings label {
    color: #3d434f;
}

/* --- 18.6 Notification bell + panel (everything is dark by default) ------ */
html.light-theme .notif-bell {
    border-color: rgba(15, 17, 25, 0.18);
    color: #0d1117;
}
html.light-theme .notif-bell:hover {
    background: rgba(15, 17, 25, 0.04);
    border-color: rgba(15, 17, 25, 0.28);
}
html.light-theme .notif-panel {
    background: #ffffff;
    border-color: rgba(15, 17, 25, 0.10);
    box-shadow: 0 12px 40px -8px rgba(15, 17, 25, 0.18);
}
html.light-theme .notif-panel-header {
    background: #faf9f5;
    border-bottom-color: rgba(15, 17, 25, 0.08);
    color: #0d1117;
}
html.light-theme .notif-mark-all {
    color: #047857;
}
html.light-theme .notif-empty {
    color: #5d6470;
}
html.light-theme .notif-item {
    border-bottom-color: rgba(15, 17, 25, 0.06);
}
html.light-theme .notif-item:hover {
    background: rgba(15, 17, 25, 0.035);
}
html.light-theme .notif-item.unread {
    background: rgba(4, 120, 87, 0.06);
}
html.light-theme .notif-item .title {
    color: #0d1117;
}
html.light-theme .notif-item .msg {
    color: #3d434f;
}
html.light-theme .notif-item .meta {
    color: #6b7280;
}
html.light-theme .notif-item .meta a {
    color: #047857;
}
/* Notification type icons stay in their semantic colors but darken slightly */
html.light-theme .notif-item.t-info .icon { color: #1d4ed8; }
html.light-theme .notif-item.t-warning .icon { color: #b45309; }
html.light-theme .notif-item.t-error .icon { color: #b91c1c; }
html.light-theme .notif-item.t-success .icon { color: #047857; }
html.light-theme .notif-badge {
    border-color: #ffffff;   /* badge sits above light surface now */
}

/* --- 18.7 Cards on white with .light-text legacy spans inside ----------- */
/* Generic descendant fix for any `.card .meta`, `.card .subtitle`, etc that
   was originally tuned for dark cards. The :not() chains keep elements that
   own their color (badges, PnL, regime, etc) untouched. */
html.light-theme .card .meta,
html.light-theme .card .subtitle,
html.light-theme .card .timestamp,
html.light-theme .card .label,
html.light-theme .card .hint {
    color: #6b7280;
}

/* --- 18.8 Buttons defined in dashboard.css with explicit `color:#000` ---- */
/* `.period-btn.active` etc have already been re-coloured (16.3). This block
   adds any remaining `color:#000` button class missed by 16. */
html.light-theme button[class*="btn"][style*="color:#000"],
html.light-theme button[class*="action"][style*="color:#000"] {
    color: #ffffff !important;
}


/* ===== 15. FOOTER OF FILE ============================================== */
