/*
 * Dark mode overrides (opt-in via `html.dark-theme`)
 *
 * Enabled site-wide: every page extending base.html / admin_base.html,
 * the standalone auth pages, and admin/users.html. The theme class is
 * applied by an inline script in each base template's <head> (before
 * first paint, no FOUC) and toggled by static/js/theme_toggle.js.
 * Palette matches node_common.css
 * (slate: #0f172a / #1e293b / #334155 / #94a3b8 / #e2e8f0).
 */

html.dark-theme {
    color-scheme: dark;
}

html.dark-theme body {
    background-color: #0b1120;
    color: #e2e8f0;
}

/* ------------------------------------------------------------------
 * Navbar dropdowns (header bar itself is already dark)
 * ------------------------------------------------------------------ */
html.dark-theme .nav-dropdown-menu {
    background-color: #1e293b;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

html.dark-theme .nav-dropdown-item {
    color: #d1d5db;
}

html.dark-theme .nav-dropdown-item:hover {
    background-color: #334155;
}

html.dark-theme .user-dropdown {
    background-color: #1e293b;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

html.dark-theme .user-dropdown-header {
    border-bottom-color: #334155;
}

html.dark-theme .user-dropdown-name {
    color: #e2e8f0;
}

html.dark-theme .user-dropdown-email {
    color: #94a3b8;
}

html.dark-theme .dropdown-item {
    color: #d1d5db;
}

html.dark-theme .dropdown-item:hover {
    background-color: #334155;
}

html.dark-theme .dropdown-divider {
    background-color: #334155;
}

html.dark-theme .logout-btn:hover {
    background-color: #450a0a;
}

/* ------------------------------------------------------------------
 * Main content shell
 * ------------------------------------------------------------------ */
html.dark-theme .main-content {
    background-color: #0f172a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

html.dark-theme .main-content h2,
html.dark-theme .main-content h3 {
    color: #e2e8f0;
}

html.dark-theme .main-content hr {
    border-top-color: #334155;
}

/* ------------------------------------------------------------------
 * Filters (main.css .filters markup used by node-summary)
 * ------------------------------------------------------------------ */
html.dark-theme .filter-col label {
    color: #94a3b8;
}

html.dark-theme .filter-col input,
html.dark-theme .filter-col select {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

html.dark-theme .filter-col input:focus,
html.dark-theme .filter-col select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Inline-styled hint text (node-summary "Consolidate" note) */
html.dark-theme .filter-col small {
    color: #94a3b8 !important;
}

html.dark-theme .advanced-filters {
    background-color: #1e293b;
}

html.dark-theme .advanced-filters summary {
    color: #e2e8f0;
}

/* Native select dropdown list (Firefox needs this explicitly) */
html.dark-theme select option,
html.dark-theme select optgroup {
    background-color: #1e293b;
    color: #e2e8f0;
}

/* ------------------------------------------------------------------
 * Metric cards (node-summary)
 * ------------------------------------------------------------------ */
html.dark-theme .metric-card {
    background-color: #1e293b;
}

html.dark-theme .metric-card h4 {
    color: #94a3b8;
}

html.dark-theme .metric-value {
    color: #e2e8f0;
}

/* ------------------------------------------------------------------
 * Help section (main.css light variant; node_common.css pages are
 * already dark — these values match, so no visual change there)
 * ------------------------------------------------------------------ */
html.dark-theme .help-section {
    background-color: #1e293b;
    border-left-color: #3b82f6;
}

html.dark-theme .help-section summary {
    color: #3b82f6;
}

html.dark-theme .help-content {
    color: #94a3b8;
}

html.dark-theme .help-content h4 {
    color: #e2e8f0;
}

/* ------------------------------------------------------------------
 * DataTables (jquery.dataTables.min.css overrides; the paginate
 * button color rules ship with !important, so we must match that)
 * ------------------------------------------------------------------ */
html.dark-theme table.dataTable {
    color: #e2e8f0;
}

html.dark-theme table.dataTable thead th,
html.dark-theme table.dataTable thead td {
    background-color: #1e293b;
    color: #94a3b8;
    border-bottom-color: #475569;
}

html.dark-theme table.dataTable tfoot th,
html.dark-theme table.dataTable tfoot td {
    border-top-color: #475569;
}

html.dark-theme table.dataTable.row-border tbody th,
html.dark-theme table.dataTable.row-border tbody td,
html.dark-theme table.dataTable.display tbody th,
html.dark-theme table.dataTable.display tbody td {
    border-top-color: #334155;
}

html.dark-theme table.dataTable.stripe tbody tr.odd,
html.dark-theme table.dataTable.display tbody tr.odd {
    background-color: #1e293b;
}

/* Sorted-column shading (default theme uses light grays) */
html.dark-theme table.dataTable.display tbody tr > .sorting_1,
html.dark-theme table.dataTable.order-column tbody tr > .sorting_1 {
    background-color: rgba(59, 130, 246, 0.06);
}

html.dark-theme table.dataTable.display tbody tr.odd > .sorting_1,
html.dark-theme table.dataTable.order-column.stripe tbody tr.odd > .sorting_1 {
    background-color: rgba(59, 130, 246, 0.10);
}

html.dark-theme table.dataTable.hover tbody tr:hover,
html.dark-theme table.dataTable.display tbody tr:hover,
html.dark-theme table.display tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.15);
}

/* Sort direction arrows are black PNG data-URIs — invert for dark bg */
html.dark-theme table.dataTable thead .sorting:before,
html.dark-theme table.dataTable thead .sorting:after,
html.dark-theme table.dataTable thead .sorting_asc:before,
html.dark-theme table.dataTable thead .sorting_asc:after,
html.dark-theme table.dataTable thead .sorting_desc:before,
html.dark-theme table.dataTable thead .sorting_desc:after,
html.dark-theme table.dataTable thead .sorting_asc_disabled:before,
html.dark-theme table.dataTable thead .sorting_asc_disabled:after,
html.dark-theme table.dataTable thead .sorting_desc_disabled:before,
html.dark-theme table.dataTable thead .sorting_desc_disabled:after {
    filter: invert(1);
}

html.dark-theme .dataTables_wrapper .dataTables_length,
html.dark-theme .dataTables_wrapper .dataTables_filter,
html.dark-theme .dataTables_wrapper .dataTables_info,
html.dark-theme .dataTables_wrapper .dataTables_processing,
html.dark-theme .dataTables_wrapper .dataTables_paginate {
    color: #94a3b8;
}

html.dark-theme .dataTables_wrapper .dataTables_length select,
html.dark-theme .dataTables_wrapper .dataTables_filter input {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
}

html.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #d1d5db !important;
}

html.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    color: #ffffff !important;
    border: 1px solid #3b82f6;
    background: #3b82f6;
}

html.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    color: #e2e8f0 !important;
    border: 1px solid #475569;
    background: #334155;
}

html.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
html.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: #64748b !important;
    border: 1px solid transparent;
    background: transparent;
}

/* ------------------------------------------------------------------
 * Select2 multi-selects (node-summary zone/type/region filters)
 * ------------------------------------------------------------------ */
html.dark-theme .select2-container--default .select2-selection--multiple {
    background-color: #1e293b;
    border: 1px solid #334155;
}

html.dark-theme .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #3b82f6;
}

html.dark-theme .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

html.dark-theme .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #94a3b8;
    border-right-color: #475569;
}

html.dark-theme .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: transparent;
    color: #e2e8f0;
}

html.dark-theme .select2-container--default .select2-search--inline .select2-search__field {
    background: transparent;
    color: #e2e8f0;
}

html.dark-theme .select2-dropdown {
    background-color: #1e293b;
    border-color: #334155;
}

html.dark-theme .select2-container--default .select2-results__option {
    color: #d1d5db;
}

html.dark-theme .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: #3b82f6;
    color: #ffffff;
}

html.dark-theme .select2-container--default .select2-results__option--selected {
    background-color: #334155;
}

html.dark-theme .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

/* ------------------------------------------------------------------
 * Misc shell pieces
 * ------------------------------------------------------------------ */
html.dark-theme footer {
    color: #94a3b8;
}

html.dark-theme .spinner {
    border-color: #334155;
    border-top-color: #3b82f6;
}

/* ------------------------------------------------------------------
 * Theme toggle button (injected into the navbar by theme_toggle.js)
 * ------------------------------------------------------------------ */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.6rem;
    margin-right: 0.75rem;
    background: transparent;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    background-color: #374151;
    border-color: #4b5563;
}

@media (max-width: 768px) {
    .theme-toggle {
        margin-right: 0;
        width: 100%;
    }
}

/* ==================================================================
 * v2 — site-wide rollout (base.html / admin_base.html / auth pages)
 * ================================================================== */

/* ------------------------------------------------------------------
 * main.css leftovers
 * ------------------------------------------------------------------ */
html.dark-theme .sidebar {
    background-color: #1e293b;
}

html.dark-theme .sidebar h3 {
    color: #e2e8f0;
}

html.dark-theme .nav-card {
    background-color: #1e293b;
    border-color: #334155;
}

html.dark-theme .nav-card h4 {
    color: #e2e8f0;
}

html.dark-theme .nav-card p {
    color: #94a3b8;
}

html.dark-theme .chart-container {
    background-color: #1e293b;
}

html.dark-theme .info-warning {
    background-color: rgba(245, 158, 11, 0.13);
    color: #fbbf24;
}

html.dark-theme .info-info {
    background-color: rgba(59, 130, 246, 0.13);
    color: #93c5fd;
}

html.dark-theme .badge-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

html.dark-theme .badge-info {
    background-color: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

html.dark-theme .badge-secondary {
    background-color: #334155;
    color: #cbd5e1;
}

html.dark-theme .empty-state {
    background-color: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}

html.dark-theme .error-state {
    background-color: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Risk-category metric cards: light gradient -> translucent dark */
html.dark-theme .metric-card.metric-extreme {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.20) 0%, #1e293b 100%);
}

html.dark-theme .metric-card.metric-high {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.20) 0%, #1e293b 100%);
}

html.dark-theme .metric-card.metric-medium {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, #1e293b 100%);
}

html.dark-theme .metric-card.metric-low {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, #1e293b 100%);
}

/* Checkbox dropdown (analytics-type filters) */
html.dark-theme .checkbox-dropdown .dropdown-toggle {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

html.dark-theme .checkbox-dropdown .dropdown-menu {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

html.dark-theme .checkbox-dropdown .dropdown-header {
    background-color: #16202f;
    border-bottom-color: #334155;
}

html.dark-theme .checkbox-dropdown .dropdown-header button {
    background-color: #1e293b;
    border-color: #334155;
    color: #d1d5db;
}

html.dark-theme .checkbox-dropdown .dropdown-header button:hover {
    background-color: #334155;
}

html.dark-theme .checkbox-dropdown .dropdown-search {
    border-bottom-color: #334155;
}

html.dark-theme .checkbox-dropdown .search-input {
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

html.dark-theme .checkbox-dropdown .dropdown-option:hover {
    background-color: #24304a;
}

html.dark-theme .checkbox-dropdown .dropdown-arrow {
    color: #94a3b8;
}

html.dark-theme .checkbox-dropdown .loading,
html.dark-theme .checkbox-dropdown .no-results {
    color: #94a3b8;
}

/* ------------------------------------------------------------------
 * Select2 single-select variant (only --multiple was covered in v1)
 * ------------------------------------------------------------------ */
html.dark-theme .select2-container--default .select2-selection--single {
    background-color: #1e293b;
    border-color: #334155;
}

html.dark-theme .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #e2e8f0;
}

html.dark-theme .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #64748b;
}

html.dark-theme .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #94a3b8 transparent transparent transparent;
}

/* ------------------------------------------------------------------
 * simulation_shared.css (si-*) — remap the palette variables, then
 * patch the rules that hardcode hex values
 * ------------------------------------------------------------------ */
html.dark-theme {
    --si-gray-50:  #16202f;
    --si-gray-100: #1f2b45;
    --si-gray-150: #26334e;
    --si-gray-200: #334155;
    --si-gray-300: #475569;
    --si-gray-400: #64748b;
    --si-gray-500: #94a3b8;
    --si-gray-600: #a8b6c8;
    --si-gray-700: #cbd5e1;
    --si-gray-800: #dde5ef;
    --si-gray-900: #f1f5f9;
    --si-emerald: #34d399;
    --si-emerald-bg: rgba(16, 185, 129, 0.15);
    --si-red:     #f87171;
    --si-red-bg:  rgba(239, 68, 68, 0.13);
    --si-amber:   #fbbf24;
    --si-amber-bg: rgba(245, 158, 11, 0.13);
    --si-blue:    #93c5fd;
    --si-blue-bg: rgba(59, 130, 246, 0.18);
    /* --si-card-bg is never defined by simulation_shared.css; templates that
       use var(--si-card-bg, #fff) would otherwise stay white in dark mode */
    --si-card-bg: #1e293b;
}

html.dark-theme .si-kpi,
html.dark-theme .si-table-card,
html.dark-theme .si-chart-card {
    background: #1e293b;
    border-color: var(--si-gray-200);
}

html.dark-theme .si-search {
    background: #0f172a;
    border-color: var(--si-gray-300);
    color: var(--si-gray-900);
}

html.dark-theme .si-chip {
    background: #1e293b;
    border-color: var(--si-gray-300);
    color: var(--si-gray-700);
}

html.dark-theme .si-chip.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

html.dark-theme .si-btn {
    background: #1e293b;
    border-color: var(--si-gray-300);
    color: var(--si-gray-700);
}

html.dark-theme .si-btn-primary {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

html.dark-theme .si-btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

html.dark-theme .si-pnl-neg,
html.dark-theme .si-neg {
    color: #f87171;
}

/* Row tints */
html.dark-theme table.si-table tbody tr.row-neg              { background: rgba(239, 68, 68, 0.07); }
html.dark-theme table.si-table tbody tr.row-neg:nth-child(even) { background: rgba(239, 68, 68, 0.10); }
html.dark-theme table.si-table tbody tr.row-neg:hover         { background: rgba(239, 68, 68, 0.16); }
html.dark-theme table.si-table tbody tr.row-pass td {
    background: rgba(250, 204, 21, 0.16) !important;
    box-shadow: inset 0 -1px 0 rgba(250, 204, 21, 0.45);
}
html.dark-theme table.si-table tbody tr.row-pass:hover td { background: rgba(250, 204, 21, 0.24) !important; }
html.dark-theme .si-cell-pass {
    background: rgba(250, 204, 21, 0.22) !important;
    color: #fde047;
}

html.dark-theme table.si-table tbody tr.row-skipped {
    color: #64748b;
    background: rgba(148, 163, 184, 0.05);
}
html.dark-theme table.si-table tbody tr.row-skipped:hover { background: rgba(148, 163, 184, 0.09); }
html.dark-theme table.si-table tbody tr.row-skipped td:first-child::after {
    color: #94a3b8;
    background: #334155;
}

html.dark-theme table.si-table tbody tr.row-danger {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.07);
}
html.dark-theme table.si-table tbody tr.row-danger:hover { background: rgba(245, 158, 11, 0.12); }
html.dark-theme table.si-table tbody tr.row-danger td:first-child::after {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.18);
    border-color: #f59e0b;
}

/* ------------------------------------------------------------------
 * cleared_actual.css (ca-*) — vars remap covers most; patch the rest
 * ------------------------------------------------------------------ */
html.dark-theme .ca-section {
    background: #1e293b;
}

html.dark-theme .pos { color: #34d399; }
html.dark-theme .neg { color: #f87171; }

html.dark-theme .ca-banner.warn  { background: rgba(245, 158, 11, 0.13); color: #fbbf24; }
html.dark-theme .ca-banner.alert { background: rgba(239, 68, 68, 0.13);  color: #f87171; }
html.dark-theme .ca-banner.ok    { background: rgba(16, 185, 129, 0.13); color: #34d399; }

html.dark-theme .pill-inc     { background: rgba(59, 130, 246, 0.18);   color: #93c5fd; }
html.dark-theme .pill-dec     { background: rgba(192, 38, 211, 0.18);   color: #f0abfc; }
html.dark-theme .pill-y       { background: rgba(16, 185, 129, 0.15);   color: #34d399; }
html.dark-theme .pill-n       { background: rgba(239, 68, 68, 0.15);    color: #f87171; }
html.dark-theme .pill-partial { background: rgba(245, 158, 11, 0.15);   color: #fbbf24; }

/* ------------------------------------------------------------------
 * auth.css (login/register/forgot/reset + admin pages using auth.css)
 * ------------------------------------------------------------------ */
html.dark-theme body {
    background: #0b1120;  /* shorthand: also kills the auth purple gradient */
}

html.dark-theme .auth-container {
    background: #1e293b;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

html.dark-theme .auth-header h1 {
    color: #60a5fa;
}

html.dark-theme .auth-header p {
    color: #94a3b8;
}

html.dark-theme .auth-form label {
    color: #cbd5e1;
}

html.dark-theme .auth-form input[type="email"],
html.dark-theme .auth-form input[type="password"],
html.dark-theme .auth-form input[type="text"] {
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

html.dark-theme .alert-error   { background-color: rgba(239, 68, 68, 0.12);  color: #f87171; }
html.dark-theme .alert-success { background-color: rgba(16, 185, 129, 0.12); color: #34d399; }
html.dark-theme .alert-info    { background-color: rgba(59, 130, 246, 0.12); color: #93c5fd; }
html.dark-theme .alert-warning { background-color: rgba(245, 158, 11, 0.12); color: #fbbf24; }

html.dark-theme .password-strength {
    background: #334155;
}

html.dark-theme .password-hint,
html.dark-theme .auth-footer p {
    color: #94a3b8;
}

html.dark-theme .forgot-password a,
html.dark-theme .text-link {
    color: #60a5fa;
}

html.dark-theme .divider::before {
    background: #334155;
}

html.dark-theme .divider span {
    background: #1e293b;
    color: #94a3b8;
}

/* auth.css ships its own white toast (separate from main.css toasts) */
html.dark-theme .toast {
    background: #1e293b;
}

html.dark-theme .toast-title {
    color: #e2e8f0;
}

html.dark-theme .toast-message {
    color: #94a3b8;
}

html.dark-theme .toast-close {
    color: #64748b;
}

html.dark-theme .toast-close:hover {
    color: #94a3b8;
}

/* ------------------------------------------------------------------
 * admin_base.html
 * ------------------------------------------------------------------ */
html.dark-theme .admin-page-container {
    background-color: transparent;
}

/* ------------------------------------------------------------------
 * v3: auth-gated tool pages whose templates hardcode light colors in
 * their own <style> blocks (verified via screenshots 2026-08-22).
 * ------------------------------------------------------------------ */

/* live_sim_hub.html (/bids/monitor) */
html.dark-theme .hub-section,
html.dark-theme .hub-link-row {
    background: #1e293b;
}
html.dark-theme .hub-link-row:hover {
    background: #26334e;
}
html.dark-theme .hub-cutoff {
    background: #1e293b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
html.dark-theme .hub-cutoff.ok      { background: rgba(22, 163, 74, 0.15);  border-color: #166534; }
html.dark-theme .hub-cutoff.warning { background: rgba(245, 158, 11, 0.15); border-color: #b45309; }
html.dark-theme .hub-cutoff.urgent  { background: rgba(239, 68, 68, 0.15);  border-color: #b91c1c; }
html.dark-theme .hub-cutoff.frozen  { background: #1f2b45;                  border-color: #475569; }
html.dark-theme .hub-cutoff.urgent .hub-cutoff-timer { color: #fca5a5; }
html.dark-theme .hub-cutoff.frozen .hub-cutoff-timer { color: #94a3b8; }
html.dark-theme .hub-cutoff-kill {
    background: transparent;
    color: #f87171;
    border-color: #b91c1c;
}
html.dark-theme .hub-cutoff-kill:hover { background: rgba(239, 68, 68, 0.15); }
html.dark-theme .hub-cutoff-kill.active { background: #7f1d1d; color: #fff; }
html.dark-theme .ls-status.pending,
html.dark-theme .ls-status.timeout,
html.dark-theme .ls-status.disabled { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
html.dark-theme .ls-status.approved,
html.dark-theme .ls-status.active   { background: rgba(22, 163, 74, 0.18);  color: #4ade80; }
html.dark-theme .ls-status.rejected { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
html.dark-theme .ls-status.submitted{ background: rgba(6, 182, 212, 0.18);  color: #67e8f9; }
html.dark-theme .ls-status.empty,
html.dark-theme .ls-status.unknown  { background: #334155;                  color: #cbd5e1; }

/* bid_builder.html + testbids.html (cards go dark via --si-card-bg remap) */
html.dark-theme .bb-btn-sm,
html.dark-theme .tb-btn-sm {
    background: #26334e;
    color: #cbd5e1;
    border-color: #475569;
}
html.dark-theme .bb-tab { background: #1f2b45; color: #cbd5e1; }
html.dark-theme .bb-tab.sel-inc { background: rgba(22, 163, 74, 0.18);  color: #4ade80; border-color: #16a34a; }
html.dark-theme .bb-tab.sel-dec { background: rgba(37, 99, 235, 0.20);  color: #93c5fd; border-color: #2563eb; }
html.dark-theme .bb-banner.warn,
html.dark-theme .tb-banner.warn,
html.dark-theme .bb-modal .warnline {
    background: rgba(245, 158, 11, 0.12);
    border-color: #b45309;
    color: #fcd34d;
}
html.dark-theme .bb-banner.info,
html.dark-theme .tb-banner.info {
    background: rgba(59, 130, 246, 0.14);
    border-color: #3b82f6;
    color: #93c5fd;
}
html.dark-theme .bb-banner.err {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
    color: #fca5a5;
}
html.dark-theme .bb-node.off { background: #16202f; }
html.dark-theme .bb-he-row.active .he { color: #f1f5f9; }
html.dark-theme .bb-he-row.active .bb-seg input { background: #0f172a; border-color: #3b82f6; }
html.dark-theme .bb-modal { background: #1e293b; }
html.dark-theme .bb-modal .row { border-bottom-color: #334155; }
html.dark-theme .bb-prog { background: #334155; }
html.dark-theme .bb-errlog { background: rgba(239, 68, 68, 0.12); border-color: #ef4444; }
html.dark-theme .bb-footer span[style*="15803d"] { color: #4ade80 !important; }
html.dark-theme .bb-footer span[style*="1e40af"] { color: #93c5fd !important; }
html.dark-theme .tb-modes .tb-mode.sel { background: rgba(37, 99, 235, 0.18); border-color: #2563eb; }
html.dark-theme .tb-he-row input.set { background: rgba(22, 163, 74, 0.15); border-color: #16a34a; }
html.dark-theme .tb-verdict.ok   { background: rgba(22, 163, 74, 0.18);  color: #4ade80; }
html.dark-theme .tb-verdict.warn { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
html.dark-theme .tb-verdict.bad  { background: rgba(239, 68, 68, 0.15);  color: #fca5a5; }
html.dark-theme table.tb-steps th,
html.dark-theme table.tb-steps td { border-bottom-color: #334155; }
html.dark-theme table.tb-steps th { color: #94a3b8; }
html.dark-theme .tb-pill.g { background: rgba(22, 163, 74, 0.18);  color: #4ade80; }
html.dark-theme .tb-pill.r { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
html.dark-theme .tb-pill.a { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

/* shadow_compare_index.html (/bids/monitor/shadow-compare) */
html.dark-theme .sci-card { background: #1e293b; }
html.dark-theme .sci-tag { background: rgba(99, 102, 241, 0.20); color: #a5b4fc; }
html.dark-theme .sci-tag.standalone { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

/* simulation_index.html view tabs + status banners/badges */
html.dark-theme .si-view-tabs { background: #16202f; }
html.dark-theme .si-view-tab { background: #1e293b; }
html.dark-theme .si-status-banner {
    background: rgba(245, 158, 11, 0.12);
    border-color: #b45309;
    color: #fcd34d;
}
html.dark-theme .si-status-banner a { color: #93c5fd; }
html.dark-theme .si-status-rejected {
    background: rgba(239, 68, 68, 0.14); color: #fca5a5; border-color: #ef4444;
}
html.dark-theme .si-status-deprecated {
    background: rgba(245, 158, 11, 0.14); color: #fcd34d; border-color: #b45309;
}
html.dark-theme .si-status-superseded {
    background: rgba(168, 85, 247, 0.16); color: #d8b4fe; border-color: #a855f7;
}
html.dark-theme .si-pnl-sub-val.si-neg { color: #f87171; }

/* admin.html (collection management) — .alert-* already covered above */
html.dark-theme .admin-section {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
html.dark-theme .section-title { color: #e2e8f0; border-bottom-color: #3b82f6; }
html.dark-theme .status-card { background: #16202f; border-color: #334155; }
html.dark-theme .status-card-title { color: #94a3b8; }
html.dark-theme .status-card-value { color: #f1f5f9; }
html.dark-theme .history-table th {
    background: #16202f;
    border-bottom-color: #334155;
    color: #94a3b8;
}
html.dark-theme .history-table td { border-bottom-color: #334155; }
html.dark-theme .history-table tr:hover { background: #1f2b45; }
html.dark-theme .btn-secondary { background: #334155; color: #e2e8f0; }
html.dark-theme .btn-secondary:hover:not(:disabled) { background: #475569; }
html.dark-theme .input-group input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .status-idle    { background: #334155;                  color: #cbd5e1; }
html.dark-theme .status-running { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
html.dark-theme .status-success { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .status-failed  { background: rgba(239, 68, 68, 0.16);  color: #fca5a5; }

/* autoresearch.html (Strategy Evolution Lab) */
html.dark-theme .ar-card { background: #1e293b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
html.dark-theme .ar-card .value { color: #f1f5f9; }
html.dark-theme .ar-card .label { color: #94a3b8; }
html.dark-theme .ar-card.running .value { color: #34d399; }
html.dark-theme .ar-card.stopped .value { color: #f87171; }
html.dark-theme .tab-btn { background: #26334e; color: #cbd5e1; }
html.dark-theme .tab-btn.active { background: #1e293b; color: #f1f5f9; }
html.dark-theme .status-keep    { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .status-discard { background: rgba(239, 68, 68, 0.16);  color: #fca5a5; }
html.dark-theme .status-crash   { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
html.dark-theme .gate-banner {
    background: rgba(59, 130, 246, 0.10);
    border-color: #3b82f6;
    color: #cbd5e1;
}
html.dark-theme .gate-banner b { color: #93c5fd; }
html.dark-theme .gate-banner .gate-pill { background: rgba(59, 130, 246, 0.20); color: #bfdbfe; }
html.dark-theme .gate-banner .stale-warn { color: #f87171; }
html.dark-theme .best-card { background: #1e293b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
html.dark-theme .best-card .best-label { color: #94a3b8; }
html.dark-theme .best-card .best-value { color: #34d399; }
html.dark-theme .best-card .best-sub { color: #cbd5e1; }
html.dark-theme .filter-bar { background: #16202f; border-color: #334155; }
html.dark-theme .filter-bar input,
html.dark-theme .filter-bar select {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .filter-bar label { color: #cbd5e1; }
html.dark-theme .filter-bar .chip {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}
html.dark-theme .filter-bar .chip.active { background: #2563eb; color: #fff; border-color: #2563eb; }
html.dark-theme .filter-bar .reset-btn {
    background: #26334e;
    border-color: #475569;
    color: #cbd5e1;
}
html.dark-theme .compare-bar { background: rgba(245, 158, 11, 0.12); border-color: #b45309; }
html.dark-theme .compare-bar button { background: #334155; }
html.dark-theme .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* myreport.html (/advance/report) — .metric-card/.metric-value covered above */
html.dark-theme .metric-label { color: #94a3b8; }
html.dark-theme .metric-subtext { color: #64748b; }
html.dark-theme .chart-section,
html.dark-theme .table-section {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
html.dark-theme .chart-section h2,
html.dark-theme .table-section h2 { color: #93c5fd; border-bottom-color: #3b82f6; }
html.dark-theme .chart-section h3 { color: #93c5fd !important; }
html.dark-theme .chart-section label { color: #cbd5e1 !important; }
html.dark-theme .chart-section input[type="date"] { border-color: #475569 !important; }
html.dark-theme .table-section th {
    background: #16202f;
    color: #94a3b8;
    border-bottom-color: #334155;
}
html.dark-theme .table-section td { border-bottom-color: #334155; }
html.dark-theme .table-section tr:hover { background: #1f2b45; }
html.dark-theme .loading { color: #94a3b8; }
html.dark-theme .error {
    background: rgba(239, 68, 68, 0.12);
    border-left-color: #ef4444;
    color: #fca5a5;
}
html.dark-theme .badge-success { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .badge-warning { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }

/* admin/users.html (standalone page — linked to dark_mode.css directly) */
html.dark-theme .admin-header h2 { color: #e2e8f0; }
html.dark-theme .admin-header p { color: #94a3b8; }
html.dark-theme .content-section { background: #1e293b; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
html.dark-theme .filter-label { color: #94a3b8; }
html.dark-theme .filter-select,
html.dark-theme .filter-input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .users-table th {
    background: #16202f;
    border-bottom-color: #334155;
    color: #94a3b8;
}
html.dark-theme .users-table td { border-bottom-color: #334155; }
html.dark-theme .users-table tr:hover { background: #1f2b45; }
html.dark-theme .user-name-cell { color: #e2e8f0; }
html.dark-theme .user-email { color: #94a3b8; }
html.dark-theme .user-meta { color: #64748b; }
html.dark-theme .status-approved             { background: rgba(16, 185, 129, 0.16);  color: #34d399; }
html.dark-theme .status-pending-approval     { background: rgba(245, 158, 11, 0.16);  color: #fcd34d; }
html.dark-theme .status-pending-verification { background: rgba(99, 102, 241, 0.20);  color: #a5b4fc; }
html.dark-theme .status-rejected             { background: rgba(239, 68, 68, 0.16);   color: #fca5a5; }
html.dark-theme .status-suspended            { background: rgba(234, 88, 12, 0.20);   color: #fdba74; }
html.dark-theme .role-user { background: #334155; color: #cbd5e1; }
html.dark-theme .action-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
html.dark-theme .action-dropdown-item { color: #d1d5db; }
html.dark-theme .action-dropdown-item:hover { background: #334155; }
html.dark-theme .action-dropdown-item.danger { color: #f87171; }
html.dark-theme .action-dropdown-item.danger:hover { background: rgba(239, 68, 68, 0.15); }
html.dark-theme .pagination-btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
html.dark-theme .pagination-btn:hover:not(:disabled) { background: #334155; color: #93c5fd; }
html.dark-theme .pagination-info { color: #94a3b8; }
html.dark-theme .user-menu-toggle {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .user-menu-toggle:hover { background: #26334e; border-color: #3b82f6; }
/* myreport header subtext sits on the blue gradient in both themes */
html.dark-theme .report-header .metric-subtext { color: rgba(255, 255, 255, 0.75); }

/* ------------------------------------------------------------------
 * live hub ops panels (ops_status.js / ops_actions.js inject inline
 * light-theme colors; scoped attribute-substring overrides so the JS
 * stays untouched). #991b1b/#92400e/#374151 are unreadable on dark.
 * ------------------------------------------------------------------ */
html.dark-theme #ops-lights [style*="color:#991b1b"],
html.dark-theme #ops-actions [style*="color:#991b1b"],
html.dark-theme .hub-card [style*="color:#991b1b"] { color: #fca5a5 !important; }
html.dark-theme #ops-lights [style*="color:#92400e"],
html.dark-theme #ops-actions [style*="color:#92400e"],
html.dark-theme .hub-card [style*="color:#92400e"] { color: #fcd34d !important; }
html.dark-theme #ops-lights [style*="color:#dc2626"],
html.dark-theme #ops-actions [style*="color:#dc2626"] { color: #f87171 !important; }
html.dark-theme #ops-lights [style*="color:#166534"],
html.dark-theme #ops-actions [style*="color:#166534"] { color: #4ade80 !important; }
html.dark-theme #ops-lights [style*="color:#374151"],
html.dark-theme #ops-actions [style*="color:#374151"] { color: #cbd5e1 !important; }
html.dark-theme #ops-lights [style*="color:#6b7280"],
html.dark-theme #ops-actions [style*="color:#6b7280"] { color: #94a3b8 !important; }
html.dark-theme #ops-actions a[style*="color:#2563eb"] { color: #60a5fa !important; }
html.dark-theme #ops-actions input[style*="background:#fff"] {
    background: #0f172a !important;
    color: #e2e8f0;
    border-color: #475569 !important;
}
html.dark-theme .hub-sleeve-error { color: #fca5a5; }
html.dark-theme .hub-feature-tick.partial { color: #fcd34d; }
html.dark-theme .hub-route-table th.h-inc { color: #4ade80; }
html.dark-theme .hub-route-table th.h-dec { color: #f87171; }

/* ------------------------------------------------------------------
 * v3b: second screenshot pass (2026-08-22) — admin dashboard + audit
 * log, posted-book detail, shadow-compare detail, autoresearch run
 * detail + admin panel, hybrid_summary controls, myreport2/3 reports.
 * ------------------------------------------------------------------ */

/* admin/dashboard.html (scoped to .admin-dashboard — .stat-card/.stat-label
   collide with myreport3's gradient stat cards, which stay as-is) */
html.dark-theme .admin-dashboard .admin-header h1 { color: #e2e8f0; }
html.dark-theme .admin-dashboard .admin-header p { color: #94a3b8; }
html.dark-theme .admin-dashboard .stat-card {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
html.dark-theme .admin-dashboard .stat-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
html.dark-theme .admin-dashboard .stat-card-title { color: #94a3b8; }
html.dark-theme .admin-dashboard .stat-card-value { color: #f1f5f9; }
html.dark-theme .admin-dashboard .stat-card-subtitle { color: #94a3b8; }
html.dark-theme .admin-dashboard .stat-card.warning .stat-card-value { color: #fbbf24; }
html.dark-theme .admin-dashboard .stat-card.danger .stat-card-value { color: #f87171; }
html.dark-theme .admin-dashboard .stat-card.success .stat-card-value { color: #34d399; }
html.dark-theme .admin-dashboard .stat-card.info .stat-card-value { color: #60a5fa; }
html.dark-theme .admin-dashboard .section-header { border-bottom-color: #334155; }
html.dark-theme .admin-dashboard .btn-link { color: #60a5fa; }
html.dark-theme .admin-dashboard .btn-link:hover { color: #93c5fd; }
html.dark-theme .admin-dashboard .activity-item { border-bottom-color: #334155; }
html.dark-theme .admin-dashboard .activity-item:hover { background: #1f2b45; }
html.dark-theme .admin-dashboard .activity-title { color: #e2e8f0; }
html.dark-theme .admin-dashboard .activity-details { color: #94a3b8; }
html.dark-theme .admin-dashboard .activity-time { color: #64748b; }
html.dark-theme .admin-dashboard .pending-users-table th {
    background: #16202f;
    border-bottom-color: #334155;
    color: #94a3b8;
}
html.dark-theme .admin-dashboard .pending-users-table td { border-bottom-color: #334155; }
html.dark-theme .admin-dashboard .pending-users-table tr:hover { background: #1f2b45; }
html.dark-theme .admin-dashboard .admin-header a[style*="e2e8f0"] {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
html.dark-theme .empty-state { color: #94a3b8; }
html.dark-theme .spinner { border-color: #334155; border-top-color: #60a5fa; }
html.dark-theme .badge-danger { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
html.dark-theme .badge-info { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }

/* admin/audit_log.html (.content-section, .filter-*, .pagination-*,
   .btn-secondary already covered by the admin/users.html rules above) */
html.dark-theme .admin-header h1 { color: #e2e8f0; }
html.dark-theme .stats-summary { border-bottom-color: #334155; }
html.dark-theme .stats-summary .stat-box { background: #16202f; }
html.dark-theme .stats-summary .stat-value { color: #f1f5f9; }
html.dark-theme .stats-summary .stat-label { color: #94a3b8; }
html.dark-theme .audit-table th {
    background: #16202f;
    color: #94a3b8;
    border-bottom-color: #334155;
}
html.dark-theme .audit-table td { border-bottom-color: #334155; }
html.dark-theme .audit-table tr:hover { background: #1f2b45; }
html.dark-theme .timestamp-cell { color: #94a3b8; }
html.dark-theme .details-cell { color: #94a3b8; }
html.dark-theme .user-cell { color: #e2e8f0; }
html.dark-theme .ip-address { background: #16202f; color: #cbd5e1; }
html.dark-theme .action-login_success,
html.dark-theme .action-user_approved,
html.dark-theme .action-user_reactivated,
html.dark-theme .action-password_reset_completed {
    background: rgba(16, 185, 129, 0.16); color: #34d399;
}
html.dark-theme .action-login_failed,
html.dark-theme .action-user_rejected,
html.dark-theme .action-admin_revoked {
    background: rgba(239, 68, 68, 0.16); color: #fca5a5;
}
html.dark-theme .action-registration_success { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
html.dark-theme .action-email_verified { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
html.dark-theme .action-user_suspended { background: rgba(234, 88, 12, 0.20); color: #fdba74; }
html.dark-theme .action-admin_granted { background: rgba(99, 102, 241, 0.20); color: #a5b4fc; }
html.dark-theme .action-password_reset_requested { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
html.dark-theme .action-logout { background: #334155; color: #cbd5e1; }

/* posted_summary.html (posted-book detail; si-var pieces already remapped) */
html.dark-theme .ls-section { background: #1e293b; }
html.dark-theme .lse-node-card.open { background: #16202f; }
html.dark-theme .lse-modal { background: #1e293b; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
html.dark-theme .lse-add-grid input,
html.dark-theme .lse-add-grid select,
html.dark-theme .lse-stack-defaults input,
html.dark-theme table.lse-stack-grid .lse-cell-edit input {
    background: #0f172a;
    color: #e2e8f0;
}
html.dark-theme .lse-row-actions button { background: #26334e; color: #cbd5e1; }
html.dark-theme .lse-row-actions button:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #b91c1c;
    color: #fca5a5;
}
html.dark-theme .lse-dir-toggle button { background: #26334e; color: #cbd5e1; }
html.dark-theme .lse-dir-toggle button.active { background: #3b82f6; color: #fff; }
html.dark-theme table.lse-stack-grid .lse-cell:hover,
html.dark-theme table.lse-stack-grid .lse-cell-empty:hover { background: rgba(59, 130, 246, 0.15); }
html.dark-theme table.lse-stack-grid .lse-cell-empty:hover { color: #60a5fa; }
html.dark-theme table.lse-stack-grid td.lse-row-total.over,
html.dark-theme table.lse-stack-grid tr.lse-peak td.lse-row-total.over {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
html.dark-theme table.lse-stack-grid tr.lse-peak td { background: rgba(245, 158, 11, 0.10); }
html.dark-theme .ls-btn { background: #26334e; color: #e2e8f0; }
html.dark-theme .ls-msg.ok   { background: rgba(22, 163, 74, 0.15);  color: #4ade80; }
html.dark-theme .ls-msg.err  { background: rgba(239, 68, 68, 0.12);  color: #fca5a5; }
html.dark-theme .ls-msg.warn { background: rgba(245, 158, 11, 0.12); color: #fcd34d; }
html.dark-theme #cutoff-line.ok      #cutoff-line-timer { color: #4ade80; }
html.dark-theme #cutoff-line.warning #cutoff-line-timer { color: #fcd34d; }
html.dark-theme #cutoff-line.urgent  #cutoff-line-timer { color: #fca5a5; }
html.dark-theme #cutoff-line.frozen  #cutoff-line-timer { color: #94a3b8; }
html.dark-theme #cutoff-line.urgent  { background: rgba(239, 68, 68, 0.12); }
/* miso-bidder chat widget */
html.dark-theme #mb-chat-panel { background: #1e293b; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5); }
html.dark-theme #mb-chat-log { background: #0f172a; }
html.dark-theme .mb-msg-user { background: rgba(59, 130, 246, 0.20); color: #bfdbfe; }
html.dark-theme .mb-msg-assistant { background: #16202f; }
html.dark-theme .mb-msg-assistant a { color: #60a5fa; }
html.dark-theme #mb-chat-banner {
    background: rgba(245, 158, 11, 0.12);
    border-bottom-color: #b45309;
    color: #fcd34d;
}
html.dark-theme #mb-chat-form { background: #1e293b; }
html.dark-theme #mb-chat-input { background: #0f172a; color: #e2e8f0; }
/* market-context fragment is rendered client-side with inline delta colors */
html.dark-theme #market-context [style*="color:#b91c1c"] { color: #f87171 !important; }
html.dark-theme #market-context [style*="color:#166534"] { color: #4ade80 !important; }

/* shadow_compare.html (per-shadow detail) */
html.dark-theme .sc-card { background: #1e293b; }
html.dark-theme .sc-gate-pending     { background: #16202f; border-color: #475569; color: #cbd5e1; }
html.dark-theme .sc-gate-in_progress { background: rgba(245, 158, 11, 0.12); border-color: #b45309; color: #fcd34d; }
html.dark-theme .sc-gate-passing     { background: rgba(16, 185, 129, 0.14); border-color: #10b981; color: #34d399; }
html.dark-theme .sc-gate-failing     { background: rgba(239, 68, 68, 0.14); border-color: #dc2626; color: #fca5a5; }
html.dark-theme .sc-table tr:hover td { background: #1f2b45; }
html.dark-theme .sc-page .pos { color: #4ade80; }
html.dark-theme .sc-page .neg { color: #f87171; }
html.dark-theme .sc-page .muted { color: #64748b; }
html.dark-theme .sc-page .badge { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
html.dark-theme .sc-table [style*="color:#15803d"] { color: #4ade80 !important; }

/* autoresearch_run.html (run detail) — .tab-btn/.filter-bar covered above */
html.dark-theme .ar-run-card { background: #1e293b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
html.dark-theme .ar-run-card .value { color: #f1f5f9; }
html.dark-theme .ar-run-card .label { color: #94a3b8; }
html.dark-theme .ar-run-card .sub { color: #64748b; }
html.dark-theme .ar-run-card.pos .value { color: #34d399; }
html.dark-theme .ar-run-card.neg .value { color: #f87171; }
html.dark-theme .ar-run-card.warn .value { color: #fbbf24; }
html.dark-theme .ar-pill.gen { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
html.dark-theme .ar-pill.hv  { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
html.dark-theme .ar-pill.lv  { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .ar-pill.cg  { background: rgba(139, 92, 246, 0.20); color: #c4b5fd; }
html.dark-theme .ar-pill.gate-pass { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .ar-pill.gate-fail { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
html.dark-theme .ar-pill.gate-na   { background: #334155; color: #cbd5e1; }
html.dark-theme .chart-container {
    background: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
html.dark-theme .meta-pair { color: #94a3b8; }
html.dark-theme .meta-pair strong { color: #e2e8f0; }
html.dark-theme .nav-arrows a,
html.dark-theme .nav-arrows span { background: #26334e; color: #cbd5e1; }
html.dark-theme .nav-arrows a:hover { background: #334155; }
html.dark-theme .empty-fwd {
    background: rgba(245, 158, 11, 0.10);
    border-color: #b45309;
    color: #fcd34d;
}
html.dark-theme .empty-fwd code { background: #0f172a; }
html.dark-theme .pnl-pos { color: #34d399; }
html.dark-theme .pnl-neg { color: #f87171; }
html.dark-theme .pnl-zero { color: #64748b; }
html.dark-theme .ar-run-header [style*="6b7280"] { color: #94a3b8 !important; }

/* autoresearch_admin.html (.ar-card/.best-card/.section-title covered above) */
html.dark-theme .ar-subnav a { background: #26334e; color: #cbd5e1; }
html.dark-theme .ar-subnav a:hover { background: #334155; }
html.dark-theme .ar-subnav a.current { background: #2563eb; color: #fff; }
html.dark-theme .runbt-panel { background: #1e293b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
html.dark-theme .runbt-header h3 { color: #e2e8f0; }
html.dark-theme .runbt-body { border-top-color: #334155; }
html.dark-theme .runbt-field input[type=date],
html.dark-theme .runbt-field input[type=number],
html.dark-theme .runbt-field select,
html.dark-theme .runbt-source-pane select,
html.dark-theme .runbt-source-pane textarea {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .runbt-source-row label { color: #cbd5e1; }
html.dark-theme .runbt-status { color: #94a3b8; }
html.dark-theme .runbt-error { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }
html.dark-theme .runbt-baseline-table th { color: #94a3b8; }
html.dark-theme .runbt-baseline-table th,
html.dark-theme .runbt-baseline-table td { border-bottom-color: #334155; }
html.dark-theme .runbt-baseline-table tr.runbt-row-self td { background: rgba(139, 92, 246, 0.15); }
html.dark-theme .runbt-baseline-table tr.runbt-row-naive td { color: #94a3b8; }
html.dark-theme .verify-block { background: #1e293b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
html.dark-theme .verify-row { border-bottom-color: #26334e; }
html.dark-theme .verify-row .label { color: #94a3b8; }
html.dark-theme .verify-row .val { color: #e2e8f0; }
html.dark-theme .verify-row .diff { color: #94a3b8; }
html.dark-theme .verify-row .diff.bad { color: #f87171; }
html.dark-theme .check-pill.ok  { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .check-pill.bad { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
html.dark-theme .check-pill.na  { background: #334155; color: #cbd5e1; }
html.dark-theme .island-pill.generalist { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
html.dark-theme .island-pill.high_vol   { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
html.dark-theme .island-pill.low_vol    { background: rgba(16, 185, 129, 0.16); color: #34d399; }
html.dark-theme .island-pill.congestion { background: rgba(139, 92, 246, 0.20); color: #c4b5fd; }
html.dark-theme .gate-table th { color: #94a3b8; }
html.dark-theme .gate-table th,
html.dark-theme .gate-table td { border-bottom-color: #26334e; }
html.dark-theme .gate-table td.val { color: #e2e8f0; }
html.dark-theme .best-card .title { color: #94a3b8; }
html.dark-theme .best-card .commit-link { color: #60a5fa; }
html.dark-theme .best-card .row { color: #94a3b8; }
html.dark-theme .best-card .row strong { color: #e2e8f0; }
html.dark-theme .btn-ghost { background: #26334e; color: #cbd5e1; }
html.dark-theme .btn-ghost:hover { background: #334155; }
html.dark-theme .corr-table th { background: #16202f; color: #94a3b8; }
html.dark-theme .corr-table td,
html.dark-theme .corr-table th { border-color: #334155; }
html.dark-theme .ar-admin-header [style*="6b7280"],
html.dark-theme .runbt-panel [style*="6b7280"] { color: #94a3b8 !important; }
html.dark-theme .runbt-panel [style*="374151"] { color: #e2e8f0 !important; }

/* hybrid_summary.html (sim portfolio pages incl. /bids/monitor/cleared-rl) —
   .metric-card covered above; scope buttons to .controls-panel so the
   green/red .btn-approve/.btn-reject in admin pages are untouched */
html.dark-theme .controls-panel .form-control {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .controls-panel .btn {
    background: #26334e;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-theme .controls-panel .btn:hover { background: #334155; border-color: #64748b; }
html.dark-theme .controls-panel .btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
html.dark-theme .controls-panel .btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
html.dark-theme .controls-panel .btn-secondary { background: #26334e; color: #e2e8f0; }
/* template pins these with !important; html.dark-theme prefix wins on specificity */
html.dark-theme .is-negative { color: #f87171 !important; }

/* myreport2.html (/advance/report2) */
html.dark-theme .report-meta { color: #94a3b8; }
html.dark-theme .summary-box { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .baseline-item,
html.dark-theme .improvement-item { border-bottom-color: #334155; }
html.dark-theme .baseline-label { color: #cbd5e1; }
html.dark-theme .baseline-value { color: #f1f5f9; }
html.dark-theme .baseline-value.success { color: #4ade80; }
html.dark-theme .improvement-label { color: #60a5fa; }
html.dark-theme .improvement-target { color: #4ade80; }
html.dark-theme .improvement-method { color: #94a3b8; }
html.dark-theme .tier-btn { background: #1e293b; border-color: #475569; color: #e2e8f0; }
html.dark-theme .tier-btn:hover { background: #26334e; border-color: #3b82f6; }
html.dark-theme .tier-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
html.dark-theme .strategy-card { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .strategy-card h3 { color: #f1f5f9; }
html.dark-theme .strategy-title { color: #f1f5f9; }
html.dark-theme .strategy-summary { color: #94a3b8; }
html.dark-theme .strategy-metric { background: #16202f; }
html.dark-theme .metric-name { color: #94a3b8; }
html.dark-theme .metric-value-lg { color: #f1f5f9; }
html.dark-theme .risk-low { color: #4ade80; }
html.dark-theme .risk-medium { color: #fbbf24; }
html.dark-theme .risk-high { color: #f87171; }
html.dark-theme .insight-card { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .insight-card h3 { color: #f1f5f9; }
html.dark-theme .insight-content li { color: #cbd5e1; }
html.dark-theme .roadmap-phase { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .phase-milestone { border-bottom-color: #334155; }
html.dark-theme .phase-milestone h4 { color: #60a5fa; }
html.dark-theme .phase-milestone li { color: #cbd5e1; }
html.dark-theme .risk-layer { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .risk-layer h3 { color: #f1f5f9; border-bottom-color: #3b82f6; }
html.dark-theme .control-item { background: #16202f; }
html.dark-theme .control-name { color: #cbd5e1; }
html.dark-theme .control-value { color: #f1f5f9; }
html.dark-theme .control-desc { color: #94a3b8; }
html.dark-theme .reference-card { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .reference-card h4 { color: #60a5fa; border-bottom-color: #334155; }
html.dark-theme .reference-list li { border-bottom-color: #334155; }
html.dark-theme .reference-list strong { color: #f1f5f9; }
html.dark-theme .reference-source { color: #94a3b8; }
html.dark-theme .data-stats { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .data-stat-item { border-bottom-color: #334155; }
html.dark-theme .data-stat-item .stat-label { color: #cbd5e1; }
html.dark-theme .data-stat-item .stat-value { color: #f1f5f9; }
html.dark-theme .system-capabilities { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
html.dark-theme .system-capabilities li { color: #cbd5e1; }
html.dark-theme .system-capabilities code { background: #0f172a; color: #f472b6; }
html.dark-theme .foundation-column h3 { color: #60a5fa; }
html.dark-theme .cta-card { background: #1e293b; color: #e2e8f0; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); }
html.dark-theme .cta-card h3 { color: #f1f5f9; }
html.dark-theme .cta-card p { color: #94a3b8; }
html.dark-theme .cta-details { border-top-color: #334155; }
html.dark-theme .cta-details strong { color: #60a5fa; }
html.dark-theme .final-note { background: #1e293b; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); }
html.dark-theme .final-note h3 { color: #60a5fa; }
html.dark-theme .highlight-text { color: #e2e8f0; }
html.dark-theme .metric-value-large { color: #60a5fa; }
html.dark-theme .metric-description { color: #94a3b8; }
html.dark-theme .metric-note { color: #64748b; }
html.dark-theme .risk-reward-chart { background: #1e293b; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }

/* myreport3.html (/advance/report3) — standalone page, scoped via the
   .myreport3-page marker class on <body> (its stylesheet uses bare element
   selectors, so unscoped overrides would leak site-wide) */
html.dark-theme body.myreport3-page { background: #0b1120; color: #e2e8f0; }
html.dark-theme .myreport3-page .container { background: #1e293b; }
html.dark-theme .myreport3-page h2 { color: #e2e8f0; }
html.dark-theme .myreport3-page h3 { color: #cbd5e1; }
html.dark-theme .myreport3-page .strategy-card { background: #1e293b; }
html.dark-theme .myreport3-page .metric { background: #16202f; }
html.dark-theme .myreport3-page .metric-value.positive { color: #4ade80; }
html.dark-theme .myreport3-page .metric-value.negative { color: #f87171; }
html.dark-theme .myreport3-page .insight-box {
    background: rgba(59, 130, 246, 0.10);
    border-left-color: #3b82f6;
}
html.dark-theme .myreport3-page .warning-box {
    background: rgba(245, 158, 11, 0.10);
    border-left-color: #b45309;
}
html.dark-theme .myreport3-page table td { border-bottom-color: #334155; }
html.dark-theme .myreport3-page table tr:hover { background: #1f2b45; }
html.dark-theme .myreport3-page .progress-bar { background: #334155; }
html.dark-theme .myreport3-page .data-source { color: #94a3b8; }
html.dark-theme .risk-badge.risk-low { background: rgba(22, 163, 74, 0.18); }
html.dark-theme .risk-badge.risk-moderate { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
html.dark-theme .risk-badge.risk-high { background: rgba(239, 68, 68, 0.18); }

/* ------------------------------------------------------------------
 * Floating toggle fallback (pages without a navbar: admin, auth)
 * ------------------------------------------------------------------ */
.theme-toggle-floating {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 1050;
    background: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

html.dark-theme .theme-toggle-floating {
    border-color: #475569;
}

@media print {
    .theme-toggle {
        display: none;
    }
}
