/* ASTrade design system: Light Modern default + persistent Dark Mode. */
html[data-theme="light"] {
    color-scheme: light;
    --workspace-bg: #f5f8fc;
    --workspace-bg-2: #edf3fa;
    --workspace-panel: #ffffff;
    --workspace-panel-2: #f8fbff;
    --workspace-highlight: #e8f0ff;
    --surface: #ffffff;
    --surface-2: #f7f9fd;
    --surface-3: #eef4fb;
    --border: rgba(31, 47, 74, .10);
    --border-strong: rgba(31, 47, 74, .17);
    --divider: rgba(31, 47, 74, .08);
    --text: #172033;
    --text-muted: #52627a;
    --text-faint: #8290a5;
    --text-inverse: #ffffff;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --primary-dark: #172033;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
}
html[data-theme="dark"] {
    color-scheme: dark;
    --workspace-bg: #07111f;
    --workspace-bg-2: #0a1728;
    --workspace-panel: #0c1a2b;
    --workspace-panel-2: #102238;
    --workspace-highlight: #142a49;
    --surface: #0d1b2c;
    --surface-2: #102238;
    --surface-3: #162a42;
    --border: rgba(143, 174, 214, .14);
    --border-strong: rgba(143, 174, 214, .23);
    --divider: rgba(143, 174, 214, .10);
    --text: #eaf2ff;
    --text-muted: #a8bad2;
    --text-faint: #7d93af;
    --text-inverse: #07111f;
    --primary: #3b82f6;
    --primary-2: #6366f1;
    --primary-dark: #eaf2ff;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #fb7185;
}
html[data-theme] body {
    background: var(--workspace-bg) !important;
    background-image: none !important;
    color: var(--text) !important;
    transition: background-color 160ms ease, color 160ms ease;
}
html[data-theme] body::before {
    opacity: .035 !important;
    animation: none !important;
}
html[data-theme="light"] body::after { display: none !important; }
html[data-theme="dark"] body::before {
    background-image: linear-gradient(rgba(100, 150, 220, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(100, 150, 220, .08) 1px, transparent 1px) !important;
}
html[data-theme="light"] .site-header,
html[data-theme="light"] .site-header .header-inner {
    background: rgba(255,255,255,.94) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
    box-shadow: 0 8px 28px rgba(22, 40, 69, .06) !important;
}
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-header .header-inner {
    background: rgba(7,17,31,.96) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
    box-shadow: 0 8px 30px rgba(0,0,0,.24) !important;
}
html[data-theme] .site-header .nav-item { color: var(--text-muted) !important; }
html[data-theme] .site-header .nav-item:hover,
html[data-theme] .site-header .nav-item:focus-visible { color: var(--primary) !important; background: var(--surface-3) !important; }
html[data-theme="light"] .main-wrap > .container {
    background: #f6f9fe !important;
    border-color: var(--border) !important;
    box-shadow: 0 16px 45px rgba(22,40,69,.07) !important;
}
html[data-theme="dark"] .main-wrap > .container {
    background: #081525 !important;
    border-color: var(--border) !important;
    box-shadow: 0 18px 48px rgba(0,0,0,.23) !important;
}
html[data-theme] h1, html[data-theme] h2, html[data-theme] h3,
html[data-theme] h4, html[data-theme] h5, html[data-theme] h6 { color: var(--text) !important; }
html[data-theme] .card, html[data-theme] .panel, html[data-theme] .dashboard-card,
html[data-theme] .stat-card, html[data-theme] .content-card, html[data-theme] .widget,
html[data-theme] .form-card, html[data-theme] .metric-card, html[data-theme] .watchlist-card,
html[data-theme] .journal-section {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    box-shadow: 0 8px 24px rgba(19, 42, 73, .045) !important;
}
html[data-theme] p, html[data-theme] label, html[data-theme] td,
html[data-theme] .text-muted, html[data-theme] .muted { color: var(--text-muted); }
html[data-theme] input, html[data-theme] select, html[data-theme] textarea {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border-strong) !important;
}
html[data-theme] table { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
html[data-theme] th { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--border) !important; }
html[data-theme] td { color: var(--text-muted) !important; border-color: var(--divider) !important; }
html[data-theme] .nav-dropdown-menu { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text) !important; }
html[data-theme] .nav-dropdown-menu a { color: var(--text) !important; }
.ast-theme-toggle {
    display: inline-flex !important; align-items: center; justify-content: center; gap: 7px;
    min-height: 36px !important; padding: 0 12px !important; margin-left: 8px;
    border: 1px solid var(--border-strong) !important; border-radius: 12px !important;
    background: var(--surface) !important; color: var(--text) !important;
    font-size: 12px !important; font-weight: 750 !important; line-height: 1.1;
    box-shadow: none !important; cursor: pointer; white-space: nowrap;
}
.ast-theme-toggle:hover { border-color: var(--primary) !important; transform: translateY(-1px); }
.ast-theme-icon { font-size: 17px; line-height: 1; color: var(--primary); }
.ast-theme-label { color: var(--text) !important; }
/* FVG radar page surfaces are explicitly themed because its first version used fixed white fills. */
html[data-theme="light"] .fvg-chip { color: #32435a; background: #ffffff; border-color: #dbe5f2; }
html[data-theme="dark"] .fvg-chip { color: #dbeafe; background: #102238; border-color: #263b55; }
html[data-theme="light"] .fvg-card { background: #ffffff; color: #172033; border-color: #e0e8f2; box-shadow: 0 12px 30px rgba(24,45,76,.06); }
html[data-theme="dark"] .fvg-card { background: #0d1b2c; color: #eaf2ff; border-color: #20364f; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
html[data-theme="light"] .fvg-warning { color: #52627a; border-color: #dbe5f2; background: #f8fbff; }
html[data-theme="dark"] .fvg-warning { color: #a8bad2; border-color: #263b55; background: #0d1b2c; }
html[data-theme="light"] .fvg-row { border-color: #e8edf5; }
html[data-theme="dark"] .fvg-row { border-color: #24364d; }
html[data-theme="light"] .fvg-confirmed { color: #047857; background: #dff8ed; }
html[data-theme="dark"] .fvg-confirmed { color: #6ee7b7; background: rgba(16,185,129,.14); }
@media (max-width: 760px) {
    .ast-theme-toggle { padding: 0 9px !important; min-height: 36px !important; }
    .ast-theme-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    html[data-theme] body { transition: none; }
    .ast-theme-toggle:hover { transform: none; }
}
