/* MysticDigit dark theme
 * Semantic surfaces preserve the light theme's hierarchy without inverting it.
 */
html.dark {
    color-scheme: dark;
    --dark-canvas: #141618;
    --dark-surface: #1b1f23;
    --dark-elevated: #23282e;
    --dark-card: #20252a;
    --dark-popover: #282e35;
    --dark-text: #f2f4ef;
    --dark-text-secondary: #c4cbc5;
    --dark-text-muted: #9aa39d;
    --dark-text-disabled: #69726d;
    --dark-inverse: #141618;
    --dark-border: #39413f;
    --dark-border-soft: #2d3532;
    --dark-input: #171a1c;
    --dark-primary: #a8cc8f;
    --dark-primary-hover: #bee0a3;
    --dark-primary-pressed: #86ac70;
    --dark-accent: #f0a08a;
    --dark-accent-hover: #ffb6a2;
    --dark-info: #9bc9d9;
    --dark-warning: #f0d68f;
    --dark-success: #a8d39a;
    --dark-error: #f49a94;
    --dark-focus: #c3e7a7;
    --dark-link: #a9d7e5;
    --dark-selection: rgba(168, 204, 143, 0.24);
    --dark-shadow-1: 0 2px 8px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.035);
    --dark-shadow-2: 0 10px 24px rgba(0, 0, 0, 0.30), 0 0 0 1px rgba(255, 255, 255, 0.045);
    --dark-shadow-3: 0 22px 48px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.055);

    /* Shared application aliases keep injected components on the same system. */
    --bg-body: var(--dark-canvas);
    --bg-card: var(--dark-card);
    --text-primary: var(--dark-text);
    --text-secondary: var(--dark-text-secondary);
    --text-muted: var(--dark-text-muted);
    --label-color: var(--dark-text-muted);
    --data-color: var(--dark-text);
    --border-color: var(--dark-border-soft);
    --border-strong: var(--dark-border);
    --primary-color: var(--dark-primary);
    --primary-dark: var(--dark-primary-pressed);
    --primary-light: rgba(168, 204, 143, 0.14);
    --primary-50: rgba(168, 204, 143, 0.08);
    --secondary-color: var(--dark-accent);
    --secondary-dark: #d47f6d;
    --secondary-light: rgba(240, 160, 138, 0.14);
    --ocean: var(--dark-info);
    --ocean-dark: #79aebd;
    --ocean-light: rgba(155, 201, 217, 0.14);
    --sun: var(--dark-warning);
    --sun-dark: #c7ae68;
    --sun-light: rgba(240, 214, 143, 0.14);
    --lavender: #dfcceb;
    --lavender-dark: #b69fc8;
    --lavender-light: rgba(196, 181, 212, 0.14);
    --backdrop-dark: rgba(8, 10, 11, 0.87);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow-sm: var(--dark-shadow-1);
    --shadow-md: var(--dark-shadow-2);
    --shadow-lg: var(--dark-shadow-2);
    --shadow-xl: var(--dark-shadow-3);
    --shadow-2xl: var(--dark-shadow-3);
    --shadow-inner: inset 0 1px 2px rgba(0, 0, 0, 0.24);
}

html.dark body,
html.dark .app-shell-main,
html.dark main,
html.dark [id^="view-"] {
    background-color: var(--dark-canvas);
    color: var(--dark-text);
}

html.dark aside,
html.dark header,
html.dark footer,
html.dark .app-shell-header,
html.dark .app-shell-mobile-header,
html.dark .app-shell-mobile-nav,
html.dark .app-shell-rail {
    background-color: color-mix(in srgb, var(--dark-surface) 94%, transparent);
    border-color: var(--dark-border-soft);
    color: var(--dark-text);
}

html.dark .bg-white,
html.dark .bg-gray-50,
html.dark .bg-gray-100,
html.dark .bg-slate-50,
html.dark .bg-slate-100,
html.dark .section-shell-card,
html.dark .metrics-card,
html.dark .macos-card,
html.dark .pipeline-card,
html.dark .pipeline-col,
html.dark .modal-content,
html.dark .modal-panel,
html.dark .fb-card,
html.dark .tribe-bento-cell,
html.dark .tribe-bento-mini-card {
    background-color: var(--dark-card);
    border-color: var(--dark-border-soft);
    color: var(--dark-text);
    box-shadow: var(--dark-shadow-1);
}

html.dark .bg-gray-200,
html.dark .bg-gray-300,
html.dark .bg-slate-200,
html.dark .bg-slate-300,
html.dark .bg-gray-50\/50,
html.dark .bg-gray-50\/80,
html.dark .bg-white\/70,
html.dark .bg-white\/80,
html.dark .bg-white\/90 {
    background-color: var(--dark-elevated);
}

html.dark .bg-transparent { background-color: transparent; }
html.dark .text-black,
html.dark .text-white,
html.dark .text-gray-50,
html.dark .text-gray-100,
html.dark .text-gray-200,
html.dark .text-gray-700,
html.dark .text-gray-800,
html.dark .text-gray-900,
html.dark .text-slate-50,
html.dark .text-slate-100,
html.dark .text-slate-200,
html.dark .text-slate-700,
html.dark .text-slate-800,
html.dark .text-slate-900 { color: var(--dark-text); }

html.dark .text-gray-300,
html.dark .text-gray-500,
html.dark .text-gray-600,
html.dark .text-slate-300,
html.dark .text-slate-400,
html.dark .text-slate-500,
html.dark .text-slate-600,
html.dark .text-muted,
html.dark label { color: var(--dark-text-secondary); }

html.dark .text-gray-400,
html.dark .text-slate-500\/60,
html.dark .text-gray-500\/60 { color: var(--dark-text-muted); }

html.dark .border,
html.dark .border-white,
html.dark .border-gray-50,
html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border-slate-200,
html.dark .border-slate-600,
html.dark .border-slate-700 { border-color: var(--dark-border); }

html.dark .divide-gray-50 > * + *,
html.dark .divide-gray-100 > * + *,
html.dark .divide-gray-200 > * + * { border-color: var(--dark-border-soft); }

/* `background` shorthand, not background-color: style_essence.css paints every
   input/select/textarea with a light gradient (`background: ... !important`), so
   a color-only override leaves the white gradient image visible in dark mode.
   Checkboxes/radios are excluded — they need a visible fill on dark surfaces. */
html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea,
html.dark .aurora-search,
html.dark .fb-search-input,
html.dark .fb-calc-input {
    background: var(--dark-input) !important;
    border-color: var(--dark-border);
    color: var(--dark-text);
    caret-color: var(--dark-primary);
}
html.dark input[type="checkbox"],
html.dark input[type="radio"] {
    background: #30373e !important;
    border-color: var(--dark-border) !important;
    accent-color: var(--dark-primary);
}

html.dark input::placeholder,
html.dark textarea::placeholder { color: var(--dark-text-disabled); }
html.dark input:disabled,
html.dark select:disabled,
html.dark textarea:disabled { color: var(--dark-text-disabled); background: var(--dark-surface); opacity: .75; }
html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus,
html.dark .aurora-search:focus {
    border-color: var(--dark-focus);
    box-shadow: 0 0 0 3px rgba(195, 231, 167, 0.22), var(--dark-shadow-1);
    outline: none;
}

html.dark button:disabled { color: var(--dark-text-disabled); background-color: var(--dark-surface); border-color: var(--dark-border-soft); }
html.dark .btn-primary,
html.dark .macos-btn-primary,
html.dark .bg-sage { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; border: 1px solid #6d8e57 !important; box-shadow: none !important; }
html.dark .btn-primary:hover,
html.dark .macos-btn-primary:hover,
html.dark .bg-sage:hover { background: var(--dark-primary-hover) !important; border-color: var(--dark-primary) !important; box-shadow: none !important; transform: none !important; }
html.dark .btn-accent,
html.dark .bg-coral { background: var(--dark-accent) !important; color: var(--dark-inverse) !important; border: 1px solid #be5f4a !important; box-shadow: none !important; }
html.dark .btn-accent:hover,
html.dark .bg-coral:hover { background: var(--dark-accent-hover) !important; border-color: var(--dark-accent) !important; box-shadow: none !important; transform: none !important; }
html.dark .btn-ghost,
html.dark button.bg-white { background: var(--dark-card) !important; border: 1px solid var(--dark-border) !important; color: var(--dark-text-secondary) !important; box-shadow: none !important; }
html.dark .btn-ghost:hover,
html.dark button.bg-white:hover,
html.dark .bottomnav-item:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; border-color: rgba(168, 204, 143, 0.42) !important; }
html.dark .nav-item:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; border-color: rgba(168, 204, 143, 0.42) !important; }

html.dark .nav-item.bg-sage-light,
html.dark .bottomnav-item.text-sage-dark,
html.dark .crm-tab-btn.bg-white,
html.dark .crm-tab-btn.active {
    background: rgba(168, 204, 143, 0.14);
    color: var(--dark-primary);
    border-color: rgba(168, 204, 143, 0.42);
}
html.dark .nav-item.bg-sage-light::after { background: var(--dark-accent); }
html.dark a { color: var(--dark-link); }
html.dark a:hover { color: var(--dark-primary-hover); }
html.dark .text-sage,
html.dark .text-sage-dark { color: var(--dark-primary); }
html.dark .text-coral,
html.dark .text-coral-dark { color: var(--dark-accent); }
html.dark .text-ocean,
html.dark .text-ocean-dark { color: var(--dark-info); }
html.dark .text-sun,
html.dark .text-sun-dark { color: var(--dark-warning); }

html.dark .bg-sage-light,
html.dark .bg-sage\/10,
html.dark .bg-sage\/20 { background-color: rgba(168, 204, 143, 0.14); }
html.dark .bg-coral-light,
html.dark .bg-coral\/10,
html.dark .bg-coral\/20 { background-color: rgba(240, 160, 138, 0.14); }
html.dark .bg-ocean-light { background-color: rgba(155, 201, 217, 0.14); }
html.dark .bg-sun-light,
html.dark .bg-yellow-50,
html.dark .bg-amber-50 { background-color: rgba(240, 214, 143, 0.14); }
html.dark .bg-red-50 { background-color: rgba(244, 154, 148, 0.14); }
html.dark .bg-purple-50,
html.dark .bg-lavender-light { background-color: rgba(196, 181, 212, 0.14); }

html.dark table { color: var(--dark-text); border-color: var(--dark-border-soft); }
html.dark thead,
html.dark th { background-color: var(--dark-surface); color: var(--dark-text-secondary); border-color: var(--dark-border); }
html.dark td { border-color: var(--dark-border-soft); }
html.dark tbody tr:nth-child(even) td { background-color: rgba(35, 40, 46, 0.42); }
html.dark tbody tr:hover td,
html.dark #resultsTable td:not(.sticky):hover { background-color: var(--dark-elevated); color: var(--dark-text); }
html.dark #resultsTable td.sticky,
html.dark #historyTable td.sticky { background-color: var(--dark-card); box-shadow: 2px 0 8px rgba(0, 0, 0, .22); }

html.dark .modal-backdrop { background-color: var(--backdrop-dark); }
html.dark [class*="backdrop"],
html.dark [class*="overlay"] { background-color: rgba(8, 10, 11, 0.76); }
html.dark .modal-content,
html.dark .modal-panel,
html.dark #more-drawer,
html.dark #accountDropdown,
html.dark #historySortMenu,
html.dark #historyRowActionMenu,
html.dark #morning-search-results { background-color: var(--dark-popover) !important; border-color: var(--dark-border) !important; box-shadow: var(--dark-shadow-3) !important; }
html.dark #toast-container > div,
html.dark #notification-center { background-color: var(--dark-popover) !important; border-color: var(--dark-border) !important; color: var(--dark-text) !important; box-shadow: var(--dark-shadow-3) !important; }
html.dark .rail-sidebar { background: var(--dark-surface) !important; }

html.dark .pipeline-column-head,
html.dark .pipeline-column-body,
html.dark .pipeline-stats-card,
html.dark .pipeline-time-pill,
html.dark .pipeline-metric-chip,
html.dark .pipeline-action-btn { background-color: var(--dark-elevated); border-color: var(--dark-border); color: var(--dark-text-secondary); }
html.dark .pipeline-card:hover,
html.dark .metrics-card:hover,
html.dark .fb-card:hover,
html.dark .tribe-bento-cell:hover { border-color: var(--dark-primary); }
html.dark .section-page-header,
html.dark .essence-chart-topbar,
html.dark .essence-chart-legend,
html.dark .macos-toolbar-group { color: var(--dark-text); }
html.dark .aurora-pill { background: rgba(35, 40, 46, .82); border-color: var(--dark-border); color: var(--dark-text-secondary); }
html.dark .aurora-search { background: rgba(20, 22, 24, .72); }
html.dark .aurora-vibe-circle { box-shadow: 0 16px 32px rgba(0, 0, 0, .34), inset 0 0 0 5px rgba(255, 255, 255, .24); }
html.dark #brief-hero-card { background: linear-gradient(135deg, rgba(240, 160, 138, .16), rgba(196, 181, 212, .12) 48%, rgba(155, 201, 217, .14)); border-color: rgba(240, 160, 138, .28); }

html.dark .smart-dropdown,
html.dark .lc-tabs,
html.dark .lc-stat,
html.dark .lc-stage,
html.dark .lc-calc,
html.dark .lc-example,
html.dark .lc-meaning,
html.dark .lc-quiz,
html.dark .lc-lesson,
html.dark .lc-num-show,
html.dark .lc-fcard,
html.dark .lc-ref-pill { background: var(--dark-card); border-color: var(--dark-border-soft); color: var(--dark-text); box-shadow: var(--dark-shadow-1); }
html.dark .smart-dropdown button:hover,
html.dark .lc-lesson:hover,
html.dark .lc-fcard-tag:hover,
html.dark .lc-ref-pill:hover { background: var(--dark-elevated); color: var(--dark-primary); }
html.dark pre,
html.dark code { background: var(--dark-input); color: var(--dark-text-secondary); border-color: var(--dark-border); }
html.dark progress { accent-color: var(--dark-primary); }

html.dark :focus-visible { outline: 2px solid var(--dark-focus); outline-offset: 2px; }
html.dark ::selection { background: var(--dark-selection); color: var(--dark-text); }
html.dark ::-webkit-scrollbar-track { background: var(--dark-surface); }
html.dark ::-webkit-scrollbar-thumb { background: #59645f; border-color: var(--dark-surface); }
html.dark ::-webkit-scrollbar-thumb:hover { background: #738079; }
html.dark * { scrollbar-color: #59645f var(--dark-surface); }

/* Reduced motion is handled by the single contract in style_essence.css
   (html[data-motion="reduced"] / prefers-reduced-motion). The previous
   html.dark block here had no !important and was always overridden. */

/* Final cascade: legacy utility classes and inline light surfaces must not leak. */
html.dark .bg-white,
html.dark [class*="bg-white"],
html.dark .bg-gray-50,
html.dark [class*="bg-gray-50"],
html.dark .bg-gray-100,
html.dark [class*="bg-gray-100"],
html.dark [class*="bg-slate-"] {
    background-color: var(--dark-card) !important;
}
/* Chart topbar: restore gradient over generic bg overrides */
html.dark .essence-chart-topbar,
html.dark .essence-chart-topbar.bg-gray-50\/50 { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-card)) !important; }

html.dark .bg-gray-200,
html.dark [class*="bg-gray-200"],
html.dark .bg-gray-300,
html.dark [class*="bg-gray-300"] { background-color: var(--dark-elevated) !important; }

html.dark .text-black,
html.dark .text-white,
html.dark .text-gray-50,
html.dark .text-gray-100,
html.dark .text-gray-200,
html.dark .text-gray-700,
html.dark .text-gray-800,
html.dark .text-gray-900,
html.dark .text-slate-50,
html.dark .text-slate-100,
html.dark .text-slate-200,
html.dark .text-slate-700,
html.dark .text-slate-800,
html.dark .text-slate-900 { color: var(--dark-text) !important; }

html.dark .text-gray-300,
html.dark .text-gray-500,
html.dark .text-gray-600,
html.dark [class*="text-gray-300"],
html.dark [class*="text-gray-500"],
html.dark [class*="text-gray-600"],
html.dark .text-slate-300,
html.dark .text-slate-400,
html.dark .text-slate-500,
html.dark .text-slate-600,
html.dark [class*="text-slate-300"],
html.dark [class*="text-slate-400"],
html.dark [class*="text-slate-500"],
html.dark [class*="text-slate-600"] { color: var(--dark-text-secondary) !important; }
html.dark .text-gray-400,
html.dark [class*="text-gray-400"] { color: var(--dark-text-muted) !important; }

html.dark [class*="border-gray-"],
html.dark [class*="border-slate-"] { border-color: var(--dark-border) !important; }

html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea,
html.dark .aurora-search,
html.dark .fb-search-input,
html.dark .fb-calc-input {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}

html.dark input[type="checkbox"],
html.dark input[type="radio"] {
    background: #30373e !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}

html.dark header,
html.dark aside,
html.dark footer,
html.dark .app-shell-header,
html.dark .app-shell-mobile-header,
html.dark .app-shell-mobile-nav,
html.dark .app-shell-rail,
html.dark .metrics-card,
html.dark .section-shell-card,
html.dark .pipeline-card,
html.dark .pipeline-col,
html.dark .modal-content,
html.dark .modal-panel {
    background-color: var(--dark-surface) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border-soft) !important;
}

html.dark #brief-hero-card,
html.dark .metrics-card,
html.dark .macos-card,
html.dark .bg-white.rounded-2xl,
html.dark .bg-white.rounded-xl { box-shadow: var(--dark-shadow-1) !important; }
html.dark #brief-hero-card { background: linear-gradient(135deg, rgba(240, 160, 138, .16), rgba(196, 181, 212, .12) 48%, rgba(155, 201, 217, .14)) !important; }

/* Intentional gradients for the shell, MacOS chrome, charts, and pipeline. */
html.dark {
    --shell-bg: linear-gradient(180deg, rgba(27, 31, 35, .98), rgba(20, 22, 24, .98));
    --shell-card-bg: var(--dark-card);
    --shell-border: var(--dark-border-soft);
    --section-header-bg: linear-gradient(135deg, rgba(35, 40, 46, .98), rgba(27, 31, 35, .98));
    --section-header-glow: radial-gradient(circle at top right, rgba(155, 201, 217, .10), transparent 34%);
    --section-surface-bg: linear-gradient(180deg, rgba(35, 40, 46, .98), rgba(27, 31, 35, .98));
    --aurora-hero-background: linear-gradient(135deg, rgba(240, 160, 138, .16), rgba(196, 181, 212, .12) 48%, rgba(155, 201, 217, .14));
    --aurora-hero-border: rgba(240, 160, 138, .28);
    --aurora-hero-shadow: var(--dark-shadow-2);
}

html.dark body.app-shell {
    background:
        radial-gradient(circle at top left, rgba(168, 204, 143, .08), transparent 30%),
        radial-gradient(circle at 85% 12%, rgba(155, 201, 217, .07), transparent 24%),
        radial-gradient(circle at bottom right, rgba(240, 160, 138, .06), transparent 26%),
        linear-gradient(180deg, var(--dark-canvas), var(--dark-surface)) !important;
}
html.dark .app-shell-main { background: linear-gradient(180deg, rgba(35, 40, 46, .34), transparent) !important; }
html.dark .app-shell-header,
html.dark .app-shell-mobile-header,
html.dark .app-shell-mobile-nav,
html.dark .app-shell-drawer,
html.dark .app-shell-rail { background: var(--shell-bg) !important; }
html.dark .app-shell-drawer { background: linear-gradient(180deg, var(--dark-popover), var(--dark-surface)) !important; }
html.dark .rail-sidebar .sidebar-sync-panel .sync-panel-inner { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important; border-color: var(--dark-border); }
html.dark .nav-item.bg-sage-light { background: linear-gradient(135deg, rgba(240, 160, 138, .20), rgba(35, 40, 46, .98)) !important; }
html.dark .section-page-header,
html.dark .section-page-header--sticky { background: var(--section-header-glow), var(--section-header-bg) !important; }
html.dark .section-page-header::before { background: linear-gradient(180deg, var(--dark-primary), var(--dark-accent)) !important; }
html.dark .section-page-header::after { background: radial-gradient(circle, rgba(168, 204, 143, .10), transparent 66%) !important; }
html.dark .section-page-header h1,
html.dark .section-page-header h2 { color: var(--dark-text) !important; }
html.dark .section-page-header p { color: var(--dark-text-secondary) !important; }
html.dark .section-page-header .bg-sage\/10,
html.dark .section-page-header [class*="bg-sage/10"] { background: linear-gradient(135deg, rgba(168, 204, 143, .20), rgba(168, 204, 143, .08)) !important; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
html.dark .section-page-header .flex.bg-white,
html.dark .section-page-header .flex.bg-gray-50,
html.dark .section-page-header .flex.bg-gray-100\/50 { background: rgba(35, 40, 46, .92) !important; }
html.dark .section-page-header button { background: rgba(35, 40, 46, .82) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }

html.dark .section-shell-card,
html.dark .section-shell-card--hero,
html.dark #view-revenue #revenue-dashboard-content > .bg-white,
html.dark #view-analysis #analysisNameResults > .bg-white,
html.dark #view-analysis #section-analysis-name > .bg-white,
html.dark #view-analysis #section-analysis-mobile > .bg-white,
html.dark #view-loshu #section-loshu-grid .bg-white,
html.dark #view-loshu #section-loshu-planes > .bg-white,
html.dark #view-loshu #section-loshu-analysis > .bg-white,
html.dark #view-intelligence .grid > .bg-white,
html.dark #view-intelligence > .bg-white { background: var(--section-surface-bg) !important; }
html.dark .section-shell-card::before,
html.dark [class*="section-shell-card"]::before { background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 26%), radial-gradient(circle at top right, rgba(168, 204, 143, .06), transparent 24%) !important; }

html.dark .essence-chart-shell,
html.dark .essence-chart-topbar,
html.dark .essence-chart-legend,
html.dark .essence-table-scroll { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark .essence-chart-shell::before,
html.dark .essence-chart-topbar::before { background: transparent !important; }
html.dark .essence-shell-accent { background: linear-gradient(90deg, var(--dark-primary), var(--dark-accent), var(--dark-info), var(--lavender)) !important; }
html.dark .essence-toolbar-input-wrap,
html.dark #quickNavContainer .mr-auto,
html.dark #quickNavContainer > div > .flex.bg-gray-100,
html.dark #quickNavContainer > div > .flex.items-center.border { background: rgba(35, 40, 46, .90) !important; border-color: var(--dark-border) !important; }
/* Chart toolbar: chips, inputs, buttons, dividers */
html.dark .essence-toolbar-chip { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark .essence-toolbar-chip:hover { background: var(--dark-card) !important; color: var(--dark-primary) !important; }
html.dark .essence-toolbar-chip.bg-white { background: var(--dark-card) !important; }
html.dark .essence-toolbar-chip.bg-sage { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; }
html.dark .essence-toolbar-chip.bg-sage:hover { background: var(--dark-primary-hover) !important; }
html.dark .essence-toolbar-input-wrap { background: rgba(35, 40, 46, .90) !important; border-color: var(--dark-border) !important; box-shadow: none !important; }
html.dark .essence-toolbar-input { color: var(--dark-text) !important; }
html.dark .essence-toolbar-input::placeholder { color: var(--dark-text-disabled) !important; }
html.dark .essence-toolbar-go { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark .essence-toolbar-go:hover { background: var(--dark-card) !important; color: var(--dark-text) !important; }
html.dark .essence-toolbar-group { background: var(--dark-elevated) !important; border-color: var(--dark-border) !important; }
html.dark #quickNavContainer > div > .flex.items-center.border input { background: transparent !important; color: var(--dark-text) !important; }
html.dark #quickNavContainer > div > .flex.items-center.border button { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #quickNavContainer > div > .flex.items-center.border button:hover { background: var(--dark-card) !important; }
html.dark .essence-chart-topbar > div:first-child h3 { color: var(--dark-text) !important; }
html.dark .essence-chart-topbar > div:first-child p { color: var(--dark-text-muted) !important; }
html.dark .essence-chart-topbar [class*="bg-sage/15"],
html.dark .essence-chart-topbar [class*="bg-gradient-to-br"] { background: linear-gradient(135deg, rgba(168,204,143,.18), rgba(168,204,143,.06)) !important; border-color: rgba(168,204,143,.28) !important; }
html.dark #quickNavContainer > div > div.bg-gray-200,
html.dark .essence-chart-topbar [class*="bg-gray-200"] { background: var(--dark-border) !important; }
html.dark .essence-table-scroll::after { background: linear-gradient(to right, transparent, rgba(32, 37, 42, .96)) !important; }
html.dark #resultsTable thead th { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important; color: var(--dark-text-secondary) !important; }
html.dark #resultsTable thead th:first-child.sticky,
html.dark #resultsTable th:first-child { background: linear-gradient(135deg, #b86f61, #8e5b52) !important; }
html.dark #resultsTable td:first-child { background: linear-gradient(180deg, var(--dark-card), var(--dark-surface)) !important; color: var(--dark-text) !important; }
html.dark #resultsTable td { background: rgba(32, 37, 42, .88) !important; color: var(--dark-text-secondary); }
html.dark #resultsTable tbody tr:nth-child(even) td { background: rgba(35, 40, 46, .92) !important; }
html.dark #resultsTable td.bg-sage-light { background: linear-gradient(180deg, rgba(168, 204, 143, .20), rgba(168, 204, 143, .10)) !important; color: var(--dark-primary) !important; }
html.dark #resultsTable td.bg-coral-light { background: linear-gradient(180deg, rgba(240, 160, 138, .20), rgba(240, 160, 138, .10)) !important; color: var(--dark-accent) !important; }
html.dark .essence-chart-legend > div { background: rgba(35, 40, 46, .90) !important; border-color: var(--dark-border); }

html.dark .pipeline-hero { background: radial-gradient(circle at top left, rgba(168, 204, 143, .14), transparent 34%), radial-gradient(circle at top right, rgba(240, 160, 138, .12), transparent 28%), linear-gradient(180deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark .pipeline-hero-icon,
html.dark .pipeline-card-avatar { background: linear-gradient(135deg, rgba(168, 204, 143, .24), rgba(168, 204, 143, .08)) !important; }
html.dark .pipeline-shell { background: linear-gradient(180deg, rgba(35, 40, 46, .96), rgba(32, 37, 42, .98)) !important; border-color: var(--dark-border-soft) !important; }
html.dark .pipeline-stage-inquiry .pipeline-column-head { background: linear-gradient(180deg, rgba(196, 181, 212, .22), rgba(35, 40, 46, .92)) !important; }
html.dark .pipeline-stage-scheduled .pipeline-column-head { background: linear-gradient(180deg, rgba(155, 201, 217, .22), rgba(35, 40, 46, .92)) !important; }
html.dark .pipeline-stage-progress .pipeline-column-head { background: linear-gradient(180deg, rgba(240, 214, 143, .20), rgba(35, 40, 46, .92)) !important; }
html.dark .pipeline-stage-completed .pipeline-column-head { background: linear-gradient(180deg, rgba(168, 211, 154, .22), rgba(35, 40, 46, .92)) !important; }

/* MacOS-style chrome. Keep the glass hierarchy, replace only its light surfaces. */
html.dark .macos-card { background: linear-gradient(145deg, rgba(35, 40, 46, .96), rgba(27, 31, 35, .98)) !important; border-color: var(--dark-border-soft) !important; box-shadow: var(--dark-shadow-1) !important; }
html.dark .macos-card::before { background: linear-gradient(180deg, rgba(255, 255, 255, .07), transparent) !important; }
html.dark .macos-btn { background: var(--dark-card) !important; color: var(--dark-text-secondary) !important; border: 1px solid var(--dark-border) !important; box-shadow: none !important; }
html.dark .macos-btn:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; border-color: rgba(168, 204, 143, .38) !important; transform: none !important; }
html.dark .macos-btn-primary { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; border: 1px solid #6d8e57 !important; box-shadow: none !important; }
html.dark .macos-segmented-control,
html.dark .macos-toolbar-group { background: var(--dark-card) !important; border: 1px solid var(--dark-border) !important; box-shadow: none !important; }
html.dark .macos-segmented-control button.active,
html.dark .macos-segmented-control .segment-btn.active { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; border: 1px solid rgba(168, 204, 143, .38) !important; box-shadow: none !important; }
html.dark .macos-toolbar-group button { color: var(--dark-text-muted) !important; }
html.dark .macos-toolbar-group button:hover { background: rgba(45, 51, 57, .96) !important; color: var(--dark-primary) !important; }
html.dark .macos-toolbar-group .macos-toolbar-divider { background: var(--dark-border) !important; }
html.dark .macos-proxy-badge.sage,
html.dark .macos-status-chip.sage { background: linear-gradient(135deg, rgba(168, 204, 143, .18), rgba(168, 204, 143, .06)) !important; border-color: rgba(168, 204, 143, .30) !important; color: var(--dark-primary) !important; }
html.dark .macos-proxy-badge.ocean,
html.dark .macos-status-chip.ocean { background: linear-gradient(135deg, rgba(155, 201, 217, .18), rgba(155, 201, 217, .06)) !important; border-color: rgba(155, 201, 217, .30) !important; color: var(--dark-info) !important; }
html.dark .macos-proxy-badge.coral,
html.dark .macos-status-chip.coral { background: linear-gradient(135deg, rgba(240, 160, 138, .18), rgba(240, 160, 138, .06)) !important; border-color: rgba(240, 160, 138, .30) !important; color: var(--dark-accent) !important; }
html.dark .macos-proxy-badge.lavender { background: linear-gradient(135deg, rgba(223, 204, 235, .18), rgba(223, 204, 235, .06)) !important; border-color: rgba(223, 204, 235, .30) !important; color: var(--lavender) !important; }
html.dark .macos-proxy-badge.sun,
html.dark .macos-status-chip.sun { background: linear-gradient(135deg, rgba(240, 214, 143, .18), rgba(240, 214, 143, .06)) !important; border-color: rgba(240, 214, 143, .30) !important; color: var(--dark-warning) !important; }
html.dark .macos-path-bar { background: linear-gradient(180deg, rgba(35, 40, 46, .82), rgba(27, 31, 35, .82)) !important; border-color: var(--dark-border) !important; color: var(--dark-text-muted) !important; }
html.dark .macos-path-bar .path-segment { color: var(--dark-text-secondary) !important; }
html.dark .macos-path-bar .path-segment.active { color: var(--dark-primary) !important; }
html.dark .aurora-qac { background: var(--dark-card) !important; color: var(--dark-text-secondary) !important; border: 1px solid var(--dark-border) !important; }
html.dark .aurora-qac:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; border-color: rgba(168, 204, 143, .42) !important; }
html.dark .aurora-go-btn { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; border: 1px solid #6d8e57 !important; }

/* Formula Bank Bento cards and their inline light gradients. */
html.dark #view-formulabank .fb-bento-card,
html.dark #view-formulabank .fb-bento-cell,
html.dark #view-formulabank .fb-mini-card,
html.dark #view-formulabank .fb-card,
html.dark #view-formulabank .fb-cat-card,
html.dark #view-formulabank .fb-expanded,
html.dark #view-formulabank .fb-example-box,
html.dark #view-formulabank .fb-meaning-box,
html.dark #view-formulabank .fb-vedic-box,
html.dark #view-formulabank .fb-about-box,
html.dark #view-formulabank .fb-stat-card { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border-soft) !important; color: var(--dark-text); box-shadow: var(--dark-shadow-1); }
html.dark #view-formulabank .fb-bento-card:hover,
html.dark #view-formulabank .fb-bento-cell:hover,
html.dark #view-formulabank .fb-mini-card:hover,
html.dark #view-formulabank .fb-card:hover {
    background: var(--dark-elevated) !important;
    border-color: rgba(168, 204, 143, .42) !important;
}
html.dark #view-formulabank .fb-bento-card [class*="bg-white"],
html.dark #view-formulabank .fb-bento-cell [class*="bg-white"],
html.dark #view-formulabank .fb-card [class*="bg-white"] { background: rgba(45, 51, 57, .82) !important; }
html.dark #view-formulabank .fb-bento-cat-tag,
html.dark #view-formulabank .fb-action-bar,
html.dark #view-formulabank .fb-meta-pill { background: rgba(20, 22, 24, .46) !important; border-color: var(--dark-border) !important; color: var(--dark-text-secondary) !important; }
html.dark #view-formulabank .fb-action-bar .fb-action-btn:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; }
html.dark #view-formulabank .fb-bento-detail .fb-bento-step-text { color: var(--dark-text-secondary) !important; }
html.dark #view-formulabank .fb-bento-detail .fb-bento-xref { color: var(--dark-text-muted) !important; }
html.dark #view-formulabank .fb-bento-detail .fb-bento-xref:hover { color: var(--dark-text) !important; }
html.dark #view-formulabank .fb-formula-block { background: linear-gradient(135deg, rgba(20, 22, 24, .72), rgba(35, 40, 46, .82)) !important; border-color: var(--dark-border) !important; }
html.dark .lc-continue { background: linear-gradient(135deg, rgba(168, 204, 143, .16), rgba(155, 201, 217, .14)) !important; border-color: var(--dark-border) !important; }
html.dark .lc-lesson.current { background: linear-gradient(90deg, rgba(155, 201, 217, .18), var(--dark-card) 30%) !important; border-left-color: var(--dark-info) !important; }

/* Inline gradients are used by generated Bento/Tribe content. */
html.dark [style*="linear-gradient"],
html.dark [style*="radial-gradient"] { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark .fb-calc-mini-btn[style*="linear-gradient"] { background: linear-gradient(135deg, var(--dark-primary-pressed), var(--dark-primary)) !important; color: var(--dark-inverse) !important; }
html.dark #tribe-map-wrapper[style*="gradient"],
html.dark .tribe-bento-cell[style*="gradient"] { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; }
html.dark [class*="bg-gradient-"] { background-image: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark .brief-theme-1,
html.dark .brief-theme-2,
html.dark .brief-theme-3,
html.dark .brief-theme-4,
html.dark .brief-theme-5,
html.dark .brief-theme-6,
html.dark .brief-theme-7,
html.dark .brief-theme-8,
html.dark .brief-theme-9,
html.dark .brief-theme-10,
html.dark .brief-theme-11,
html.dark .brief-theme-12 { background: linear-gradient(135deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; color: var(--dark-text) !important; }

/* Requested view surfaces: header, Brief, Console/CRM, Records, and Pipeline. */
html.dark .app-shell-header .capsule-pill,
html.dark .app-shell-header.is-scrolled .capsule-pill {
    background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important;
    border-color: var(--dark-border) !important;
    box-shadow: var(--dark-shadow-2) !important;
}
html.dark .app-shell-header .capsule-pill button,
html.dark .app-shell-header .capsule-pill kbd {
    background: var(--dark-card) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border) !important;
}
html.dark .app-shell-header .capsule-pill button:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; }

html.dark #view-morning input,
html.dark #view-morning select,
html.dark #view-morning textarea {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #view-morning input::placeholder,
html.dark #view-morning textarea::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #view-morning .macos-card,
html.dark #view-morning .metrics-card,
html.dark #view-morning section.bg-white { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark #view-morning .quick-lookup-wrap { background: linear-gradient(135deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border-soft) !important; }
html.dark #view-morning .quick-lookup-wrap .quick-lookup-card { background: rgba(35,40,46,.7) !important; border-color: var(--dark-border-soft) !important; }

html.dark #view-calculator > .section-shell-card,
html.dark #calculatorForm details,
html.dark #calculatorForm details > summary,
html.dark #calculatorForm details > div {
    background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #calculatorForm input,
html.dark #calculatorForm select,
html.dark #calculatorForm textarea,
html.dark #calculatorForm .smart-date-input {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .24) !important;
}
html.dark #calculatorForm input::placeholder,
html.dark #calculatorForm textarea::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #calculatorForm details summary:hover { background: var(--dark-elevated) !important; }
html.dark #calculatorForm .crm-tab-btn { color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #calculatorForm .crm-tab-btn.bg-white,
html.dark #calculatorForm .crm-tab-btn.active { background: rgba(168, 204, 143, .16) !important; color: var(--dark-primary) !important; }
html.dark #calculatorForm .crm-tab-content,
html.dark #calculatorForm .crm-tab-content.bg-white { background: var(--dark-card) !important; border-color: var(--dark-border) !important; }
html.dark #calculatorForm .bg-coral-light\/10 { background: rgba(240, 160, 138, .10) !important; border-color: rgba(240, 160, 138, .28) !important; }
html.dark #calculatorForm .ring-gray-200,
html.dark #calculatorForm .ring-gray-200\/50 { --tw-ring-color: var(--dark-border) !important; }

html.dark #view-history input,
html.dark #view-history select {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #view-history input::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #historyTable,
html.dark #historyTable thead,
html.dark #historyTable thead tr,
html.dark #historyTable th {
    background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border) !important;
}
html.dark #historyTable,
html.dark #historyTable tbody,
html.dark #historyTable tr,
html.dark #historyTable td { border-color: var(--dark-border-soft) !important; }
html.dark #historyContainer,
html.dark #historyScrollContainer { border-color: transparent !important; box-shadow: none !important; }
html.dark #historyTable { border: 0 !important; box-shadow: none !important; }
html.dark #historyTable tbody tr,
html.dark #historyTable tbody tr td { background-color: var(--dark-card) !important; color: var(--dark-text-secondary) !important; }
html.dark #historyTable tbody tr:nth-child(even) td { background-color: rgba(35, 40, 46, .86) !important; }
html.dark #historyTable tbody tr:hover td { background-color: var(--dark-elevated) !important; }
html.dark #historyTable .history-action-btn,
html.dark #historyTable .history-action-menu-trigger,
html.dark #historyTable .history-actions-wrap button {
    background: var(--dark-elevated) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border) !important;
    box-shadow: none !important;
}
html.dark #historyTable .history-action-btn:hover,
html.dark #historyTable .history-actions-wrap button:hover { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; border-color: var(--dark-primary) !important; }
/* Section 3: Recovery & Maintenance — dark safe */
html.dark #recoverySection { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; box-shadow: var(--dark-shadow-1) !important; }
html.dark #recoverySection h4 { color: var(--dark-warning) !important; }
html.dark #recoverySection p { color: var(--dark-text-secondary) !important; }
html.dark #recoverySection button { background: var(--dark-card) !important; border-color: var(--dark-border) !important; box-shadow: none !important; }
html.dark #recoverySection button.text-red-600 { color: var(--dark-error) !important; border-color: rgba(244,154,148,0.35) !important; }
html.dark #recoverySection button.text-red-600:hover { background: rgba(244,154,148,0.12) !important; }
html.dark #recoverySection button.text-orange-600 { color: var(--dark-accent) !important; border-color: rgba(240,160,138,0.35) !important; }
html.dark #recoverySection button.text-orange-600:hover { background: rgba(240,160,138,0.12) !important; }
html.dark #recoverySection button.text-amber-700 { color: var(--dark-warning) !important; border-color: rgba(240,214,143,0.35) !important; background: rgba(240,214,143,0.10) !important; }
html.dark #recoverySection button.text-amber-700:hover { background: rgba(240,214,143,0.16) !important; }
html.dark #recoverySection button.text-coral-dark,
html.dark #recoverySection button[class*="text-coral"] { color: var(--dark-accent) !important; border-color: rgba(240,160,138,0.30) !important; background: rgba(240,160,138,0.10) !important; }
html.dark #recoverySection button.text-indigo-600 { color: #a5b4fc !important; border-color: rgba(165,180,252,0.30) !important; }
html.dark #recoverySection button.text-indigo-600:hover { background: rgba(165,180,252,0.10) !important; }
html.dark #recoverySection #binCountBadge { background: rgba(240,214,143,0.20) !important; color: var(--dark-warning) !important; }

/* New Client Profile Modal (#editHistoryModal) — dark safe */
html.dark #editHistoryModal > div { background: var(--dark-card) !important; border-color: var(--dark-border) !important; }
html.dark #editHistoryModal .bg-gray-50\/80,
html.dark #editHistoryModal .bg-gray-50,
html.dark #editHistoryModal .bg-white { background: var(--dark-card) !important; border-color: var(--dark-border-soft) !important; }
html.dark #editHistoryModal .bg-white\/70,
html.dark #editHistoryModal .bg-white\/80 { background: var(--dark-elevated) !important; }
html.dark #editHistoryModal input,
html.dark #editHistoryModal select,
html.dark #editHistoryModal textarea { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; caret-color: var(--dark-primary); }
html.dark #editHistoryModal input::placeholder,
html.dark #editHistoryModal textarea::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #editHistoryModal input:focus,
html.dark #editHistoryModal select:focus,
html.dark #editHistoryModal textarea:focus { background: var(--dark-input) !important; border-color: var(--dark-focus) !important; box-shadow: 0 0 0 3px rgba(195,231,167,0.18) !important; }
html.dark #editHistoryModal label { color: var(--dark-text-muted) !important; }
html.dark #editHistoryModal h4 { color: var(--dark-text) !important; }
html.dark #editHistoryModal .text-sage-dark { color: var(--dark-primary) !important; }
html.dark #editHistoryModal .text-coral-dark { color: var(--dark-accent) !important; }
html.dark #editHistoryModal .border-sage\/10,
html.dark #editHistoryModal .border-coral\/10,
html.dark #editHistoryModal .border-sky\/10,
html.dark #editHistoryModal .border-gray-100 { border-color: var(--dark-border-soft) !important; }
html.dark #editHistoryModal .bg-sage-light\/20 { background: rgba(168,204,143,0.10) !important; }
html.dark #editHistoryModal .bg-sky-light\/10 { background: rgba(155,201,217,0.10) !important; }
html.dark #editHistoryModal .bg-coral-light\/10 { background: rgba(240,160,138,0.10) !important; }
html.dark #editHistoryModal #editFamilyClusterContainer { background: rgba(155,201,217,0.12) !important; }
html.dark #editHistoryModal .close,
html.dark #editHistoryModal button.bg-white { background: var(--dark-card) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #editHistoryModal .close:hover,
html.dark #editHistoryModal button.bg-white:hover { background: var(--dark-elevated) !important; color: var(--dark-text) !important; }
html.dark #editHistoryModal #editReferredBySuggestions { background: var(--dark-popover) !important; border-color: var(--dark-border) !important; }
html.dark #editHistoryModal .custom-scrollbar::-webkit-scrollbar-thumb { background: var(--dark-border) !important; }

html.dark #historySortMenu,
html.dark #historyRowActionMenu { background: var(--dark-popover) !important; border-color: var(--dark-border) !important; }
html.dark .history-summary-card,
html.dark .history-filter-bar,
html.dark #historyStickyBar > div { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; }
html.dark #historyStickyBar { background: transparent !important; border-color: transparent !important; backdrop-filter: none !important; box-shadow: none !important; }
html.dark #historyStickyBar input { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark #historyStickyBar .bg-gray-50,
html.dark #historyStickyBar [class*="bg-gray-50"],
html.dark #historyStickyBar .bg-gray-100,
html.dark #historyStickyBar [class*="bg-gray-100"] { background: var(--dark-elevated) !important; border-color: var(--dark-border) !important; }
html.dark #historyStickyBar .bg-white,
html.dark #historyStickyBar [class*="bg-white"] { background: var(--dark-card) !important; border-color: var(--dark-border) !important; color: var(--dark-text-secondary) !important; }
html.dark .history-filter-bar button,
html.dark #historyStickyBar [data-history-filter],
html.dark #historyStickyBar [data-history-sort],
html.dark #historyStickyBar [data-history-density],
html.dark .history-filter-bar-mobile [data-history-filter],
html.dark .history-filter-bar-mobile [data-history-sort],
html.dark .history-filter-bar-mobile [data-history-density] { color: var(--dark-text-secondary) !important; }
html.dark .history-filter-bar button:hover,
html.dark #historyStickyBar [data-history-filter]:hover,
html.dark #historyStickyBar [data-history-sort]:hover,
html.dark #historyStickyBar [data-history-density]:hover,
html.dark .history-filter-bar-mobile [data-history-filter]:hover,
html.dark .history-filter-bar-mobile [data-history-sort]:hover { background: var(--dark-elevated) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark .history-filter-bar button.active,
html.dark #historyStickyBar [data-history-filter].active,
html.dark #historyStickyBar [data-history-sort].active,
html.dark #historyStickyBar [data-history-density].active,
html.dark .history-filter-bar-mobile [data-history-filter].active,
html.dark .history-filter-bar-mobile [data-history-sort].active { background: rgba(168, 204, 143, .16) !important; color: var(--dark-primary) !important; border-color: rgba(168, 204, 143, .36) !important; }
html.dark #historyStickyBar #historyViewToggleBtn,
html.dark #historyStickyBar #historyDensityToggleBtn { background: var(--dark-card) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #historyStickyBar #historyViewToggleBtn:hover,
html.dark #historyStickyBar #historyDensityToggleBtn:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; }
html.dark #historyStickyBar #historyViewToggleBtn[aria-pressed="true"],
html.dark #historyStickyBar #historyDensityToggleBtn[aria-pressed="true"] { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; border-color: transparent !important; }

html.dark #pipeline-search-container > div,
html.dark #pipeline-search-container input,
html.dark #pipeline-search-container select,
html.dark #pipelineFilterType {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #pipeline-search-container > div { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark #pipeline-search-container input { background: transparent !important; }
html.dark #pipeline-search-container select option { background: var(--dark-popover); color: var(--dark-text); }
html.dark #pipeline-board,
html.dark .pipeline-column-body { background: linear-gradient(180deg, rgba(35, 40, 46, .94), rgba(27, 31, 35, .98)) !important; }
html.dark .pipeline-column-head,
html.dark .pipeline-stage-inquiry .pipeline-column-head,
html.dark .pipeline-stage-scheduled .pipeline-column-head,
html.dark .pipeline-stage-progress .pipeline-column-head,
html.dark .pipeline-stage-completed .pipeline-column-head {
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark .pipeline-column-count { background: rgba(20, 22, 24, .56) !important; border-color: var(--dark-border) !important; color: var(--dark-text) !important; }
html.dark .pipeline-action-btn,
html.dark .pipeline-column-action { background: rgba(35, 40, 46, .88) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark .pipeline-action-btn:hover,
html.dark .pipeline-column-action:hover { background: rgba(168, 204, 143, .16) !important; color: var(--dark-primary) !important; }

/* Intelligence Matrix */
html.dark #view-intelligence #section-intel-patterns > .grid > div,
html.dark #view-intelligence #section-intel-patterns .lg\:col-span-2 > div,
html.dark #view-intelligence #section-intel-patterns .flex.flex-col.gap-4 > div {
    background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}
html.dark #view-intelligence #user-filter-lp,
html.dark #view-intelligence #user-filter-category,
html.dark #view-intelligence #section-intel-patterns select {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #view-intelligence #section-intel-patterns > .grid > div:first-child .flex.bg-gray-50,
html.dark #view-intelligence #section-intel-patterns .flex.bg-gray-50.rounded-lg { background: var(--dark-surface) !important; border-color: var(--dark-border) !important; }
html.dark #view-intelligence #section-intel-patterns .flex.bg-gray-50 button { color: var(--dark-text-secondary) !important; }
html.dark #view-intelligence #section-intel-patterns .flex.bg-gray-50 button.active,
html.dark #view-intelligence #section-intel-patterns .flex.bg-gray-50 button.bg-sage { color: var(--dark-inverse) !important; background: var(--dark-primary) !important; }
html.dark #view-intelligence #section-intel-patterns > .grid > div:nth-child(2) > div:first-child,
html.dark #view-intelligence #section-intel-patterns > .grid > div:nth-child(2) > div:first-child > div { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; }
html.dark #view-intelligence #section-intel-patterns table,
html.dark #view-intelligence #section-intel-patterns thead,
html.dark #view-intelligence #section-intel-patterns thead tr,
html.dark #view-intelligence #section-intel-patterns th { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #view-intelligence #user-intel-body tr,
html.dark #view-intelligence #user-intel-body td { background: var(--dark-card) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border-soft) !important; }
html.dark #view-intelligence #user-intel-body tr:hover td { background: var(--dark-elevated) !important; }
html.dark #view-intelligence #user-insights-body { background: var(--dark-card) !important; color: var(--dark-text-secondary) !important; }
html.dark #view-intelligence #user-insights-body > * { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; color: var(--dark-text-secondary) !important; }
html.dark #view-intelligence #user-insights-body strong,
html.dark #view-intelligence #user-insights-body h4,
html.dark #view-intelligence #user-insights-body h5 { color: var(--dark-text) !important; }

/* Formula Bank search and quick calculators */
html.dark #view-formulabank .fb-search-input,
html.dark #view-formulabank .fb-calc-input { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark #view-formulabank .fb-search-input::placeholder,
html.dark #view-formulabank .fb-calc-input::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #view-formulabank .relative:has(> .fb-search-input) > i { color: var(--dark-text-muted) !important; }
html.dark #view-formulabank .fb-view-toggle-btn,
html.dark #view-formulabank .fb-search-input ~ div button { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #view-formulabank .fb-view-toggle-btn:hover,
html.dark #view-formulabank .fb-search-input ~ div button:hover { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; }
html.dark #view-formulabank .fb-bento-card .fb-icon-wrap,
html.dark #view-formulabank .fb-bento-icon,
html.dark #view-formulabank .fb-cat-icon-wrap { background: linear-gradient(145deg, rgba(168, 204, 143, .22), rgba(35, 40, 46, .90)) !important; border-color: var(--dark-border) !important; color: var(--dark-primary) !important; }
html.dark #view-formulabank .fb-calc-input:focus { border-color: var(--dark-focus) !important; box-shadow: 0 0 0 2px rgba(195, 231, 167, .22) !important; }
html.dark #view-formulabank .fb-calc-result,
html.dark #view-formulabank .fb-calc-result-mini { background: linear-gradient(145deg, var(--dark-surface), var(--dark-elevated)) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }

/* Native selects and every shared custom dropdown. */
html.dark select,
html.dark select option,
html.dark select optgroup { background-color: var(--dark-input) !important; color: var(--dark-text) !important; }
html.dark .smart-dropdown,
html.dark [id$="Dropdown"],
html.dark [id$="dropdown"],
html.dark [id*="Suggestions"],
html.dark [id*="suggestions"] { background: var(--dark-popover) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; box-shadow: var(--dark-shadow-3) !important; }
html.dark .smart-dropdown-item,
html.dark [id$="Dropdown"] button,
html.dark [id$="dropdown"] button { color: var(--dark-text-secondary) !important; border-color: var(--dark-border-soft) !important; }
html.dark .smart-dropdown-item:hover,
html.dark .smart-dropdown-item.selected,
html.dark [id$="Dropdown"] button:hover,
html.dark [id$="dropdown"] button:hover { background: var(--dark-elevated) !important; color: var(--dark-text) !important; }
html.dark .smart-dropdown::-webkit-scrollbar-track { background: var(--dark-surface) !important; }
html.dark .smart-dropdown::-webkit-scrollbar-thumb { background: var(--dark-border) !important; }
html.dark .wa-preset-card { background: var(--dark-card) !important; border-color: var(--dark-border) !important; }
html.dark .wa-preset-card:hover { border-color: rgba(168, 204, 143, 0.4) !important; }
html.dark .wa-preset-card span { color: var(--dark-text) !important; }
html.dark .wa-preset-card p { color: var(--dark-text-secondary) !important; }
html.dark #wa-template-menu { background: var(--dark-card) !important; border-color: var(--dark-border) !important; }

/* Account Dropdown & Account Center — dark mode */
html.dark .ac-row { color: var(--dark-text-secondary) !important; }
html.dark .ac-row:hover { background: var(--dark-elevated) !important; color: var(--dark-text) !important; }
html.dark .ac-row.danger { color: #e88d78 !important; }
html.dark .ac-row.danger:hover { background: rgba(232, 141, 120, 0.12) !important; }
html.dark .ac-tab { color: var(--dark-text-disabled) !important; }
html.dark .ac-tab.active { color: var(--dark-text) !important; border-bottom-color: var(--dark-primary) !important; }
html.dark .ac-tab:hover:not(.active) { color: var(--dark-text-secondary) !important; }
html.dark .ac-divider { border-color: var(--dark-border-soft) !important; }
html.dark .ac-badge { background: rgba(232, 141, 120, 0.15) !important; color: #e88d78 !important; }
html.dark .ac-toggle .slider { background: var(--dark-input) !important; }
html.dark .ac-toggle .slider::before { background: var(--dark-text-secondary) !important; }
html.dark .ac-toggle input:checked + .slider { background: var(--dark-primary) !important; }
html.dark .ac-toggle input:checked + .slider::before { background: white !important; }
html.dark .intake-link-row { background: var(--dark-surface) !important; border-color: var(--dark-border) !important; }
html.dark .intake-link-row .link-area { color: var(--dark-text-secondary) !important; }
html.dark .intake-link-row .link-area:hover { background: var(--dark-elevated) !important; }
html.dark .intake-link-row .copy-btn { background: #4a6b4f !important; color: white !important; }
html.dark .intake-link-row .share-btn { background: rgba(61, 110, 130, 0.3) !important; color: #7ec8e3 !important; }
html.dark .intake-link-row .share-btn:hover { background: rgba(91, 143, 168, 0.4) !important; color: white !important; }
html.dark #accountDropdown .border-b,
html.dark #accountDropdown .border-t,
html.dark #accountCenterModal .border-b,
html.dark #accountCenterModal .border-t { border-color: var(--dark-border-soft) !important; }
html.dark #accountCenterModal > div:first-child { background: var(--dark-card) !important; }
html.dark #accountCenterModal .text-gray-800 { color: var(--dark-text) !important; }
html.dark #accountCenterModal .text-gray-500,
html.dark #accountCenterModal .text-gray-400 { color: var(--dark-text-secondary) !important; }
html.dark #accountCenterModal .hover\:bg-gray-200:hover { background: var(--dark-elevated) !important; }
html.dark #accountCenterModal .bg-sage-light { background: rgba(151, 184, 129, 0.15) !important; }
html.dark #accountCenterModal .text-sage-dark { color: var(--dark-primary) !important; }
html.dark #accountCenterModal input,
html.dark #accountCenterModal select,
html.dark #accountCenterModal textarea {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #accountCenterModal .bg-gray-50 { background: var(--dark-surface) !important; }
html.dark .wa-menu-item { color: var(--dark-text-secondary) !important; }
html.dark .wa-menu-item:hover { background: var(--dark-elevated) !important; }
html.dark .wa-menu-default { color: var(--dark-text) !important; border-color: var(--dark-border-soft) !important; }
html.dark .wa-menu-icon { background: var(--dark-surface) !important; }
html.dark #tribe-input-root { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark #tribe-root-header,
html.dark #tribe-map-wrapper { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; }

/* Partnership Matrix empty state: the 1 > 2 > 3 onboarding cards. */
html.dark #synergy-empty-state,
html.dark #synergy-empty-state > div,
html.dark #synergy-empty-state .bg-sage-light\/30,
html.dark #synergy-empty-state .bg-coral-light\/30,
html.dark #synergy-empty-state .bg-gradient-to-br { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; color: var(--dark-text-secondary) !important; }
html.dark #synergy-empty-state h3,
html.dark #synergy-empty-state strong,
html.dark #synergy-empty-state .text-gray-800 { color: var(--dark-text) !important; }
html.dark #synergy-empty-state .text-gray-500,
html.dark #synergy-empty-state .text-gray-600 { color: var(--dark-text-secondary) !important; }
html.dark #synergy-empty-state .bg-sage-light\/30 { background: rgba(168, 204, 143, .14) !important; }
html.dark #synergy-empty-state .bg-coral-light\/30 { background: rgba(240, 160, 138, .14) !important; }
html.dark #synergy-empty-state input { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }

/* Pipeline stage identity: Inquiry and Scheduled remain distinct, not light. */
html.dark .pipeline-stage-inquiry .pipeline-column-head { background: linear-gradient(180deg, rgba(196, 181, 212, .28), rgba(35, 40, 46, .96)) !important; }
html.dark .pipeline-stage-scheduled .pipeline-column-head { background: linear-gradient(180deg, rgba(155, 201, 217, .28), rgba(35, 40, 46, .96)) !important; }

/* Runtime pipeline columns use IDs — colhead-* for headers, col-* for bodies. */
html.dark #colhead-Inquiry,
html.dark #colhead-Scheduled,
html.dark #colhead-InProgress,
html.dark #colhead-Completed {
    border-color: var(--dark-border) !important;
}
html.dark #colhead-Inquiry { background: linear-gradient(180deg, rgba(196, 181, 212, .30), rgba(35, 40, 46, .96)) !important; }
html.dark #colhead-Scheduled { background: linear-gradient(180deg, rgba(155, 201, 217, .30), rgba(35, 40, 46, .96)) !important; }
html.dark #colhead-InProgress { background: linear-gradient(180deg, rgba(240, 214, 143, .24), rgba(35, 40, 46, .96)) !important; }
html.dark #colhead-Completed { background: linear-gradient(180deg, rgba(168, 211, 154, .26), rgba(35, 40, 46, .96)) !important; }
html.dark #colhead-Inquiry h4,
html.dark #colhead-Scheduled h4,
html.dark #colhead-InProgress h4,
html.dark #colhead-Completed h4 { color: var(--dark-text) !important; }
html.dark #colhead-Inquiry button,
html.dark #colhead-Scheduled button,
html.dark #colhead-InProgress button,
html.dark #colhead-Completed button { color: var(--dark-text-secondary) !important; }
html.dark #count-Inquiry,
html.dark #count-Scheduled,
html.dark #count-InProgress,
html.dark #count-Completed { background: rgba(20, 22, 24, .58) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark #rev-Inquiry,
html.dark #rev-Scheduled,
html.dark #rev-InProgress,
html.dark #rev-Completed { color: var(--dark-text-secondary) !important; }

/* Name Analysis toggles, input, and tool panels. */
html.dark #section-analysis-name .flex.bg-gray-50,
html.dark #section-analysis-name #tool-name-compare,
html.dark #section-analysis-name #tool-target-tuner,
html.dark #section-analysis-name #tool-name-optimizer,
html.dark #section-analysis-name #tool-name-correction {
    background: var(--dark-card) !important;
    border-color: var(--dark-border) !important;
}
html.dark #section-analysis-name .aw-seg-btn { background: transparent !important; color: var(--dark-text-secondary) !important; border-color: transparent !important; }
html.dark #section-analysis-name .aw-seg-btn.is-active { background: rgba(168, 204, 143, .18) !important; color: var(--dark-primary) !important; border-color: rgba(168, 204, 143, .38) !important; }
html.dark #section-analysis-name .aw-seg-btn:hover { background: var(--dark-elevated) !important; color: var(--dark-primary) !important; }
html.dark #section-analysis-name input,
html.dark #section-analysis-name select,
html.dark #section-analysis-name textarea,
html.dark #analysisNameInput,
html.dark #compareNameA,
html.dark #compareNameB,
html.dark #tunerBaseName,
html.dark #tunerTargetRoot {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #section-analysis-name input::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #section-analysis-name #btn-tool-compare,
html.dark #section-analysis-name #btn-tool-optimizer,
html.dark #section-analysis-name #btn-tool-correction,
html.dark #section-analysis-name #correction-live-total button { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #section-analysis-name #btn-tool-compare:hover,
html.dark #section-analysis-name #btn-tool-optimizer:hover,
html.dark #section-analysis-name #btn-tool-correction:hover,
html.dark #section-analysis-name #correction-live-total button:hover { background: rgba(168, 204, 143, .16) !important; color: var(--dark-primary) !important; }
html.dark #view-pipeline .bg-sky-100,
html.dark #view-pipeline .bg-sky-50 { background: rgba(155, 201, 217, .18) !important; color: var(--dark-info) !important; border-color: rgba(155, 201, 217, .34) !important; }
html.dark #view-pipeline .bg-emerald-100,
html.dark #view-pipeline .bg-emerald-50 { background: rgba(168, 211, 154, .18) !important; color: var(--dark-success) !important; border-color: rgba(168, 211, 154, .34) !important; }
html.dark #view-pipeline .text-sky-600 { color: var(--dark-info) !important; }
html.dark #view-pipeline .text-emerald-600 { color: var(--dark-success) !important; }

/* Partnership Matrix dropdown fields and selector surface. */
html.dark #synergy-root-container > div:first-child,
html.dark #synergy-root-container > div:nth-child(2) { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; }
html.dark #synergy-input-a,
html.dark #synergy-input-b { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark #synergy-input-a::placeholder,
html.dark #synergy-input-b::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #synergy-profile-a-card { background: linear-gradient(145deg, rgba(168, 204, 143, .16), var(--dark-card)) !important; border-color: rgba(168, 204, 143, .34) !important; }
html.dark #synergy-root-container .bg-gray-50 { background: var(--dark-surface) !important; border-color: var(--dark-border) !important; }

/* Revenue Analytics year selector. */
html.dark #revenue-header-actions select,
html.dark #revenue-header-actions select option { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark #revenue-header-actions select:focus { border-color: var(--dark-focus) !important; box-shadow: 0 0 0 3px rgba(195, 231, 167, .20) !important; }

/* Intelligence title bars. */
html.dark #view-intelligence #section-intel-patterns .lg\:col-span-2 > div > div:first-child,
html.dark #view-intelligence #section-intel-patterns .flex.flex-col.gap-4 > div:last-child > div:first-child {
    background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border) !important;
}
html.dark #view-intelligence #section-intel-patterns .lg\:col-span-2 > div > div:first-child h3,
html.dark #view-intelligence #section-intel-patterns .flex.flex-col.gap-4 > div:last-child > div:first-child h3 { color: var(--dark-text) !important; }

/* Section audit baseline: every view gets the same canvas, controls, and native menus. */
html.dark #view-morning,
html.dark #view-calculator,
html.dark #view-pipeline,
html.dark #view-revenue,
html.dark #view-analysis,
html.dark #view-history,
html.dark #view-loshu,
html.dark #view-intelligence,
html.dark #view-synergy,
html.dark #view-tribe,
html.dark #view-formulabank,
html.dark #view-settings { color: var(--dark-text) !important; }

html.dark #view-revenue input,
html.dark #view-revenue select,
html.dark #view-analysis input,
html.dark #view-analysis select,
html.dark #view-analysis textarea,
html.dark #view-loshu input,
html.dark #view-loshu select,
html.dark #view-synergy input,
html.dark #view-synergy select,
html.dark #view-tribe input,
html.dark #view-tribe select,
html.dark #view-formulabank input,
html.dark #view-formulabank select,
html.dark #view-settings input,
html.dark #view-settings select,
html.dark #view-settings textarea {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark #view-revenue input::placeholder,
html.dark #view-analysis input::placeholder,
html.dark #view-analysis textarea::placeholder,
html.dark #view-loshu input::placeholder,
html.dark #view-synergy input::placeholder,
html.dark #view-tribe input::placeholder,
html.dark #view-formulabank input::placeholder,
html.dark #view-settings input::placeholder,
html.dark #view-settings textarea::placeholder { color: var(--dark-text-disabled) !important; }

html.dark #view-revenue .bg-white,
html.dark #view-analysis .bg-white,
html.dark #view-loshu .bg-white,
html.dark #view-intelligence .bg-white,
html.dark #view-synergy .bg-white,
html.dark #view-tribe .bg-white,
html.dark #view-formulabank .bg-white,
html.dark #view-settings .bg-white { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; border-color: var(--dark-border) !important; }

html.dark #view-synergy .synergy-type-btn:not(.bg-sage),
html.dark #view-synergy .syn-nav-btn:not(.active),
html.dark #view-synergy .bg-gray-100 { background: var(--dark-surface) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #view-synergy .synergy-type-btn.bg-sage,
html.dark #view-synergy .syn-nav-btn.active { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; }
html.dark #view-synergy [id^="syn-sec-"] { border-color: var(--dark-border) !important; }
html.dark #view-tribe [class*="tribe-bento"],
html.dark #view-tribe .tribe-view-btn { background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark #view-settings .peer + div,
html.dark #view-settings .ac-toggle .slider { background: var(--dark-surface) !important; border-color: var(--dark-border) !important; }
html.dark #view-settings .peer:checked + div,
html.dark #view-settings .ac-toggle input:checked + .slider { background: var(--dark-primary) !important; }
html.dark .cfg-nav-item:not(.active) { color: var(--dark-text-secondary) !important; }
html.dark .cfg-nav-item:not(.active):hover { background: var(--dark-elevated) !important; color: var(--dark-text) !important; }
html.dark .cfg-rail { background: var(--dark-card) !important; border-color: var(--dark-border) !important; }
html.dark #view-settings .bg-gray-50 { background: var(--dark-surface) !important; border-color: var(--dark-border-soft) !important; }
html.dark #view-settings .bg-sage\/5 { background: rgba(168,204,143,0.08) !important; border-color: rgba(168,204,143,0.15) !important; }
html.dark #view-settings .bg-coral-light\/20 { background: rgba(244,114,94,0.08) !important; border-color: rgba(244,114,94,0.15) !important; }
html.dark #view-settings .bg-orange-50\/60 { background: rgba(249,115,22,0.08) !important; border-color: rgba(249,115,22,0.15) !important; }
html.dark #view-settings .bg-blue-50\/50 { background: rgba(59,130,246,0.08) !important; border-color: rgba(59,130,246,0.15) !important; }

/* Mobile bottom nav & capsule bar */
html.dark #mobile-bottom-nav > div { background: var(--dark-surface) !important; }
html.dark .app-shell-mobile-nav .capsule-nav { background: var(--dark-surface) !important; }
html.dark .app-shell-mobile-nav .capsule-pill { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-surface)) !important; }

/* Command bar / omni search */
html.dark #command-bar-input,
html.dark #omni-search-input { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }

/* Mobile modal header bars */
html.dark .modal-content .border-b,
html.dark #authModal .border-b,
html.dark #editHistoryModal .border-b,
html.dark #quickEditModal .border-b,
html.dark #quickCalcModal .border-b,
html.dark #addClientPipelineModal .border-b,
html.dark #quickLoadModal .border-b { background: var(--dark-surface) !important; border-color: var(--dark-border-soft) !important; }
html.dark #quickLoadModal [id^="sort-"] { background: transparent !important; border-color: var(--dark-border) !important; color: var(--dark-text-secondary) !important; }
html.dark #quickLoadModal [id^="sort-"]:hover { background: var(--dark-elevated) !important; color: var(--dark-text) !important; border-color: var(--dark-primary) !important; }
html.dark #quickLoadModal [id^="sort-"].active,
html.dark #quickLoadModal [id^="sort-"][class*="bg-sage"] { background: rgba(168,204,143,0.18) !important; color: var(--dark-primary) !important; border-color: rgba(168,204,143,0.40) !important; }
html.dark #quickLoadModal #quickLoadResults { color: var(--dark-text-secondary) !important; }
/* Quick Load modal — searchbox + container dark safe */
html.dark #quickLoadModal > div { background: var(--dark-card) !important; border-color: var(--dark-border) !important; }
html.dark #quickLoadModal .bg-gray-50\/80,
html.dark #quickLoadModal .bg-white,
html.dark #quickLoadModal [class*="bg-white"] { background: var(--dark-card) !important; border-color: var(--dark-border-soft) !important; }
html.dark #quickLoadModal #quickLoadSearchInput { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; caret-color: var(--dark-primary); }
html.dark #quickLoadModal #quickLoadSearchInput::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #quickLoadModal #quickLoadSearchInput:focus { background: var(--dark-input) !important; border-color: var(--dark-focus) !important; box-shadow: 0 0 0 3px rgba(195,231,167,0.18) !important; }
html.dark #quickLoadModal #quickLoadSearchInput + i,
html.dark #quickLoadModal .relative i[data-lucide="scan-line"] { color: var(--dark-text-muted) !important; }
html.dark #quickLoadModal #quickLoadClearBtn { color: var(--dark-text-muted) !important; }
html.dark #quickLoadModal #quickLoadClearBtn:hover { color: var(--dark-text) !important; }

/* Modal glass shine line — hide in dark */
html.dark .modal-content::before { background: transparent !important; }
html.dark .cfg-nav-item.active { background: rgba(168, 204, 143, 0.14) !important; color: var(--dark-primary) !important; }
/* Essence Chart — final dark overrides (high specificity, covers light !important) */
html.dark #essenceChartHeader,
html.dark #essenceChartHeader.essence-chart-shell { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-card)) !important; background-color: var(--dark-card) !important; border-color: var(--dark-border-soft) !important; }
html.dark #essenceChartHeader .essence-chart-topbar,
html.dark .essence-chart-topbar { background: linear-gradient(180deg, var(--dark-elevated), var(--dark-card)) !important; background-color: var(--dark-elevated) !important; border-color: var(--dark-border-soft) !important; }
html.dark #essenceChartHeader .essence-chart-topbar > div:first-child h3 { color: var(--dark-text) !important; }
html.dark #essenceChartHeader .essence-chart-topbar > div:first-child p { color: var(--dark-text-muted) !important; }
html.dark #quickNavContainer .mr-auto,
html.dark .essence-toolbar-client { background: rgba(35,40,46,.92) !important; border-color: var(--dark-border) !important; color: var(--dark-text) !important; }
html.dark #jumpToInput,
html.dark #jumpToInputMobile,
html.dark .essence-toolbar-input { background: transparent !important; background-color: transparent !important; color: var(--dark-text) !important; caret-color: var(--dark-primary) !important; }
html.dark #jumpToInput::placeholder,
html.dark #jumpToInputMobile::placeholder,
html.dark .essence-toolbar-input::placeholder { color: var(--dark-text-disabled) !important; }
html.dark .essence-toolbar-input-wrap,
html.dark #quickNavContainer .essence-toolbar-input-wrap,
html.dark #quickNavContainer > div > .flex.items-center.border { background: rgba(35,40,46,.92) !important; border-color: var(--dark-border) !important; box-shadow: none !important; }
html.dark .essence-toolbar-go,
html.dark #quickNavContainer .essence-toolbar-go,
html.dark #quickNavContainer > div > .flex.items-center.border button { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark .essence-toolbar-group,
html.dark #quickNavContainer .essence-toolbar-group { background: var(--dark-elevated) !important; border-color: var(--dark-border) !important; }
html.dark .essence-toolbar-chip { background: var(--dark-elevated) !important; color: var(--dark-text-secondary) !important; border-color: var(--dark-border) !important; }
html.dark .essence-toolbar-chip.bg-white,
html.dark .essence-toolbar-chip[class*="bg-white"] { background: var(--dark-card) !important; }
html.dark .essence-toolbar-chip.bg-sage,
html.dark .essence-toolbar-chip--active { background: var(--dark-primary) !important; color: var(--dark-inverse) !important; border-color: transparent !important; }
/* Topbar name pill: sage on light → white on dark for readability */
html.dark .essence-toolbar-client span.bg-sage-light,
html.dark .essence-toolbar-client span[class*="bg-sage-light"] { background: rgba(168,204,143,.22) !important; color: #fff !important; border-color: rgba(168,204,143,.38) !important; }
html.dark .essence-toolbar-client span.bg-sage-light.text-sage-dark,
html.dark .essence-toolbar-client span[class*="bg-sage-light"].text-sage-dark { color: #fff !important; }
html.dark .essence-toolbar-client span.text-gray-300 { color: #fff !important; }
/* Active client chip — dark mode safe (was bg-sage-light/60 text-sage-dark) */
html.dark #active-client-chip,
html.dark #mobile-active-client-chip { background: rgba(168,204,143,.18) !important; border-color: rgba(168,204,143,.32) !important; color: #fff !important; box-shadow: var(--dark-shadow-1) !important; }
html.dark #active-client-chip .bg-sage,
html.dark #mobile-active-client-chip .bg-sage { background: #fff !important; }
html.dark #active-client-chip [class*="bg-sage/20"],
html.dark #mobile-active-client-chip [class*="bg-sage/20"] { background: rgba(255,255,255,.22) !important; }
html.dark #active-client-chip button:hover,
html.dark #mobile-active-client-chip button:hover { background: rgba(255,255,255,.10) !important; color: #fff !important; }

/* ==========================================================================
   MODALS + PIPELINE + TAGS: Comprehensive dark safety net
   Covers all light-mode backgrounds, opacity variants, and color tints
   that Tailwind inline dark: variants miss (especially JS-generated content).
   ========================================================================== */

/* ── Missing opacity variants → elevated surface ── */
html.dark .bg-white\/40,
html.dark .bg-white\/50,
html.dark .bg-white\/60,
html.dark .bg-sage-light\/10,
html.dark .bg-sage-light\/20,
html.dark .bg-sage-light\/30,
html.dark .bg-coral-light\/30,
html.dark .bg-gray-50\/50 { background-color: var(--dark-elevated) !important; }

/* ── Missing color tints → card surface ── */
html.dark .bg-sage-light,
html.dark .bg-coral-light,
html.dark .bg-ocean-light,
html.dark .bg-sun-light,
html.dark .bg-lavender-light,
html.dark .bg-orange-50,
html.dark .bg-orange-100,
html.dark .bg-blue-50,
html.dark .bg-blue-100,
html.dark .bg-red-50,
html.dark .bg-red-100,
html.dark .bg-green-50,
html.dark .bg-green-100,
html.dark .bg-emerald-50,
html.dark .bg-emerald-100,
html.dark .bg-amber-50,
html.dark .bg-amber-100,
html.dark .bg-sky-50,
html.dark .bg-sky-100,
html.dark .bg-pink-100,
html.dark .bg-indigo-50,
html.dark .bg-purple-900\/30,
html.dark .bg-blue-900\/30,
html.dark .bg-red-900\/30,
html.dark .bg-green-900\/30,
html.dark .bg-emerald-900\/30,
html.dark .bg-amber-900\/30,
html.dark .bg-yellow-900\/30,
html.dark .bg-orange-900\/30 {
    background-color: var(--dark-card) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border-soft) !important;
}

/* ── Update Reading Modal (#quickEditModal) ── */
html.dark #quickEditModal .bg-sage-light,
html.dark #quickEditModal [class*="bg-sage-light"] {
    background: rgba(168,204,143,.18) !important;
    color: var(--dark-primary) !important;
}
html.dark #quickEditModal .bg-white,
html.dark #quickEditModal [class*="bg-white"] {
    background-color: var(--dark-card) !important;
}
html.dark #quickEditModal .bg-gray-50,
html.dark #quickEditModal [class*="bg-gray-50"] {
    background-color: var(--dark-elevated) !important;
}
html.dark #quickEditModal .border-gray-100,
html.dark #quickEditModal .border-gray-200,
html.dark #quickEditModal [class*="border-gray-1"],
html.dark #quickEditModal [class*="border-gray-2"] {
    border-color: var(--dark-border-soft) !important;
}
html.dark #quickEditModal .text-gray-800,
html.dark #quickEditModal .text-gray-700 {
    color: var(--dark-text) !important;
}
html.dark #quickEditModal .text-gray-400,
html.dark #quickEditModal .text-gray-500 {
    color: var(--dark-text-muted) !important;
}
html.dark #quickEditModal .text-sage-dark {
    color: var(--dark-primary) !important;
}
html.dark #quickEditModal .text-coral-dark {
    color: var(--dark-accent) !important;
}
/* Status boxes active states */
html.dark #quickEditModal .bg-lavender-light { background: rgba(196,181,212,.22) !important; color: #dfcceb !important; }
html.dark #quickEditModal .bg-blue-50 { background: rgba(59,130,246,.22) !important; color: #93c5fd !important; }
html.dark #quickEditModal .bg-orange-50 { background: rgba(249,115,22,.22) !important; color: #fdba74 !important; }
html.dark #quickEditModal .bg-sage-light { background: rgba(168,204,143,.22) !important; color: var(--dark-primary) !important; }
html.dark #quickEditModal .bg-green-50 { background: rgba(34,197,94,.22) !important; color: #86efac !important; }
/* Date/time shortcuts + time pills */
html.dark #quickEditModal .bg-emerald-50 { background: rgba(16,185,129,.18) !important; color: #6ee7b7 !important; border-color: rgba(16,185,129,.30) !important; }
html.dark #qe-time-shortcuts .bg-white,
html.dark #qe-time-shortcuts [class*="bg-white"],
html.dark #qe-fee-shortcuts .bg-white,
html.dark #qe-fee-shortcuts [class*="bg-white"] {
    background-color: var(--dark-card) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border-soft) !important;
}

/* ── Client Intelligence Modal (#clientIntelligenceModal) ── */
html.dark #clientIntelligenceModal .bg-white,
html.dark #clientIntelligenceModal [class*="bg-white"] {
    background-color: var(--dark-card) !important;
}
html.dark #clientIntelligenceModal .bg-gray-50\/50,
html.dark #clientIntelligenceModal .bg-gray-50,
html.dark #clientIntelligenceModal [class*="bg-gray-50"] {
    background-color: var(--dark-elevated) !important;
}
html.dark #clientIntelligenceModal .bg-sage-light\/20,
html.dark #clientIntelligenceModal [class*="bg-sage-light"] {
    background: rgba(168,204,143,.14) !important;
    border-color: rgba(168,204,143,.20) !important;
    color: var(--dark-text) !important;
}
html.dark #clientIntelligenceModal .bg-orange-50,
html.dark #clientIntelligenceModal .bg-orange-100,
html.dark #clientIntelligenceModal [class*="bg-orange-"] {
    background: rgba(249,115,22,.18) !important;
    color: #fdba74 !important;
    border-color: rgba(249,115,22,.30) !important;
}
html.dark #clientIntelligenceModal .bg-gray-100,
html.dark #clientIntelligenceModal [class*="bg-gray-100"] {
    background: var(--dark-elevated) !important;
    color: var(--dark-text-secondary) !important;
}
html.dark #clientIntelligenceModal .text-gray-700,
html.dark #clientIntelligenceModal .text-gray-800 {
    color: var(--dark-text) !important;
}
html.dark #clientIntelligenceModal .text-gray-400,
html.dark #clientIntelligenceModal .text-gray-500 {
    color: var(--dark-text-muted) !important;
}
html.dark #clientIntelligenceModal .border-gray-100,
html.dark #clientIntelligenceModal .border-gray-200 {
    border-color: var(--dark-border-soft) !important;
}
/* CI tabs */
html.dark #clientIntelligenceModal .flex.bg-gray-50 button,
html.dark #clientIntelligenceModal button[class*="bg-white"] {
    background: var(--dark-card) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border-soft) !important;
}
/* CI Referral / Heritage / Link Relative buttons */
html.dark #ci-btn-referrals,
html.dark #ci-btn-family,
html.dark .bg-sage-light.text-sage-dark,
html.dark .bg-orange-50.text-orange-600,
html.dark [class*="bg-sage-light"].text-sage-dark,
html.dark [class*="bg-orange-50"].text-orange-600 {
    background: var(--dark-card) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border-soft) !important;
}
/* CI right column */
html.dark #ci-right-col { background: var(--dark-surface) !important; }
html.dark #ciFamilyIntelContainer,
html.dark #ciReferralIntelContainer { background: var(--dark-card) !important; }

/* ── Pipeline: Reading cards, badges, status pills ── */
html.dark .pipeline-col .draggable,
html.dark .pipeline-col .bg-white {
    background-color: var(--dark-card) !important;
    border-color: var(--dark-border-soft) !important;
    color: var(--dark-text) !important;
}
/* Pipeline NEW / INTAKE / DECEASED badges (from getRecordBadges in essence.js) */
html.dark [class*="bg-coral\/10"] {
    background: rgba(240,160,138,.16) !important;
    color: var(--dark-accent) !important;
    border-color: rgba(240,160,138,.28) !important;
}
html.dark .bg-blue-100.text-blue-600,
html.dark [class*="bg-blue-100"].text-blue-600 {
    background: rgba(59,130,246,.18) !important;
    color: #93c5fd !important;
    border-color: rgba(59,130,246,.30) !important;
}
html.dark .bg-slate-100.text-slate-500,
html.dark [class*="bg-slate-100"].text-slate-500 {
    background: var(--dark-elevated) !important;
    color: var(--dark-text-muted) !important;
    border-color: var(--dark-border-soft) !important;
}
html.dark .history-badge-birthday-today {
    background-color: rgba(240, 160, 138, 0.2) !important;
    color: var(--dark-accent) !important;
    border-color: rgba(240, 160, 138, 0.4) !important;
}
html.dark .history-badge-birthday-upcoming {
    background-color: rgba(245, 158, 11, 0.18) !important;
    color: #fcd34d !important;
    border-color: rgba(245, 158, 11, 0.35) !important;
}
/* Pipeline count badge */
html.dark .pipeline-col span.bg-white,
html.dark .pipeline-col span[class*="bg-white"] {
    background: var(--dark-card) !important;
    border-color: var(--dark-border-soft) !important;
}
/* Pipeline column headers */
html.dark .pipeline-col h4 { color: var(--dark-text) !important; }

/* ── Tag classes (from style_essence.css .tag-system / .tag-manual) ── */
html.dark .tag-system {
    background: rgba(196,181,212,.18) !important;
    color: #dfcceb !important;
    border-color: rgba(196,181,212,.30) !important;
}
html.dark .tag-manual {
    background: var(--dark-card) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border-soft) !important;
}

/* ==========================================================================
   Email workspace (#view-email) — dark safe.

   style_essence.css paints inputs/selects/textareas with a light `background`
   gradient (!important) and table headers with #f8fafc (!important). The generic
   html.dark input / th rules only set background-color, so the gradient image and
   the solid header colour survive. Use the `background` shorthand, scoped to the
   email view plus its portaled modal IDs, to win on both counts.
   ========================================================================== */
html.dark #view-email input,
html.dark #view-email select,
html.dark #view-email textarea,
html.dark #em-history-modal input,
html.dark #em-history-modal select,
html.dark #em-history-modal textarea,
html.dark #em-edit-modal input,
html.dark #em-edit-modal select,
html.dark #em-edit-modal textarea,
html.dark #em-preview-modal input,
html.dark #em-preview-modal select,
html.dark #em-preview-modal textarea,
html.dark #em-camp-modal input,
html.dark #em-camp-modal select,
html.dark #em-camp-modal textarea,
html.dark #em-reply-modal input,
html.dark #em-reply-modal select,
html.dark #em-reply-modal textarea {
    background: var(--dark-input) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
    box-shadow: none !important;
    caret-color: var(--dark-primary);
}
html.dark #view-email input::placeholder,
html.dark #view-email textarea::placeholder,
html.dark #em-history-modal input::placeholder,
html.dark #em-edit-modal input::placeholder,
html.dark #em-camp-modal input::placeholder,
html.dark #em-reply-modal input::placeholder,
html.dark #em-reply-modal textarea::placeholder { color: var(--dark-text-disabled) !important; }
html.dark #view-email input:focus,
html.dark #view-email select:focus,
html.dark #view-email textarea:focus,
html.dark #em-history-modal input:focus,
html.dark #em-history-modal select:focus,
html.dark #em-history-modal textarea:focus,
html.dark #em-edit-modal input:focus,
html.dark #em-edit-modal select:focus,
html.dark #em-edit-modal textarea:focus,
html.dark #em-preview-modal input:focus,
html.dark #em-preview-modal select:focus,
html.dark #em-preview-modal textarea:focus,
html.dark #em-camp-modal input:focus,
html.dark #em-camp-modal select:focus,
html.dark #em-camp-modal textarea:focus,
html.dark #em-reply-modal input:focus,
html.dark #em-reply-modal select:focus,
html.dark #em-reply-modal textarea:focus {
    border-color: var(--dark-focus) !important;
    box-shadow: 0 0 0 3px rgba(195, 231, 167, .22) !important;
}
html.dark #view-email select option,
html.dark #em-camp-modal select option,
html.dark #em-reply-modal select option { background-color: var(--dark-popover) !important; color: var(--dark-text) !important; }

/* Table headers + rows (recipients, replies, delivery log). */
html.dark #view-email thead,
html.dark #view-email thead tr,
html.dark #view-email thead th {
    background: var(--dark-surface) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border) !important;
}
html.dark #view-email tbody tr,
html.dark #view-email tbody td { border-color: var(--dark-border-soft) !important; }
html.dark #view-email tbody tr:hover td { background-color: var(--dark-elevated) !important; }
html.dark #view-email tr.bg-sage-light\/40,
html.dark #view-email .bg-sage-light\/40 { background-color: rgba(168, 204, 143, .14) !important; }

/* Light hover tints on row action buttons must not flash light in dark mode. */
html.dark #view-email .hover\:bg-blue-50:hover,
html.dark #view-email .hover\:bg-green-50:hover,
html.dark #view-email .hover\:bg-purple-50:hover,
html.dark #view-email .hover\:bg-orange-50:hover,
html.dark #view-email .hover\:bg-sage\/10:hover,
html.dark #view-email .hover\:bg-coral-light:hover,
html.dark #em-reply-modal .hover\:bg-coral-light:hover { background-color: var(--dark-elevated) !important; }

/* Scheduled-campaign status badges (bg-blue-50 / bg-amber-50 tints) need
   readable text — the generic text rules only remap gray/slate. */
html.dark #view-email .text-blue-700 { color: #93c5fd !important; }
html.dark #view-email .text-amber-700 { color: var(--dark-warning) !important; }

/* Account Center v2 (two-pane) */
html.dark #accountCenterModal {
    --acx-surface: var(--dark-card); --acx-surface-2: var(--dark-elevated); --acx-border: var(--dark-border);
    --acx-text: var(--dark-text-secondary); --acx-muted: var(--dark-text-secondary); --acx-head: var(--dark-text);
    --acx-sage-light: rgba(151, 184, 129, 0.15); --acx-sage: #97B881; --acx-sage-dark: var(--dark-primary); --acx-ok-text: #a9cf96;
    --acx-coral-light: rgba(232, 141, 120, 0.14); --acx-danger-text: #f0a898;
    --acx-sun-light: rgba(236, 212, 137, 0.14); --acx-warn-text: #ECD489;
    --acx-ocean-light: rgba(143, 184, 202, 0.14); --acx-info-text: #8FB8CA;
    --acx-lav-light: rgba(196, 181, 212, 0.14); --acx-lav-text: #c4b5d4;
}
html.dark .acx-field input { background: var(--dark-input) !important; color: var(--dark-text) !important; border-color: var(--dark-border) !important; }
html.dark .acx-field input:focus { border-color: var(--dark-primary) !important; }
html.dark .acx-btn.primary { color: #12161a; }

/* Client Records "More actions" menu */
html.dark .history-floating-menu { --history-table-border: var(--dark-border); }
html.dark .history-action-menu .ham-head { border-color: var(--dark-border-soft); }
html.dark .history-action-menu .ham-handle { background: var(--dark-border); }
html.dark .history-action-menu .ham-avatar { background: rgba(151, 184, 129, 0.15); color: var(--dark-primary); }
html.dark .history-action-menu .ham-name, html.dark .history-action-menu .ham-item, html.dark .history-action-menu .ham-tile { color: var(--dark-text); }
html.dark .history-action-menu .ham-meta, html.dark .history-action-menu .ham-item svg, html.dark .history-action-menu .ham-tile svg { color: var(--dark-text-secondary); }
html.dark .history-action-menu .ham-tile { border-color: var(--dark-border); }
html.dark .history-action-menu .ham-sep { background: var(--dark-border-soft); }
html.dark .history-action-menu .ham-item.danger, html.dark .history-action-menu .ham-item.danger svg { color: #f0a898; }
html.dark .history-action-menu .ham-item:hover, html.dark .history-action-menu .ham-item:focus-visible, html.dark .history-action-menu .ham-tile:hover, html.dark .history-action-menu .ham-tile:focus-visible { background: var(--dark-elevated); }

/* Login preloader */
html.dark .ppl { --ppl-ink-m: var(--dark-text-secondary); background: var(--dark-card); color: var(--dark-text); }
html.dark .ppl-ul { background: var(--dark-border); }
html.dark .ppl-acts button { background: var(--dark-elevated); border-color: var(--dark-border); color: var(--dark-text); }
html.dark .ppl-acts button.primary { background: var(--dark-primary); border-color: var(--dark-primary); color: #12161a; }

/* Emails campaign composer — dark mode: the sage/coral fills are light in dark
   mode, so the label must be dark ink. Same contract as .bg-sage / .bg-coral. */
html.dark #email-content .em-btn--primary,
html.dark #email-content .em-btn--accent { color: var(--dark-inverse); }

/* ==========================================================================
   Late leaks in style_essence.css — light `background: <gradient> !important`
   scoped by view IDs. Use the `background` shorthand here so the gradient
   image is removed, not just repainted underneath.
   ========================================================================== */

/* Analysis tools / Lo-Shu / Intelligence / Pipeline / Calculator tinted cards.
   Fixes: Yantra boxes, Baby Name gender selector, and the same tints elsewhere. */
html.dark #view-analysis .bg-gray-50,
html.dark #view-analysis .bg-gray-50\/80,
html.dark #view-loshu .bg-gray-50,
html.dark #view-intelligence .bg-gray-50,
html.dark #view-intelligence .bg-gray-50\/50,
html.dark #view-pipeline .bg-gray-50,
html.dark #view-calculator .bg-gray-50\/50 {
    background: linear-gradient(145deg, var(--dark-elevated), var(--dark-card)) !important;
}
/* Inside those tinted cards the yantra magic-square cells stay readable. */
html.dark .yantra-grid > div {
    background: var(--dark-elevated) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}
html.dark .yantra-card .text-gray-800,
html.dark .yantra-card .text-gray-500 { color: var(--dark-text) !important; }

/* Generic thead: style_essence.css paints it #f8fafc !important; tables not
   covered by a view-specific dark rule (Tribe, Revenue, modals) stayed light. */
html.dark thead,
html.dark thead tr,
html.dark th {
    background: var(--dark-surface) !important;
    color: var(--dark-text-secondary) !important;
    border-color: var(--dark-border) !important;
}

/* ==========================================================================
   Client Records (#view-history): the section's light CSS variables
   (--history-table-*) were never remapped, so names/meta/action buttons
   kept their light-mode ink and fills. Fix at the variable source — every
   consumer (.hc-name, .hc-meta, th, action buttons, badges) follows.
   ========================================================================== */
html.dark #view-history {
    --history-table-header-bg: var(--dark-elevated);
    --history-table-row-hover: rgba(35, 40, 46, 0.62);
    --history-table-border: var(--dark-border-soft);
    --history-table-text: var(--dark-text);
    --history-table-text-secondary: var(--dark-text-secondary);
    --history-table-text-muted: var(--dark-text-muted);
    --history-action-bg: var(--dark-elevated);
    --history-action-hover: var(--dark-card);
    --history-active-row-bg: rgba(240, 160, 138, 0.12);
    --history-mobile-badge-bg-b: rgba(155, 201, 217, 0.14);
    --history-mobile-badge-border-b: rgba(155, 201, 217, 0.32);
    --history-mobile-badge-bg-p: rgba(168, 204, 143, 0.14);
    --history-mobile-badge-border-p: rgba(168, 204, 143, 0.32);
    --history-mobile-badge-bg-d: rgba(196, 181, 212, 0.14);
    --history-mobile-badge-border-d: rgba(196, 181, 212, 0.32);
}

/* Client Records scrollbar: #historyScrollContainer/#historyCards keep the
   light sage track/thumb (ID specificity beats html.dark *). */
html.dark #historyScrollContainer,
html.dark #historyCards {
    scrollbar-color: #59645f var(--dark-surface);
}
html.dark #historyScrollContainer::-webkit-scrollbar-track,
html.dark #historyCards::-webkit-scrollbar-track {
    background: var(--dark-surface);
}
html.dark #historyScrollContainer::-webkit-scrollbar-thumb,
html.dark #historyCards::-webkit-scrollbar-thumb {
    background: #59645f;
    border-color: var(--dark-surface);
}
html.dark #historyScrollContainer::-webkit-scrollbar-thumb:hover,
html.dark #historyCards::-webkit-scrollbar-thumb:hover {
    background: #738079;
}

/* "Tap for meaning" chip inverts to white in dark mode; keep it dark instead. */
html.dark .ci-tap-meaning-btn {
    background-color: var(--dark-card) !important;
    color: var(--dark-text) !important;
    border: 1px solid var(--dark-border) !important;
}
html.dark .ci-tap-meaning-btn:hover {
    background-color: var(--dark-elevated) !important;
    color: var(--dark-primary) !important;
    border-color: rgba(168, 204, 143, 0.4) !important;
}
