﻿/* ==========================================================================
   DARK MODE OVERRIDES — OraSoftApp
   --------------------------------------------------------------------------
   Trigger:  <html data-theme="dark">           (set by ThemeService)
   Also responds to Bootstrap's data-bs-theme for completeness, but the
   primary selector is data-theme so it works even without Bootstrap 5.3.

   Load ORDER matters:  this file MUST come after every page-specific
   stylesheet, because the rules below have equal-or-higher specificity
   than the originals and rely on source order to win.

   Nothing here changes LIGHT mode: every rule is gated behind
   html[data-theme="dark"].
   ========================================================================== */


/* ==========================================================================
   00. GLOBAL SHELL
   ========================================================================== */

html[data-theme="dark"] {
    color-scheme: dark;
    --bs-body-bg: #14172a;
    --bs-body-color: #e8eaf6;
    --bs-border-color: #363a5a;
}

    html[data-theme="dark"] body {
        background: #14172a !important;
        color: #e8eaf6;
    }

    /* Scrollbars (page-level; the storetransfer ones already use vars) */
    html[data-theme="dark"] ::-webkit-scrollbar-track {
        background: #14171d;
    }

    html[data-theme="dark"] ::-webkit-scrollbar-thumb {
        background: #3a4050;
    }

        html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
            background: #4b5563;
        }


/* ==========================================================================
   01. STORE BALANCE   (storebalance-premium.css · --sb-*)
   ========================================================================== */

/* ---- tokens ---- */
html[data-theme="dark"] {
    --sb-surface-1: #1a1d2e;
    --sb-surface-2: #232640;
    --sb-surface-3: #2c3058;
    --sb-border: #363a5a;
    --sb-border-hi: #4a4f78;
    --sb-text-1: #e8eaf6;
    --sb-text-2: #9198b0;
    --sb-text-3: #5a6076;
    --sb-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --sb-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);
}

    /* ---- surfaces ---- */
    html[data-theme="dark"] .sb-shell,
    html[data-theme="dark"] .sb-filter-card,
    html[data-theme="dark"] .sb-table-card,
    html[data-theme="dark"] .modal-content,
    html[data-theme="dark"] .print-preview {
        background: var(--sb-surface-1) !important;
        border-color: var(--sb-border) !important;
        color: var(--sb-text-1);
    }

    html[data-theme="dark"] .table {
        color: var(--sb-text-1);
    }

    html[data-theme="dark"] .table-secondary {
        background: var(--sb-surface-3) !important;
    }

    /* ---- sticky table footer ---- */
    html[data-theme="dark"] .sb-table-wrap .table tfoot td {
        background: var(--sb-surface-3) !important;
        border-top-color: var(--sb-border-hi) !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    }

        html[data-theme="dark"] .sb-table-wrap .table tfoot td:last-child,
        html[data-theme="dark"] .sb-table-wrap .table tfoot td:nth-last-child(2) {
            background: var(--sb-surface-1) !important;
        }

    /* ---- totals ---- */
    html[data-theme="dark"] #totalsumsale {
        color: #34d399;
        background: rgba(52, 211, 153, 0.1);
    }

    html[data-theme="dark"] #totalsumcost {
        color: #94a3b8;
        background: rgba(148, 163, 184, 0.1);
    }

    /* ---- hardcoded label colors ---- */
    html[data-theme="dark"] span#totalValueLabel {
        color: #fca5a5;
    }

    html[data-theme="dark"] span#pageLabel {
        color: #c4b5fd;
    }

    html[data-theme="dark"] span.badge.bg-primary-subtle,
    html[data-theme="dark"] span.badge.bg-info-subtle {
        color: #cbd5e1;
    }

    html[data-theme="dark"] td.text-end.text-primary.border-top {
        color: #93c5fd !important;
    }

    /* ---- validation / loading ---- */
    html[data-theme="dark"] .invalid-feedback {
        background: rgba(239, 68, 68, 0.14);
        border-right-color: #f87171;
        color: #fca5a5;
    }

    html[data-theme="dark"] .is-invalid,
    html[data-theme="dark"] select.is-invalid,
    html[data-theme="dark"] input.is-invalid {
        background-color: rgba(239, 68, 68, 0.08) !important;
    }

    html[data-theme="dark"] .loading-backdrop {
        background: rgba(0, 0, 0, 0.65);
    }


/* ==========================================================================
   02. STORE TRANSFER   (storetransfer.css · --nova-* / --st-* / --acc-* / --fw-* / --pil-*)
   ========================================================================== */

/* ---- tokens (root only; every --st-/--acc-/--fw-/--pil- alias follows automatically) ---- */
html[data-theme="dark"] {
    --nova-bg: #0e0f1e;
    --nova-surface: #171830;
    --nova-surface-2: #131426;
    --nova-surface-3: #1e2040;
    --nova-border: rgba(148, 145, 255, .16);
    --nova-border-soft: rgba(148, 145, 255, .08);
    --nova-border-hi: rgba(148, 145, 255, .24);
    --nova-text: #e6e6f7;
    --nova-text-2: #b7b6d8;
    --nova-text-muted: #9391b8;
    --nova-text-faint: #6f6d93;
    --nova-shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --nova-shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --nova-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    --nova-shadow-lg: 0 22px 60px rgba(0, 0, 0, .55);
    --nova-glow: 0 0 0 3px rgba(148, 145, 255, .24);
}

    html[data-theme="dark"] body {
        background: var(--nova-bg);
        color: var(--nova-text);
    }

    /* ---- inputs / selects ---- */
    html[data-theme="dark"] .st-search-input,
    html[data-theme="dark"] .st-filter-select,
    html[data-theme="dark"] .st-page-btn,
    html[data-theme="dark"] .st-pagination .page-link,
    html[data-theme="dark"] .st-per-page select {
        background: var(--nova-surface-3);
        color: var(--nova-text);
    }

    /* ---- table rows / badges / action buttons ---- */
    html[data-theme="dark"] .st-table tbody tr:hover {
        background: rgba(148, 145, 255, .06);
    }

    html[data-theme="dark"] .st-type-badge {
        background: var(--nova-surface-3);
        border-color: var(--nova-border);
        color: var(--nova-text-2);
    }

    html[data-theme="dark"] .st-action-btn {
        background: var(--nova-surface-3);
    }

    /* ---- ghost / outline buttons that use hardcoded #fff ---- */
    html[data-theme="dark"] .st-filter-btn-ghost,
    html[data-theme="dark"] .btn-outline-success,
    html[data-theme="dark"] .btn-outline-warning,
    html[data-theme="dark"] .btn-outline-danger,
    html[data-theme="dark"] .btn-outline-primary,
    html[data-theme="dark"] .btn-outline-secondary,
    html[data-theme="dark"] .btn-secondary {
        background: var(--nova-surface-3);
        color: var(--nova-text);
        border-color: var(--nova-border);
    }

    /* ---- premium customer list / sidebar / modal chrome ---- */
    html[data-theme="dark"] .list-group-item.premium-customer-item {
        background: var(--nova-surface);
        color: var(--nova-text);
    }

    html[data-theme="dark"] .modal-sidebar,
    html[data-theme="dark"] .modal-content-area,
    html[data-theme="dark"] .form-card,
    html[data-theme="dark"] .form-card-body {
        background: var(--nova-surface);
        color: var(--nova-text);
    }

    /* ---- qty stepper + compact form controls ---- */
    html[data-theme="dark"] .qty-control .qty,
    html[data-theme="dark"] .qty-control .btn,
    html[data-theme="dark"] .form-control,
    html[data-theme="dark"] .form-select,
    html[data-theme="dark"] .form-control-compact,
    html[data-theme="dark"] .form-select-compact {
        background: var(--nova-surface-3);
        color: var(--nova-text);
        border-color: var(--nova-border);
    }

        html[data-theme="dark"] .form-control:disabled,
        html[data-theme="dark"] .form-select:disabled,
        html[data-theme="dark"] .form-control-compact:disabled,
        html[data-theme="dark"] .form-select-compact:disabled {
            background: var(--nova-surface-2);
            color: var(--nova-text-muted);
        }

    /* ---- loading overlay ---- */
    html[data-theme="dark"] .loading-overlay-micro {
        background: rgba(14, 15, 30, 0.88);
    }

    /* ---- SweetAlert2 chrome tuned for the premium module ---- */
    html[data-theme="dark"] .swal2-popup {
        background: var(--nova-surface);
        color: var(--nova-text);
    }


/* ==========================================================================
   03. ACCOUNT REPORT   (accountreport.css · --ar-*)
   ========================================================================== */

/* ---- tokens ---- */
html[data-theme="dark"] {
    --ar-surface-1: #1a1d2e;
    --ar-surface-2: #232640;
    --ar-surface-3: #2c3058;
    --ar-border: #363a5a;
    --ar-border-hi: #4a4f78;
    --ar-text-1: #e8eaf6;
    --ar-text-2: #9198b0;
    --ar-text-3: #5a6076;
    --ar-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --ar-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);
}

    html[data-theme="dark"] body {
        background: #14172a !important;
        color: var(--ar-text-1);
    }

    /* ---- surfaces ---- */
    html[data-theme="dark"] .ar-shell,
    html[data-theme="dark"] .ar-filter-card,
    html[data-theme="dark"] .ar-table-card,
    html[data-theme="dark"] .modal-content {
        background: var(--ar-surface-1) !important;
        border-color: var(--ar-border) !important;
        color: var(--ar-text-1);
    }

    html[data-theme="dark"] .table {
        color: var(--ar-text-1);
    }

    html[data-theme="dark"] .table-secondary {
        background: var(--ar-surface-3) !important;
    }

    /* ---- premium table-section header / stats ---- */
    html[data-theme="dark"] .ar-table-card-head {
        background: linear-gradient(135deg, var(--ar-surface-2) 0%, var(--ar-surface-3) 100%);
        border-color: var(--ar-border);
    }

    html[data-theme="dark"] .ar-stats-bar {
        background: linear-gradient(135deg, rgba(67, 97, 238, 0.08) 0%, rgba(67, 97, 238, 0.03) 100%);
        border-color: var(--ar-border);
    }

    html[data-theme="dark"] .ar-data-table tbody tr:hover {
        background: rgba(67, 97, 238, 0.10);
    }

    html[data-theme="dark"] .empty-state i {
        color: var(--ar-text-3);
    }

    /* ---- inputs / pills / page controls with hardcoded #fff ---- */
    html[data-theme="dark"] .stat-item,
    html[data-theme="dark"] .stat-value,
    html[data-theme="dark"] .action-group,
    html[data-theme="dark"] .action-btn-print,
    html[data-theme="dark"] .report-type-label,
    html[data-theme="dark"] .ar-input,
    html[data-theme="dark"] .ar-select,
    html[data-theme="dark"] .search-input,
    html[data-theme="dark"] .rows-per-page-select,
    html[data-theme="dark"] .page-btn,
    html[data-theme="dark"] .pagination-nav-btn {
        background: var(--ar-surface-2);
        color: var(--ar-text-1);
        border-color: var(--ar-border-hi);
    }

    /* ---- hardcoded label colors ---- */
    html[data-theme="dark"] span.badge.bg-primary-subtle,
    html[data-theme="dark"] span.badge.bg-info-subtle {
        color: #cbd5e1;
    }

    html[data-theme="dark"] span#totalValueLabel {
        color: #fca5a5;
    }

    html[data-theme="dark"] span#pageLabel {
        color: #c4b5fd;
    }


/* ==========================================================================
   04. ITEMS ORDER LIMIT   (itemsorderlimit.css · --iol-*)
   ========================================================================== */

/* ---- tokens ---- */
html[data-theme="dark"] {
    --iol-bg: #0f1116;
    --iol-surface: #1a1d24;
    --iol-surface2: #21252e;
    --iol-border: #2f3441;
    --iol-border2: #3a4050;
    --iol-text: #e5e7eb;
    --iol-muted: #9ca3af;
    --iol-accent: #3b82f6;
    --iol-accent-lt: #1e293b;
    --iol-accent-glow: rgba(59, 130, 246, 0.28);
    --iol-danger: #f87171;
    --iol-danger-lt: #2a1a1c;
    --iol-warning: #fbbf24;
    --iol-warning-lt: #2a2217;
    --iol-success: #4ade80;
    --iol-success-lt: #142a1c;
    --iol-info: #38bdf8;
    --iol-info-lt: #0f1f2e;
    --iol-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --iol-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
}

    /* ---- base / cards ---- */
    html[data-theme="dark"] .iol-page {
        background: var(--iol-bg);
        color: var(--iol-text);
    }

    html[data-theme="dark"] .iol-shell,
    html[data-theme="dark"] .iol-fcard,
    html[data-theme="dark"] .iol-results {
        background: var(--iol-surface);
        border-color: var(--iol-border);
    }

    html[data-theme="dark"] .iol-body {
        background: var(--iol-bg);
    }

    html[data-theme="dark"] .iol-fcard:hover {
        border-color: #4b5563;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    }

    html[data-theme="dark"] .iol-fcard-head {
        background: var(--iol-surface2);
    }

    /* ---- inputs / selects ---- */
    html[data-theme="dark"] .iol-input,
    html[data-theme="dark"] .iol-select,
    html[data-theme="dark"] .iol-pagination-page-size,
    html[data-theme="dark"] .iol-pagination-btn,
    html[data-theme="dark"] .iol-pagination-num,
    html[data-theme="dark"] .iol-search-input,
    html[data-theme="dark"] div.dataTables_wrapper div.dataTables_filter input,
    html[data-theme="dark"] div.dataTables_wrapper div.dataTables_length select {
        background: var(--iol-surface);
        color: var(--iol-text);
        border-color: var(--iol-border2);
    }

    /* ---- radio-pill toggle ---- */
    html[data-theme="dark"] .iol-toggle-pill {
        background: #2a2f3a;
        border-color: var(--iol-border);
    }

        html[data-theme="dark"] .iol-toggle-pill label {
            color: var(--iol-muted);
        }

        html[data-theme="dark"] .iol-toggle-pill input[type="radio"]:checked + label {
            background: var(--iol-surface);
            color: var(--iol-accent);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
        }

    /* ---- switch ---- */
    html[data-theme="dark"] .iol-switch-track {
        background: #374151;
        border-color: #4b5563;
    }

        html[data-theme="dark"] .iol-switch-track::after {
            background: #e5e7eb;
        }

    html[data-theme="dark"] .iol-switch input:checked ~ .iol-switch-track {
        background: var(--iol-accent);
        border-color: #1d4ed8;
    }

    /* ---- results header ---- */
    html[data-theme="dark"] .iol-results-head {
        background: #1e293b;
        border-color: #334155;
    }

    html[data-theme="dark"] .iol-results-head-title {
        color: #93c5fd;
    }

    /* ---- table ---- */
    html[data-theme="dark"] .iol-table thead th {
        background: #21252e;
        color: #9ca3af;
        border-color: var(--iol-border2);
    }

    html[data-theme="dark"] .iol-table tbody td {
        color: var(--iol-text);
    }

    html[data-theme="dark"] .iol-table tbody tr:hover {
        filter: brightness(1.10);
    }

    html[data-theme="dark"] .iol-table tfoot td {
        background: #21252e;
        border-color: var(--iol-border2);
        color: var(--iol-muted);
    }

    /* ---- row states ---- */
    html[data-theme="dark"] .iol-row-danger {
        background: rgba(220, 38, 38, 0.08);
    }

    html[data-theme="dark"] .iol-row-warning {
        background: rgba(217, 119, 6, 0.08);
    }

    html[data-theme="dark"] .iol-row-success {
        background: rgba(22, 163, 74, 0.08);
    }

    /* ---- badges ---- */
    html[data-theme="dark"] .iol-badge-danger {
        background: rgba(220, 38, 38, 0.15);
        color: #fca5a5;
        border-color: rgba(220, 38, 38, 0.3);
    }

    html[data-theme="dark"] .iol-badge-warning {
        background: rgba(217, 119, 6, 0.15);
        color: #fcd34d;
        border-color: rgba(217, 119, 6, 0.3);
    }

    html[data-theme="dark"] .iol-badge-success {
        background: rgba(22, 163, 74, 0.15);
        color: #86efac;
        border-color: rgba(22, 163, 74, 0.3);
    }

    html[data-theme="dark"] .iol-badge-neutral {
        background: #2a2f3a;
        color: #9ca3af;
        border-color: var(--iol-border);
    }

    html[data-theme="dark"] .iol-badge-blue {
        background: rgba(59, 130, 246, 0.15);
        color: #93c5fd;
        border-color: rgba(59, 130, 246, 0.3);
    }

    /* ---- sequence pill ---- */
    html[data-theme="dark"] .iol-seq {
        background: #2a2f3a;
        color: #9ca3af;
        border-color: var(--iol-border);
    }

    /* ---- buttons / empty state ---- */
    html[data-theme="dark"] .iol-btn-clear {
        background: var(--iol-danger-lt);
        border-color: rgba(248, 113, 113, 0.3);
    }

        html[data-theme="dark"] .iol-btn-clear:hover {
            background: rgba(220, 38, 38, 0.2);
            border-color: rgba(248, 113, 113, 0.5);
        }

    html[data-theme="dark"] .iol-empty {
        color: var(--iol-muted);
    }

        html[data-theme="dark"] .iol-empty i {
            color: var(--iol-muted);
            opacity: .35;
        }

    /* ---- DataTables wrapper + pagination ---- */
    html[data-theme="dark"] div.dataTables_wrapper {
        color: var(--iol-text);
    }

        html[data-theme="dark"] div.dataTables_wrapper div.dataTables_info,
        html[data-theme="dark"] div.dataTables_wrapper div.dataTables_filter label,
        html[data-theme="dark"] div.dataTables_wrapper div.dataTables_length label {
            color: var(--iol-muted);
        }

        html[data-theme="dark"] div.dataTables_wrapper div.dataTables_paginate .paginate_button {
            background: var(--iol-surface) !important;
            border-color: var(--iol-border) !important;
            color: var(--iol-muted) !important;
        }

            html[data-theme="dark"] div.dataTables_wrapper div.dataTables_paginate .paginate_button:hover {
                background: var(--iol-accent-lt) !important;
                border-color: var(--iol-accent) !important;
                color: #93c5fd !important;
            }

            html[data-theme="dark"] div.dataTables_wrapper div.dataTables_paginate .paginate_button.current {
                background: var(--iol-accent) !important;
                border-color: var(--iol-accent) !important;
                color: #fff !important;
            }

    /* ---- manual pagination bar ---- */
    html[data-theme="dark"] .iol-manual-pagination {
        background: var(--iol-surface2);
        border-color: var(--iol-border);
    }

    html[data-theme="dark"] .iol-pagination-btn:hover:not(:disabled),
    html[data-theme="dark"] .iol-pagination-num:hover {
        background: var(--iol-accent-lt);
        border-color: var(--iol-accent);
        color: #93c5fd;
    }

    html[data-theme="dark"] .iol-pagination-num.active {
        background: var(--iol-accent);
        border-color: var(--iol-accent);
        color: #fff;
    }

    /* ---- toasts ---- */
    html[data-theme="dark"] .iol-toast-info {
        background: rgba(37, 99, 235, 0.15);
        color: #93c5fd;
        border-color: #3b82f6;
    }

    html[data-theme="dark"] .iol-toast-success {
        background: rgba(22, 163, 74, 0.15);
        color: #86efac;
        border-color: #22c55e;
    }

    html[data-theme="dark"] .iol-toast-danger {
        background: rgba(220, 38, 38, 0.15);
        color: #fca5a5;
        border-color: #ef4444;
    }

    html[data-theme="dark"] .iol-toast-warning {
        background: rgba(217, 119, 6, 0.15);
        color: #fcd34d;
        border-color: #f59e0b;
    }

    /* ---- print-preview charts inside the modal ---- */
    html[data-theme="dark"] .iol-print-status-card,
    html[data-theme="dark"] .iol-print-settings {
        background: var(--iol-surface);
        color: var(--iol-text);
        border-color: var(--iol-border);
    }


    /* ==========================================================================
   05. SHARED / BOOTSTRAP COMPONENT PATCHES
   These apply everywhere, in case a custom class inherits a Bootstrap
   default that didn't pick up data-bs-theme.
   ========================================================================== */

    html[data-theme="dark"] .form-control,
    html[data-theme="dark"] .form-select {
        background-color: #1a1d2e;
        border-color: #363a5a;
        color: #e8eaf6;
    }

        html[data-theme="dark"] .form-control::placeholder {
            color: #6f6d93;
        }

    html[data-theme="dark"] .dropdown-menu {
        background-color: #1a1d2e;
        border-color: #363a5a;
        color: #e8eaf6;
    }

    html[data-theme="dark"] .dropdown-item {
        color: #e8eaf6;
    }

        html[data-theme="dark"] .dropdown-item:hover,
        html[data-theme="dark"] .dropdown-item:focus {
            background-color: #232640;
            color: #fff;
        }


    /* ==========================================================================
   06. COST CENTERS · ACTIVITIES  (activities.css)
   --------------------------------------------------------------------------
   activities.css redefines --st-* at :root with its own blue palette. Scope
   these overrides to .nova-act so they never touch StoreTransfer, which uses
   --st-* as aliases to --nova-*.
   ========================================================================== */

    html[data-theme="dark"] .nova-act {
        --st-primary: #4f7dfb;
        --st-primary-dark: #3b6af5;
        --st-primary-soft: rgba(79,125,251,.14);
        --st-success: #22c55e;
        --st-danger: #ef4444;
        --st-warning: #f59e0b;
        --st-surface: #1e293b;
        --st-surface-2: #0f172a;
        --st-surface-3: #334155;
        --st-border: #475569;
        --st-border-soft: rgba(255,255,255,.06);
        --st-text: #f1f5f9;
        --st-text-muted: #94a3b8;
        --st-shadow: 0 2px 12px rgba(0,0,0,.35);
        --st-shadow-hover: 0 4px 24px rgba(0,0,0,.5);
        background: #0b1120;
    }

        /* Hardcoded #fff surfaces inside activities */
        html[data-theme="dark"] .nova-act .st-card,
        html[data-theme="dark"] .nova-act .st-search-input,
        html[data-theme="dark"] .nova-act .st-filter-btn,
        html[data-theme="dark"] .nova-act .st-stat-pill,
        html[data-theme="dark"] .nova-act .st-pagination .page-link,
        html[data-theme="dark"] .nova-act .modal-sidebar,
        html[data-theme="dark"] .nova-act .modal-content-area,
        html[data-theme="dark"] .nova-act .form-card,
        html[data-theme="dark"] .nova-act .detail-panel-root,
        html[data-theme="dark"] .nova-act .premium-record-info {
            background: var(--st-surface-2);
            color: var(--st-text);
            border-color: var(--st-border);
        }

        /* Gradient headers keep the blue scheme but darker */
        html[data-theme="dark"] .nova-act .st-card-header,
        html[data-theme="dark"] .nova-act .premium-modal-header {
            background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
        }

        html[data-theme="dark"] .nova-act .st-table thead {
            background: var(--st-surface-3);
            color: var(--st-text);
            border-color: var(--st-border);
        }

        html[data-theme="dark"] .nova-act .st-table th,
        html[data-theme="dark"] .nova-act .st-table td {
            color: var(--st-text);
            border-color: var(--st-border-soft);
        }

        html[data-theme="dark"] .nova-act .st-table tbody tr:hover {
            background: rgba(79,125,251,.08);
        }

        html[data-theme="dark"] .nova-act .st-filter-bar,
        html[data-theme="dark"] .nova-act .st-active-filters,
        html[data-theme="dark"] .nova-act .st-table-footer,
        html[data-theme="dark"] .nova-act .premium-modal-footer {
            background: var(--st-surface-2);
            border-color: var(--st-border-soft);
        }

        html[data-theme="dark"] .nova-act .form-control,
        html[data-theme="dark"] .nova-act .form-select,
        html[data-theme="dark"] .nova-act .premium-search-input {
            background: var(--st-surface-2);
            border-color: var(--st-border);
            color: var(--st-text);
        }

            html[data-theme="dark"] .nova-act .form-control[readonly],
            html[data-theme="dark"] .nova-act .form-control:disabled {
                background: var(--st-surface-3);
                color: var(--st-text-muted);
            }

        html[data-theme="dark"] .nova-act .pil-item:hover,
        html[data-theme="dark"] .nova-act .pil-item.active {
            background: rgba(79,125,251,.10);
            border-right-color: var(--st-primary);
        }

        html[data-theme="dark"] .nova-act .st-empty,
        html[data-theme="dark"] .nova-act .pil-empty {
            color: var(--st-text-muted);
        }

        html[data-theme="dark"] .nova-act .st-empty-icon,
        html[data-theme="dark"] .nova-act .pil-empty-icon {
            color: var(--st-border);
        }

        /* Related Data Dialog (rdd-*) — was on prefers-color-scheme */
        html[data-theme="dark"] .nova-act .rdd-summary {
            background: rgba(220,38,38,.12);
            border-color: rgba(220,38,38,.28);
        }

        html[data-theme="dark"] .nova-act .rdd-summary-text strong {
            color: #f1f5f9;
        }

        html[data-theme="dark"] .nova-act .rdd-summary-text span {
            color: #94a3b8;
        }

        html[data-theme="dark"] .nova-act .rdd-summary-text b {
            color: #fca5a5;
        }

        html[data-theme="dark"] .nova-act .rdd-card {
            background: #1e293b;
            border-color: rgba(255,255,255,.06);
        }

        html[data-theme="dark"] .nova-act .rdd-card-title {
            color: #f1f5f9;
        }

        html[data-theme="dark"] .nova-act .rdd-card-subtitle {
            color: #94a3b8;
        }

        html[data-theme="dark"] .nova-act .rdd-card-sample {
            border-top-color: rgba(255,255,255,.06);
            color: #94a3b8;
        }

        html[data-theme="dark"] .nova-act .rdd-note {
            background: rgba(217,119,6,.12);
            border-color: rgba(217,119,6,.28);
            color: #fcd34d;
        }

        html[data-theme="dark"] .nova-act .rdd-card-count {
            background: rgba(255,255,255,.08);
            color: #cbd5e1;
        }


/* ==========================================================================
   07. PREMIUM MODALS · KAID · KD-PANEL  (Pasted text.txt)
   --------------------------------------------------------------------------
   Three token families live in that file:
     · --acc-*  — modal / detail panel chrome (also handles --gradient-header)
     · --k-*    — .kaid-* tables & cards (currently gated on body.dark)
     · --kd-*   — .kd-panel scope (already has [data-bs-theme="dark"] — this
                  adds html[data-theme="dark"] for parity)
   ========================================================================== */

/* --acc-* tokens (were [data-bs-theme="dark"] only) */
html[data-theme="dark"] {
    --acc-bg: #0f172a;
    --acc-surface: #1e293b;
    --acc-surface-2: #334155;
    --acc-surface-3: #475569;
    --acc-border: rgba(255,255,255,.08);
    --acc-border-hi: rgba(79,120,255,.35);
    --acc-text: #f1f5f9;
    --acc-text-2: #cbd5e1;
    --acc-text-3: #94a3b8;
    --gradient-header: linear-gradient(135deg,#1e1b4b 0%,#0f172a 50%,#1e1b4b 100%);
}

/* --k-* tokens (were body.dark only) */
html[data-theme="dark"] {
    --k-bg: #0d1117;
    --k-surface: #161b22;
    --k-surface-2: #1c2128;
    --k-border: #30363d;
    --k-border-light: #21262d;
    --k-text: #e6edf3;
    --k-text-muted: #848d97;
    --k-text-light: #6e7681;
    --k-primary-glow: rgba(37,99,235,.15);
}

    /* --kd-* tokens (already scoped to .kd-panel via data-bs-theme; mirror it) */
    html[data-theme="dark"] .kd-panel {
        --kd-bg: #10131c;
        --kd-surface: #171b28;
        --kd-surface-2: #1d2233;
        --kd-border: #262c40;
        --kd-text: #e7e9f3;
        --kd-text-muted: #9aa1b8;
        --kd-shadow-md: 0 8px 24px -8px rgba(0,0,0,.55);
    }

    /* --acc hardcoded components */
    html[data-theme="dark"] .modal-header-button {
        background: rgba(255,255,255,.08);
        border-color: rgba(255,255,255,.14);
        color: var(--acc-text-2);
    }

        html[data-theme="dark"] .modal-header-button:hover {
            background: var(--acc-blue-glow);
            color: var(--acc-blue);
            border-color: var(--acc-blue);
        }

    html[data-theme="dark"] .premium-modal-content {
        background: var(--acc-surface) !important;
        border-color: var(--acc-border-hi) !important;
    }

    html[data-theme="dark"] .premium-modal-body,
    html[data-theme="dark"] .modal-content-area {
        background: var(--acc-bg) !important;
    }

    html[data-theme="dark"] .modal-sidebar {
        background: var(--acc-surface) !important;
        border-inline-end-color: var(--acc-border) !important;
    }

    html[data-theme="dark"] .premium-search-box {
        background: var(--acc-surface-2);
        border-color: var(--acc-border);
    }

    html[data-theme="dark"] .premium-customer-item {
        background: transparent !important;
        border-bottom-color: var(--acc-border) !important;
        color: var(--acc-text);
    }

        html[data-theme="dark"] .premium-customer-item:hover {
            background: var(--acc-surface-2) !important;
        }

    html[data-theme="dark"] .premium-stats-footer {
        background: var(--acc-surface-2);
        border-top-color: var(--acc-border);
    }

    html[data-theme="dark"] .premium-record-info,
    html[data-theme="dark"] .premium-modal-footer {
        background: var(--acc-surface-2);
        border-color: var(--acc-border);
        color: var(--acc-text);
    }

    /* --k hardcoded components */
    html[data-theme="dark"] .kaid-card,
    html[data-theme="dark"] .kaid-table tbody tr {
        background: #1e293b;
        color: #e2e8f0;
        border-color: #334155;
    }

    html[data-theme="dark"] .kaid-table thead th {
        background: linear-gradient(180deg, #1e3a5f, #1e3a8a);
        color: #93c5fd;
        border-bottom-color: #3b82f6;
    }

    html[data-theme="dark"] .kaid-table tbody tr:hover {
        background: #334155;
    }

    html[data-theme="dark"] .kaid-table tbody td {
        color: #cbd5e1;
        border-color: #334155;
    }

    html[data-theme="dark"] .filter-bar,
    html[data-theme="dark"] .filter-input {
        background: #0f172a;
        border-color: #334155;
        color: #e2e8f0;
    }

    html[data-theme="dark"] .kaid-stats {
        background: var(--k-surface-2);
        border-color: var(--k-border);
    }

    html[data-theme="dark"] .bulk-bar {
        background: linear-gradient(90deg, #451a03, #1c0a00);
        border-color: #78350f;
        color: #fcd34d;
    }

    html[data-theme="dark"] .pagination-controls {
        background: #1e293b;
        border-color: var(--k-border);
    }

    html[data-theme="dark"] .detail-content {
        background: #334155;
    }

    html[data-theme="dark"] .k-page-btn,
    html[data-theme="dark"] .pagination-controls .form-select {
        background: var(--k-surface-2);
        border-color: var(--k-border);
        color: var(--k-text);
    }

    /* Premium detail tables (--k tokens + body.dark triggers) */
    html[data-theme="dark"] .premium-details-table thead th,
    html[data-theme="dark"] .premium-sanad-table thead th {
        background: linear-gradient(135deg, #1e293b, #334155);
        color: #94a3b8;
        border-bottom-color: #3b82f6;
    }

    html[data-theme="dark"] .premium-details-table tbody tr,
    html[data-theme="dark"] .premium-sanad-table tbody tr {
        background: transparent;
        border-bottom-color: rgba(255,255,255,.06);
    }

    html[data-theme="dark"] .premium-details-table tbody td,
    html[data-theme="dark"] .premium-sanad-table tbody td {
        color: #e2e8f0;
    }

    html[data-theme="dark"] .premium-details-table tbody tr:hover,
    html[data-theme="dark"] .premium-sanad-table tbody tr:hover {
        background: var(--k-primary-glow);
    }

    html[data-theme="dark"] .premium-badge-account,
    html[data-theme="dark"] .premium-sanad-badge {
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
    }

    html[data-theme="dark"] .value-chip-madin,
    html[data-theme="dark"] .sanad-chip-madin {
        background: rgba(239,68,68,.15);
        color: #f87171;
    }

    html[data-theme="dark"] .value-chip-dain,
    html[data-theme="dark"] .sanad-chip-dain {
        background: rgba(16,185,129,.15);
        color: #34d399;
    }

    html[data-theme="dark"] .value-chip-zero,
    html[data-theme="dark"] .sanad-chip-zero {
        color: #6b7280;
    }

    html[data-theme="dark"] .premium-footer,
    html[data-theme="dark"] .premium-sanad-footer {
        background: linear-gradient(135deg, #1e293b, #0f172a);
        border-top-color: #334155;
    }

    html[data-theme="dark"] .premium-total-madin,
    html[data-theme="dark"] .premium-sanad-total-madin {
        background: rgba(239,68,68,.15);
        color: #f87171;
        border-color: rgba(239,68,68,.25);
    }

    html[data-theme="dark"] .premium-total-dain,
    html[data-theme="dark"] .premium-sanad-total-dain {
        background: rgba(16,185,129,.15);
        color: #34d399;
        border-color: rgba(16,185,129,.25);
    }

    html[data-theme="dark"] .premium-serial,
    html[data-theme="dark"] .premium-sanad-serial {
        background: #1e293b;
        border-color: #334155;
        color: #94a3b8;
    }

    html[data-theme="dark"] .premium-note,
    html[data-theme="dark"] .premium-sanad-note {
        color: #e2e8f0;
    }

    html[data-theme="dark"] .premium-action-edit,
    html[data-theme="dark"] .premium-sanad-edit {
        background: linear-gradient(135deg, #d97706, #b45309);
    }

    html[data-theme="dark"] .print-mode::before {
        background: #059669;
    }

    html[data-theme="dark"] .print-ready {
        border-color: #059669 !important;
        box-shadow: 0 0 0 4px rgba(5,150,105,.15) !important;
    }

        html[data-theme="dark"] .print-ready thead th {
            background: #0f172a !important;
        }

        html[data-theme="dark"] .print-ready tbody tr:nth-child(even) {
            background: #1e293b !important;
        }


    /* ==========================================================================
   08. SANAD / AUTOCOMPLETE  (root {.txt · --sn-*)
   --------------------------------------------------------------------------
   The file has body.dark-mode token overrides + body.dark-mode autocomplete
   dropdown. Neither fires. Scope everything under .sn-panel and the dropdown.
   ========================================================================== */

    html[data-theme="dark"] .sn-panel {
        --sn-bg-1: #0d0f1a;
        --sn-bg-2: #10121e;
        --sn-surface: #171a29;
        --sn-surface-2: #1e2233;
        --sn-border: #2b2f45;
        --sn-text: #eceefc;
        --sn-text-muted: #8d94b3;
        --sn-shadow: 0 1px 2px rgba(0,0,0,.3);
        --sn-shadow-md: 0 12px 32px rgba(91,95,242,.22);
    }

        html[data-theme="dark"] .sn-panel .sn-card,
        html[data-theme="dark"] .sn-panel .sn-input-group,
        html[data-theme="dark"] .sn-panel .sn-ledger-total,
        html[data-theme="dark"] .sn-panel .sn-type-btn,
        html[data-theme="dark"] .sn-panel .sn-gear-btn {
            background: var(--sn-surface);
            border-color: var(--sn-border);
            color: var(--sn-text);
        }

        html[data-theme="dark"] .sn-panel .sn-input-icon,
        html[data-theme="dark"] .sn-panel .sn-input,
        html[data-theme="dark"] .sn-panel .sn-account-block,
        html[data-theme="dark"] .sn-panel .sn-col-settings {
            background: var(--sn-surface-2);
            border-color: var(--sn-border);
            color: var(--sn-text);
        }

        html[data-theme="dark"] .sn-panel .sn-input-readonly {
            background: var(--sn-surface-2) !important;
            color: var(--sn-text-muted);
        }

        html[data-theme="dark"] .sn-panel .sn-card-header,
        html[data-theme="dark"] .sn-panel .sn-table thead th {
            background: var(--sn-surface-2);
            border-bottom-color: var(--sn-border);
            color: var(--sn-text-muted);
        }

        html[data-theme="dark"] .sn-panel .sn-table td {
            border-color: var(--sn-border);
            color: var(--sn-text);
        }

        html[data-theme="dark"] .sn-panel .sn-table tbody tr:hover {
            background: var(--sn-surface-2);
        }

        html[data-theme="dark"] .sn-panel .sn-ledger {
            background: linear-gradient(135deg, rgba(91,95,242,.08), rgba(139,92,246,.08));
            border-top-color: var(--sn-border);
        }

        html[data-theme="dark"] .sn-panel .sn-badge-primary {
            background: rgba(91,95,242,.20);
            color: #a5b4fc;
        }

        html[data-theme="dark"] .sn-panel .sn-badge-success {
            background: rgba(16,185,129,.18);
            color: #6ee7b7;
        }

        html[data-theme="dark"] .sn-panel .sn-badge-warning {
            background: rgba(245,158,11,.18);
            color: #fbbf24;
        }

    /* Autocomplete dropdown (was body.dark-mode) */
    html[data-theme="dark"] .autocomplete-dropdown {
        background: rgba(23,26,41,.98);
        border-color: var(--sn-border, #2b2f45);
    }

        html[data-theme="dark"] .autocomplete-dropdown .dropdown-item {
            color: var(--sn-text, #eceefc);
            border-bottom-color: rgba(255,255,255,.05);
        }

            html[data-theme="dark"] .autocomplete-dropdown .dropdown-item .account-number {
                background: rgba(91,95,242,.25);
                color: #8b9cff;
            }

            html[data-theme="dark"] .autocomplete-dropdown .dropdown-item:hover .account-number,
            html[data-theme="dark"] .autocomplete-dropdown .dropdown-item.active .account-number {
                background: rgba(255,255,255,.15);
                color: #fff;
            }

        html[data-theme="dark"] .autocomplete-dropdown .dropdown-loading .spinner {
            border-color: rgba(255,255,255,.15);
            border-top-color: #8b9cff;
        }

        html[data-theme="dark"] .autocomplete-dropdown .dropdown-empty,
        html[data-theme="dark"] .autocomplete-dropdown .dropdown-loading {
            color: var(--sn-text-muted);
        }


/* ==========================================================================
   09. TRIAL BALANCE  (trialbalance-premium.css · --tb-*)
   --------------------------------------------------------------------------
   File had body.tb-dark token overrides. Convert to html[data-theme="dark"].
   NOTE: --tb-* here is the trial-balance token family; the bonds report file
   redefines a different --tb-* set at .tb-report scope (handled in §12).
   ========================================================================== */

html[data-theme="dark"] {
    --tb-bg: #0f172a;
    --tb-surface-0: #1e293b;
    --tb-surface-1: #162032;
    --tb-surface-2: #0f172a;
    --tb-surface-3: #334155;
    --tb-border: #334155;
    --tb-border-hi: #475569;
    --tb-text-hi: #f1f5f9;
    --tb-text-md: #cbd5e1;
    --tb-text-lo: #94a3b8;
    --tb-text-ghost: #64748b;
    --tb-blue-lt: rgba(37,99,235,.18);
}

    html[data-theme="dark"] body {
        background: var(--tb-bg);
        color: var(--tb-text-md);
    }

    html[data-theme="dark"] .tb-shell,
    html[data-theme="dark"] .tb-filter-card,
    html[data-theme="dark"] .tb-action-bar,
    html[data-theme="dark"] .tb-table-card,
    html[data-theme="dark"] .enhanced-table-wrapper,
    html[data-theme="dark"] .modal-content,
    html[data-theme="dark"] .premium-modal-content,
    html[data-theme="dark"] .premium-modal-footer,
    html[data-theme="dark"] .financial-summary .card {
        background: var(--tb-surface-0) !important;
        border-color: var(--tb-border) !important;
        color: var(--tb-text-md);
    }

    html[data-theme="dark"] .tb-filter-card-head,
    html[data-theme="dark"] .tb-table-card-head,
    html[data-theme="dark"] .table-controls,
    html[data-theme="dark"] .table-footer,
    html[data-theme="dark"] .card-item-actions,
    html[data-theme="dark"] .modal-footer {
        background: var(--tb-surface-1);
        border-color: var(--tb-border);
        color: var(--tb-text-md);
    }

    html[data-theme="dark"] .tb-input,
    html[data-theme="dark"] .tb-select,
    html[data-theme="dark"] .form-control,
    html[data-theme="dark"] .form-select,
    html[data-theme="dark"] .search-input,
    html[data-theme="dark"] .filter-select,
    html[data-theme="dark"] .page-size-select,
    html[data-theme="dark"] .input-group-text,
    html[data-theme="dark"] .ig-icon {
        background: var(--tb-surface-1) !important;
        border-color: var(--tb-border-hi) !important;
        color: var(--tb-text-hi);
    }

    html[data-theme="dark"] #tabledetails tbody tr:nth-child(even) {
        background: var(--tb-surface-1);
    }

    html[data-theme="dark"] #tabledetails tbody tr:hover,
    html[data-theme="dark"] .enhanced-table tbody tr:hover {
        background: #1e3a5f !important;
    }

    html[data-theme="dark"] #tabledetails tbody td,
    html[data-theme="dark"] .enhanced-table tbody td {
        border-color: var(--tb-border);
        color: var(--tb-text-md);
    }

    html[data-theme="dark"] #tabledetails tfoot tr {
        background: linear-gradient(135deg, #1e293b 0%, #172033 100%);
    }

    html[data-theme="dark"] #tabledetails tfoot td {
        color: var(--tb-text-hi);
        border-color: var(--tb-border-hi);
    }

    html[data-theme="dark"] .enhanced-table tfoot tr {
        background: linear-gradient(135deg, #1e293b 0%, #172033 100%);
    }

    html[data-theme="dark"] .enhanced-table tfoot td {
        color: var(--tb-text-hi);
        border-color: var(--tb-border-hi);
    }

    html[data-theme="dark"] .account-badge {
        background: rgba(37,99,235,.25);
        border-color: rgba(37,99,235,.35);
        color: #93c5fd;
    }

    html[data-theme="dark"] .account-name-text {
        color: var(--tb-text-hi);
    }

    html[data-theme="dark"] .card-item {
        background: var(--tb-surface-0);
        border-color: var(--tb-border);
    }

        html[data-theme="dark"] .card-item:hover {
            background: var(--tb-surface-1);
        }

    html[data-theme="dark"] .card-metric {
        border-color: var(--tb-border);
    }

        html[data-theme="dark"] .card-metric:hover {
            background: var(--tb-surface-1);
        }

        html[data-theme="dark"] .card-metric label {
            color: var(--tb-text-lo);
        }

        html[data-theme="dark"] .card-metric.balance {
            background: var(--tb-surface-1);
        }

    html[data-theme="dark"] .btn-action,
    html[data-theme="dark"] .page-btn,
    html[data-theme="dark"] .view-btn.active {
        background: var(--tb-surface-1);
        border-color: var(--tb-border);
        color: var(--tb-text-md);
    }

        html[data-theme="dark"] .page-btn:hover:not([disabled]) {
            background: rgba(37,99,235,.20);
            color: #93c5fd;
            border-color: var(--tb-blue);
        }

        html[data-theme="dark"] .page-btn.active {
            background: var(--tb-blue);
            color: #fff;
        }

    html[data-theme="dark"] .col-lg-3.bg-light {
        background: var(--tb-surface-1) !important;
    }

    html[data-theme="dark"] .premium-modal-header {
        background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #0891b2 100%) !important;
    }

    html[data-theme="dark"] .premium-modal-body {
        background: var(--tb-bg) !important;
    }

    html[data-theme="dark"] #searchPanel {
        background: var(--tb-surface-1);
        border-color: var(--tb-border);
    }

    html[data-theme="dark"] .select2-container .select2-selection--single,
    html[data-theme="dark"] .select2-dropdown {
        background: var(--tb-surface-1) !important;
        border-color: var(--tb-border-hi) !important;
        color: var(--tb-text-hi) !important;
    }

    html[data-theme="dark"] .select2-results__option {
        color: var(--tb-text-md) !important;
    }


/* ==========================================================================
   10. ACCOUNT DETAIL  (accountdetail-premium.css · --ad-*)
   --------------------------------------------------------------------------
   That file has NO dark mode at all. Build it from scratch.
   ========================================================================== */

html[data-theme="dark"] {
    --ad-bg: #0f172a;
    --ad-surface: #1e293b;
    --ad-border: #334155;
    --ad-border-light: #263042;
    --ad-primary: #60a5fa;
    --ad-primary-dim: rgba(96,165,250,.15);
    --ad-primary-glow: rgba(96,165,250,.12);
    --ad-teal: #22d3ee;
    --ad-green: #34d399;
    --ad-green-dim: rgba(52,211,153,.15);
    --ad-amber: #fbbf24;
    --ad-amber-dim: rgba(251,191,36,.15);
    --ad-red: #f87171;
    --ad-red-dim: rgba(248,113,113,.15);
    --ad-violet: #c4b5fd;
    --ad-text: #e2e8f0;
    --ad-text-muted: #94a3b8;
    --ad-text-light: #64748b;
    --ad-shadow: 0 1px 4px rgba(0,0,0,.4), 0 0 0 1px var(--ad-border);
    --ad-shadow-lg: 0 4px 20px rgba(0,0,0,.5);
}

    html[data-theme="dark"] .ad-page {
        background: var(--ad-bg);
        color: var(--ad-text);
    }

    html[data-theme="dark"] .ad-card {
        background: var(--ad-surface);
        box-shadow: var(--ad-shadow);
    }

    html[data-theme="dark"] .ad-card-header {
        background: linear-gradient(180deg, #263042 0%, #1e293b 100%);
        border-bottom-color: var(--ad-border-light);
    }

    html[data-theme="dark"] .ad-input-group {
        background: #263042;
        border-color: var(--ad-border);
    }

    html[data-theme="dark"] .ad-input-group-icon {
        background: #1e293b;
        border-color: var(--ad-border);
        color: var(--ad-text-muted);
    }

    html[data-theme="dark"] .ad-input-group input,
    html[data-theme="dark"] .ad-input-group select {
        color: var(--ad-text);
        background: transparent;
    }

        html[data-theme="dark"] .ad-input-group input[readonly],
        html[data-theme="dark"] .ad-input-group input[disabled] {
            background: #162032;
            color: var(--ad-text-muted);
        }

    html[data-theme="dark"] .ad-pill-group {
        background: #263042;
        border-color: var(--ad-border);
    }

        html[data-theme="dark"] .ad-pill-group label {
            color: var(--ad-text-muted);
        }

    html[data-theme="dark"] .ad-btn-ghost {
        border-color: var(--ad-border);
        color: var(--ad-text-muted);
    }

        html[data-theme="dark"] .ad-btn-ghost:hover {
            color: var(--ad-primary);
            border-color: var(--ad-primary);
        }

    html[data-theme="dark"] .ad-table thead th {
        background: linear-gradient(180deg, #1e3a5f 0%, #1e293b 100%);
        color: #93c5fd;
        border-bottom-color: #3b82f6;
    }

    html[data-theme="dark"] .ad-table tbody tr:nth-child(even) td {
        background: #162032;
    }

    html[data-theme="dark"] .ad-table tbody tr:hover td {
        background: var(--ad-primary-glow);
    }

    html[data-theme="dark"] .ad-table td {
        color: var(--ad-text);
        border-bottom-color: var(--ad-border-light);
    }

    html[data-theme="dark"] .ad-cell-debit {
        color: var(--ad-teal);
    }

    html[data-theme="dark"] .ad-cell-credit {
        color: var(--ad-amber);
    }

    html[data-theme="dark"] .ad-cell-balance {
        color: var(--ad-green);
    }

    html[data-theme="dark"] .ad-table tfoot td {
        background: #162032;
        border-top-color: var(--ad-border);
    }

    html[data-theme="dark"] .ad-summary-row,
    html[data-theme="dark"] .ad-safi-row {
        background: #263042;
        border-color: var(--ad-border);
    }

    html[data-theme="dark"] .ad-safi-label {
        background: #1e293b;
        border-color: var(--ad-border);
        color: var(--ad-text-muted);
    }

    html[data-theme="dark"] .ad-safi-row input {
        color: var(--ad-green);
    }

    html[data-theme="dark"] .ad-pagination-bar {
        background: #162032;
        border-top-color: var(--ad-border-light);
    }

    html[data-theme="dark"] .ad-page-size-group select {
        background: var(--ad-surface);
        border-color: var(--ad-border);
        color: var(--ad-text);
    }

    html[data-theme="dark"] #tablePaginationControls .page-item .page-link {
        background: #263042;
        border-color: var(--ad-border);
        color: var(--ad-text-muted);
    }

    html[data-theme="dark"] #tablePaginationControls .page-item.active .page-link {
        background: var(--ad-primary);
        color: #0f172a;
    }

    html[data-theme="dark"] .ad-aging-btn {
        background: #263042;
        border-color: var(--ad-border);
        color: var(--ad-text-muted);
    }

        html[data-theme="dark"] .ad-aging-btn:hover {
            color: var(--ad-primary);
            border-color: var(--ad-primary);
            background: var(--ad-primary-glow);
        }

        html[data-theme="dark"] .ad-aging-btn .ad-aging-badge {
            background: var(--ad-red-dim);
            color: var(--ad-red);
        }

    html[data-theme="dark"] .ad-overlay {
        background: rgba(15,23,42,.85);
    }

        html[data-theme="dark"] .ad-overlay .spinner-border {
            color: var(--ad-primary);
        }

    html[data-theme="dark"] .ad-overlay-msg {
        color: var(--ad-primary);
    }


/* ==========================================================================
   11. DAILY MOVEMENT  (dailymovement*.css · --dm-*)
   --------------------------------------------------------------------------
   File already gates tokens on [data-bs-theme="dark"], which ThemeService
   sets — so tokens mostly work. Add html[data-theme="dark"] parity + fix the
   hardcoded light surfaces and the empty-state gradients.
   ========================================================================== */

html[data-theme="dark"] {
    --dm-bg: #0f172a;
    --dm-surface: #1e293b;
    --dm-surface-2: #334155;
    --dm-surface-3: #475569;
    --dm-border: rgba(255,255,255,.07);
    --dm-border-hi: rgba(79,120,255,.32);
    --dm-text: #f1f5f9;
    --dm-text-2: #cbd5e1;
    --dm-text-3: #94a3b8;
    --gradient-header: linear-gradient(135deg,#1e1b4b 0%,#0f172a 50%,#1e1b4b 100%);
}

    html[data-theme="dark"] .dm-container {
        background: var(--dm-bg);
    }

    html[data-theme="dark"] .dm-card,
    html[data-theme="dark"] .dm-stat-card,
    html[data-theme="dark"] .dm-modal-content,
    html[data-theme="dark"] .dm-detail-panel .card,
    html[data-theme="dark"] .dm-action-toolbar,
    html[data-theme="dark"] .dm-pay-card {
        background: var(--dm-surface) !important;
        border-color: var(--dm-border) !important;
        color: var(--dm-text);
    }

    html[data-theme="dark"] .dm-stats-grid,
    html[data-theme="dark"] .dm-action-bar,
    html[data-theme="dark"] .dm-footer-bar,
    html[data-theme="dark"] .dm-total-strip,
    html[data-theme="dark"] .dm-modal-footer,
    html[data-theme="dark"] .dm-sidebar-footer,
    html[data-theme="dark"] .dm-search-wrap {
        background: var(--dm-surface-2);
        border-color: var(--dm-border);
        color: var(--dm-text-2);
    }

    html[data-theme="dark"] .dm-modal-header,
    html[data-theme="dark"] .dm-sidebar-header,
    html[data-theme="dark"] .dm-detail-panel .card-header,
    html[data-theme="dark"] .dm-section-header {
        background: var(--dm-surface-2) !important;
        border-color: var(--dm-border) !important;
    }

    html[data-theme="dark"] .dm-action-toolbar .card-header {
        background: linear-gradient(135deg,#1e293b 0%,#312e81 60%,#1e293b 100%) !important;
    }

    html[data-theme="dark"] .dm-sidebar,
    html[data-theme="dark"] .dm-content-area,
    html[data-theme="dark"] .dm-modal-body,
    html[data-theme="dark"] .dm-table-wrap,
    html[data-theme="dark"] .dm-item-row {
        background: var(--dm-bg) !important;
        border-color: var(--dm-border) !important;
        color: var(--dm-text);
    }

        html[data-theme="dark"] .dm-item-row:hover {
            background: var(--dm-surface-2) !important;
        }

        html[data-theme="dark"] .dm-item-row.active {
            background: linear-gradient(90deg,var(--dm-blue-glow),transparent) !important;
            border-inline-start-color: var(--dm-blue) !important;
        }

    html[data-theme="dark"] .dm-search-box input,
    html[data-theme="dark"] .dm-detail-panel .form-control,
    html[data-theme="dark"] .dm-detail-panel .form-select,
    html[data-theme="dark"] .dm-detail-panel .input-group-text,
    html[data-theme="dark"] .dm-table .input-group-sm .form-control,
    html[data-theme="dark"] .dm-table .input-group-sm .input-group-text {
        background: var(--dm-surface-2) !important;
        border-color: var(--dm-border) !important;
        color: var(--dm-text) !important;
    }

    html[data-theme="dark"] .dm-detail-panel .btn-outline-secondary {
        background: var(--dm-surface-3) !important;
        border-color: var(--dm-border) !important;
        color: var(--dm-text-3) !important;
    }

    html[data-theme="dark"] .dm-table thead th,
    html[data-theme="dark"] .dm-report-table thead th {
        background: var(--dm-surface-3) !important;
        color: var(--dm-text-2) !important;
        border-color: var(--dm-border) !important;
    }

    html[data-theme="dark"] .dm-table tbody tr:hover,
    html[data-theme="dark"] .dm-report-table tbody tr:hover {
        background: var(--dm-surface-2) !important;
    }

    html[data-theme="dark"] .dm-row-net {
        background: rgba(5,150,105,.12) !important;
    }

    html[data-theme="dark"] .dm-row-cost {
        background: rgba(220,38,38,.10) !important;
    }

    html[data-theme="dark"] .dm-row-profit {
        background: rgba(59,91,219,.12) !important;
    }

    /* Empty state gradient was hardcoded white → dark surface */
    html[data-theme="dark"] .dm-empty-state-premium {
        background: linear-gradient(135deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
        border-color: var(--dm-border);
    }

    html[data-theme="dark"] .dm-empty-filtered {
        background: var(--dm-surface-2);
    }

    html[data-theme="dark"] .dm-clear-filters-btn {
        background: var(--dm-surface);
        border-color: var(--dm-border);
        color: var(--dm-text);
    }

        html[data-theme="dark"] .dm-clear-filters-btn:hover {
            background: var(--dm-blue);
            border-color: var(--dm-blue);
            color: #fff;
        }

    html[data-theme="dark"] .modal-content {
        background: var(--dm-surface) !important;
        border-color: var(--dm-border-hi) !important;
        color: var(--dm-text) !important;
    }

    html[data-theme="dark"] .modal-body {
        background: var(--dm-bg) !important;
        color: var(--dm-text) !important;
    }

    html[data-theme="dark"] .modal-footer {
        background: var(--dm-surface-2) !important;
        border-color: var(--dm-border) !important;
    }

    html[data-theme="dark"] .print-preview {
        background: var(--dm-surface);
        color: var(--dm-text);
    }

    html[data-theme="dark"] #loading-overlay {
        background: rgba(15,23,42,.85);
    }

    html[data-theme="dark"] #toastContainer .toast {
        background: var(--dm-surface-2) !important;
        border-color: var(--dm-border-hi) !important;
        color: var(--dm-text) !important;
    }


/* ==========================================================================
   12. BONDS REPORT  (bonds report css · --bp-* + .tb-report --tb-*)
   --------------------------------------------------------------------------
   File gated on .dark-mode class, which nothing adds. Use html[data-theme].
   .tb-report scopes its own --tb-* redefinition (different from §09).
   ========================================================================== */

html[data-theme="dark"] {
    --bp-bg: #0f1117;
    --bp-surface-0: #1a1d26;
    --bp-surface-1: rgba(255,255,255,.035);
    --bp-surface-2: rgba(255,255,255,.06);
    --bp-border: rgba(255,255,255,.10);
    --bp-ink: #eef1ff;
    --bp-ink-soft: #c7cbe8;
    --bp-muted: #9aa0c3;
}

    html[data-theme="dark"] .tb-report {
        --tb-primary: #6366f1;
        --tb-primary-dark: #4f46e5;
        --tb-violet: #8b5cf6;
        --tb-cyan: #22d3ee;
        --tb-debit: #10b981;
        --tb-credit: #f43f5e;
        --tb-surface: #151324;
        --tb-surface-alt: #1b1930;
        --tb-border: #2b2846;
        --tb-text: #ece9f9;
        --tb-text-muted: #9c96c0;
        --tb-shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -12px rgba(124,58,237,.35);
    }

    html[data-theme="dark"] body {
        background: var(--bp-bg);
        color: var(--bp-ink-soft);
    }

    html[data-theme="dark"] .bp-page {
        background: var(--bp-bg);
    }

    html[data-theme="dark"] .ac-page-card,
    html[data-theme="dark"] .tb-search-card,
    html[data-theme="dark"] .tb-filter-card,
    html[data-theme="dark"] .tb-card,
    html[data-theme="dark"] .tb-report .tb-results-head,
    html[data-theme="dark"] .tb-report .table-footer {
        background: var(--bp-surface-0);
        border-color: var(--bp-border);
        color: var(--bp-ink-soft);
    }

    html[data-theme="dark"] .ac-page-title {
        color: var(--bp-ink);
    }

    html[data-theme="dark"] .ac-page-desc {
        color: var(--bp-ink-soft);
    }

    html[data-theme="dark"] .tb-report .tb-field,
    html[data-theme="dark"] .tb-report .tb-field-combo,
    html[data-theme="dark"] .tb-report .tb-filter-block,
    html[data-theme="dark"] .tb-report .tb-btn-icon,
    html[data-theme="dark"] .tb-report .tb-seg,
    html[data-theme="dark"] .tb-report .tb-chip,
    html[data-theme="dark"] .tb-report .page-btn,
    html[data-theme="dark"] .tb-report .page-size-select {
        background: var(--tb-surface-alt);
        border-color: var(--tb-border);
        color: var(--tb-text);
    }

        html[data-theme="dark"] .tb-report .tb-field .form-control,
        html[data-theme="dark"] .tb-report .tb-field-combo .form-control {
            color: var(--tb-text);
        }

    html[data-theme="dark"] .tb-report .tb-table thead th,
    html[data-theme="dark"] .tb-report .pl-thead th {
        background: var(--tb-surface-alt);
        border-color: var(--tb-border);
        color: var(--tb-text-muted);
    }

    html[data-theme="dark"] .tb-report .tb-table tbody td {
        border-color: var(--tb-border);
        color: var(--tb-text);
    }

    html[data-theme="dark"] .tb-report .tb-table tbody tr:nth-child(even) {
        background: var(--tb-surface-alt);
    }

    html[data-theme="dark"] .tb-report .tb-table tbody tr:hover {
        background: rgba(99,102,241,.10);
    }

    html[data-theme="dark"] .tb-report .pl-tfoot tr:first-child td {
        border-top: 2px solid color-mix(in srgb, var(--tb-primary) 40%, var(--tb-border)) !important;
    }

    html[data-theme="dark"] .tb-report .pl-tfoot__label-text {
        color: var(--tb-text);
    }

    html[data-theme="dark"] .tb-report .pl-tfoot__badge--credit {
        background: color-mix(in srgb, var(--tb-debit) 15%, var(--tb-surface));
        color: var(--tb-debit);
        border-color: color-mix(in srgb, var(--tb-debit) 35%, transparent);
    }

    html[data-theme="dark"] .tb-report .search-input {
        background: var(--tb-surface-alt);
        border-color: var(--tb-border);
        color: var(--tb-text);
    }

    html[data-theme="dark"] .tb-report .search-clear {
        color: var(--tb-text-muted);
    }

    html[data-theme="dark"] .tb-report.br-report .report-tabs-nav .nav-link {
        background: var(--tb-surface-alt);
        border-color: var(--tb-border);
        color: var(--tb-text-muted);
    }

        html[data-theme="dark"] .tb-report.br-report .report-tabs-nav .nav-link.active {
            color: #fff;
            background: linear-gradient(135deg, var(--tb-primary), var(--tb-violet));
        }

    html[data-theme="dark"] .tb-report.br-report .br-loading-overlay {
        background: color-mix(in srgb, var(--tb-surface) 82%, transparent);
    }

/* ==========================================================================
   13. USER ACCOUNT  (style.txt · --ua-*)
   --------------------------------------------------------------------------
   style.txt has NO dark mode at all. It uses glass surfaces built from
   rgba(255,255,255,…) which look wrong on dark. All of that needs rebuilding
   here. The @keyframes / @media lines in the source use doubled `@@` because
   they're Razor-escaped — leave them alone; nothing below depends on them.
   ========================================================================== */

html[data-theme="dark"] {
    --ua-primary: #6b8aff;
    --ua-primary-dark: #5578f5;
    --ua-accent: #94a6ff;
    --ua-danger: #fca5a5;
    --ua-success: #34d399;
    --ua-bg-glass: rgba(30, 41, 59, 0.78);
    --ua-border: rgba(107, 138, 255, 0.24);
}

    /* Card shell + header */
    html[data-theme="dark"] .ua-card {
        background: var(--ua-bg-glass);
        border-color: var(--ua-border);
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
    }

    html[data-theme="dark"] .ua-header {
        background: linear-gradient(135deg, #3548a8 0%, #4a5cc4 45%, #6475d8 100%);
    }

    /* Tabs */
    html[data-theme="dark"] .ua-tabs {
        background: rgba(15, 23, 42, 0.5);
        border-bottom-color: var(--ua-border);
    }

    html[data-theme="dark"] .ua-tab-btn {
        color: #94a3b8;
    }

        html[data-theme="dark"] .ua-tab-btn:hover {
            color: #e2e8f0;
            background: rgba(107, 138, 255, 0.10);
        }

        html[data-theme="dark"] .ua-tab-btn.active {
            color: #eef2ff;
            background: #1e293b;
        }

    /* Body + form controls */
    html[data-theme="dark"] .ua-body {
        color: #e2e8f0;
    }

    html[data-theme="dark"] .ua-wrap .form-label {
        color: #94a3b8;
    }

    html[data-theme="dark"] .ua-wrap .form-control,
    html[data-theme="dark"] .ua-wrap .form-select {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.10);
        color: #e2e8f0;
    }

        html[data-theme="dark"] .ua-wrap .form-control:focus,
        html[data-theme="dark"] .ua-wrap .form-select:focus {
            border-color: var(--ua-primary);
            box-shadow: 0 0 0 3px rgba(107, 138, 255, 0.22);
        }

    html[data-theme="dark"] .ua-wrap .input-group-text {
        background: #172033;
        border-color: rgba(255, 255, 255, 0.08);
        color: var(--ua-primary-dark);
    }

    /* Mini card (profile panel) */
    html[data-theme="dark"] .ua-mini-card {
        background: #1e293b;
        border-color: var(--ua-border);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    }

        html[data-theme="dark"] .ua-mini-card .ua-mini-header {
            color: #cbd5e1;
            border-bottom-color: rgba(255, 255, 255, 0.06);
        }

    /* Avatar + footer */
    html[data-theme="dark"] .ua-avatar-img {
        border-color: rgba(255, 255, 255, 0.10);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    }

    html[data-theme="dark"] .ua-footer {
        background: rgba(15, 23, 42, 0.6);
        border-top-color: var(--ua-border);
    }

    /* Danger zone */
    html[data-theme="dark"] .ua-danger-zone {
        background: rgba(229, 86, 107, 0.10);
        border-color: rgba(229, 86, 107, 0.35);
    }


/* ==========================================================================
   14. COLUMN SETTINGS  (columnssettings.css · --cp-*)
   --------------------------------------------------------------------------
   File has NO dark mode at all. It's built on CSS variables, so re-defining
   the tokens handles most of it; the hardcoded white/grey hits are patched
   below.
   ========================================================================== */

html[data-theme="dark"] {
    --cp-accent: #a3d977;
    --cp-accent-mid: #8ec466;
    --cp-accent-pale: rgba(163, 217, 119, 0.14);
    --cp-accent-light: rgba(163, 217, 119, 0.28);
    --cp-amber: #fbbf24;
    --cp-amber-pale: rgba(251, 191, 36, 0.12);
    --cp-danger-pale: rgba(248, 113, 113, 0.14);
    --cp-danger: #f87171;
    --cp-info-pale: rgba(96, 165, 250, 0.14);
    --cp-info: #60a5fa;
    --cp-border: rgba(255, 255, 255, 0.08);
    --cp-border-mid: rgba(255, 255, 255, 0.14);
    --cp-surface: #1e293b;
    --cp-bg: #0f172a;
    --cp-text: #e2e8f0;
    --cp-muted: #94a3b8;
    --cp-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    --cp-row-hover: #263449;
    --cp-row-selected: rgba(163, 217, 119, 0.10);
}

    html[data-theme="dark"] body {
        background: var(--cp-bg);
        color: var(--cp-text);
    }

    html[data-theme="dark"] .cp-shell,
    html[data-theme="dark"] .cp-header,
    html[data-theme="dark"] .cp-filter-tags,
    html[data-theme="dark"] .cp-pagination-strip,
    html[data-theme="dark"] .cp-sidebar,
    html[data-theme="dark"] .cp-panel,
    html[data-theme="dark"] .cp-modal .modal-content {
        background: var(--cp-surface);
        border-color: var(--cp-border);
        color: var(--cp-text);
    }

    /* Search box — file sets `background: #fff` on focus */
    html[data-theme="dark"] .cp-search-input {
        background: var(--cp-bg);
        border-color: var(--cp-border-mid);
        color: var(--cp-text);
    }

        html[data-theme="dark"] .cp-search-input:focus {
            background: var(--cp-surface);
            border-color: var(--cp-accent-mid);
        }

    /* Buttons that were white / transparent */
    html[data-theme="dark"] .cp-btn,
    html[data-theme="dark"] .cp-page-size,
    html[data-theme="dark"] .cp-select-sm,
    html[data-theme="dark"] .cp-form-control,
    html[data-theme="dark"] .cp-order-input {
        background: var(--cp-bg);
        border-color: var(--cp-border-mid);
        color: var(--cp-text);
    }

        html[data-theme="dark"] .cp-order-input:focus {
            background: var(--cp-surface);
            border-color: var(--cp-accent-mid);
        }

    html[data-theme="dark"] .cp-btn-primary {
        background: var(--cp-accent);
        border-color: var(--cp-accent);
        color: #0f172a;
    }

        html[data-theme="dark"] .cp-btn-primary:hover {
            background: var(--cp-accent-mid);
            border-color: var(--cp-accent-mid);
        }

    html[data-theme="dark"] .cp-btn-ghost {
        color: var(--cp-muted);
    }

        html[data-theme="dark"] .cp-btn-ghost:hover {
            background: var(--cp-bg);
            color: var(--cp-text);
        }

    /* Pagination */
    html[data-theme="dark"] .cp-page-link {
        color: var(--cp-muted);
    }

        html[data-theme="dark"] .cp-page-link:hover {
            background: var(--cp-bg);
            color: var(--cp-text);
            border-color: var(--cp-border);
        }

    /* Sidebar nav + actions */
    html[data-theme="dark"] .cp-nav-link {
        color: var(--cp-muted);
    }

        html[data-theme="dark"] .cp-nav-link:hover {
            background: var(--cp-bg);
            color: var(--cp-text);
        }

        html[data-theme="dark"] .cp-nav-link.active {
            background: var(--cp-accent-pale);
            color: var(--cp-accent);
            border-color: var(--cp-accent-light);
        }

    html[data-theme="dark"] .cp-action-btn {
        color: var(--cp-text);
        border-color: var(--cp-border-mid);
    }

        html[data-theme="dark"] .cp-action-btn:hover {
            background: var(--cp-bg);
            border-color: var(--cp-accent-light);
        }

        html[data-theme="dark"] .cp-action-btn i {
            color: var(--cp-muted);
        }

    /* Stats cards */
    html[data-theme="dark"] .cp-stat {
        background: var(--cp-bg);
        border: 1px solid var(--cp-border);
    }

    /* Table head / row hover */
    html[data-theme="dark"] .cp-table thead th {
        background: var(--cp-bg);
        color: var(--cp-muted);
        border-bottom-color: var(--cp-border-mid);
    }

    html[data-theme="dark"] .cp-table tbody tr {
        border-bottom-color: var(--cp-border);
    }

        html[data-theme="dark"] .cp-table tbody tr:hover {
            background: var(--cp-row-hover);
        }

        html[data-theme="dark"] .cp-table tbody tr.selected {
            background: var(--cp-row-selected);
        }

    /* ID badge / group tag */
    html[data-theme="dark"] .cp-idx {
        background: var(--cp-bg);
        color: var(--cp-muted);
        border: 1px solid var(--cp-border);
    }

    html[data-theme="dark"] .cp-group-tag {
        background: var(--cp-info-pale);
        color: var(--cp-info);
        border-color: rgba(96, 165, 250, 0.28);
    }

    /* Switch slider — hardcoded #ddd and #fff */
    html[data-theme="dark"] .cp-slider {
        background: #475569;
    }

        html[data-theme="dark"] .cp-slider::before {
            background: #e2e8f0;
        }

    /* Row action buttons */
    html[data-theme="dark"] .cp-act-btn {
        color: var(--cp-muted);
        border-color: var(--cp-border-mid);
    }

        html[data-theme="dark"] .cp-act-btn:hover {
            background: var(--cp-bg);
            color: var(--cp-text);
        }

    /* Sortable ghost */
    html[data-theme="dark"] .sortable-ghost {
        background: var(--cp-accent-pale) !important;
    }

    /* Empty state — hardcoded #ddd */
    html[data-theme="dark"] .cp-empty i {
        color: #475569;
    }

    /* Dropdown + filter buttons */
    html[data-theme="dark"] .cp-dropdown-menu {
        background: var(--cp-surface);
        border-color: var(--cp-border-mid);
    }

    html[data-theme="dark"] .cp-filter-btn {
        background: transparent;
        color: var(--cp-muted);
        border-color: var(--cp-border-mid);
    }

        html[data-theme="dark"] .cp-filter-btn:hover,
        html[data-theme="dark"] .cp-filter-btn.active {
            background: var(--cp-accent-pale);
            color: var(--cp-accent);
            border-color: var(--cp-accent);
        }

    /* Modals */
    html[data-theme="dark"] .cp-modal .modal-header {
        background: var(--cp-bg);
        border-bottom-color: var(--cp-border);
    }

    html[data-theme="dark"] .cp-modal .modal-footer {
        border-top-color: var(--cp-border);
    }

    /* Loading overlay — hardcoded rgba(255,255,255,.7) */
    html[data-theme="dark"] .cp-spinner-overlay {
        background: rgba(15, 23, 42, 0.72);
    }

    /* Toast */
    html[data-theme="dark"] .cp-toast {
        background: var(--cp-surface);
        border-color: var(--cp-border-mid);
        color: var(--cp-text);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    }

    /* Table scrollbar */
    html[data-theme="dark"] .cp-table-wrap::-webkit-scrollbar-thumb {
        background: var(--cp-border-mid);
    }


/* ==========================================================================
   15. ADFORM SCREENS  (adformnew.css · --ud-* / .adf-* / .gp-*)
   --------------------------------------------------------------------------
   adformnew.css already defines [data-theme="dark"] (bare attribute) for a
   subset of --ud-* tokens and a `[data-theme="dark"]` block for .gp-*. Those
   work because ThemeService sets data-theme on <html>. The overrides below
   fill in the tokens that were missed (shadow-sm/lg, yellow) and patch the
   hardcoded hex values in badges and modal chrome.
   ========================================================================== */

html[data-theme="dark"] {
    --ud-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
    --ud-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    --ud-yellow: #fbbf24;
    --ud-green: #34d399;
    --ud-red: #f87171;
    --ud-cyan: #22d3ee;
}

    /* Already-scoped tokens but the hardcoded badge fill / text colors */
    html[data-theme="dark"] .ud-badge--amber {
        background: rgba(217, 119, 6, 0.20);
        color: #fbbf24;
    }

    html[data-theme="dark"] .ud-badge--gray {
        background: rgba(148, 163, 184, 0.18);
        color: #cbd5e1;
    }

    html[data-theme="dark"] .ud-badge--indigo {
        background: rgba(99, 126, 240, 0.20);
        color: #a5b4fc;
    }

    /* Status pill / type badge variants use fixed dark pills already in the file
   — leave them; but check "ud-badge" fallback */
    html[data-theme="dark"] .ud-badge {
        border-color: transparent;
    }

    /* Chip active state — uses #fff via the accent */
    html[data-theme="dark"] .chip.active {
        background: #4f6fff;
        border-color: #4f6fff;
    }

    /* The eliter table header gradient is deep purple, fine in dark.
   Row hover uses --ud-surface-2 which is already redefined. */

    /* Stat pills — --pill-rgb values stay readable; only the inactive stat needs
   a slightly brighter bg to keep the shadow visible */
    html[data-theme="dark"] .stat-premium-pill:hover {
        box-shadow: 0 4px 14px rgba(var(--pill-rgb), 0.28);
    }

    /* Details modal shell */
    html[data-theme="dark"] .adf-details-modal .modal-content {
        background: var(--ud-surface);
        border-color: var(--ud-border-hi);
    }

    html[data-theme="dark"] .adf-details-body {
        background: var(--ud-surface-2);
    }

    /* Partials — .adf-d-card, .adf-form, .adf-win-* */
    html[data-theme="dark"] .adf-d-card {
        background: var(--ud-surface);
        border-color: var(--ud-border);
    }

    html[data-theme="dark"] .adf-d-head {
        background: var(--ud-surface-2);
        border-color: var(--ud-border);
        color: var(--ud-text);
    }

    html[data-theme="dark"] .adf-d-item {
        background: var(--ud-surface-2);
    }

    html[data-theme="dark"] .adf-form .form-control,
    html[data-theme="dark"] .adf-form .form-select {
        background-color: var(--ud-surface);
        border-color: var(--ud-border);
        color: var(--ud-text);
    }

        html[data-theme="dark"] .adf-form .form-control[readonly] {
            background: var(--ud-surface-2);
        }

    /* Windows sub-table */
    html[data-theme="dark"] .adf-win-head {
        background: linear-gradient(90deg, rgba(99, 126, 240, 0.14), rgba(124, 58, 237, 0.10));
        border-color: var(--ud-border);
        color: var(--ud-text);
    }

    html[data-theme="dark"] .adf-win-title {
        color: var(--ud-text);
    }

    html[data-theme="dark"] #windowsTable tbody td {
        color: var(--ud-text);
        border-color: var(--ud-border);
    }

    html[data-theme="dark"] .adf-win-foot {
        background: var(--ud-surface-2);
        border-top-color: var(--ud-border);
    }

    /* General Permissions modal (gp-*) — already covered by its own
   [data-theme="dark"] block; add the checkbox accent color for consistency */
    html[data-theme="dark"] .gp-modal .form-check-input:checked {
        background-color: #7c8fff;
        border-color: #7c8fff;
    }


/* ==========================================================================
   16. INIT MODAL · STORE · SIGNATURE  (init-* glass system)
   --------------------------------------------------------------------------
   Files: init-store.css, init-modal-premium.css, and the INITIALIZATION
   MODAL file with tokens --primary / --glass-bg / --glass-border. The IP
   tokens (--ip-*) already have dark values (item-premium.css ships a
   [data-bs-theme="dark"] block). What's missing is:
     · --glass-bg / --glass-border / --font-sans text colors for the init
       modal that uses its OWN token set
     · the rgba(255,255,255,…) surfaces inside the modal body
     · #fef0f0 invalid-row background in init-table-wrap
   ========================================================================== */

/* Init modal tokens (the purple/violet --primary one) */
html[data-theme="dark"] {
    --bg-overlay: rgba(0, 0, 0, 0.75);
    --glass-bg: rgba(17, 24, 39, 0.88);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-strong: 0 12px 40px rgba(0, 0, 0, 0.7);
}

    html[data-theme="dark"] .init-modal {
        background: var(--glass-bg);
        border-color: var(--glass-border);
    }

    html[data-theme="dark"] .init-modal-header {
        background: linear-gradient(135deg, #4a3db8, #6c5ce7);
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    html[data-theme="dark"] .init-modal-body-wrap {
        background: rgba(15, 23, 42, 0.45);
    }

    html[data-theme="dark"] .init-sidebar {
        background: rgba(15, 23, 42, 0.6);
        border-right-color: rgba(255, 255, 255, 0.06);
    }

        html[data-theme="dark"] .init-sidebar .tab-btn {
            color: #94a3b8;
        }

            html[data-theme="dark"] .init-sidebar .tab-btn i {
                color: #a29bfe;
            }

            html[data-theme="dark"] .init-sidebar .tab-btn:hover {
                background: rgba(108, 92, 231, 0.14);
                color: #e2e8f0;
            }

            html[data-theme="dark"] .init-sidebar .tab-btn.active {
                background: rgba(108, 92, 231, 0.22);
                color: #eef2ff;
                border-left-color: #a29bfe;
            }

    html[data-theme="dark"] .init-content {
        background: rgba(15, 23, 42, 0.35);
    }

    /* Toolbar */
    html[data-theme="dark"] .init-toolbar .search-box input {
        background: rgba(30, 41, 59, 0.7);
        border-color: rgba(255, 255, 255, 0.08);
        color: #e2e8f0;
    }

        html[data-theme="dark"] .init-toolbar .search-box input:focus {
            background: #1e293b;
            border-color: #a29bfe;
            box-shadow: 0 0 0 3px rgba(162, 155, 254, 0.18);
        }

    html[data-theme="dark"] .init-btn-outline {
        background: rgba(30, 41, 59, 0.6);
        border-color: rgba(255, 255, 255, 0.08);
        color: #cbd5e1;
    }

        html[data-theme="dark"] .init-btn-outline:hover {
            background: #1e293b;
            border-color: #a29bfe;
            color: #eef2ff;
        }

    /* Table wrapper */
    html[data-theme="dark"] .init-table-wrap {
        background: rgba(15, 23, 42, 0.55);
        border-color: rgba(255, 255, 255, 0.06);
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
    }

        html[data-theme="dark"] .init-table-wrap thead {
            background: rgba(108, 92, 231, 0.14);
        }

            html[data-theme="dark"] .init-table-wrap thead th {
                color: #cbd5e1;
                border-bottom-color: rgba(162, 155, 254, 0.28);
            }

        html[data-theme="dark"] .init-table-wrap tbody td {
            color: #e2e8f0;
            border-bottom-color: rgba(255, 255, 255, 0.04);
        }

        html[data-theme="dark"] .init-table-wrap tbody tr:hover {
            background: rgba(108, 92, 231, 0.08);
        }

        /* Inline editors */
        html[data-theme="dark"] .init-table-wrap .edit-input,
        html[data-theme="dark"] .init-table-wrap .edit-select,
        html[data-theme="dark"] .init-table-wrap .edit-file {
            background: rgba(30, 41, 59, 0.75);
            border-color: rgba(255, 255, 255, 0.08);
            color: #e2e8f0;
        }

            html[data-theme="dark"] .init-table-wrap .edit-input:focus,
            html[data-theme="dark"] .init-table-wrap .edit-select:focus {
                background: #1e293b;
                border-color: #a29bfe;
                box-shadow: 0 0 0 3px rgba(162, 155, 254, 0.20);
            }

            /* Invalid row — file hardcodes #fef0f0 */
            html[data-theme="dark"] .init-table-wrap .edit-input.invalid,
            html[data-theme="dark"] .init-table-wrap .edit-select.invalid {
                background-color: rgba(248, 113, 113, 0.10) !important;
                border-color: #f87171 !important;
                box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.22) !important;
            }

        /* Row action hover */
        html[data-theme="dark"] .init-table-wrap .row-actions .action-btn {
            background: rgba(255, 255, 255, 0.05);
            color: #cbd5e1;
        }

            html[data-theme="dark"] .init-table-wrap .row-actions .action-btn:hover {
                background: rgba(162, 155, 254, 0.20);
                color: #eef2ff;
            }

    html[data-theme="dark"] .action-delete:hover {
        background: rgba(248, 113, 113, 0.20);
        color: #f87171;
    }

    html[data-theme="dark"] .action-save:hover {
        background: rgba(52, 211, 153, 0.20);
        color: #34d399;
    }

    html[data-theme="dark"] .action-cancel:hover {
        background: rgba(251, 191, 36, 0.20);
        color: #fbbf24;
    }

    /* Toast */
    html[data-theme="dark"] .init-toast {
        background: var(--glass-bg);
        border-color: var(--glass-border);
        color: #e2e8f0;
    }

        html[data-theme="dark"] .init-toast.error {
            border-right-color: #f87171;
        }

            html[data-theme="dark"] .init-toast.error i {
                color: #f87171;
            }

    /* init-store.css helpers — sidebar nav (from init-modal-premium.css) */
    html[data-theme="dark"] .ip-side-nav-col {
        background: var(--ip-surface-2);
        border-inline-end-color: var(--ip-border);
    }

    html[data-theme="dark"] .ip-side-tab-btn {
        color: var(--ip-text-2);
    }

        html[data-theme="dark"] .ip-side-tab-btn:hover {
            background: rgba(99, 102, 241, 0.12);
        }

        html[data-theme="dark"] .ip-side-tab-btn.active {
            background: var(--ip-primary);
            color: #fff;
        }

    html[data-theme="dark"] .ip-inline-search {
        background: var(--ip-surface-2);
        border-color: var(--ip-border);
    }

        html[data-theme="dark"] .ip-inline-search input {
            color: var(--ip-text);
        }

    /* init-toast inside init-modal-premium.css uses --ip-* — already dark; nothing
   else needed. init-store.css itself only adds structural rules that inherit
   --ip-* tokens, which the item-premium [data-bs-theme="dark"] block handles. */

    /* Submit spinner — ism-* uses same token set */
    html[data-theme="dark"] .ism-submit-btn {
        background: var(--ip-primary);
        color: #fff;
    }


/* ==========================================================================
   17. PRINTER SETTINGS  (printer-settings.css · --ps-*)
   --------------------------------------------------------------------------
   File ships a [data-bs-theme="dark"] block that ThemeService activates, so
   most tokens are correct. But the file redefines --ps-border / --ps-blue /
   --ps-shadow in a SECOND `:root` near the bottom (as light values), which
   overwrites the dark set. Also --ps-shadow-hover is referenced but never
   defined. Fix both here.
   ========================================================================== */

html[data-theme="dark"] {
    --ps-border: rgba(255, 255, 255, 0.09);
    --ps-shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.55);
}

    /* Second :root also fixes --ps-blue to #0d6efd — bright blue is fine on dark,
   but the badges that rely on --ps-blue-soft need their own bg back. */
    html[data-theme="dark"] .ps-header-badge {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.18);
    }

    html[data-theme="dark"] .ps-stat-chip {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-search-panel {
        background: var(--ps-surface-2);
        border-bottom-color: var(--ps-border);
    }

        html[data-theme="dark"] .ps-search-panel .form-control,
        html[data-theme="dark"] .ps-search-panel .form-select {
            background: var(--ps-surface) !important;
            border-color: var(--ps-border-hi) !important;
            color: var(--ps-text) !important;
        }

    html[data-theme="dark"] .ps-action-bar,
    html[data-theme="dark"] .ps-table-toolbar {
        background: var(--ps-surface);
        border-bottom-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-search-box .form-control {
        background: var(--ps-bg);
        border-color: var(--ps-border);
        color: var(--ps-text);
    }

    html[data-theme="dark"] .ps-table-toolbar .form-select {
        background: var(--ps-surface);
        border-color: var(--ps-border);
        color: var(--ps-text);
    }

    /* Table header gradient (file uses light --ps-surface-3 / --ps-surface-2) */
    html[data-theme="dark"] .ps-table thead tr {
        background: linear-gradient(90deg, #1e293b, #172033) !important;
    }

    html[data-theme="dark"] .ps-table thead th {
        color: #cbd5e1 !important;
        border-bottom-color: var(--ps-border-hi) !important;
        border-right-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-table tbody td {
        border-right-color: var(--ps-border);
        color: var(--ps-text);
    }

    html[data-theme="dark"] .ps-table tbody tr:hover {
        background: rgba(99, 102, 241, 0.10) !important;
    }

    html[data-theme="dark"] .ps-footer-bar {
        background: var(--ps-bg);
        border-top-color: var(--ps-border);
    }

        html[data-theme="dark"] .ps-footer-bar .pagination .page-link {
            background: var(--ps-surface);
            border-color: var(--ps-border);
            color: var(--ps-text-2);
        }

        html[data-theme="dark"] .ps-footer-bar .pagination .active .page-link {
            background: var(--ps-blue);
            border-color: var(--ps-blue);
            color: #fff;
        }

    /* Modal shell */
    html[data-theme="dark"] .ps-modal-content,
    html[data-theme="dark"] .premium-modal-content {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-modal-body {
        background: var(--ps-bg);
    }

    html[data-theme="dark"] .ps-sidebar {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-search-wrap .input-group {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-search-input {
        color: var(--ps-text);
    }

    html[data-theme="dark"] .ps-item-row {
        border-bottom-color: var(--ps-border);
        color: var(--ps-text);
    }

        html[data-theme="dark"] .ps-item-row:hover {
            background: var(--ps-surface-2);
        }

        html[data-theme="dark"] .ps-item-row.active {
            background: rgba(99, 102, 241, 0.14);
            border-right-color: var(--ps-blue);
        }

    html[data-theme="dark"] .ps-item-avatar {
        background: rgba(99, 102, 241, 0.20);
        color: #a5b4fc;
    }

    html[data-theme="dark"] .ps-content-area {
        background: var(--ps-surface);
        border-left-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-sidebar-footer {
        background: var(--ps-surface);
        border-top-color: var(--ps-border);
    }

    /* Detail panel inner cards */
    html[data-theme="dark"] .ps-detail-panel .card {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-detail-panel .card-header {
        background: var(--ps-surface-2);
        border-bottom-color: var(--ps-border);
        color: var(--ps-text-2);
    }

    html[data-theme="dark"] .ps-detail-panel .form-control,
    html[data-theme="dark"] .ps-detail-panel .form-select {
        background: var(--ps-surface);
        border-color: var(--ps-border);
        color: var(--ps-text);
    }

    html[data-theme="dark"] .ps-detail-panel .input-group-text {
        background: var(--ps-bg);
        border-color: var(--ps-border);
        color: var(--ps-text-3);
    }

    html[data-theme="dark"] .ps-detail-panel .ps-detail-table thead th {
        background: var(--ps-bg);
        color: var(--ps-text-2);
        border-bottom-color: var(--ps-border);
    }

    html[data-theme="dark"] .ps-detail-panel .ps-section-header {
        background: var(--ps-surface-2);
    }

        html[data-theme="dark"] .ps-detail-panel .ps-section-header:hover {
            background: var(--ps-surface-3);
        }

    /* Empty state card (dashed border) */
    html[data-theme="dark"] .ps-empty-card {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    /* Toast */
    html[data-theme="dark"] .toast {
        background: var(--ps-surface);
        border-color: var(--ps-border);
        color: var(--ps-text);
    }

        html[data-theme="dark"] .toast .toast-body {
            color: var(--ps-text);
        }

    /* Second-half of the file (premium-modal-* overrides) uses fixed #fafbfc
   for the sidebar and #f8f9fa for header/footer */
    html[data-theme="dark"] .premium-modal-header {
        background: linear-gradient(135deg, #1e293b 0%, #172033 100%);
        border-bottom-color: var(--ps-border);
    }

    html[data-theme="dark"] .modal-sidebar {
        background: var(--ps-surface-2);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .premium-search-box {
        background: var(--ps-surface);
        border-color: var(--ps-border);
    }

    html[data-theme="dark"] .pil-item {
        background: var(--ps-surface);
        color: var(--ps-text);
    }

        html[data-theme="dark"] .pil-item:hover,
        html[data-theme="dark"] .pil-item.active {
            background: rgba(13, 110, 253, 0.14);
        }

    html[data-theme="dark"] .pil-type,
    html[data-theme="dark"] .pil-stat-value {
        color: var(--ps-text);
    }

    html[data-theme="dark"] .pil-fsno,
    html[data-theme="dark"] .pil-stat-label {
        color: var(--ps-text-2);
    }

    html[data-theme="dark"] .pil-chip {
        background: var(--ps-surface-2);
        color: var(--ps-text-2);
    }

    html[data-theme="dark"] .pil-footer {
        background: var(--ps-surface-2);
        border-top-color: var(--ps-border);
    }

    html[data-theme="dark"] .modal-content-area {
        background: var(--ps-surface);
        color: var(--ps-text);
    }

    html[data-theme="dark"] .premium-modal-footer {
        background: var(--ps-surface-2);
        border-top-color: var(--ps-border);
    }

    html[data-theme="dark"] .premium-modal-content {
        background: var(--ps-surface);
    }


/* ==========================================================================
   18. ZATCA  (zatca.css · --zp-*)
   --------------------------------------------------------------------------
   File has NO dark mode. Tokens + hardcoded whites need full treatment.
   ========================================================================== */

html[data-theme="dark"] {
    --zp-primary: #7d95ff;
    --zp-primary-dark: #5b76f0;
    --zp-success: #34d399;
    --zp-warning: #fbbf24;
    --zp-danger: #f87171;
    --zp-info: #22d3ee;
    --zp-text: #e2e8f0;
    --zp-muted: #94a3b8;
    --zp-light: #64748b;
    --zp-surface: #1e293b;
    --zp-surface-2: #0f172a;
    --zp-border: rgba(255, 255, 255, 0.08);
    --zp-border-md: rgba(255, 255, 255, 0.14);
    --zp-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.32);
    --zp-shadow-md: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

    html[data-theme="dark"] body {
        background: var(--zp-surface-2);
        color: var(--zp-text);
    }

    /* Page header / badges */
    html[data-theme="dark"] .zp-page-header {
        background: var(--zp-surface);
        border-color: var(--zp-border);
    }

    html[data-theme="dark"] .zp-badge-zatca {
        background: rgba(125, 149, 255, 0.16);
        color: #a5b4fc;
    }

    /* Buttons */
    html[data-theme="dark"] .zp-btn-ghost {
        background: transparent;
        border-color: var(--zp-border-md);
        color: var(--zp-text);
    }

        html[data-theme="dark"] .zp-btn-ghost:hover:not(:disabled) {
            background: var(--zp-surface);
            border-color: var(--zp-primary);
            color: var(--zp-primary);
        }

    html[data-theme="dark"] .zp-btn-icon {
        background: var(--zp-surface);
        border-color: var(--zp-border);
        color: var(--zp-text);
    }

    /* Modal shell */
    html[data-theme="dark"] .zp-modal-shell {
        background: var(--zp-surface-2);
        border-color: var(--zp-border);
    }

    html[data-theme="dark"] .zp-modal-header,
    html[data-theme="dark"] .zp-footer {
        background: var(--zp-surface);
        border-color: var(--zp-border);
    }

    /* Step / inner tabs (both horizontal tab bars and the vertical left rail) */
    html[data-theme="dark"] .zp-step-bar,
    html[data-theme="dark"] .zp-inner-tabs {
        background: var(--zp-surface);
        border-bottom-color: var(--zp-border);
    }

    html[data-theme="dark"] .zp-step-tab,
    html[data-theme="dark"] .zp-inner-tab {
        color: var(--zp-muted);
    }

        html[data-theme="dark"] .zp-step-tab:hover,
        html[data-theme="dark"] .zp-inner-tab:hover {
            background: rgba(125, 149, 255, 0.10);
            color: var(--zp-primary);
        }

        html[data-theme="dark"] .zp-step-tab.active,
        html[data-theme="dark"] .zp-inner-tab.active {
            background: rgba(125, 149, 255, 0.18);
            border-color: rgba(125, 149, 255, 0.36);
            color: #a5b4fc;
        }

    /* Certificate modal left rail */
    html[data-theme="dark"] #certificateModal #certificateTabs {
        background: linear-gradient(180deg, #1e293b 0%, #172033 100%);
        border-color: var(--zp-border);
    }

        html[data-theme="dark"] #certificateModal #certificateTabs .zp-step-tab {
            color: var(--zp-muted);
        }

            html[data-theme="dark"] #certificateModal #certificateTabs .zp-step-tab.active {
                background: rgba(125, 149, 255, 0.18);
                border-color: rgba(125, 149, 255, 0.36);
                box-shadow: 0 5px 14px rgba(125, 149, 255, 0.18);
            }

    /* Card / section chrome */
    html[data-theme="dark"] .zp-card,
    html[data-theme="dark"] .zp-section {
        background: var(--zp-surface);
        border-color: var(--zp-border);
    }

    html[data-theme="dark"] .zp-card-head,
    html[data-theme="dark"] .zp-section-head {
        background: #172033;
        border-bottom-color: var(--zp-border);
        color: var(--zp-text);
    }

    html[data-theme="dark"] .zp-chevron {
        color: var(--zp-light);
    }

    /* Fields */
    html[data-theme="dark"] .zp-input-wrap .form-control,
    html[data-theme="dark"] .zp-input-wrap .form-select,
    html[data-theme="dark"] .zp-field > .form-control,
    html[data-theme="dark"] .zp-field > .form-select {
        background: var(--zp-surface-2);
        border-color: var(--zp-border-md);
        color: var(--zp-text);
    }

        html[data-theme="dark"] .zp-input-wrap .form-control:focus,
        html[data-theme="dark"] .zp-input-wrap .form-select:focus,
        html[data-theme="dark"] .zp-field > .form-control:focus,
        html[data-theme="dark"] .zp-field > .form-select:focus {
            border-color: var(--zp-primary);
            box-shadow: 0 0 0 3px rgba(125, 149, 255, 0.18);
        }

    html[data-theme="dark"] .zp-textarea {
        background: var(--zp-surface-2);
        border-color: var(--zp-border-md);
        color: var(--zp-text);
    }

        html[data-theme="dark"] .readonly-textarea,
        html[data-theme="dark"] .zp-textarea[readonly] {
            background: #0f172a;
            color: var(--zp-muted);
        }

    /* Radio / env toggle */
    html[data-theme="dark"] .zp-radio-item {
        color: var(--zp-muted);
    }

        html[data-theme="dark"] .zp-radio-item:hover {
            background: rgba(125, 149, 255, 0.08);
            color: var(--zp-primary);
        }

    html[data-theme="dark"] .zp-env-toggle label {
        border-color: var(--zp-border-md);
        color: var(--zp-text);
    }

    html[data-theme="dark"] .zp-env-toggle .btn-check:checked + label {
        background: rgba(125, 149, 255, 0.18);
        color: var(--zp-primary);
        border-color: var(--zp-primary);
    }

    /* Table */
    html[data-theme="dark"] .zp-table th {
        background: #172033;
        color: var(--zp-muted);
        border-bottom-color: var(--zp-border-md);
    }

    html[data-theme="dark"] .zp-table td {
        border-bottom-color: var(--zp-border);
        color: var(--zp-text);
    }

    html[data-theme="dark"] .zp-table tbody tr:hover {
        background: rgba(125, 149, 255, 0.06);
    }

    html[data-theme="dark"] .zp-table .form-control {
        background: var(--zp-surface-2);
        border-color: var(--zp-border-md);
        color: var(--zp-text);
    }

    html[data-theme="dark"] .zp-table .input-group-text {
        background: #172033;
        border-color: var(--zp-border-md);
        color: var(--zp-muted);
    }

    /* QR image — keep white so it scans */
    html[data-theme="dark"] .zp-qr-code {
        background: #fff;
        border-color: var(--zp-border-md);
    }

    /* Nav process / progress */
    html[data-theme="dark"] .zp-nav-step {
        color: var(--zp-muted);
    }

        html[data-theme="dark"] .zp-nav-step.active {
            color: var(--zp-primary);
        }

    html[data-theme="dark"] .zp-nav-step-num {
        background: var(--zp-text);
        border-color: var(--zp-surface);
    }

    html[data-theme="dark"] .zp-nav-connector {
        background: var(--zp-border-md);
    }

    html[data-theme="dark"] .zp-progress-bar {
        background: var(--zp-border);
    }

    /* Response badges — file already pairs light bg / dark fg; invert for dark */
    html[data-theme="dark"] .zp-badge-cleared {
        background: rgba(52, 211, 153, 0.16);
        color: #6ee7b7;
    }

    html[data-theme="dark"] .zp-badge-reported {
        background: rgba(251, 191, 36, 0.16);
        color: #fbbf24;
    }

    html[data-theme="dark"] .zp-badge-rejected {
        background: rgba(248, 113, 113, 0.16);
        color: #fca5a5;
    }

    html[data-theme="dark"] .zp-badge-pending {
        background: rgba(148, 163, 184, 0.14);
        color: var(--zp-muted);
    }

    /* Toast */
    html[data-theme="dark"] #toastContainer .toast,
    html[data-theme="dark"] #toast-container .toast {
        background: var(--zp-surface);
        color: var(--zp-text);
        border: 1px solid var(--zp-border);
    }

    /* Footer note */
    html[data-theme="dark"] .zp-footer-note {
        color: var(--zp-muted);
    }

    /* Modal shell inside #certificateModal — has its own gradient bg in-file
   via #certificateTabs; the shell itself was --zp-surface-2 (already dark). */
    html[data-theme="dark"] #certificateModal .zp-modal-shell {
        border-color: var(--zp-border);
        box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    }


/* ==========================================================================
   19. MAIN POS / SALES SCREEN  (root{--acc-bg#f8fafc… file)
   --------------------------------------------------------------------------
   The file already ships [data-bs-theme="dark"] rules for its --acc-* /
   --pos-* / --fw-* / --ss-* tokens, which work via ThemeService. What's
   missing:
     · --sp-*  (summary card system)
     · --it-*  (invoice table system)
     · --nova-* (card-header-advanced system)
     · The appended "MODERN CARDS" block (hardcoded #fff / #eef2f6 / …)
     · keyboard-shortcuts / kbd variants
     · modern-toolbar / user-info-box / sp-nav / fw-pgr-display
   ========================================================================== */

/* ---- Token sub-systems ---- */
html[data-theme="dark"] {
    /* --sp-* : summary cards */
    --sp-blue-50: rgba(99,130,255,0.10);
    --sp-blue-100: rgba(99,130,255,0.22);
    --sp-blue-200: rgba(99,130,255,0.35);
    --sp-blue-400: #60a5fa;
    --sp-blue-600: #93c5fd;
    --sp-blue-800: #cbd5e1;
    --sp-teal-50: rgba(16,217,146,0.10);
    --sp-teal-100: rgba(16,217,146,0.22);
    --sp-teal-200: rgba(16,217,146,0.35);
    --sp-teal-400: #34d399;
    --sp-teal-600: #6ee7b7;
    --sp-amber-50: rgba(245,158,11,0.10);
    --sp-amber-100: rgba(245,158,11,0.22);
    --sp-amber-200: rgba(245,158,11,0.35);
    --sp-amber-600: #fbbf24;
    --sp-coral-50: rgba(244,63,94,0.10);
    --sp-coral-100: rgba(244,63,94,0.22);
    --sp-coral-600: #fca5a5;
    --sp-purple-50: rgba(124,58,237,0.10);
    --sp-purple-100: rgba(124,58,237,0.22);
    --sp-purple-600: #c4b5fd;
    --sp-green-50: rgba(16,185,129,0.10);
    --sp-green-100: rgba(16,185,129,0.22);
    --sp-green-600: #6ee7b7;
    --sp-gray-50: rgba(255,255,255,0.04);
    --sp-gray-100: rgba(255,255,255,0.08);
    --sp-gray-400: #94a3b8;
    --sp-gray-600: #cbd5e1;
    /* --it-* : invoice line items */
    --it-blue-50: rgba(99,130,255,0.08);
    --it-blue-100: rgba(99,130,255,0.18);
    --it-blue-200: rgba(99,130,255,0.30);
    --it-blue-400: #60a5fa;
    --it-blue-600: #93c5fd;
    --it-blue-800: #cbd5e1;
    --it-teal-50: rgba(16,217,146,0.08);
    --it-teal-100: rgba(16,217,146,0.18);
    --it-teal-200: rgba(16,217,146,0.30);
    --it-teal-400: #34d399;
    --it-teal-600: #6ee7b7;
    --it-teal-800: #a7f3d0;
    --it-amber-50: rgba(245,158,11,0.08);
    --it-amber-100: rgba(245,158,11,0.18);
    --it-amber-200: rgba(245,158,11,0.30);
    --it-amber-600: #fbbf24;
    --it-amber-800: #fcd34d;
    --it-coral-50: rgba(244,63,94,0.08);
    --it-coral-100: rgba(244,63,94,0.18);
    --it-coral-200: rgba(244,63,94,0.30);
    --it-coral-400: #f87171;
    --it-coral-600: #fca5a5;
    --it-purple-50: rgba(124,58,237,0.08);
    --it-purple-100: rgba(124,58,237,0.18);
    --it-purple-200: rgba(124,58,237,0.30);
    --it-purple-400: #a78bfa;
    --it-purple-600: #c4b5fd;
    --it-purple-800: #ddd6fe;
    --it-green-50: rgba(16,185,129,0.08);
    --it-green-100: rgba(16,185,129,0.18);
    --it-green-400: #34d399;
    --it-green-600: #6ee7b7;
    --it-gray-50: rgba(255,255,255,0.04);
    --it-gray-100: rgba(255,255,255,0.08);
    --it-gray-200: rgba(255,255,255,0.14);
    --it-gray-400: #94a3b8;
    --it-gray-600: #cbd5e1;
    /* --nova-* : card-header-advanced wrapper */
    --nova-bg-page: #0f172a;
    --nova-surface-0: #1e293b;
    --nova-surface-1: #172033;
    --nova-surface-2: #232f47;
    --nova-surface-3: #334155;
    --nova-border: rgba(255,255,255,0.08);
    --nova-border-soft: rgba(255,255,255,0.05);
    --nova-text: #e2e8f0;
    --nova-text-dim: #94a3b8;
    --nova-text-mute: #64748b;
    --nova-shadow: 0 8px 24px -10px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.02) inset;
}

    /* --nova-* hardcoded card-header-advanced components */
    html[data-theme="dark"] .card-header-advanced {
        background: var(--nova-surface-0);
        border-color: var(--nova-border);
    }

    html[data-theme="dark"] .header-badge {
        background: var(--nova-surface-1);
        border-color: var(--nova-border);
    }

    html[data-theme="dark"] .badge-title {
        color: var(--nova-text);
    }

    html[data-theme="dark"] .badge-subtitle {
        color: var(--nova-text-mute);
    }

    html[data-theme="dark"] .stat-label {
        color: var(--nova-text-mute);
    }

    html[data-theme="dark"] .stat-value {
        color: var(--nova-text);
    }

    html[data-theme="dark"] .stat-divider {
        background: var(--nova-border);
    }

    html[data-theme="dark"] .nova-toggle-card,
    html[data-theme="dark"] .form-check.form-switch.nova-toggle-card {
        background: var(--nova-surface-1);
        border-color: var(--nova-border);
    }

        html[data-theme="dark"] .nova-toggle-card:hover {
            background: var(--nova-surface-2);
            border-color: rgba(8,145,178,.35);
        }

        html[data-theme="dark"] .nova-toggle-card .form-check-label {
            color: var(--nova-text) !important;
        }

    html[data-theme="dark"] .settings-header {
        border-bottom-color: var(--nova-border-soft);
    }

        html[data-theme="dark"] .settings-header h6 {
            color: var(--nova-text);
        }

    html[data-theme="dark"] .settings-content {
        background: var(--nova-surface-1);
    }

    html[data-theme="dark"] .setting-group {
        background: var(--nova-surface-0);
        border-color: var(--nova-border);
    }

    html[data-theme="dark"] .group-title {
        color: var(--nova-text-mute);
        border-bottom-color: var(--nova-border);
    }

    html[data-theme="dark"] .setting-item label {
        color: var(--nova-text-dim);
    }

        html[data-theme="dark"] .setting-item label i {
            color: var(--nova-text-mute);
        }

    html[data-theme="dark"] .settings-footer {
        border-top-color: var(--nova-border-soft);
    }

    html[data-theme="dark"] .btn-outline-secondary {
        background: var(--nova-surface-0) !important;
        border-color: var(--nova-border) !important;
        color: var(--nova-text-dim) !important;
    }

        html[data-theme="dark"] .btn-outline-secondary:hover {
            color: #fca5a5 !important;
            border-color: rgba(248,113,113,.35) !important;
            background: rgba(248,113,113,.08) !important;
        }

    /* --sp / --it card surface (uses --sp-* / --it-* tokens, so tokens do the work;
   patch a couple of hardcoded #fff / #0d6efd hits that bypass them) */
    html[data-theme="dark"] .sp-card {
        background: var(--acc-surface);
        border-color: var(--acc-border);
    }

    html[data-theme="dark"] .sp-card-header {
        background: var(--acc-surface);
        border-bottom-color: var(--acc-border);
    }

        html[data-theme="dark"] .sp-card-header:hover {
            background: var(--acc-surface-2);
        }

    html[data-theme="dark"] .sp-hdr-title {
        color: var(--acc-text);
    }

    html[data-theme="dark"] .sp-hdr-sub {
        color: var(--acc-text-3);
    }

    html[data-theme="dark"] .sp-pay-field {
        background: rgba(255,255,255,.03);
        border-color: rgba(255,255,255,.10);
    }

        html[data-theme="dark"] .sp-pay-field.highlight {
            background: var(--sp-blue-50);
            border-color: var(--sp-blue-100);
        }

    html[data-theme="dark"] .sp-pay-input {
        color: var(--acc-text);
    }

    html[data-theme="dark"] .sp-nav {
        background: var(--acc-surface-2);
        border-color: var(--acc-border);
    }

    html[data-theme="dark"] .sp-nav-btn {
        background: var(--acc-surface);
        border-color: var(--acc-border);
        color: var(--acc-text-2);
    }

        html[data-theme="dark"] .sp-nav-btn:hover {
            background: var(--acc-blue);
            border-color: var(--acc-blue);
            color: #fff;
        }

    html[data-theme="dark"] .sp-nav-counter {
        background: var(--acc-surface);
        border-color: var(--acc-border);
        color: var(--acc-text);
    }

    html[data-theme="dark"] .it-card {
        background: var(--acc-surface);
        border-color: var(--acc-border);
    }

    html[data-theme="dark"] .it-table-responsive {
        background: var(--acc-surface);
    }

    html[data-theme="dark"] #invoiceTable thead tr {
        background: #1e293b;
    }

    html[data-theme="dark"] #invoiceTable thead th {
        background: #1e293b;
        border-bottom-color: #334155;
        color: var(--it-blue-200);
    }

    html[data-theme="dark"] #invoiceTable tbody tr {
        border-bottom-color: rgba(255,255,255,.06);
    }

        html[data-theme="dark"] #invoiceTable tbody tr:nth-child(even) {
            background: rgba(255,255,255,.02);
        }

            html[data-theme="dark"] #invoiceTable tbody tr:hover,
            html[data-theme="dark"] #invoiceTable tbody tr:nth-child(even):hover {
                background: rgba(99,130,255,.08);
            }

    html[data-theme="dark"] #invoiceTable td {
        color: var(--acc-text);
    }

    html[data-theme="dark"] #invoiceTable input[type="number"],
    html[data-theme="dark"] #invoiceTable input[type="text"] {
        background: var(--acc-surface-2);
        border-color: var(--acc-border);
        color: var(--acc-text);
    }

    html[data-theme="dark"] #invoiceTable input:focus {
        border-color: var(--it-blue-400);
    }

    html[data-theme="dark"] #invoiceTable input[readonly] {
        background: var(--acc-surface-3);
        color: var(--acc-text-3);
    }

    html[data-theme="dark"] .qty-control {
        background: var(--it-purple-50);
        border-color: var(--acc-border);
    }

    html[data-theme="dark"] .qty-input {
        border-inline-start-color: var(--acc-border) !important;
        border-inline-end-color: var(--acc-border) !important;
        color: var(--it-purple-800);
    }

    html[data-theme="dark"] .empty-row-placeholder td {
        color: var(--acc-text-3);
    }

    html[data-theme="dark"] .column-settings-panel .settings-content {
        background: var(--acc-surface-2);
        border-top-color: var(--acc-border);
    }

    /* ---- keyboard-shortcuts + kbd variants ---- */
    html[data-theme="dark"] .keyboard-shortcuts {
        background: linear-gradient(135deg, #2d3748 0, #1a202c 100%);
        border-color: rgba(255,255,255,.05);
        color: #a0aec0;
    }

        html[data-theme="dark"] .keyboard-shortcuts .shortcut-divider {
            color: #4a5568;
        }

    html[data-theme="dark"] kbd {
        color: #e2e8f0;
        background: linear-gradient(180deg, #4a5568 0, #2d3748 100%);
        border-color: #4a5568;
        text-shadow: 0 1px 0 rgba(0,0,0,.3);
    }

        html[data-theme="dark"] kbd:hover {
            background: linear-gradient(180deg, #5a6578 0, #3d4a5d 100%);
            border-color: #5a6578;
        }

        html[data-theme="dark"] kbd.has-icon i {
            color: #cbd5e1;
        }

        html[data-theme="dark"] kbd.primary {
            background: linear-gradient(180deg, #1e3a5f 0, #1a365d 100%);
            border-color: #2b6cb0;
            color: #bee3f8;
        }

        html[data-theme="dark"] kbd.success {
            background: linear-gradient(180deg, #0d3d2e 0, #064e3b 100%);
            border-color: #0d9488;
            color: #a7f3d0;
        }

        html[data-theme="dark"] kbd.warning {
            background: linear-gradient(180deg, #3d2e0d 0, #4e3b06 100%);
            border-color: #b45309;
            color: #fde68a;
        }

        html[data-theme="dark"] kbd.danger {
            background: linear-gradient(180deg, #3d0d0d 0, #4e0606 100%);
            border-color: #b00909;
            color: #fca5a5;
        }

        html[data-theme="dark"] kbd.dark {
            background: linear-gradient(180deg, #6b7280 0, #4b5563 100%);
            border-color: #6b7280;
            color: #f3f4f6;
        }

    html[data-theme="dark"] .shortcut-combo {
        background: rgba(255,255,255,.05);
        border-color: rgba(255,255,255,.08);
    }

        html[data-theme="dark"] .shortcut-combo kbd {
            background: 0 0;
            border-color: transparent;
        }

    html[data-theme="dark"] .kbd-separator {
        color: #4a5568;
    }

    /* ---- modern-toolbar / user-info-box / fw-pgr-display ---- */
    html[data-theme="dark"] .modern-toolbar {
        background: var(--acc-surface);
        border-color: var(--acc-border);
        box-shadow: 0 2px 8px rgba(0,0,0,.35);
    }

    html[data-theme="dark"] .user-info-box {
        background: var(--acc-surface-2);
        border-color: var(--acc-border);
    }

        html[data-theme="dark"] .user-info-box i {
            color: var(--acc-text-2);
        }

    html[data-theme="dark"] .user-label {
        color: var(--acc-text-3);
    }

    html[data-theme="dark"] .user-name {
        color: var(--acc-text);
    }

    html[data-theme="dark"] .fw-pgr-display {
        background: var(--acc-surface) !important;
        border-color: var(--acc-border) !important;
        box-shadow: inset 0 1px 2px rgba(0,0,0,.2) !important;
    }

        html[data-theme="dark"] .fw-pgr-display input {
            color: var(--acc-blue) !important;
        }

    html[data-theme="dark"] .btn-action-group .btn {
        color: var(--acc-text-2);
    }

    /* ---- MODERN CARDS block (hardcoded #fff / #eef2f6 / #f8fafc) ---- */
    html[data-theme="dark"] .modern-card {
        background: var(--acc-surface);
        border-color: var(--acc-border);
        box-shadow: 0 2px 6px rgba(0,0,0,.3);
    }

        html[data-theme="dark"] .modern-card:hover {
            border-color: var(--acc-border-hi);
            box-shadow: 0 6px 18px rgba(0,0,0,.45);
        }

        html[data-theme="dark"] .modern-card.deleted-card {
            background: rgba(127, 29, 29, .16);
            border-color: rgba(248, 113, 113, .35);
        }

            html[data-theme="dark"] .modern-card.deleted-card:hover {
                border-color: rgba(248, 113, 113, .6);
            }

        html[data-theme="dark"] .modern-card h5 {
            color: var(--acc-text);
        }

        html[data-theme="dark"] .modern-card .text-muted small {
            color: var(--acc-text-3);
        }

        html[data-theme="dark"] .modern-card .border-top,
        html[data-theme="dark"] .modern-card .border-bottom {
            border-color: var(--acc-border) !important;
        }

    html[data-theme="dark"] .details-group .text-muted {
        color: var(--acc-text-3);
    }

    html[data-theme="dark"] .details-group .fw-medium {
        color: var(--acc-text);
    }
    /* modern-card amount-value has more specific selector than the [data-bs-theme=dark] rule */
    html[data-theme="dark"] .modern-card .amount-value {
        color: #34d399;
    }

        html[data-theme="dark"] .modern-card .amount-value small {
            color: var(--acc-text-3);
        }

    html[data-theme="dark"] .modern-card.deleted-card .amount-value {
        color: #f87171;
    }

    html[data-theme="dark"] .modern-card .status-badge.completed {
        background: rgba(52, 211, 153, .16);
        color: #6ee7b7;
    }

    html[data-theme="dark"] .modern-card .status-badge.pending {
        background: rgba(251, 191, 36, .16);
        color: #fbbf24;
    }

    html[data-theme="dark"] .modern-card .status-badge.deleted {
        background: rgba(248, 113, 113, .18);
        color: #fca5a5;
    }

    html[data-theme="dark"] .modern-card .view-btn {
        background: rgba(96, 165, 250, .14);
        color: #93c5fd;
    }

        html[data-theme="dark"] .modern-card .view-btn:hover {
            background: rgba(96, 165, 250, .24);
            color: #bfdbfe;
        }

    html[data-theme="dark"] .modern-card .edit-btn,
    html[data-theme="dark"] .modern-card .restore-btn {
        background: rgba(52, 211, 153, .14);
        color: #6ee7b7;
    }

        html[data-theme="dark"] .modern-card .edit-btn:hover,
        html[data-theme="dark"] .modern-card .restore-btn:hover {
            background: rgba(52, 211, 153, .24);
            color: #a7f3d0;
        }

    html[data-theme="dark"] .modern-card .permanent-delete-btn {
        background: rgba(248, 113, 113, .14);
        color: #fca5a5;
    }

        html[data-theme="dark"] .modern-card .permanent-delete-btn:hover {
            background: rgba(248, 113, 113, .24);
            color: #fecaca;
        }

    html[data-theme="dark"] .modern-card .dropdown-menu {
        background: var(--acc-surface);
        border-color: var(--acc-border);
        box-shadow: 0 8px 24px rgba(0,0,0,.5);
    }

        html[data-theme="dark"] .modern-card .dropdown-menu .dropdown-item {
            color: var(--acc-text);
        }

            html[data-theme="dark"] .modern-card .dropdown-menu .dropdown-item:hover {
                background: var(--acc-surface-2);
            }

            html[data-theme="dark"] .modern-card .dropdown-menu .dropdown-item.text-danger {
                color: #f87171;
            }

                html[data-theme="dark"] .modern-card .dropdown-menu .dropdown-item.text-danger:hover {
                    background: rgba(248, 113, 113, .1);
                }

    html[data-theme="dark"] .modern-card .dropdown-divider {
        border-color: var(--acc-border);
    }

    html[data-theme="dark"] .cards-empty-state-modal {
        color: var(--acc-text-3);
    }

        html[data-theme="dark"] .cards-empty-state-modal .empty-icon-modal {
            color: var(--acc-text-3);
        }

        html[data-theme="dark"] .cards-empty-state-modal h5 {
            color: var(--acc-text);
        }

        html[data-theme="dark"] .cards-empty-state-modal .btn-primary {
            background: var(--acc-blue);
        }

            html[data-theme="dark"] .cards-empty-state-modal .btn-primary:hover {
                background: var(--acc-blue-d);
            }

    /* ---- fw-header base (already has [data-bs-theme=dark] but ensure consistency) ---- */
    html[data-theme="dark"] #fwatirListModal .fw-header {
        background: linear-gradient(135deg, #0f1a3e 0, #1a2e6e 60%, #2040a0 100%);
    }


    /* ==========================================================================
   20. POS — PRODUCT AREA  (#paymentForm .pos-original-workspace)
   --------------------------------------------------------------------------
   No dark mode in the source. Tokens --po-* live at .pos-original-workspace
   scope, so re-defining them covers most surfaces. The hardcoded `#fffefa`,
   `#f2f3ee`, `#173833`, `#fff` hits are patched below.
   ========================================================================== */

    html[data-theme="dark"] #paymentForm .pos-original-workspace {
        --po-teal: #2dd4bf;
        --po-ink: #e2e8f0;
        --po-paper: #1e293b;
        --po-stone: #172033;
        --po-line: rgba(255, 255, 255, 0.10);
        --po-gold: #fbbf24;
        background: #0f172a;
    }

    /* Grid + panels */
    html[data-theme="dark"] #paymentForm .pos-oe-grid {
        background: var(--po-paper);
        border-color: var(--po-line);
    }

    html[data-theme="dark"] #paymentForm .catalog-workbench {
        background: var(--po-stone);
        border-inline-end-color: var(--po-line);
    }

    html[data-theme="dark"] #paymentForm .sale-ledger {
        background: var(--po-paper);
    }

    /* Status card keeps its teal gradient — fine on dark */
    html[data-theme="dark"] #paymentForm .pos-status-card {
        background: linear-gradient(120deg, #173b37, #276d64);
    }

    /* Search */
    html[data-theme="dark"] #paymentForm .pos-search {
        background: var(--po-paper);
        border-color: var(--po-line);
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .pos-search input {
            color: var(--po-ink);
        }

        html[data-theme="dark"] #paymentForm .pos-search kbd {
            background: var(--acc-surface-3, #334155);
            color: #cbd5e1;
        }

    html[data-theme="dark"] #paymentForm .scan-button {
        background: var(--po-teal);
        color: #0f172a;
    }

    /* Category chips */
    html[data-theme="dark"] #paymentForm .pos-category {
        background: var(--po-paper);
        border-color: var(--po-line);
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .pos-category.active,
        html[data-theme="dark"] #paymentForm .pos-category:hover {
            background: var(--po-teal);
            border-color: var(--po-teal);
            color: #0f172a;
        }

    /* Catalog caption */
    html[data-theme="dark"] #paymentForm .catalog-caption {
        border-bottom-color: var(--po-line);
        color: #cbd5e1;
    }

        html[data-theme="dark"] #paymentForm .catalog-caption small {
            color: #94a3b8;
        }

    /* Catalog grid scrollbar */
    html[data-theme="dark"] #paymentForm .pos-catalog-grid {
        border-top-color: var(--po-line);
        scrollbar-color: #475569 var(--po-stone);
    }

        html[data-theme="dark"] #paymentForm .pos-catalog-grid::-webkit-scrollbar-track {
            background: var(--po-stone);
        }

        html[data-theme="dark"] #paymentForm .pos-catalog-grid::-webkit-scrollbar-thumb {
            background: #475569;
            border-color: var(--po-stone);
        }

    /* Product card */
    html[data-theme="dark"] #paymentForm .pos-product-card {
        background: var(--po-paper);
        border-color: var(--po-line);
        box-shadow: 0 2px 8px rgba(0,0,0,.35);
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .pos-product-card:hover {
            border-color: var(--po-teal);
            box-shadow: 0 5px 14px rgba(45, 212, 191, .18);
        }

        html[data-theme="dark"] #paymentForm .pos-product-card .product-mark {
            background: rgba(45, 212, 191, .15);
            color: var(--po-teal);
        }

        html[data-theme="dark"] #paymentForm .pos-product-card strong {
            color: var(--po-ink);
        }

        html[data-theme="dark"] #paymentForm .pos-product-card small {
            color: #94a3b8;
        }

        html[data-theme="dark"] #paymentForm .pos-product-card .product-price {
            color: #6ee7b7;
        }

        html[data-theme="dark"] #paymentForm .pos-product-card .product-balance {
            background: rgba(45, 212, 191, .15);
            color: #6ee7b7;
        }

    /* Ledger heading + actions */
    html[data-theme="dark"] #paymentForm .ledger-heading h2 {
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .ledger-heading h2 span {
            color: #94a3b8;
        }

    html[data-theme="dark"] #paymentForm .ledger-heading p {
        color: #94a3b8;
    }

    html[data-theme="dark"] #paymentForm .ledger-action {
        background: var(--po-paper);
        border-color: var(--po-line);
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .ledger-action:hover {
            border-color: var(--po-teal);
            color: var(--po-teal);
        }

        html[data-theme="dark"] #paymentForm .ledger-action.destructive:hover {
            border-color: #fca5a5;
            color: #fca5a5;
        }

    /* Sale table */
    html[data-theme="dark"] #paymentForm .sale-table-wrap {
        background: var(--po-paper);
        border-color: var(--po-line);
    }

    html[data-theme="dark"] #paymentForm .sale-table th {
        background: var(--po-stone);
        border-bottom-color: var(--po-line);
        color: #94a3b8;
    }

    html[data-theme="dark"] #paymentForm .sale-table td {
        border-bottom-color: rgba(255,255,255,.06);
        color: var(--po-ink);
    }

    html[data-theme="dark"] #paymentForm .pos-line-name {
        color: var(--po-ink);
    }

    html[data-theme="dark"] #paymentForm .sale-table small {
        color: #94a3b8;
    }

    html[data-theme="dark"] #paymentForm .pos-line-price,
    html[data-theme="dark"] #paymentForm .pos-line-total {
        color: #6ee7b7;
    }

    html[data-theme="dark"] #paymentForm .pos-qty button,
    html[data-theme="dark"] #paymentForm .pos-line-delete {
        background: var(--po-paper);
        border-color: var(--po-line);
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .pos-qty button:hover {
            background: var(--po-teal);
            color: #0f172a;
            border-color: var(--po-teal);
        }

    html[data-theme="dark"] #paymentForm .pos-qty input {
        color: var(--po-ink);
    }

    html[data-theme="dark"] #paymentForm .pos-line-delete:hover {
        border-color: #fca5a5;
        color: #fca5a5;
    }

    html[data-theme="dark"] #paymentForm .empty-sale {
        background: var(--po-paper);
        color: #94a3b8;
    }

        html[data-theme="dark"] #paymentForm .empty-sale b {
            color: var(--po-ink);
        }

    /* Footer */
    html[data-theme="dark"] #paymentForm .customer-chip {
        background: var(--po-paper);
        border-color: var(--po-line);
        color: var(--po-ink);
    }

        html[data-theme="dark"] #paymentForm .customer-chip small {
            color: #94a3b8;
        }

        html[data-theme="dark"] #paymentForm .customer-chip b {
            color: var(--po-ink);
        }

    html[data-theme="dark"] #paymentForm .invoice-meta {
        color: #94a3b8;
    }

    html[data-theme="dark"] #paymentForm .zatca-state {
        background: rgba(45, 212, 191, .15);
        color: #6ee7b7;
    }


    /* ==========================================================================
   21. COUNTERTOP POS  (#posSaleForm)
   --------------------------------------------------------------------------
   The full replacement stylesheet for #posSaleForm. No dark mode at all.
   Token re-definitions cover the surfaces; hardcoded whites patched below.
   ========================================================================== */

    html[data-theme="dark"] #posSaleForm {
        --teal: #14b8a6;
        --teal-dark: #0f766e;
        --ink: #0f172a;
        --paper: #1e293b;
        --stone: #172033;
        --line: rgba(255, 255, 255, 0.10);
        --muted: #94a3b8;
        --gold: #fbbf24;
        background: #0f172a;
        color: #e2e8f0;
    }

        /* Rail (already dark, keep as-is but lighten the active state) */
        html[data-theme="dark"] #posSaleForm .pos-rail {
            background: #0a0f1c;
        }

        html[data-theme="dark"] #posSaleForm .rail-button.active {
            background: var(--teal);
        }

        /* Header */
        html[data-theme="dark"] #posSaleForm .pos-header {
            background: #131a17;
            border-bottom-color: var(--line);
        }

        html[data-theme="dark"] #posSaleForm .header-identity h1 {
            color: #e2e8f0;
        }

        html[data-theme="dark"] #posSaleForm .terminal-caption {
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .shift-chip,
        html[data-theme="dark"] #posSaleForm .cashier-chip {
            background: #1e293b;
            border-color: var(--line) !important;
            color: #cbd5e1;
        }

            html[data-theme="dark"] #posSaleForm .cashier-chip b {
                color: #e2e8f0;
            }

            html[data-theme="dark"] #posSaleForm .cashier-chip small {
                color: #94a3b8;
            }

        html[data-theme="dark"] #posSaleForm .header-icon {
            color: #94a3b8;
        }

        /* Layout gutters */
        html[data-theme="dark"] #posSaleForm .pos-layout {
            background: var(--line);
        }

        html[data-theme="dark"] #posSaleForm .catalog-workbench {
            background: var(--stone);
        }

        html[data-theme="dark"] #posSaleForm .sale-ledger {
            background: var(--paper);
        }

        /* Search */
        html[data-theme="dark"] #posSaleForm .pos-search {
            background: #131a17;
            border-color: var(--line);
            color: #94a3b8;
        }

            html[data-theme="dark"] #posSaleForm .pos-search input {
                color: #e2e8f0;
            }

            html[data-theme="dark"] #posSaleForm .pos-search kbd {
                background: #334155;
                color: #cbd5e1;
            }

        html[data-theme="dark"] #posSaleForm .scan-button {
            background: var(--teal);
            color: #0f172a;
        }

            html[data-theme="dark"] #posSaleForm .scan-button:hover {
                background: #0d9488;
            }

        /* Category chips */
        html[data-theme="dark"] #posSaleForm .category-chip {
            background: var(--stone);
            border-color: var(--line) !important;
            color: #cbd5e1;
        }

            html[data-theme="dark"] #posSaleForm .category-chip.active {
                background: var(--teal);
                border-color: var(--teal) !important;
                color: #0f172a;
            }

        /* Catalog caption */
        html[data-theme="dark"] #posSaleForm .catalog-caption {
            color: #cbd5e1;
            border-bottom-color: var(--line);
        }

            html[data-theme="dark"] #posSaleForm .catalog-caption small {
                color: #94a3b8;
            }

        /* Catalog scrollbar */
        html[data-theme="dark"] #posSaleForm .pos-catalog-grid {
            scrollbar-color: var(--teal) var(--stone);
        }

            html[data-theme="dark"] #posSaleForm .pos-catalog-grid::-webkit-scrollbar-track {
                background: var(--stone);
            }

            html[data-theme="dark"] #posSaleForm .pos-catalog-grid::-webkit-scrollbar-thumb {
                background: #475569;
                border-color: var(--stone);
            }

                html[data-theme="dark"] #posSaleForm .pos-catalog-grid::-webkit-scrollbar-thumb:hover {
                    background: var(--teal);
                }

        /* Catalog cards */
        html[data-theme="dark"] #posSaleForm .catalog-card {
            background: var(--paper);
            border-color: var(--line) !important;
            color: #e2e8f0;
        }

            html[data-theme="dark"] #posSaleForm .catalog-card:hover {
                border-color: var(--teal) !important;
                box-shadow: 0 6px 14px rgba(20, 184, 166, .25);
            }

        html[data-theme="dark"] #posSaleForm .catalog-icon {
            background: var(--stone);
            border-bottom-color: var(--line);
            color: var(--teal);
        }

            html[data-theme="dark"] #posSaleForm .catalog-icon:after {
                background: #475569;
            }

        html[data-theme="dark"] #posSaleForm .catalog-glyph {
            color: var(--teal);
        }

        html[data-theme="dark"] #posSaleForm .catalog-copy {
            background: var(--paper);
        }

        html[data-theme="dark"] #posSaleForm .catalog-meta {
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .catalog-title {
            color: #e2e8f0 !important;
        }

        html[data-theme="dark"] #posSaleForm .catalog-arabic {
            color: #94a3b8 !important;
        }

        html[data-theme="dark"] #posSaleForm .catalog-price {
            border-top-color: var(--line);
        }

            html[data-theme="dark"] #posSaleForm .catalog-price span {
                color: #94a3b8;
            }

            html[data-theme="dark"] #posSaleForm .catalog-price b {
                color: #6ee7b7 !important;
            }

        html[data-theme="dark"] #posSaleForm .catalog-empty {
            color: #94a3b8;
        }

        /* Sale ledger */
        html[data-theme="dark"] #posSaleForm .ledger-heading h2 {
            color: #e2e8f0;
        }

            html[data-theme="dark"] #posSaleForm .ledger-heading h2 span {
                color: #94a3b8;
            }

        html[data-theme="dark"] #posSaleForm .ledger-heading p {
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .ledger-action {
            background: var(--paper);
            border-color: var(--line) !important;
            color: #cbd5e1;
        }

            html[data-theme="dark"] #posSaleForm .ledger-action:hover {
                border-color: var(--teal) !important;
                color: var(--teal);
            }

            html[data-theme="dark"] #posSaleForm .ledger-action.destructive:hover {
                border-color: #fca5a5 !important;
                color: #fca5a5;
            }

        /* Sale table */
        html[data-theme="dark"] #posSaleForm .sale-table-wrap {
            background: var(--paper);
            border-color: var(--line);
        }

        html[data-theme="dark"] #posSaleForm .sale-table th {
            background: var(--stone);
            border-bottom-color: var(--line);
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .sale-table td {
            border-bottom-color: rgba(255,255,255,.06);
            color: #e2e8f0;
        }

        html[data-theme="dark"] #posSaleForm .line-number {
            background: var(--stone);
            border-color: var(--line);
            color: #cbd5e1;
        }

        html[data-theme="dark"] #posSaleForm .sale-item b {
            color: #e2e8f0;
        }

        html[data-theme="dark"] #posSaleForm .sale-item small {
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .sale-item em {
            color: #fbbf24;
        }

        html[data-theme="dark"] #posSaleForm .quantity-control button {
            background: var(--paper);
            border-color: var(--line) !important;
            color: #cbd5e1;
        }

            html[data-theme="dark"] #posSaleForm .quantity-control button:hover {
                background: var(--teal);
                border-color: var(--teal) !important;
                color: #0f172a;
            }

        html[data-theme="dark"] #posSaleForm .quantity-control b {
            color: #e2e8f0;
        }

        html[data-theme="dark"] #posSaleForm .line-total {
            color: #6ee7b7;
        }

        html[data-theme="dark"] #posSaleForm .line-delete {
            color: #94a3b8;
        }

            html[data-theme="dark"] #posSaleForm .line-delete:hover {
                color: #fca5a5;
            }

        html[data-theme="dark"] #posSaleForm .empty-sale {
            background: var(--paper);
            color: #94a3b8;
        }

            html[data-theme="dark"] #posSaleForm .empty-sale b {
                color: #e2e8f0;
            }

        /* Footer */
        html[data-theme="dark"] #posSaleForm .customer-chip {
            background: var(--paper);
            border-color: var(--line) !important;
            color: #cbd5e1;
        }

            html[data-theme="dark"] #posSaleForm .customer-chip small {
                color: #94a3b8;
            }

            html[data-theme="dark"] #posSaleForm .customer-chip b {
                color: #e2e8f0;
            }

        html[data-theme="dark"] #posSaleForm .invoice-meta {
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .zatca-state {
            background: rgba(20, 184, 166, .18);
            color: #6ee7b7;
        }

        /* Receipt spine (already dark by design — keep as-is) */
        html[data-theme="dark"] #posSaleForm .receipt-spine {
            background: linear-gradient(160deg, #0f2a26, #0a1f1c);
        }

        /* Dialog (customer / discount) */
        html[data-theme="dark"] #posSaleForm .pos-dialog {
            background: rgba(10, 15, 28, .88);
        }

        html[data-theme="dark"] #posSaleForm .dialog-panel {
            background: var(--paper);
            border: 1px solid var(--line);
            box-shadow: 0 24px 70px rgba(0,0,0,.7);
            color: #e2e8f0;
        }

            html[data-theme="dark"] #posSaleForm .dialog-panel h3 {
                color: #e2e8f0;
            }

            html[data-theme="dark"] #posSaleForm .dialog-panel label {
                color: #94a3b8;
            }

            html[data-theme="dark"] #posSaleForm .dialog-panel input {
                background: var(--stone);
                border-color: var(--line);
                color: #e2e8f0;
            }

        html[data-theme="dark"] #posSaleForm .dialog-close {
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .dialog-save {
            background: var(--teal);
            color: #0f172a;
        }

        /* Toast */
        html[data-theme="dark"] #posSaleForm .pos-toast {
            background: #173833;
            color: #e2e8f0;
            box-shadow: 0 12px 34px rgba(0,0,0,.7);
        }

            html[data-theme="dark"] #posSaleForm .pos-toast.success {
                background: var(--teal);
                color: #0f172a;
            }

            html[data-theme="dark"] #posSaleForm .pos-toast.error {
                background: #b91c1c;
                color: #fecaca;
            }


        /* ==========================================================================
   22. COUNTERTOP POS — CATALOG CARD EXTENSION
   (#posSaleForm .catalog-card detail from the follow-up stylesheet)
   --------------------------------------------------------------------------
   The extension adds .catalog-inventory, .catalog-unit, .catalog-balance.
   These were styled with hardcoded `#edf0eb`, `#e7f3ed`, `#fff2d6`,
   `#f9e1df` — all need dark overrides.
   ========================================================================== */

        html[data-theme="dark"] #posSaleForm .catalog-inventory {
            border-top-color: var(--line);
            color: #94a3b8;
        }

        html[data-theme="dark"] #posSaleForm .catalog-unit b {
            color: #cbd5e1;
        }

        html[data-theme="dark"] #posSaleForm .catalog-balance {
            background: rgba(45, 212, 191, .14);
            color: #6ee7b7;
        }

            html[data-theme="dark"] #posSaleForm .catalog-balance.is-low {
                background: rgba(251, 191, 36, .16);
                color: #fbbf24;
            }

            html[data-theme="dark"] #posSaleForm .catalog-balance.is-out {
                background: rgba(248, 113, 113, .18);
                color: #fca5a5;
            }


    /* ==========================================================================
   23. SALES cp-scope  —  cart · customer · ZATCA · payment layout
   --------------------------------------------------------------------------
   Covered markup (both variants of the block are identical apart from which
   .tab-panel has `.active`):
     · #customers-panel  →  QR / Customer / Invoice / Store cards
     · #fulfillment-panel →  ZATCA card + Additional Details card
     · #payment-panel     →  "Payment Processing" empty state

   The source sets --cp-* on .cp-scope itself, so the tokens must be
   re-declared under `html[data-theme="dark"] .cp-scope`, not at :root.
   Sibling scopes on the same page (.cp-tb-scope, .ihdr-scope, .cp-af-scope,
   .it-scope) are also covered so nothing on the screen stays light.
   ========================================================================== */

    /* ---- 23.1  .cp-scope tokens ---- */
    html[data-theme="dark"] .cp-scope {
        --cp-indigo: #8b95ff;
        --cp-indigo-dark: #6a78f0;
        --cp-violet: #a78bfa;
        --cp-cyan: #22d3ee;
        --cp-amber: #fbbf24;
        --cp-rose: #fb7185;
        --cp-surface: #1e293b;
        --cp-surface-soft: #172033;
        --cp-border: rgba(255, 255, 255, 0.10);
        --cp-border-soft: rgba(255, 255, 255, 0.06);
        --cp-text: #e2e8f0;
        --cp-text-muted: #94a3b8;
        --cp-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
        --cp-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.5);
        color: var(--cp-text);
    }

        /* ---- 23.2  Card shell + header ---- */
        html[data-theme="dark"] .cp-scope .cp-card {
            background: var(--cp-surface);
            border-color: var(--cp-border-soft);
            box-shadow: var(--cp-shadow);
        }

            html[data-theme="dark"] .cp-scope .cp-card:hover {
                box-shadow: var(--cp-shadow-hover);
            }

        html[data-theme="dark"] .cp-scope .cp-card-header {
            background: linear-gradient(135deg, rgba(139, 149, 255, 0.10), rgba(34, 211, 238, 0.06));
            border-bottom-color: var(--cp-border-soft);
        }

            html[data-theme="dark"] .cp-scope .cp-card-header:hover {
                background: linear-gradient(135deg, rgba(139, 149, 255, 0.16), rgba(34, 211, 238, 0.10));
            }
            /* ZATCA header keeps its indigo→violet gradient — that reads well on dark */
            html[data-theme="dark"] .cp-scope .cp-card-header.cp-header-zatca {
                background: linear-gradient(135deg, #6d4dd6, #8b5cf6);
                border-bottom: none;
            }

        html[data-theme="dark"] .cp-scope .cp-title {
            color: var(--cp-text);
        }

            html[data-theme="dark"] .cp-scope .cp-title .cp-ico {
                background: rgba(139, 149, 255, 0.16);
                color: var(--cp-indigo);
            }

        html[data-theme="dark"] .cp-scope .cp-header-zatca .cp-title .cp-ico {
            background: rgba(255, 255, 255, 0.20);
            color: #fff;
        }

        html[data-theme="dark"] .cp-scope .cp-chevron {
            color: var(--cp-text-muted);
        }

        /* ---- 23.3  Labels + inputs ---- */
        html[data-theme="dark"] .cp-scope label.cp-label {
            color: var(--cp-text-muted);
        }

        html[data-theme="dark"] .cp-scope .form-control,
        html[data-theme="dark"] .cp-scope .form-select {
            background-color: var(--cp-surface-soft);
            border-color: var(--cp-border);
            color: var(--cp-text);
        }

            html[data-theme="dark"] .cp-scope .form-control:focus,
            html[data-theme="dark"] .cp-scope .form-select:focus {
                background-color: var(--cp-surface);
                border-color: var(--cp-indigo);
                box-shadow: 0 0 0 .18rem rgba(139, 149, 255, 0.20);
            }

            html[data-theme="dark"] .cp-scope .form-control[readonly],
            html[data-theme="dark"] .cp-scope .form-control[disabled] {
                background-color: var(--cp-surface);
                color: var(--cp-text-muted);
            }

            html[data-theme="dark"] .cp-scope .form-control::placeholder {
                color: #64748b;
            }

        /* Input-group chrome */
        html[data-theme="dark"] .cp-scope .input-group-sm .input-group-text {
            background: var(--cp-surface-soft);
            border-color: var(--cp-border);
            color: var(--cp-indigo);
        }

        html[data-theme="dark"] .cp-scope .input-group > .form-control:not(:first-child),
        html[data-theme="dark"] .cp-scope .input-group > .form-select:not(:first-child) {
            border-radius: 0 var(--cp-radius-sm) var(--cp-radius-sm) 0;
        }

        /* "Search Customer" side button (btn-outline-secondary inside input-group) */
        html[data-theme="dark"] .cp-scope .btn-outline-secondary.js-open-customer {
            background: var(--cp-surface-soft);
            border-color: var(--cp-border);
            color: var(--cp-indigo);
        }

            html[data-theme="dark"] .cp-scope .btn-outline-secondary.js-open-customer:hover {
                background: var(--cp-indigo);
                border-color: var(--cp-indigo);
                color: #0f172a;
            }

        /* Sale-type toggle pill group */
        html[data-theme="dark"] .cp-scope .btn-check + .btn.btn-outline-primary {
            border-color: rgba(139, 149, 255, 0.35);
            color: var(--cp-text-muted);
            background: transparent;
        }

        html[data-theme="dark"] .cp-scope .btn-check:checked + .btn.btn-outline-primary {
            background: linear-gradient(135deg, var(--cp-indigo), var(--cp-violet));
            border-color: var(--cp-indigo);
            color: #fff;
            box-shadow: 0 2px 8px rgba(139, 149, 255, 0.30);
        }

        /* ---- 23.4  QR card ---- */
        html[data-theme="dark"] .cp-scope .cp-qr-wrap {
            background: linear-gradient(160deg, var(--cp-surface), var(--cp-surface-soft));
            border-color: var(--cp-border);
        }
            /* Keep the QR image on white so scanners still read it */
            html[data-theme="dark"] .cp-scope .cp-qr-wrap #qrCodeImg {
                background: #ffffff;
                border-radius: 8px;
                padding: 4px;
            }

        html[data-theme="dark"] .cp-scope .cp-qr-actions .btn-light {
            background: rgba(30, 41, 59, 0.90);
            border-color: var(--cp-border);
            color: var(--cp-text);
        }

            html[data-theme="dark"] .cp-scope .cp-qr-actions .btn-light:hover {
                background: #1e293b;
                border-color: var(--cp-indigo);
                color: var(--cp-indigo);
            }

        html[data-theme="dark"] .cp-scope .cp-qr-meta small {
            color: var(--cp-text-muted);
        }

        html[data-theme="dark"] .cp-scope #qrLoadingOverlay {
            background: rgba(30, 41, 59, 0.85) !important;
        }

        /* ---- 23.5  ZATCA response pills ---- */
        html[data-theme="dark"] .cp-scope input#ResponseText,
        html[data-theme="dark"] .cp-scope input#ResponseStatus {
            border: 0 !important;
            color: #fff !important;
        }
        /* Bootstrap utility classes on #ResponseStatus */
        html[data-theme="dark"] .cp-scope #ResponseStatus.bg-success {
            background: linear-gradient(135deg, #16a34a, #22c55e) !important;
        }

        html[data-theme="dark"] .cp-scope #ResponseStatus.bg-danger {
            background: linear-gradient(135deg, #dc2626, #ef4444) !important;
        }

        html[data-theme="dark"] .cp-scope #ResponseStatus.bg-secondary {
            background: linear-gradient(135deg, #475569, #64748b) !important;
        }

        /* ---- 23.6  ZATCA environment toggle ---- */
        html[data-theme="dark"] .cp-scope .cp-env-group .btn-outline-success {
            color: #34d399;
            border-color: rgba(52, 211, 153, 0.35);
        }

            html[data-theme="dark"] .cp-scope .cp-env-group .btn-outline-success:hover,
            html[data-theme="dark"] .cp-scope .cp-env-group .btn-check:checked + .btn-outline-success {
                background: linear-gradient(135deg, #16a34a, #22c55e);
                border-color: #16a34a;
                color: #fff;
            }

        html[data-theme="dark"] .cp-scope .cp-env-group .btn-outline-danger {
            color: #f87171;
            border-color: rgba(248, 113, 113, 0.35);
        }

            html[data-theme="dark"] .cp-scope .cp-env-group .btn-outline-danger:hover,
            html[data-theme="dark"] .cp-scope .cp-env-group .btn-check:checked + .btn-outline-danger {
                background: linear-gradient(135deg, #dc2626, #ef4444);
                border-color: #dc2626;
                color: #fff;
            }

        /* ---- 23.7  Sync progress bar (inline background needs !important) ---- */
        html[data-theme="dark"] .cp-scope #syncProgressContainer .progress {
            background: rgba(255, 255, 255, 0.08) !important;
        }

        html[data-theme="dark"] .cp-scope .sync-progress-text,
        html[data-theme="dark"] .cp-scope .sync-progress-text .text-muted {
            color: var(--cp-text-muted) !important;
        }

        /* ---- 23.8  Payment panel empty state ---- */
        html[data-theme="dark"] .cp-scope .cp-payment-empty h5 {
            color: var(--cp-text);
        }

        html[data-theme="dark"] .cp-scope .cp-payment-empty p {
            color: var(--cp-text-muted);
        }

        html[data-theme="dark"] .cp-scope .cp-payment-empty .btn-primary {
            background: linear-gradient(135deg, var(--cp-indigo), var(--cp-violet));
            border: 0;
            color: #fff;
            box-shadow: 0 3px 10px rgba(139, 149, 255, 0.30);
        }

            html[data-theme="dark"] .cp-scope .cp-payment-empty .btn-primary:hover {
                background: linear-gradient(135deg, var(--cp-indigo-dark), var(--cp-violet));
                box-shadow: 0 4px 14px rgba(139, 149, 255, 0.45);
            }

        /* ---- 23.9  Bootstrap utilities used inside .cp-scope ---- */
        html[data-theme="dark"] .cp-scope .text-muted,
        html[data-theme="dark"] .cp-scope .small.text-muted {
            color: var(--cp-text-muted) !important;
        }

        html[data-theme="dark"] .cp-scope hr {
            border-color: var(--cp-border);
            opacity: 1;
        }

        html[data-theme="dark"] .cp-scope .spinner-border.text-primary {
            color: var(--cp-indigo) !important;
        }

        html[data-theme="dark"] .cp-scope .bg-white {
            background: var(--cp-surface) !important;
        }

        html[data-theme="dark"] .cp-scope .bg-light {
            background: var(--cp-surface-soft) !important;
        }


    /* ==========================================================================
   23B. SIBLING SCOPES  (same page — topbar, header, footer actions, line items)
   These IDs/classes appear on the same sales screen as .cp-scope, and each
   defines its own tokens locally. Redeclare them so the whole page goes dark.
   ========================================================================== */

    /* ---- .cp-tb-scope (invoice topbar strip) ---- */
    html[data-theme="dark"] .cp-tb-scope {
        --tb-indigo: #8b95ff;
        --tb-violet: #a78bfa;
        --tb-cyan: #22d3ee;
        --tb-text: #e2e8f0;
        --tb-text-muted: #94a3b8;
        --tb-border: rgba(255, 255, 255, 0.08);
    }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-bar {
            background: linear-gradient(135deg, rgba(139, 149, 255, 0.06), rgba(34, 211, 238, 0.04));
            border-color: var(--tb-border);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
        }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-user-name,
        html[data-theme="dark"] .cp-tb-scope #totalInvoices {
            color: var(--tb-text);
        }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-user-role,
        html[data-theme="dark"] .cp-tb-scope .cp-tb-of {
            color: var(--tb-text-muted);
        }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-nav {
            background: #1e293b;
            border-color: var(--tb-border);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
        }

            html[data-theme="dark"] .cp-tb-scope .cp-tb-nav .btn {
                color: var(--tb-text-muted);
            }

                html[data-theme="dark"] .cp-tb-scope .cp-tb-nav .btn:hover {
                    background: rgba(139, 149, 255, 0.14);
                    color: #a5b4fc;
                }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-counter {
            background: linear-gradient(135deg, rgba(139, 149, 255, 0.10), rgba(34, 211, 238, 0.06));
        }

            html[data-theme="dark"] .cp-tb-scope .cp-tb-counter input#currentInvoiceNumber {
                color: #a5b4fc;
            }

            html[data-theme="dark"] .cp-tb-scope .cp-tb-counter .badge {
                background: rgba(139, 149, 255, 0.18) !important;
                color: #a5b4fc !important;
            }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-ghost {
            background: rgba(255, 255, 255, 0.05);
            color: var(--tb-text-muted);
        }

            html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-ghost:hover {
                background: rgba(139, 149, 255, 0.14);
                color: #a5b4fc;
            }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-primary-soft {
            background: linear-gradient(135deg, #6d4dd6, #8b5cf6);
        }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-preview-soft {
            background: rgba(139, 149, 255, 0.16);
            color: #a5b4fc;
        }

            html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-preview-soft:hover {
                background: rgba(139, 149, 255, 0.26);
            }

        html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-danger-soft {
            background: rgba(251, 113, 133, 0.16);
            color: #fda4af;
        }

            html[data-theme="dark"] .cp-tb-scope .cp-tb-actions .btn-danger-soft:hover {
                background: rgba(251, 113, 133, 0.26);
            }

    /* ---- .ihdr-scope (invoice header card) ---- */
    html[data-theme="dark"] .ihdr-scope {
        --ih-indigo: #8b95ff;
        --ih-violet: #a78bfa;
        --ih-cyan: #22d3ee;
        --ih-amber: #fbbf24;
        --ih-green: #34d399;
        --ih-text: #e2e8f0;
        --ih-text-muted: #94a3b8;
        --ih-border: rgba(255, 255, 255, 0.08);
    }

        html[data-theme="dark"] .ihdr-scope .card-header-advanced {
            background: linear-gradient(135deg, rgba(139, 149, 255, 0.08), rgba(34, 211, 238, 0.05));
            border-color: var(--ih-border);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
        }

        html[data-theme="dark"] .ihdr-scope .header-badge,
        html[data-theme="dark"] .ihdr-scope .header-stats {
            background: #1e293b;
            border-color: var(--ih-border);
        }

        html[data-theme="dark"] .ihdr-scope .badge-title,
        html[data-theme="dark"] .ihdr-scope .stat-label {
            color: var(--ih-text-muted);
        }

        html[data-theme="dark"] .ihdr-scope .badge-subtitle,
        html[data-theme="dark"] .ihdr-scope .stat-value {
            color: var(--ih-text);
        }

        html[data-theme="dark"] .ihdr-scope .stat-divider {
            background: var(--ih-border);
        }

        html[data-theme="dark"] .ihdr-scope .btn-action {
            background: #1e293b;
            border-color: var(--ih-border);
            color: var(--ih-text-muted);
        }

            html[data-theme="dark"] .ihdr-scope .btn-action:hover {
                background: rgba(139, 149, 255, 0.12);
                color: #a5b4fc;
                border-color: rgba(139, 149, 255, 0.35);
            }

        html[data-theme="dark"] .ihdr-scope .btn-collapse {
            background: #1e293b;
            border-color: var(--ih-border);
            color: var(--ih-text-muted);
        }

            html[data-theme="dark"] .ihdr-scope .btn-collapse:hover {
                background: rgba(139, 149, 255, 0.12);
                color: #a5b4fc;
            }

        html[data-theme="dark"] .ihdr-scope .nova-toggle-card {
            background: #1e293b;
            border-color: var(--ih-border);
        }

            html[data-theme="dark"] .ihdr-scope .nova-toggle-card .form-check-label {
                color: var(--ih-text);
            }

        html[data-theme="dark"] .ihdr-scope .column-settings-panel {
            background: linear-gradient(180deg, #1e293b, #172033);
            border-top-color: var(--ih-border);
        }

        html[data-theme="dark"] .ihdr-scope .settings-header h6 {
            color: var(--ih-text);
        }

        html[data-theme="dark"] .ihdr-scope .btn-close-settings {
            background: rgba(255, 255, 255, 0.06);
            color: var(--ih-text-muted);
        }

            html[data-theme="dark"] .ihdr-scope .btn-close-settings:hover {
                background: rgba(251, 113, 133, 0.16);
                color: #fda4af;
            }

        html[data-theme="dark"] .ihdr-scope .setting-group {
            background: #1e293b;
            border-color: var(--ih-border);
        }

        html[data-theme="dark"] .ihdr-scope .group-title {
            color: #a5b4fc;
            border-bottom-color: var(--ih-border);
        }

        html[data-theme="dark"] .ihdr-scope .setting-item label,
        html[data-theme="dark"] .ihdr-scope .setting-item label i {
            color: var(--ih-text-muted);
        }

            html[data-theme="dark"] .ihdr-scope .setting-item label:hover {
                background: rgba(139, 149, 255, 0.08);
            }

        html[data-theme="dark"] .ihdr-scope .setting-item input.toggle-column:checked + label {
            background: rgba(139, 149, 255, 0.16);
            color: #a5b4fc;
        }

            html[data-theme="dark"] .ihdr-scope .setting-item input.toggle-column:checked + label i {
                color: #a5b4fc;
            }

        html[data-theme="dark"] .ihdr-scope .settings-footer {
            border-top-color: var(--ih-border);
        }

    /* ---- .cp-af-scope (footer action row) ---- */
    html[data-theme="dark"] .cp-af-scope {
        --af-border: rgba(255, 255, 255, 0.08);
        --af-text-muted: #94a3b8;
    }

        html[data-theme="dark"] .cp-af-scope #btninfo {
            background: rgba(255, 255, 255, 0.05);
            border-color: var(--af-border);
            color: var(--af-text-muted);
        }

            html[data-theme="dark"] .cp-af-scope #btninfo:hover {
                background: rgba(139, 149, 255, 0.12);
                color: #a5b4fc;
            }

        html[data-theme="dark"] .cp-af-scope .btnkaidpartial {
            background: rgba(251, 113, 133, 0.12);
            border-color: rgba(251, 113, 133, 0.25);
            color: #fda4af;
        }

            html[data-theme="dark"] .cp-af-scope .btnkaidpartial:hover {
                background: #fb7185;
                color: #0f172a;
                border-color: transparent;
            }

    /* ---- .it-scope (invoice line table) ---- */
    html[data-theme="dark"] .it-scope {
        --it-indigo: #8b95ff;
        --it-violet: #a78bfa;
        --it-green: #34d399;
        --it-rose: #fb7185;
        --it-text: #e2e8f0;
        --it-text-muted: #94a3b8;
        --it-border: rgba(255, 255, 255, 0.08);
    }

        html[data-theme="dark"] .it-scope .table-responsive {
            border-color: var(--it-border);
            background: #1e293b;
        }

        html[data-theme="dark"] .it-scope #invoiceTable {
            color: var(--it-text);
            background: #1e293b;
        }

            html[data-theme="dark"] .it-scope #invoiceTable thead th {
                background: linear-gradient(135deg, #6d4dd6, #8b5cf6);
                border-bottom-color: rgba(255, 255, 255, 0.10);
                color: #fff !important;
            }

            html[data-theme="dark"] .it-scope #invoiceTable tbody tr {
                background: #1e293b;
                border-bottom-color: var(--it-border);
            }

                html[data-theme="dark"] .it-scope #invoiceTable tbody tr.invoice-item-row:hover {
                    background: rgba(139, 149, 255, 0.08);
                }

            html[data-theme="dark"] .it-scope #invoiceTable tbody td {
                border-color: var(--it-border);
                color: var(--it-text);
            }

        html[data-theme="dark"] .it-scope .it-item-name {
            color: var(--it-text);
        }

        html[data-theme="dark"] .it-scope .it-item-sub {
            color: var(--it-text-muted);
        }

        html[data-theme="dark"] .it-scope .form-control,
        html[data-theme="dark"] .it-scope .form-control.form-control-sm {
            background: #172033;
            border-color: var(--it-border);
            color: var(--it-text);
        }

            html[data-theme="dark"] .it-scope .form-control:focus {
                background: #1e293b;
                border-color: var(--it-indigo);
                box-shadow: 0 0 0 .15rem rgba(139, 149, 255, 0.20);
            }

            html[data-theme="dark"] .it-scope .form-control[readonly] {
                background: #1e293b;
                color: var(--it-text-muted);
            }

        html[data-theme="dark"] .it-scope .item-search.is-invalid {
            border-color: var(--it-rose) !important;
            box-shadow: 0 0 0 .15rem rgba(251, 113, 133, 0.22) !important;
        }

        html[data-theme="dark"] .it-scope .qty-control {
            background: #1e293b;
            border-color: var(--it-border);
        }

        html[data-theme="dark"] .it-scope .qty-btn {
            color: #a5b4fc;
        }

            html[data-theme="dark"] .it-scope .qty-btn:hover {
                background: rgba(139, 149, 255, 0.14);
            }

        html[data-theme="dark"] .it-scope .qty-input {
            color: var(--it-text);
        }

        html[data-theme="dark"] .it-scope .badge.bg-success {
            background: rgba(52, 211, 153, 0.18) !important;
            color: #6ee7b7 !important;
        }

        html[data-theme="dark"] .it-scope .badge.bg-warning {
            background: rgba(251, 191, 36, 0.18) !important;
            color: #fbbf24 !important;
        }

        html[data-theme="dark"] .it-scope .badge.bg-danger {
            background: rgba(251, 113, 133, 0.18) !important;
            color: #fda4af !important;
        }

        html[data-theme="dark"] .it-scope .empty-row-placeholder td {
            color: var(--it-text-muted);
        }


    /* ==========================================================================
   24. SWEETALERT PREMIUM DIALOGS  (.swal-premium-* / .swal-icon-* / .swal-btn-*)
   --------------------------------------------------------------------------
   Both `public-app.js` and the standalone premium-Swal module inject the same
   CSS under `#swal-premium-styles`. Their dark variants live inside
   `@media (prefers-color-scheme:dark)` — that never matches the manual
   `html[data-theme="dark"]` toggle. The rules below bridge that.
   ========================================================================== */

    /* ---- popup shell ---- */
    html[data-theme="dark"] .swal-premium-popup {
        background: #1e293b !important;
        border-color: rgba(255, 255, 255, .08) !important;
        box-shadow: 0 24px 64px rgba(0, 0, 0, .55), 0 4px 16px rgba(0, 0, 0, .35) !important;
    }

    /* ---- title / text / html ---- */
    html[data-theme="dark"] .swal-title {
        color: #f1f5f9 !important;
    }

    html[data-theme="dark"] .swal-text,
    html[data-theme="dark"] .swal-html {
        color: #94a3b8 !important;
    }

        html[data-theme="dark"] .swal-html .text-danger {
            color: #fca5a5 !important;
        }

        html[data-theme="dark"] .swal-html .text-success {
            color: #86efac !important;
        }

        html[data-theme="dark"] .swal-html .text-warning {
            color: #fbbf24 !important;
        }

    /* ---- icon wraps ---- */
    html[data-theme="dark"] .swal-icon-success {
        background: rgba(52, 211, 153, .18);
        color: #34d399;
    }

    html[data-theme="dark"] .swal-icon-error {
        background: rgba(248, 113, 113, .18);
        color: #f87171;
    }

    html[data-theme="dark"] .swal-icon-warning {
        background: rgba(251, 191, 36, .18);
        color: #fbbf24;
    }

    html[data-theme="dark"] .swal-icon-info {
        background: rgba(96, 165, 250, .18);
        color: #60a5fa;
    }

    html[data-theme="dark"] .swal-icon-question {
        background: rgba(167, 139, 250, .18);
        color: #a78bfa;
    }

    html[data-theme="dark"] .swal-icon-loading {
        background: rgba(96, 165, 250, .18);
        color: #60a5fa;
    }

    html[data-theme="dark"] .swal-spinner {
        border-color: rgba(96, 165, 250, .25);
        border-top-color: #60a5fa;
    }

    /* ---- actions bar ---- */
    html[data-theme="dark"] .swal-premium-actions.swal2-actions {
        background: #0f172a;
        border-top-color: rgba(255, 255, 255, .06);
    }

    /* ---- cancel button (confirm / danger-confirm gradients are fine on dark) ---- */
    html[data-theme="dark"] .swal-btn-cancel {
        background: #1e293b;
        color: #cbd5e1;
        border-color: rgba(255, 255, 255, .10);
    }

        html[data-theme="dark"] .swal-btn-cancel:hover {
            background: #334155;
            border-color: rgba(255, 255, 255, .20);
        }

    /* ---- timer progress bar ---- */
    html[data-theme="dark"] .swal2-timer-progress-bar {
        background: linear-gradient(90deg, #60a5fa, #a78bfa) !important;
    }

    /* ---- premium toast (.swal-toast) ---- */
    html[data-theme="dark"] .swal-toast {
        background: #1e293b;
        border-color: rgba(255, 255, 255, .08);
        box-shadow: 0 8px 32px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .35);
    }

    html[data-theme="dark"] .swal-toast-body {
        color: #f1f5f9;
    }

    html[data-theme="dark"] .swal-toast-close {
        color: #64748b;
    }

        html[data-theme="dark"] .swal-toast-close:hover {
            background: rgba(255, 255, 255, .06);
            color: #94a3b8;
        }

    /* ---- SweetAlert2 base popup (in case any vanilla Swal.fire slips through) ---- */
    html[data-theme="dark"] .swal2-popup {
        background: #1e293b;
        color: #f1f5f9;
    }

    html[data-theme="dark"] .swal2-title {
        color: #f1f5f9;
    }

    html[data-theme="dark"] .swal2-html-container {
        color: #94a3b8;
    }

    /* ---- legacy .swal-theme (SwalConfig.baseOptions) ---- */
    html[data-theme="dark"] .swal-theme {
        background: #1e293b !important;
        color: #f1f5f9 !important;
        border-color: rgba(255, 255, 255, .08) !important;
    }

        html[data-theme="dark"] .swal-theme .modal-title,
        html[data-theme="dark"] .swal-theme .fs-5,
        html[data-theme="dark"] .swal-theme .fs-6 {
            color: #e2e8f0 !important;
        }

        html[data-theme="dark"] .swal-theme .btn-secondary {
            background: #475569 !important;
            border-color: #475569 !important;
            color: #f1f5f9 !important;
        }

        html[data-theme="dark"] .swal-theme hr {
            border-color: rgba(255, 255, 255, .10);
        }

    /* ---- permission-dialog chrome (SwalConfig.injectStyles) ---- */
    html[data-theme="dark"] .permission-card {
        background: linear-gradient(135deg, #1e293b, #172033);
        box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
    }

    html[data-theme="dark"] .permission-icon-box {
        background: linear-gradient(145deg, #422006, #78350f);
        box-shadow: inset 0 0 10px rgba(255, 193, 7, .10);
    }

        html[data-theme="dark"] .permission-icon-box i {
            color: #fbbf24;
        }

    /* ---- locked-button hover (was light-grey) ---- */
    html[data-theme="dark"] .btn-locked:hover {
        background-color: #1e293b !important;
        border-color: #334155 !important;
    }

    /* ---- legacy spinner in SwalConfig.injectStyles ---- */
    html[data-theme="dark"] .modern-spinner {
        border-color: #475569;
        border-top-color: #22c55e;
    }


    /* ==========================================================================
   25. NOTIFICATION MICRO TOASTS  (.toast-micro, from NotificationService.injectStyles)
   --------------------------------------------------------------------------
   The toast is hardcoded `background: white` — invisible on dark pages until
   overridden.
   ========================================================================== */

    html[data-theme="dark"] .toast-micro {
        background: #1e293b;
        border: 1px solid rgba(255, 255, 255, .06);
        box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
    }

    html[data-theme="dark"] .toast-message {
        color: #f1f5f9;
    }

    html[data-theme="dark"] .toast-time {
        color: #94a3b8;
    }

    html[data-theme="dark"] .toast-close {
        color: #64748b;
    }

        html[data-theme="dark"] .toast-close:hover {
            color: #cbd5e1;
        }


    /* ==========================================================================
   26. PREMIUM LOADING OVERLAY  (.premium-loading-overlay .pl-*)
   --------------------------------------------------------------------------
   The overlay's dark variant lives only inside `@media (prefers-color-scheme:
   dark)` (see `_injectCompactLoadingStyles`). Bridge it to the manual theme.
   ========================================================================== */

    /* Backdrop is already rgba(15,23,42,.65) — leave it, it works on both themes. */

    /* ---- card shell ---- */
    html[data-theme="dark"] .pl-card {
        background: #1e293b;
        border-color: rgba(255, 255, 255, .06);
        box-shadow: 0 16px 48px rgba(0, 0, 0, .55), 0 3px 10px rgba(0, 0, 0, .35);
    }

    /* ---- close button ---- */
    html[data-theme="dark"] .pl-close-btn {
        background: #334155;
        color: #94a3b8;
    }

        html[data-theme="dark"] .pl-close-btn:hover {
            background: #475569;
            color: #f1f5f9;
        }

    /* ---- title / subtitle ---- */
    html[data-theme="dark"] .pl-title {
        color: #f1f5f9;
    }

    html[data-theme="dark"] .pl-subtitle {
        color: #94a3b8;
    }

    /* ---- progress ---- */
    html[data-theme="dark"] .pl-progress-track {
        background: #334155;
    }

    html[data-theme="dark"] .pl-progress-text {
        color: #93c5fd;
    }

    html[data-theme="dark"] .pl-progress-status {
        color: #94a3b8;
    }

    /* ---- icon wrappers ---- */
    html[data-theme="dark"] .pl-icon-wrapper.info {
        background: rgba(67, 97, 238, .20);
    }

    html[data-theme="dark"] .pl-icon-wrapper.success {
        background: rgba(22, 163, 74, .20);
    }

    html[data-theme="dark"] .pl-icon-wrapper.error {
        background: rgba(220, 38, 38, .20);
    }

    html[data-theme="dark"] .pl-icon-wrapper.warning {
        background: rgba(217, 119, 6, .20);
    }

    /* ---- spinner ring + dots ---- */
    html[data-theme="dark"] .pl-spinner-ring {
        border-color: rgba(99, 130, 255, .18);
        border-top-color: #8b95ff;
    }

    html[data-theme="dark"] .pl-spinner-dots span {
        background: #8b95ff;
    }

    /* ---- steps ---- */
    html[data-theme="dark"] .pl-step-label {
        color: #94a3b8;
    }

    html[data-theme="dark"] .pl-step.active .pl-step-label {
        color: #f1f5f9;
    }

    html[data-theme="dark"] .pl-step.completed .pl-step-label {
        color: #34d399;
    }

    html[data-theme="dark"] .pl-step-dot {
        border-color: #475569;
    }

    html[data-theme="dark"] .pl-step.active .pl-step-dot {
        border-color: #8b95ff;
        background: #8b95ff;
        box-shadow: 0 0 10px rgba(139, 149, 255, .40);
    }

    html[data-theme="dark"] .pl-step.completed .pl-step-dot {
        border-color: #34d399;
        background: #34d399;
    }


    /* ==========================================================================
   27. AUTH PAGE  —  inline SweetAlert2 + suggestion-box detail  (authuser.js)
   --------------------------------------------------------------------------
   The auth page's own CSS bridge (:is(html[data-theme="dark"], …)) already
   handles the auth container / tabs / inputs / .suggestion-box shell. The
   rules below cover what that bridge cannot reach:

     · Every Swal2 dialog created by authuser.js uses an INLINE
       `background: '#ffffff'` (or '#fff8f8') in its config object, so
       stylesheet rules need `!important` to win.
     · Suggestion items are injected at runtime with <mark> highlights,
       Bootstrap badges, and a .not-found line that have no dark treatment.
     · Hint / error notices appended under the username input.
     · The forgot-password form's hardcoded `bg-white` spans.
     · The #resetPasswordModal legacy reset flow.
     · The #register-tab disabled state.

   As the §27 rules come after §24, the `!important` on `.swal2-popup` here
   supersedes §24's non-important version — no need to edit §24.
   ========================================================================== */

    /* ---- 27.1  Every Swal2 dialog (overrides inline `background:` from config) ---- */
    html[data-theme="dark"] .swal2-popup {
        background: #1e293b !important;
        color: #f1f5f9 !important;
        border: 1px solid rgba(255, 255, 255, .08) !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .55) !important;
    }

        html[data-theme="dark"] .swal2-popup.swal2-toast {
            background: #1e293b !important;
            border: 1px solid rgba(255, 255, 255, .08) !important;
            box-shadow: 0 8px 24px rgba(0, 0, 0, .45) !important;
        }

    html[data-theme="dark"] .swal2-title {
        color: #f1f5f9 !important;
    }

    html[data-theme="dark"] .swal2-html-container {
        color: #cbd5e1 !important;
    }

        /* Explicit colour helpers that appear inside authuser.js messages */
        html[data-theme="dark"] .swal2-html-container .text-dark,
        html[data-theme="dark"] .swal2-title .text-dark,
        html[data-theme="dark"] .swal2-title.text-dark {
            color: #e2e8f0 !important;
        }

        html[data-theme="dark"] .swal2-html-container .text-muted,
        html[data-theme="dark"] .swal2-title .text-muted {
            color: #94a3b8 !important;
        }

        html[data-theme="dark"] .swal2-html-container .text-danger,
        html[data-theme="dark"] .swal2-html-container .text-danger strong,
        html[data-theme="dark"] .swal2-title .text-danger,
        html[data-theme="dark"] .swal2-title.text-danger {
            color: #fca5a5 !important;
        }

        /* Lists inside the "login error" / "account locked" dialogs */
        html[data-theme="dark"] .swal2-html-container ul,
        html[data-theme="dark"] .swal2-html-container ul li {
            color: #94a3b8;
        }

        html[data-theme="dark"] .swal2-html-container strong {
            color: #e2e8f0;
        }

    /* Loader inside "Signing in…" / "Initializing database…" */
    html[data-theme="dark"] .swal2-loader {
        border-color: rgba(96, 165, 250, .30) !important;
        border-top-color: #60a5fa !important;
    }

    html[data-theme="dark"] .swal2-container .spinner-border.text-primary,
    html[data-theme="dark"] .swal2-container .spinner-border.text-warning {
        color: #60a5fa !important;
        border-color: currentColor transparent transparent transparent !important;
    }

    /* Timer bar (login / register success toast, and the register-success mixin) */
    html[data-theme="dark"] .swal2-timer-progress-bar {
        background: linear-gradient(90deg, #60a5fa, #a78bfa) !important;
    }

        html[data-theme="dark"] .swal2-timer-progress-bar.bg-success {
            background: linear-gradient(90deg, #10b981, #34d399) !important;
        }

    /* Inline .progress bar inside the "Database is being initialized" retry
   dialog: it hardcodes #e9ecef. Match any inline style attribute that
   references that hex value. */
    html[data-theme="dark"] .swal2-container [style*="background:#e9ecef"],
    html[data-theme="dark"] .swal2-container [style*="background: #e9ecef"] {
        background: #334155 !important;
    }

    /* Confirm button text colour override from `.text-danger` inside fieldError */
    html[data-theme="dark"] .swal2-html-container .fw-bold {
        color: #e2e8f0;
    }


    /* ---- 27.2  Suggestion dropdown — dynamic content only ----
   The auth page bridge handles the outer `.suggestion-box` shell. The rules
   below style what SuggestionsService injects at runtime. */

    html[data-theme="dark"] #usernameSuggestions mark,
    html[data-theme="dark"] .suggestion-box mark {
        background: rgba(251, 191, 36, .35) !important;
        color: #fde68a !important;
        padding: 0 2px;
        border-radius: 2px;
    }

    html[data-theme="dark"] #usernameSuggestions .badge.bg-success,
    html[data-theme="dark"] .suggestion-box .badge.bg-success {
        background: rgba(52, 211, 153, .20) !important;
        color: #6ee7b7 !important;
    }

    html[data-theme="dark"] #usernameSuggestions .badge.bg-info,
    html[data-theme="dark"] .suggestion-box .badge.bg-info {
        background: rgba(96, 165, 250, .20) !important;
        color: #93c5fd !important;
    }

    html[data-theme="dark"] #usernameSuggestions .text-primary,
    html[data-theme="dark"] .suggestion-box .text-primary {
        color: #93c5fd !important;
    }

    html[data-theme="dark"] #usernameSuggestions .text-success,
    html[data-theme="dark"] .suggestion-box .text-success {
        color: #6ee7b7 !important;
    }

    html[data-theme="dark"] #usernameSuggestions .text-muted,
    html[data-theme="dark"] .suggestion-box .text-muted {
        color: #94a3b8 !important;
    }

    html[data-theme="dark"] #usernameSuggestions .not-found,
    html[data-theme="dark"] .suggestion-box .not-found {
        color: #94a3b8 !important;
        font-style: italic;
    }


    /* ---- 27.3  JS-injected hint / error notices under username input ---- */
    html[data-theme="dark"] .database-hint,
    html[data-theme="dark"] .database-hint.text-info {
        color: #93c5fd !important;
    }

    html[data-theme="dark"] input + .database-hint,
    html[data-theme="dark"] input + .text-danger.small {
        /* Fallback when the hint sits directly next to the input (authuser.js
       appends them into `input.parentNode`). */
        color: #93c5fd !important;
    }

    html[data-theme="dark"] .text-danger.small,
    html[data-theme="dark"] .input-error.text-danger {
        color: #fca5a5 !important;
    }


    /* ---- 27.4  Forgot-password form (ForgotPasswordService.templates.*) ----
   These templates use `<span class="input-group-text bg-white border-0">`
   inside `<div class="input-group rounded shadow-sm border">`. The auth
   bridge's `.input-group` rule wins, but `.bg-white` sets an !important
   background-color from Bootstrap — need to override it here so both the
   span and the wrapper match. */

    html[data-theme="dark"] #forgotPasswordForm .input-group {
        background: #172033 !important;
        border-color: rgba(255, 255, 255, .12) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .25) !important;
    }

    html[data-theme="dark"] #forgotPasswordForm .input-group-text.bg-white,
    html[data-theme="dark"] #forgotPasswordForm .input-group-text {
        background: #1e293b !important;
        border-color: transparent !important;
        color: #94a3b8 !important;
    }

    html[data-theme="dark"] #forgotPasswordForm .form-control,
    html[data-theme="dark"] #forgotPasswordForm .form-control.border-0 {
        background: #172033 !important;
        border-color: transparent !important;
        color: #e2e8f0 !important;
    }

        html[data-theme="dark"] #forgotPasswordForm .form-control::placeholder {
            color: #64748b !important;
        }

    html[data-theme="dark"] #forgotPasswordForm .form-label,
    html[data-theme="dark"] #forgotPasswordForm .fw-bold {
        color: #e2e8f0 !important;
    }

    html[data-theme="dark"] #forgotPasswordForm .text-muted,
    html[data-theme="dark"] #forgotPasswordForm small.text-muted {
        color: #94a3b8 !important;
    }

    html[data-theme="dark"] #forgotPasswordForm .text-primary {
        color: #93c5fd !important;
    }

    html[data-theme="dark"] #forgotPasswordForm .btn-outline-secondary {
        border-color: rgba(255, 255, 255, .14) !important;
        color: #94a3b8 !important;
    }

        html[data-theme="dark"] #forgotPasswordForm .btn-outline-secondary:hover {
            border-color: rgba(255, 255, 255, .24) !important;
            color: #e2e8f0 !important;
            background: #1e293b !important;
        }


    /* ---- 27.5  Password eye-toggle spans (#toggleNewPassword, etc.) ----
   They're `.input-group-text bg-white border-0` with `cursor:pointer` — the
   base rule is already re-skinned by the auth bridge, but `.bg-white`
   arrives with `!important` from Bootstrap so we override again to the
   auth-user markup specifically. */
    html[data-theme="dark"] #toggleNewPassword,
    html[data-theme="dark"] #toggleConfirmPassword,
    html[data-theme="dark"] #loginShowPwd,
    html[data-theme="dark"] #registerShowPwd {
        background: #1e293b !important;
        border-color: transparent !important;
        color: #cbd5e1 !important;
    }

        html[data-theme="dark"] #toggleNewPassword:hover,
        html[data-theme="dark"] #toggleConfirmPassword:hover {
            color: #e2e8f0 !important;
        }


    /* ---- 27.6  Reset-password legacy modal (#resetPasswordModal) ---- */
    html[data-theme="dark"] #resetPasswordModal .modal-content {
        background: #1e293b;
        border: 1px solid rgba(255, 255, 255, .08);
        color: #e2e8f0;
    }

    html[data-theme="dark"] #resetPasswordModal .modal-header,
    html[data-theme="dark"] #resetPasswordModal .modal-footer {
        background: #172033;
        border-color: rgba(255, 255, 255, .08);
    }

    html[data-theme="dark"] #resetPasswordModal .modal-title {
        color: #f1f5f9;
    }

    html[data-theme="dark"] #resetPasswordModal .form-label {
        color: #cbd5e1;
    }

    html[data-theme="dark"] #resetPasswordModal .form-control {
        background: #172033;
        border-color: rgba(255, 255, 255, .10);
        color: #e2e8f0;
    }

        html[data-theme="dark"] #resetPasswordModal .form-control::placeholder {
            color: #64748b;
        }

    html[data-theme="dark"] #resetPasswordModal .input-group-text {
        background: #1e293b;
        border-color: rgba(255, 255, 255, .10);
        color: #94a3b8;
    }

    html[data-theme="dark"] #resetPasswordModal .btn-close {
        filter: invert(1) grayscale(1) brightness(1.6);
    }


    /* ---- 27.7  Registration guard (RegistrationGuardService.applyToTab) ---- */
    html[data-theme="dark"] #register-tab.disabled,
    html[data-theme="dark"] #register-tab[disabled] {
        color: #64748b !important;
        opacity: .55;
        pointer-events: none;
    }

    html[data-theme="dark"] #register-tab.text-muted {
        color: #64748b !important;
    }


    /* ---- 27.8  "Toggle user suggestions" row ---- */
    html[data-theme="dark"] #toggleUserSuggestions.form-check-input {
        background-color: #334155;
        border-color: rgba(255, 255, 255, .20);
    }

        html[data-theme="dark"] #toggleUserSuggestions.form-check-input:checked {
            background-color: #8b95ff;
            border-color: #8b95ff;
        }

        html[data-theme="dark"] #toggleUserSuggestions.form-check-input:disabled {
            opacity: .45;
            cursor: not-allowed;
        }

    html[data-theme="dark"] label[for="toggleUserSuggestions"],
    html[data-theme="dark"] #toggleUserSuggestions + label {
        color: #94a3b8 !important;
    }


    /* ---- 27.9  Misc auth-page chrome ---- */
    html[data-theme="dark"] #clearSearch {
        color: #94a3b8;
    }

        html[data-theme="dark"] #clearSearch:hover {
            color: #fca5a5;
        }

    /* Bootstrap "text-info" hints under password fields */
    html[data-theme="dark"] .text-info.small,
    html[data-theme="dark"] .form-text {
        color: #93c5fd !important;
    }

    /* Tab-focus / active on #authTab (matches the auth bridge colours but
   reinforces #register-tab.disabled above) */
    html[data-theme="dark"] #authTab .nav-link:not(.active):hover {
        background: rgba(255, 255, 255, .06) !important;
        color: #e2e8f0 !important;
    }