/**
 * SHG theme layer — light defaults live in base.html :root.
 * Dark mode: html[data-theme="dark"] (+ Bootstrap data-bs-theme="dark").
 * Keep SHG slate brand; high-contrast text; no purple/glow skins.
 */

html[data-theme="dark"] {
    color-scheme: dark;

    --primary-dark: #15202b;
    --primary-light: #1e2d3d;
    --accent-blue: #5dade2;
    --accent-green: #2ecc71;
    --accent-orange: #f5b041;
    --accent-red: #ec7063;
    --text-light: #f1f5f9;
    --text-dark: #e8eef4;
    --border-color: #3d4f61;
    --bg-light: #0f1620;
    --bg-lighter: #1a2433;
    --bg-hover: #243447;
    --surface-border: #3d4f61;
    /* Secondary copy: keep ≥ ~4.5:1 on #0f1620 / #1a2433 (avoid dim #6c757d greys) */
    --muted-text: #c5d0dc;
}

/* —— Shell chrome ——
 * base.html sets .app-sidebar .nav-link { color: #475569 !important } for light mode.
 * Dark must beat that !important with near-white ink (≥4.5:1 on #1a2433). */
html[data-theme="dark"] .app-sidebar {
    background: var(--bg-lighter) !important;
    border-right-color: var(--border-color) !important;
    color: #f1f5f9;
}

html[data-theme="dark"] .app-sidebar .nav-link,
html[data-theme="dark"] .app-sidebar .nav-link.nav-group-toggle,
html[data-theme="dark"] .app-sidebar .collapse .nav-link,
html[data-theme="dark"] .app-sidebar .collapse .collapse .nav-link {
    color: #eef3f8 !important;
}

html[data-theme="dark"] .app-sidebar .nav-link i,
html[data-theme="dark"] .app-sidebar .nav-group-toggle .nav-chevron {
    color: #d0dae6 !important;
    opacity: 1;
}

html[data-theme="dark"] .app-sidebar .nav-link:hover,
html[data-theme="dark"] .app-sidebar .nav-link:focus-visible {
    background: var(--bg-hover) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .app-sidebar .nav-link:hover i,
html[data-theme="dark"] .app-sidebar .nav-link:focus-visible i {
    color: #8fd0f5 !important;
}

html[data-theme="dark"] .app-sidebar .nav-link.active {
    background: rgba(93, 173, 226, 0.22) !important;
    color: #ffffff !important;
    box-shadow: inset 3px 0 0 #5dade2;
}

html[data-theme="dark"] .app-sidebar .nav-link.active i {
    color: #8fd0f5 !important;
}

html[data-theme="dark"] .app-sidebar-section,
html[data-theme="dark"] .app-sidebar .nav-group-label {
    color: #c5d0dc !important;
}

html[data-theme="dark"] .nav-backup-dot {
    background: var(--bg-lighter);
    color: #f87171;
}

html[data-theme="dark"] .app-sidebar-backdrop {
    background: rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .app-topbar-brand .navbar-brand-logo,
html[data-theme="dark"] .shg-user-menu-avatar {
    background: #fff;
}

html[data-theme="dark"] .shg-profile-dropdown {
    background: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--surface-border);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .shg-profile-subtitle,
html[data-theme="dark"] .shg-profile-subheading,
html[data-theme="dark"] .shg-device-status-time {
    color: var(--muted-text) !important;
}

html[data-theme="dark"] .shg-profile-link:hover,
html[data-theme="dark"] .shg-profile-link:focus-visible {
    background: var(--bg-hover);
    color: var(--text-dark);
}

html[data-theme="dark"] .shg-profile-theme input:disabled + span {
    opacity: 1;
}

/* —— Surfaces / tables / forms —— */
html[data-theme="dark"] .card {
    background: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .card-header.bg-white,
html[data-theme="dark"] .card-header.bg-light,
html[data-theme="dark"] .card-header.bg-transparent,
html[data-theme="dark"] .card-header.shg-card-header-light,
html[data-theme="dark"] .lead-card .card-header {
    color: var(--text-dark) !important;
    background-color: var(--bg-hover) !important;
    border-bottom: 1px solid var(--border-color);
}

html[data-theme="dark"] .card-header.bg-white .card-title,
html[data-theme="dark"] .card-header.bg-light .card-title,
html[data-theme="dark"] .card-header.bg-transparent .card-title,
html[data-theme="dark"] .card-header.shg-card-header-light .card-title,
html[data-theme="dark"] .lead-card .card-header h5,
html[data-theme="dark"] .lead-card .card-header .mb-0,
html[data-theme="dark"] .lead-card .card-header a:not(.btn),
html[data-theme="dark"] .card-header.bg-white h1,
html[data-theme="dark"] .card-header.bg-white h2,
html[data-theme="dark"] .card-header.bg-white h3,
html[data-theme="dark"] .card-header.bg-white h4,
html[data-theme="dark"] .card-header.bg-white h5,
html[data-theme="dark"] .card-header.bg-white h6,
html[data-theme="dark"] .card-header.bg-light h1,
html[data-theme="dark"] .card-header.bg-light h2,
html[data-theme="dark"] .card-header.bg-light h3,
html[data-theme="dark"] .card-header.bg-light h4,
html[data-theme="dark"] .card-header.bg-light h5,
html[data-theme="dark"] .card-header.bg-light h6,
html[data-theme="dark"] .lead-card .card-header h1,
html[data-theme="dark"] .lead-card .card-header h2,
html[data-theme="dark"] .lead-card .card-header h3,
html[data-theme="dark"] .lead-card .card-header h4,
html[data-theme="dark"] .lead-card .card-header h5,
html[data-theme="dark"] .lead-card .card-header h6 {
    color: var(--text-dark) !important;
}

html[data-theme="dark"] .table {
    background: var(--bg-lighter);
    color: var(--text-dark);
    --bs-table-bg: var(--bg-lighter);
    --bs-table-color: var(--text-dark);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
    --bs-table-striped-color: var(--text-dark);
    --bs-table-hover-bg: rgba(93, 173, 226, 0.12);
    --bs-table-hover-color: var(--text-dark);
    --bs-table-border-color: var(--border-color);
}

html[data-theme="dark"] .table > thead.table-light > tr > th,
html[data-theme="dark"] .table-light > tr > th,
html[data-theme="dark"] .table-light {
    color: var(--text-dark) !important;
    background-color: var(--bg-hover) !important;
    --bs-table-bg: var(--bg-hover);
    --bs-table-color: var(--text-dark);
}

html[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(93, 173, 226, 0.12);
}

/* Contextual table rows — keep readable ink on tinted fills */
html[data-theme="dark"] .table-warning,
html[data-theme="dark"] .table-warning > th,
html[data-theme="dark"] .table-warning > td {
    --bs-table-bg: #3a2e14;
    --bs-table-color: #f8e9c4;
    --bs-table-striped-bg: #46371a;
    --bs-table-hover-bg: #52401e;
    --bs-table-hover-color: #fff8e8;
    color: #f8e9c4 !important;
    background-color: #3a2e14 !important;
}

html[data-theme="dark"] .table-warning a:not(.btn) {
    color: #fbbf24 !important;
}

html[data-theme="dark"] .table-danger,
html[data-theme="dark"] .table-danger > th,
html[data-theme="dark"] .table-danger > td {
    --bs-table-bg: #3a1c1c;
    --bs-table-color: #fecaca;
    color: #fecaca !important;
    background-color: #3a1c1c !important;
}

html[data-theme="dark"] .table-success,
html[data-theme="dark"] .table-success > th,
html[data-theme="dark"] .table-success > td {
    --bs-table-bg: #143528;
    --bs-table-color: #bbf7d0;
    color: #bbf7d0 !important;
    background-color: #143528 !important;
}

html[data-theme="dark"] .table-info,
html[data-theme="dark"] .table-info > th,
html[data-theme="dark"] .table-info > td {
    --bs-table-bg: #1a2f40;
    --bs-table-color: #bae6fd;
    color: #bae6fd !important;
    background-color: #1a2f40 !important;
}

html[data-theme="dark"] .table-primary,
html[data-theme="dark"] .table-primary > th,
html[data-theme="dark"] .table-primary > td {
    --bs-table-bg: #1a2a40;
    --bs-table-color: #bfdbfe;
    color: #bfdbfe !important;
    background-color: #1a2a40 !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .text-body-secondary,
html[data-theme="dark"] .text-body-tertiary,
html[data-theme="dark"] .shg-page-header__sub,
html[data-theme="dark"] .shg-empty__body,
html[data-theme="dark"] .shg-empty__icon,
html[data-theme="dark"] .shg-device-status-time,
html[data-theme="dark"] .shg-profile-subtitle,
html[data-theme="dark"] .shg-profile-subheading,
html[data-theme="dark"] .shg-xfer-meta,
html[data-theme="dark"] .small:not(.badge):not(.btn),
html[data-theme="dark"] small:not(.badge) {
    color: var(--muted-text) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .col-form-label {
    color: var(--text-dark) !important;
}

/* Hardcoded greys from base / shg_surfaces that ignore tokens */
html[data-theme="dark"] .shg-page-header__sub,
html[data-theme="dark"] .shg-empty__body {
    color: #c5d0dc !important;
}

html[data-theme="dark"] .shg-empty__icon {
    color: #b8c5d4 !important;
}

html[data-theme="dark"] .shg-filter-toolbar .form-label,
html[data-theme="dark"] .shg-filter-toolbar .form-text {
    color: #d0dae6 !important;
}

html[data-theme="dark"] .card .text-muted,
html[data-theme="dark"] .table .text-muted,
html[data-theme="dark"] .modal .text-muted,
html[data-theme="dark"] .list-group-item .text-muted {
    color: #c5d0dc !important;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light {
    background-color: var(--bg-lighter) !important;
    color: var(--text-dark);
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,
html[data-theme="dark"] .border-end {
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .readonly-field,
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-select:disabled {
    background-color: var(--bg-hover) !important;
    border-color: var(--border-color) !important;
    color: var(--muted-text) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text {
    background-color: #121a24;
    border-color: var(--border-color);
    color: var(--text-dark);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-select::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #b0bcc9;
    opacity: 1;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
    background-color: #121a24;
    border-color: var(--accent-blue);
    color: var(--text-dark);
    box-shadow: 0 0 0 0.2rem rgba(93, 173, 226, 0.25);
}

html[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-lighter);
    border-color: var(--border-color);
    color: var(--text-dark);
}

html[data-theme="dark"] .dropdown-item {
    color: var(--text-dark);
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--bg-hover);
    color: var(--text-dark);
}

html[data-theme="dark"] .modal-content {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color);
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--border-color);
}

html[data-theme="dark"] .list-group-item {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color);
}

html[data-theme="dark"] .alert {
    border-color: var(--border-color);
}

html[data-theme="dark"] .alert-light,
html[data-theme="dark"] .alert-secondary {
    background-color: var(--bg-hover);
    color: var(--text-dark);
}

html[data-theme="dark"] .pagination .page-link {
    background-color: var(--bg-lighter);
    border-color: var(--border-color);
    color: var(--text-dark);
}

html[data-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #0f1620;
}

html[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: var(--bg-hover);
    color: var(--muted-text);
}

html[data-theme="dark"] .footer {
    background: var(--primary-dark);
    color: var(--text-light);
}

/* Filter / empty / page chrome helpers */
html[data-theme="dark"] .shg-filter-toolbar,
html[data-theme="dark"] .shg-empty-state,
html[data-theme="dark"] .shg-page-header {
    color: var(--text-dark);
}

/*
 * Outline / icon actions — set Bootstrap 5.3 btn CSS variables so table
 * View / Edit / WhatsApp / More glyphs stay visible on charcoal rows.
 */
html[data-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: #e8eef4;
    --bs-btn-border-color: #8b9aab;
    --bs-btn-hover-color: #0f1620;
    --bs-btn-hover-bg: #e8eef4;
    --bs-btn-hover-border-color: #e8eef4;
    --bs-btn-active-color: #0f1620;
    --bs-btn-active-bg: #e8eef4;
    --bs-btn-active-border-color: #e8eef4;
    --bs-btn-disabled-color: #9aa8b8;
    --bs-btn-disabled-border-color: #5a6a7a;
}

html[data-theme="dark"] .btn-outline-primary {
    --bs-btn-color: #8fd0f5;
    --bs-btn-border-color: #5dade2;
    --bs-btn-hover-color: #0f1620;
    --bs-btn-hover-bg: #5dade2;
    --bs-btn-hover-border-color: #5dade2;
    --bs-btn-active-color: #0f1620;
    --bs-btn-active-bg: #5dade2;
    --bs-btn-active-border-color: #5dade2;
}

html[data-theme="dark"] .btn-outline-success {
    --bs-btn-color: #6ee7a0;
    --bs-btn-border-color: #34d399;
    --bs-btn-hover-color: #0f1620;
    --bs-btn-hover-bg: #34d399;
    --bs-btn-hover-border-color: #34d399;
    --bs-btn-active-color: #0f1620;
    --bs-btn-active-bg: #34d399;
    --bs-btn-active-border-color: #34d399;
}

html[data-theme="dark"] .btn-outline-info {
    --bs-btn-color: #7dd3fc;
    --bs-btn-border-color: #38bdf8;
    --bs-btn-hover-color: #0f1620;
    --bs-btn-hover-bg: #38bdf8;
    --bs-btn-hover-border-color: #38bdf8;
    --bs-btn-active-color: #0f1620;
    --bs-btn-active-bg: #38bdf8;
    --bs-btn-active-border-color: #38bdf8;
}

html[data-theme="dark"] .btn-outline-warning {
    --bs-btn-color: #fbbf24;
    --bs-btn-border-color: #f59e0b;
    --bs-btn-hover-color: #1a1a1a;
    --bs-btn-hover-bg: #f59e0b;
    --bs-btn-hover-border-color: #f59e0b;
    --bs-btn-active-color: #1a1a1a;
    --bs-btn-active-bg: #f59e0b;
    --bs-btn-active-border-color: #f59e0b;
}

html[data-theme="dark"] .btn-outline-danger {
    --bs-btn-color: #fca5a5;
    --bs-btn-border-color: #f87171;
    --bs-btn-hover-color: #0f1620;
    --bs-btn-hover-bg: #f87171;
    --bs-btn-hover-border-color: #f87171;
    --bs-btn-active-color: #0f1620;
    --bs-btn-active-bg: #f87171;
    --bs-btn-active-border-color: #f87171;
}

html[data-theme="dark"] .btn-outline-dark {
    --bs-btn-color: #f1f5f9;
    --bs-btn-border-color: #94a3b8;
    --bs-btn-hover-color: #0f1620;
    --bs-btn-hover-bg: #e2e8f0;
    --bs-btn-hover-border-color: #e2e8f0;
    --bs-btn-active-color: #0f1620;
    --bs-btn-active-bg: #e2e8f0;
    --bs-btn-active-border-color: #e2e8f0;
    --bs-btn-disabled-color: #9aa8b8;
    --bs-btn-disabled-border-color: #5a6a7a;
}

html[data-theme="dark"] .table .btn-outline-secondary,
html[data-theme="dark"] .table .btn-outline-primary,
html[data-theme="dark"] .table .btn-outline-success,
html[data-theme="dark"] .table .btn-outline-dark,
html[data-theme="dark"] .shg-row-actions .btn,
html[data-theme="dark"] .shg-actions-cell .btn {
    background-color: transparent;
}

/* Transfer / sale summary panels that use --bg-light inline */
html[data-theme="dark"] [style*="--bg-light"],
html[data-theme="dark"] .rounded[style*="background"] {
    color: var(--text-dark);
}

/* KPI / soft surfaces often using Bootstrap utility whites */
html[data-theme="dark"] .shadow-sm {
    box-shadow: 0 0.125rem 0.35rem rgba(0, 0, 0, 0.45) !important;
}

/* Warning badges keep dark ink for contrast on orange */
html[data-theme="dark"] .bg-warning,
html[data-theme="dark"] .badge.bg-warning,
html[data-theme="dark"] .btn-warning {
    color: #1a1a1a !important;
}

/* In-content links: brighter than default Bootstrap blue on charcoal */
html[data-theme="dark"] a:not(.btn):not(.nav-link):not(.dropdown-item):not(.page-link):not(.app-topbar-brand) {
    color: #7ec8f0;
}

html[data-theme="dark"] a:not(.btn):not(.nav-link):not(.dropdown-item):not(.page-link):not(.app-topbar-brand):hover,
html[data-theme="dark"] a:not(.btn):not(.nav-link):not(.dropdown-item):not(.page-link):not(.app-topbar-brand):focus-visible {
    color: #b6e0f8;
}

html[data-theme="dark"] .badge.bg-secondary,
html[data-theme="dark"] .badge.text-bg-secondary {
    background-color: #4a5a6c !important;
    color: #f1f5f9 !important;
}

/* Focus rings stay visible on dark chrome */
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] .btn:focus-visible,
html[data-theme="dark"] .form-control:focus-visible,
html[data-theme="dark"] .form-select:focus-visible,
html[data-theme="dark"] .nav-link:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Notifications — readable on dark pages */
html[data-theme="dark"] .notification {
    background: var(--bg-lighter);
    color: #f1f5f9 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .notification-message {
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .notification-dismiss {
    color: #c5d0dc !important;
}

html[data-theme="dark"] .notification-dismiss:hover,
html[data-theme="dark"] .notification-dismiss:focus-visible {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .notification-success {
    background: linear-gradient(135deg, #143528 0%, var(--bg-lighter) 100%);
}

html[data-theme="dark"] .notification-success .notification-icon {
    color: #6ee7a0 !important;
}

html[data-theme="dark"] .notification-danger,
html[data-theme="dark"] .notification-error {
    background: linear-gradient(135deg, #3a1c1c 0%, var(--bg-lighter) 100%);
}

html[data-theme="dark"] .notification-danger .notification-icon,
html[data-theme="dark"] .notification-error .notification-icon {
    color: #fca5a5 !important;
}

html[data-theme="dark"] .notification-warning {
    background: linear-gradient(135deg, #3a2e14 0%, var(--bg-lighter) 100%);
}

html[data-theme="dark"] .notification-warning .notification-icon {
    color: #fbbf24 !important;
}

html[data-theme="dark"] .notification-info {
    background: linear-gradient(135deg, #1a2f40 0%, var(--bg-lighter) 100%);
}

html[data-theme="dark"] .notification-info .notification-icon {
    color: #7dd3fc !important;
}

/* Tabs / accordion / breadcrumb / offcanvas / toast */
html[data-theme="dark"] .nav-tabs {
    border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .nav-tabs .nav-link {
    color: var(--muted-text);
}

html[data-theme="dark"] .nav-tabs .nav-link:hover,
html[data-theme="dark"] .nav-tabs .nav-link:focus-visible {
    color: var(--text-dark);
    border-color: var(--border-color);
}

html[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color) var(--border-color) var(--bg-lighter);
}

html[data-theme="dark"] .nav-pills .nav-link {
    color: var(--muted-text);
}

html[data-theme="dark"] .nav-pills .nav-link.active {
    background-color: var(--accent-blue);
    color: #0f1620;
}

html[data-theme="dark"] .accordion-item {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color);
}

html[data-theme="dark"] .accordion-button {
    background-color: var(--bg-hover);
    color: var(--text-dark);
}

html[data-theme="dark"] .accordion-button:not(.collapsed) {
    background-color: var(--bg-hover);
    color: var(--text-dark);
    box-shadow: inset 0 -1px 0 var(--border-color);
}

html[data-theme="dark"] .accordion-button::after {
    filter: invert(1) brightness(1.4);
}

html[data-theme="dark"] .accordion-body {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
}

html[data-theme="dark"] .breadcrumb {
    --bs-breadcrumb-divider-color: var(--muted-text);
}

html[data-theme="dark"] .breadcrumb-item,
html[data-theme="dark"] .breadcrumb-item a {
    color: var(--muted-text);
}

html[data-theme="dark"] .breadcrumb-item.active {
    color: var(--text-dark);
}

html[data-theme="dark"] .offcanvas,
html[data-theme="dark"] .offcanvas-header,
html[data-theme="dark"] .offcanvas-body {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color);
}

html[data-theme="dark"] .toast {
    background-color: var(--bg-lighter);
    color: var(--text-dark);
    border-color: var(--border-color);
}

html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1) brightness(1.6);
}

html[data-theme="dark"] hr {
    border-color: var(--border-color);
    opacity: 1;
}

html[data-theme="dark"] .table > :not(caption) > * > * {
    border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .table thead th {
    color: var(--text-dark);
    border-color: var(--border-color);
}

/* Custom form shells that hardcode white surfaces (renew / hubs / analytics) */
html[data-theme="dark"] .main-card,
html[data-theme="dark"] .program-card,
html[data-theme="dark"] .status-card,
html[data-theme="dark"] .form-section,
html[data-theme="dark"] .ma-cat-card,
html[data-theme="dark"] .ma-toolbar,
html[data-theme="dark"] .ma-panel,
html[data-theme="dark"] .ma-leader,
html[data-theme="dark"] .wc-member-list li,
html[data-theme="dark"] .wc-plan-list li,
html[data-theme="dark"] .member-registration-wizard,
html[data-theme="dark"] .activity-log-card,
html[data-theme="dark"] .plan-confirm-dialog {
    background: var(--bg-lighter) !important;
    color: var(--text-dark) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .form-section {
    background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-lighter) 100%) !important;
}

html[data-theme="dark"] .section-title,
html[data-theme="dark"] .section-header,
html[data-theme="dark"] .ma-cat-card .ma-count,
html[data-theme="dark"] .card-info .card-title,
html[data-theme="dark"] .status-item .value {
    color: var(--text-dark) !important;
}

html[data-theme="dark"] .program-radio:checked + .program-label .program-card {
    background: linear-gradient(135deg, var(--bg-lighter) 0%, var(--bg-hover) 100%) !important;
}

html[data-theme="dark"] .status-card {
    background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-lighter) 100%) !important;
}

/* CRM page styles that hardcode light grey surfaces */
html[data-theme="dark"] .crm-content h1 {
    color: var(--text-dark) !important;
}

html[data-theme="dark"] .lead-card {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .lead-card .card-header {
    background: var(--bg-hover) !important;
    color: var(--text-dark) !important;
    border-bottom-color: var(--border-color) !important;
}

html[data-theme="dark"] .lead-card .table tbody td {
    border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .lead-card .table tbody tr:hover,
html[data-theme="dark"] .table tbody tr:hover {
    background-color: var(--bg-hover) !important;
}

html[data-theme="dark"] code,
html[data-theme="dark"] pre,
html[data-theme="dark"] .form-control-plaintext {
    color: var(--text-dark);
}

html[data-theme="dark"] .progress {
    background-color: #243447;
}

html[data-theme="dark"] .popover,
html[data-theme="dark"] .tooltip-inner {
    background-color: #243447;
    color: var(--text-dark);
    border-color: var(--border-color);
}

/* Motion: never hide content; only shorten motion when requested */
@media (prefers-reduced-motion: reduce) {
    html[data-theme="dark"] .notification,
    html[data-theme="dark"] .notification.notification-slide-out,
    .notification,
    .notification.notification-slide-out {
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }

    html[data-theme="dark"] .card,
    html[data-theme="dark"] .shg-user-menu-trigger,
    body.app-shell-auth .main-container,
    body.app-shell-auth .footer {
        transition: none !important;
    }
}
