/* ERPPlus final application theme overrides.
   Loaded after component-scoped CSS so every operational page follows MainLayout theme.
   Public, authentication and print layouts are intentionally outside .erp-page-reference. */

body.erpdb-dark .erp-page-reference {
    --erp-theme-bg: #020617;
    --erp-theme-surface: #0f172a;
    --erp-theme-surface-raised: #111c30;
    --erp-theme-surface-soft: #172033;
    --erp-theme-border: #2a394f;
    --erp-theme-border-soft: #223047;
    --erp-theme-text: #f8fafc;
    --erp-theme-text-soft: #dbe7f7;
    --erp-theme-muted: #a8b3c7;
    color: var(--erp-theme-text) !important;
    background:
        radial-gradient(circle at 68% 0%, rgba(var(--erp-primary-rgb, 37, 99, 235), .10), transparent 360px),
        #020617 !important;
}

/* Page roots that currently declare fixed light gradients. */
body.erpdb-dark .erp-page-reference :is(
    .suppliers-page,
    .purchase-list-page,
    .purchase-pro-page,
    .products-page,
    .customers-page,
    .erp-warehouse-page,
    .sale-pro-page,
    .sales-list-page,
    .accounting-page,
    .treasury-page,
    .reports-page,
    .inventory-page,
    .settings-page,
    .branches-page,
    [class$="-page"]
) {
    color: var(--erp-theme-text) !important;
    background:
        radial-gradient(circle at 18% 0%, rgba(var(--erp-accent-rgb, 124, 58, 237), .10), transparent 340px),
        linear-gradient(180deg, #020617 0%, #07101f 48%, #020617 100%) !important;
}

/* Primary structural surfaces. Exclusions preserve semantic badges/actions. */
body.erpdb-dark .erp-page-reference :is(
    [class$="-hero"],
    [class*="-hero "],
    [class$="-card"],
    [class*="-card "],
    [class$="-panel"],
    [class*="-panel "],
    [class$="-toolbar"],
    [class*="-toolbar "],
    [class$="-section"],
    [class*="-section "],
    [class$="-widget"],
    [class*="-widget "],
    [class$="-dialog"],
    [class*="-dialog "],
    [class$="-modal"],
    [class*="-modal "],
    [class$="-drawer"],
    [class*="-drawer "],
    .card,
    .modal-content,
    .dropdown-menu,
    .offcanvas,
    fieldset,
    details
):not([class*="status"]):not([class*="badge"]):not([class*="chip"]):not([class*="alert"]):not([class*="action"]):not([class*="button"]):not([class*="primary"]):not([class*="success"]):not([class*="danger"]):not([class*="warning"]) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .24) !important;
}

/* Common page-specific surfaces whose names do not end in card/panel. */
body.erpdb-dark .erp-page-reference :is(
    .suppliers-hero,
    .supplier-stats .stat-card,
    .supplier-toolbar,
    .supplier-table-card,
    .purchase-list-hero,
    .purchase-card,
    .purchase-state,
    .purchase-stat-card,
    .purchase-pro-hero,
    .products-hero,
    .products-card,
    .products-stat-card,
    .customers-hero,
    .customers-card,
    .customers-summary article,
    .erp-warehouse-header,
    .erp-filter-card,
    .erp-table-card,
    .erp-state-card,
    .sale-pro-hero,
    .sale-card,
    .sale-summary,
    .sale-suspended-panel,
    .sales-list-hero,
    .sales-card,
    .sales-state,
    .sales-stat-card
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: linear-gradient(180deg, rgba(15, 23, 42, .99), rgba(10, 18, 34, .97)) !important;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .24) !important;
}

/* Remove white shine layers that wash out headings in dark mode. */
body.erpdb-dark .erp-page-reference :is(
    .suppliers-hero,
    .purchase-list-hero,
    .purchase-pro-hero,
    .products-hero,
    .customers-hero,
    .erp-warehouse-header,
    .sale-pro-hero,
    .sales-list-hero
)::before,
body.erpdb-dark .erp-page-reference :is(
    .suppliers-hero,
    .purchase-list-hero,
    .purchase-pro-hero,
    .products-hero,
    .customers-hero,
    .erp-warehouse-header,
    .sale-pro-hero,
    .sales-list-hero
)::after {
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .06), transparent) !important;
}

/* Readable primary typography. */
body.erpdb-dark .erp-page-reference :is(
    h1, h2, h3, h4, h5, h6,
    legend,
    label,
    dt,
    strong,
    .mud-typography,
    .mud-input-label,
    .mud-select
):not([class*="success"]):not([class*="danger"]):not([class*="warning"]) {
    color: var(--erp-theme-text) !important;
    text-shadow: none !important;
}

body.erpdb-dark .erp-page-reference :is(
    p,
    small,
    dd,
    .text-muted,
    [class$="-subtitle"],
    [class*="-subtitle "],
    [class$="-description"],
    [class*="-description "],
    [class$="-hint"],
    [class*="-hint "],
    [class$="-meta"],
    [class*="-meta "],
    [class$="-caption"],
    [class*="-caption "]
) {
    color: var(--erp-theme-muted) !important;
    text-shadow: none !important;
}

/* Page-specific fixed muted text. */
body.erpdb-dark .erp-page-reference :is(
    .suppliers-hero p,
    .stat-card span,
    .stat-card small,
    .toolbar-meta span,
    .purchase-list-hero p,
    .purchase-stat-card span,
    .purchase-stat-card small,
    .products-hero p,
    .products-stat-card span,
    .products-stat-card small,
    .customers-hero p,
    .customers-summary span,
    .customers-summary small,
    .erp-warehouse-header p,
    .sale-card-title p,
    .sale-summary-row span,
    .sales-list-hero p,
    .sales-card-head p,
    .sales-number-cell span,
    .sales-last-payment
) {
    color: var(--erp-theme-muted) !important;
}

/* Inputs, filters and pickers. */
body.erpdb-dark .erp-page-reference :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea,
    .form-control,
    .form-select,
    [class$="-input"],
    [class*="-input "],
    [class$="-select"],
    [class*="-select "],
    [class$="-search-box"],
    [class*="-search-box "],
    .search-box,
    .mud-input-root,
    .mud-input-slot,
    .mud-select-input,
    .mud-picker-input-button
) {
    color: var(--erp-theme-text) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference :is(input, textarea)::placeholder {
    color: #8492a8 !important;
    opacity: 1 !important;
}

body.erpdb-dark .erp-page-reference :is(input, select, textarea, .form-control, .form-select):focus {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-accent, #7c3aed) !important;
    background: #142038 !important;
    box-shadow: 0 0 0 3px rgba(var(--erp-accent-rgb, 124, 58, 237), .14) !important;
}

/* Tables and large data lists. */
body.erpdb-dark .erp-page-reference :is(
    .table-wrap,
    [class$="-table-wrap"],
    [class*="-table-wrap "],
    .table-responsive,
    .mud-table-container
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: #0b1425 !important;
}

body.erpdb-dark .erp-page-reference :is(table, .table, .mud-table-root) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
}

body.erpdb-dark .erp-page-reference :is(thead, thead tr, thead th, .mud-table-head, .mud-table-head .mud-table-cell) {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference :is(tbody, tbody tr, tbody td, tfoot, tfoot tr, tfoot td, .mud-table-body, .mud-table-row, .mud-table-cell) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background-color: transparent !important;
}

body.erpdb-dark .erp-page-reference :is(tbody tr, .mud-table-row):hover {
    background-color: #17233a !important;
}

body.erpdb-dark .erp-page-reference :is(tfoot, tfoot tr, tfoot td) {
    background-color: var(--erp-theme-surface-raised) !important;
}

/* Neutral buttons only; branded and semantic actions keep their own colors. */
body.erpdb-dark .erp-page-reference button:not(
    .primary-action,
    .primary,
    .erp-btn-primary,
    .purchase-btn.primary,
    .products-btn.primary,
    .customers-button.primary,
    .sales-btn.primary,
    .sales-btn.pay,
    .sales-btn.print-list,
    [class*="success"],
    [class*="danger"],
    [class*="warning"],
    [class*="active"]
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised, #111c30) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference button:disabled {
    color: #91a0b6 !important;
    opacity: .72 !important;
}

/* Dashboard controls and component-scoped brand text need explicit contrast. */
body.erpdb-dark .erp-page-reference .erpdb-reference {
    --erpdc-card-bg: #0f172a !important;
    --erpdc-card-soft: #111827 !important;
    --erpdc-card-soft-2: #172033 !important;
    --erpdc-text: #f8fafc !important;
    --erpdc-muted: #a8b3c7 !important;
    color: #f8fafc !important;
}

body.erpdb-dark .erp-page-reference :is(
    .erpdc-toolbar-pro,
    .erpdc-reference-widget,
    .erpdc-reference-widget-body,
    .erpdc-kpi-card,
    .erpdc-chart-card,
    .erpdc-reports-enterprise,
    .erpdc-actions-enterprise,
    .erpdc-finance-enterprise,
    .erpdc-ai-enterprise,
    .erpdc-health-pro
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background-color: var(--erp-theme-surface) !important;
}

body.erpdb-dark .erp-page-reference .erpdc-toolbar-pro button {
    color: #f8fafc !important;
}

body.erpdb-dark .erp-page-reference .erpdc-toolbar-pro button:disabled {
    color: #a8b3c7 !important;
}

/* MudBlazor portals render outside the page element. */
body.erpdb-dark :is(
    .mud-popover,
    .mud-paper,
    .mud-card,
    .mud-menu,
    .mud-list,
    .mud-dialog,
    .mud-picker,
    .mud-snackbar
) {
    color: #f8fafc !important;
    border-color: #2a394f !important;
    background-color: #0f172a !important;
}

body.erpdb-dark :is(
    .mud-list-item,
    .mud-menu-item,
    .mud-picker-calendar-header,
    .mud-picker-calendar-content,
    .mud-dialog-title,
    .mud-dialog-content
) {
    color: #f8fafc !important;
}

/* Dark-mode scrollbars improve contrast on dense tables/forms. */
body.erpdb-dark .erp-page-reference * {
    scrollbar-color: #475569 #0b1425;
}

/* Printing must always stay paper-white. */
@media print {
    body.erpdb-dark .erp-page-reference,
    body.erpdb-dark .erp-page-reference * {
        color: #000 !important;
        text-shadow: none !important;
        background: #fff !important;
        box-shadow: none !important;
    }
}


/* =========================================================
   Exact dark-theme coverage for branches and management reports.
   These pages use generic or domain-specific class names that cannot be
   reliably inferred by the generic surface bridge.
   ========================================================= */

/* Shared organization identity shown above report pages. */
body.erpdb-dark .erp-page-reference .erp-organization-report-identity,
body.erpdb-dark .erp-page-reference .organization-identity {
    color: #f8fafc !important;
    border-color: #2a394f !important;
    background: #0f172a !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .24) !important;
}
body.erpdb-dark .erp-page-reference .organization-identity__name {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .organization-identity__contact {
    color: #b7c3d5 !important;
}
body.erpdb-dark .erp-page-reference .organization-identity__logo {
    border-color: #3a4960 !important;
    background: #f8fafc !important;
}

/* Branch management. */
body.erpdb-dark .erp-page-reference .branches-page {
    color: #f8fafc !important;
    background: transparent !important;
}
body.erpdb-dark .erp-page-reference .branches-page .hero {
    color: var(--erp-on-brand, #fff) !important;
    border: 1px solid rgba(var(--erp-primary-rgb, 37, 99, 235), .30) !important;
    background:
        radial-gradient(circle at 12% 16%, rgba(255,255,255,.10), transparent 34%),
        linear-gradient(135deg, var(--erp-primary, #2563eb), var(--erp-accent, #7c3aed)) !important;
    box-shadow: 0 20px 50px rgba(var(--erp-primary-rgb, 37, 99, 235), .20) !important;
}
body.erpdb-dark .erp-page-reference .branches-page .hero :is(h1, p, small) {
    color: #fff !important;
}
body.erpdb-dark .erp-page-reference .branches-page :is(
    .summary > div,
    .toolbar,
    .table-card,
    .report-toolbar,
    .report-card,
    .rank-card,
    .dialog,
    .detail-grid article,
    .defaults-panel
) {
    color: #f8fafc !important;
    border-color: #2a394f !important;
    background: #0f172a !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
}
body.erpdb-dark .erp-page-reference .branches-page .summary :is(span, small),
body.erpdb-dark .erp-page-reference .branches-page :is(.branch-cell small, td small, .resource-list i, .report-title p, .rank-card small, .empty, .detail-grid article span, .detail-grid article small, .defaults-panel span) {
    color: #a8b3c7 !important;
}
body.erpdb-dark .erp-page-reference .branches-page .summary b,
body.erpdb-dark .erp-page-reference .branches-page .rank-card strong {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .branches-page :is(
    .date-filter input,
    .toolbar input,
    .toolbar select,
    .report-title select,
    .form-grid input,
    .form-grid textarea,
    .form-grid select
) {
    color: #f8fafc !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
}
body.erpdb-dark .erp-page-reference .branches-page .view-tabs {
    background: #111c30 !important;
}
body.erpdb-dark .erp-page-reference .branches-page .view-tabs button {
    color: #cbd5e1 !important;
    background: transparent !important;
}
body.erpdb-dark .erp-page-reference .branches-page .view-tabs button.active {
    color: var(--erp-on-brand, #fff) !important;
    border-color: var(--erp-primary, #2563eb) !important;
    background: linear-gradient(
        135deg,
        var(--erp-primary, #2563eb),
        var(--erp-accent, #7c3aed)
    ) !important;
    box-shadow: 0 6px 16px rgba(var(--erp-primary-rgb, 37, 99, 235), .20) !important;
}
body.erpdb-dark .erp-page-reference .branches-page :is(th, .report-title, .detail-head, .defaults-panel h3) {
    color: #dbe7f7 !important;
    border-color: #2a394f !important;
    background: #172033 !important;
}
body.erpdb-dark .erp-page-reference .branches-page td {
    color: #f8fafc !important;
    border-color: #223047 !important;
}
body.erpdb-dark .erp-page-reference .branches-page tr:hover {
    background: rgba(var(--erp-primary-rgb, 37, 99, 235), .10) !important;
}
body.erpdb-dark .erp-page-reference .branches-page .dialog header,
body.erpdb-dark .erp-page-reference .branches-page .dialog footer,
body.erpdb-dark .erp-page-reference .branches-page .form-section-title,
body.erpdb-dark .erp-page-reference .branches-page .defaults-panel div {
    border-color: #2a394f !important;
}

/* Management report hub. */
body.erpdb-dark .erp-page-reference .reports-page {
    --reports-text: #f8fafc !important;
    --reports-muted: #a8b3c7 !important;
    --reports-border: #2a394f !important;
    --reports-surface: #0f172a !important;
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .reports-page :is(
    .reports-hero,
    .summary-card,
    .reports-section,
    a.report-card,
    a.quick-link
) {
    color: #f8fafc !important;
    border-color: #2a394f !important;
    background: #0f172a !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
}
body.erpdb-dark .erp-page-reference .reports-page .reports-hero {
    background:
        radial-gradient(circle at 92% 82%, rgba(var(--erp-accent-rgb, 124,58,237), .14) 0 108px, transparent 109px),
        linear-gradient(135deg, #0f172a, #111c30) !important;
}
body.erpdb-dark .erp-page-reference .reports-page :is(
    .reports-hero h1,
    .summary-card strong,
    .section-heading h2,
    a.report-card .report-card__body strong,
    a.quick-link span
) {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .reports-page :is(
    .reports-hero p,
    .summary-card span:not(.summary-card__icon),
    .section-heading p,
    a.report-card .report-card__body small
) {
    color: #a8b3c7 !important;
}
body.erpdb-dark .erp-page-reference .reports-page a.report-card .report-card__arrow {
    color: #cbd5e1 !important;
    border-color: #3a4960 !important;
    background: #172033 !important;
}

/* Treasury management report. */
body.erpdb-dark .erp-page-reference .treasury-report-page {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .treasury-report-page :is(
    .treasury-report-hero,
    .treasury-report-toolbar,
    .treasury-report-filter-card,
    .treasury-report-period,
    .treasury-report-kpis article,
    .treasury-report-insights article,
    .treasury-report-card,
    .treasury-report-state
) {
    color: #f8fafc !important;
    border-color: #2a394f !important;
    background: #0f172a !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
}
body.erpdb-dark .erp-page-reference .treasury-report-page .treasury-report-hero {
    background:
        radial-gradient(circle at 5% 55%, rgba(100, 116, 139, .12), transparent 235px),
        linear-gradient(135deg, #0f172a, #111c30) !important;
}
body.erpdb-dark .erp-page-reference .treasury-report-page :is(h1, h2, h3, strong) {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .treasury-report-page :is(p, small, .treasury-report-toolbar__copy span, .treasury-report-field > span) {
    color: #a8b3c7 !important;
}
body.erpdb-dark .erp-page-reference .treasury-report-page :is(.treasury-report-field input, .treasury-report-field select) {
    color: #f8fafc !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
}

/* Profit and loss management report. */
body.erpdb-dark .erp-page-reference .profit-management-page {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page :is(
    .profit-hero,
    .profit-toolbar,
    .profit-filter-card,
    .profit-period-card,
    .profit-kpi,
    .profit-statement-card,
    .profit-analysis-card,
    .profit-state
) {
    color: #f8fafc !important;
    border-color: #2a394f !important;
    background: #0f172a !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page .profit-hero {
    background:
        radial-gradient(circle at 5% 55%, rgba(16, 185, 129, .12), transparent 230px),
        linear-gradient(135deg, #0f172a, #10211f) !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page :is(
    .profit-hero h1,
    .profit-toolbar-copy strong,
    .profit-period-card strong,
    .profit-kpi strong,
    .profit-card-header h2,
    .profit-line strong,
    .profit-metric strong
) {
    color: #f8fafc !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page :is(
    .profit-hero p,
    .profit-toolbar-copy span,
    .profit-field span,
    .profit-period-card span,
    .profit-kpi span,
    .profit-kpi small,
    .profit-card-header span,
    .profit-line span,
    .profit-metric span
) {
    color: #a8b3c7 !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page :is(
    .profit-field input,
    .profit-card-header,
    .profit-line.subtotal
) {
    color: #f8fafc !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page :is(
    .profit-card-header,
    .profit-line
) {
    border-color: #223047 !important;
}
body.erpdb-dark .erp-page-reference .profit-management-page .profit-line.final :is(span, strong) {
    color: #fff !important;
}

/* Keep semantic accents readable after the global typography rules. */
body.erpdb-dark .erp-page-reference :is(
    .reports-eyebrow,
    .profit-eyebrow,
    .treasury-report-eyebrow
) {
    color: #6ee7b7 !important;
}


/* =========================================================
   Accounting hub and electronic commercial books.
   Scoped component styles use fixed light surfaces and action-card names,
   so they need exact dark-theme mappings. Screen-only keeps legal print white.
   ========================================================= */
@media screen {
    body.erpdb-dark .erp-page-reference .accounting-dashboard {
        color: #f8fafc !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard :is(
        .accounting-header,
        .accounting-stat-card,
        .accounting-panel,
        .accounting-action-card,
        .accounting-status-item
    ) {
        color: #f8fafc !important;
        border-color: #2a394f !important;
        background: #0f172a !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard .accounting-header {
        background:
            radial-gradient(circle at 12% 20%, rgba(var(--erp-accent-rgb, 124, 58, 237), .12), transparent 30%),
            linear-gradient(135deg, #0f172a, #111c30) !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard :is(
        .accounting-header h1,
        .accounting-stat-card strong,
        .accounting-panel-header h2,
        .accounting-action-card strong,
        .accounting-status-item strong
    ) {
        color: #f8fafc !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard :is(
        .accounting-header p,
        .accounting-stat-card span,
        .accounting-stat-card small,
        .accounting-panel-header span,
        .accounting-action-card small,
        .accounting-status-item small
    ) {
        color: #a8b3c7 !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard .accounting-action-symbol {
        color: #93c5fd !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard .accounting-btn.secondary {
        color: #dbe7f7 !important;
        border-color: #3a4960 !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard .accounting-note {
        color: #dbe7f7 !important;
        border-color: #475569 !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .accounting-dashboard .accounting-note p {
        color: #b7c3d5 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page {
        color: #f8fafc !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page :is(
        .ecb-toolbar,
        .ecb-state,
        .ecb-identity,
        .ecb-print-header,
        .ecb-seal-row > div,
        .ecb-kpis article,
        .ecb-card,
        .ecb-signatures > div
    ) {
        color: #f8fafc !important;
        border-color: #2a394f !important;
        background: #0f172a !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-identity {
        background: #0b1425 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page :is(
        .ecb-org-title h2,
        .ecb-identity-meta,
        .ecb-seal-row strong,
        .ecb-kpis article strong,
        .ecb-card-title h3,
        .ecb-signatures span
    ) {
        color: #f8fafc !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page :is(
        .ecb-org-title p,
        .ecb-seal-row span,
        .ecb-seal-row small,
        .ecb-kpis article span,
        .ecb-kpis article small,
        .ecb-signatures small,
        .ecb-print-footer
    ) {
        color: #a8b3c7 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-hash code {
        color: #dbe7f7 !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-final-seal.final,
    body.erpdb-dark .erp-page-reference .ecb-page .ecb-kpis article.ready {
        color: #d1fae5 !important;
        border-color: #166534 !important;
        background: #052e24 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-final-seal.draft {
        color: #fde68a !important;
        border-color: #854d0e !important;
        background: #422006 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-kpis article.blocked {
        color: #fecaca !important;
        border-color: #991b1b !important;
        background: #450a0a !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-tabs {
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-tabs button:not(.active) {
        color: #cbd5e1 !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page :is(.ecb-card-title, .ecb-print-footer) {
        border-color: #2a394f !important;
    }

    body.erpdb-dark .erp-page-reference .ecb-page .ecb-note {
        color: #b7c3d5 !important;
        background: #172033 !important;
    }
}


/* =========================================================
   Application button contract.
   Normalizes action hierarchy across operational pages while preserving
   icon controls, tabs, navigation, semantic status buttons and print.
   ========================================================= */
.erp-page-reference {
    --erp-action-height: 44px;
    --erp-action-radius: 13px;
    --erp-action-gap: 8px;
    --erp-action-padding: 0 16px;
    --erp-action-font-size: 12px;
    --erp-action-primary: var(--erp-primary, #2563eb);
    --erp-action-accent: var(--erp-accent, #7c3aed);
}

@media screen {
    .erp-page-reference :is(
        button[class*="btn"],
        button[class*="button"],
        button[class*="action"],
        a[class*="btn"],
        a[class*="button"],
        a[class*="action"]
    ):not([class*="icon"]):not([class*="tab"]):not([class*="toggle"]):not([class*="close"]):not([class*="back"]):not([class*="nav"]):not([class*="card"]):not([class*="symbol"]) {
        min-height: var(--erp-action-height) !important;
        padding: var(--erp-action-padding) !important;
        border-radius: var(--erp-action-radius) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: var(--erp-action-gap) !important;
        font-family: inherit !important;
        font-size: var(--erp-action-font-size) !important;
        line-height: 1.2 !important;
        font-weight: 900 !important;
        text-decoration: none !important;
        white-space: nowrap !important;
        cursor: pointer;
        transition: transform .16s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease !important;
    }

    .erp-page-reference :is(
        button[class*="btn"],
        button[class*="button"],
        button[class*="action"],
        a[class*="btn"],
        a[class*="button"],
        a[class*="action"]
    ):not(:disabled):not([aria-disabled="true"]):not([class*="icon"]):not([class*="tab"]):not([class*="toggle"]):not([class*="close"]):not([class*="back"]):not([class*="nav"]):not([class*="card"]):hover {
        transform: translateY(-1px) !important;
    }

    .erp-page-reference :is(
        .primary-action,
        .primary-action-button,
        .apply-button,
        .profit-apply-button,
        .erp-btn-primary,
        .erp-btn-refresh,
        .profit-btn.primary,
        .accounting-btn.primary,
        button.primary,
        a.primary
    ):not([class*="danger"]):not([class*="delete"]) {
        color: #fff !important;
        border: 1px solid var(--erp-action-primary) !important;
        background: linear-gradient(135deg, var(--erp-action-primary), var(--erp-action-accent)) !important;
        box-shadow: 0 9px 20px rgba(var(--erp-primary-rgb, 37, 99, 235), .24) !important;
    }

    .erp-page-reference :is(
        .secondary-action,
        .clear-button,
        .erp-btn-excel,
        .erp-btn-print,
        .profit-btn.secondary,
        .accounting-btn.secondary,
        button.secondary,
        a.secondary
    ) {
        color: #334155 !important;
        border: 1px solid #cbd5e1 !important;
        background: #fff !important;
        box-shadow: 0 5px 14px rgba(15, 23, 42, .06) !important;
    }

    .erp-page-reference :is(
        button[class*="danger"],
        button[class*="delete"],
        a[class*="danger"],
        a[class*="delete"]
    ) {
        color: #fff !important;
        border-color: #dc2626 !important;
        background: #dc2626 !important;
        box-shadow: 0 8px 18px rgba(220, 38, 38, .20) !important;
    }

    .erp-page-reference :is(
        button[class*="success"],
        a[class*="success"]
    ) {
        color: #fff !important;
        border-color: #059669 !important;
        background: #059669 !important;
        box-shadow: 0 8px 18px rgba(5, 150, 105, .20) !important;
    }

    .erp-page-reference :is(button, a)[class*="btn"]:disabled,
    .erp-page-reference :is(button, a)[class*="button"]:disabled,
    .erp-page-reference :is(button, a)[class*="action"]:disabled,
    .erp-page-reference :is(button, a)[aria-disabled="true"] {
        transform: none !important;
        box-shadow: none !important;
        cursor: not-allowed !important;
        opacity: .55 !important;
    }

    /* Exact report families shown in management reports. */
    .erp-page-reference :is(
        .profit-toolbar-actions,
        .hero-actions,
        .report-actions
    ) {
        display: flex !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .erp-page-reference .purchase-report-page .apply-button,
    .erp-page-reference .profit-management-page .profit-apply-button {
        min-width: 128px !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .secondary-action,
        .clear-button,
        .erp-btn-excel,
        .erp-btn-print,
        .profit-btn.secondary,
        .accounting-btn.secondary,
        button.secondary,
        a.secondary
    ) {
        color: #dbe7f7 !important;
        border-color: #3a4960 !important;
        background: #172033 !important;
        box-shadow: 0 6px 16px rgba(0, 0, 0, .18) !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .secondary-action,
        .clear-button,
        .erp-btn-excel,
        .erp-btn-print,
        .profit-btn.secondary,
        .accounting-btn.secondary,
        button.secondary,
        a.secondary
    ):disabled {
        color: #91a0b6 !important;
        background: #111827 !important;
    }
}

@media (max-width: 620px) {
    .erp-page-reference :is(.profit-toolbar-actions, .hero-actions, .report-actions) {
        width: 100% !important;
    }

    .erp-page-reference :is(.profit-toolbar-actions, .hero-actions, .report-actions) > button {
        flex: 1 1 120px !important;
    }
}


/* =========================================================
   Complete dark-theme coverage for the report family.
   Loaded after scoped CSS because several report components use fixed light
   colors and bare article elements that generic card selectors cannot reach.
   ========================================================= */
@media screen {
    body.erpdb-dark .erp-page-reference :is(
        .customer-report-page,
        .purchase-report-page,
        .sales-report-page,
        .treasury-report-page,
        .profit-management-page,
        .executive-report-page,
        .trade-performance-page,
        .operational-report-page
    ) {
        color: #f8fafc !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-hero,
        .customer-report-toolbar,
        .customer-report-filter-card,
        .customer-report-period,
        .customer-report-kpis article,
        .customer-report-insights article,
        .customer-report-card,
        .customer-report-state
    ),
    body.erpdb-dark .erp-page-reference :is(
        .purchase-report-page,
        .sales-report-page,
        .executive-report-page,
        .trade-performance-page
    ) :is(
        [class$="-hero"],
        [class$="-toolbar"],
        [class$="-filter-card"],
        [class$="-filter-panel"],
        [class$="-period"],
        [class$="-period-card"],
        [class$="-panel"],
        [class$="-card"],
        [class$="-state"],
        [class$="-insights"] article,
        [class$="-kpis"] article,
        [class$="-kpi-grid"] article
    ) {
        color: #f8fafc !important;
        border-color: #2a394f !important;
        background: #0f172a !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page .customer-report-hero {
        background:
            radial-gradient(circle at 5% 55%, rgba(219, 39, 119, .16), transparent 235px),
            linear-gradient(135deg, #111827, #0f172a) !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-hero h1,
        .customer-report-toolbar__copy strong,
        .customer-report-period strong,
        .customer-report-kpis strong,
        .customer-report-insights strong,
        .customer-report-card__heading h2,
        .customer-report-state strong
    ) {
        color: #f8fafc !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-hero p,
        .customer-report-back,
        .customer-report-toolbar__copy span,
        .customer-report-field > span,
        .customer-report-period > div > span,
        .customer-report-kpis article > div > span,
        .customer-report-kpis small,
        .customer-report-insights small,
        .customer-report-card__heading > div > span,
        .customer-report-card__heading p,
        .customer-report-empty
    ) {
        color: #a8b3c7 !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-field input,
        .customer-report-field select
    ) {
        color: #f8fafc !important;
        border-color: #3a4960 !important;
        background: #111c30 !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-btn.secondary,
        .customer-report-btn.export,
        .customer-report-clear
    ) {
        color: #dbe7f7 !important;
        border-color: #3a4960 !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-card__heading,
        .customer-report-table th,
        .customer-report-table td,
        .customer-report-table tfoot td
    ) {
        border-color: #273449 !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page .customer-report-table th,
    body.erpdb-dark .erp-page-reference .customer-report-page .customer-report-table tfoot td {
        color: #dbe7f7 !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page .customer-report-table td {
        color: #f8fafc !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page .customer-report-table tbody tr:hover {
        background: #17233a !important;
    }

    body.erpdb-dark .erp-page-reference .customer-report-page :is(
        .customer-report-count,
        .customer-report-status
    ) {
        border: 1px solid #3a4960 !important;
    }

    body.erpdb-dark .erp-page-reference .operational-fallback > section,
    body.erpdb-dark .erp-page-reference .operational-fallback-links a {
        color: #f8fafc !important;
        border-color: #2a394f !important;
        background: #0f172a !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .20) !important;
    }

    body.erpdb-dark .erp-page-reference .operational-fallback :is(span, p, small) {
        color: #a8b3c7 !important;
    }

    body.erpdb-dark .erp-page-reference .operational-fallback :is(h1, strong) {
        color: #f8fafc !important;
    }

    /* Shared report tables, filter controls and empty/loading states. */
    body.erpdb-dark .erp-page-reference [class*="report"] :is(
        input:not([type="checkbox"]):not([type="radio"]),
        select,
        textarea
    ) {
        color: #f8fafc !important;
        border-color: #3a4960 !important;
        background-color: #111c30 !important;
    }

    body.erpdb-dark .erp-page-reference [class*="report"] :is(
        [class$="-table-wrap"],
        [class$="-table-card"],
        [class$="-table-panel"],
        [class$="-empty"],
        [class$="-loading"]
    ) {
        color: #f8fafc !important;
        border-color: #2a394f !important;
        background-color: #0f172a !important;
    }
}

/* =========================================================
   Exact dark coverage: treasury, product trade, trial balance and balance sheet.
   Component-scoped CSS in these report families declares fixed light colors.
   Keep this screen-only so printable financial statements remain paper-white.
   ========================================================= */
@media screen {
    body.erpdb-dark .erp-page-reference :is(.trial-page, .balance-sheet-page, .trade-report-page) {
        color: #f8fafc !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .trial-page :is(
        .trial-hero, .trial-filter-card, .trial-status-card, .trial-summary-card,
        .trial-table-card, .trial-state, .trial-period
    ),
    body.erpdb-dark .erp-page-reference .balance-sheet-page :is(
        .balance-sheet-hero, .balance-sheet-filter-card, .balance-sheet-status-card,
        .balance-sheet-summary-card, .balance-sheet-main-card, .balance-sheet-analysis-card,
        .balance-sheet-state, .balance-sheet-date
    ),
    body.erpdb-dark .erp-page-reference .trade-report-page :is(
        .trade-hero, .filters, .state, .kpis article, .report-card, .movement-card,
        .filter-heading, .filter-grid
    ) {
        color: #f8fafc !important;
        border-color: #2a394f !important;
        background: #0f172a !important;
        box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
    }

    body.erpdb-dark .erp-page-reference :is(.trial-hero, .balance-sheet-hero, .trade-hero) {
        background:
            radial-gradient(circle at 12% 20%, rgba(var(--erp-primary-rgb, 37, 99, 235), .14), transparent 32%),
            linear-gradient(135deg, #0f172a, #111c30) !important;
    }

    body.erpdb-dark .erp-page-reference .trial-page :is(
        h1, h2, h3, strong, b, .account-code, .account-name, .money,
        .trial-table td, .trial-count
    ),
    body.erpdb-dark .erp-page-reference .balance-sheet-page :is(
        h1, h2, h3, strong, b, .balance-sheet-line div strong,
        .balance-sheet-line b
    ),
    body.erpdb-dark .erp-page-reference .trade-report-page :is(
        h1, h2, h3, strong, b, td, .report-card header > strong
    ) {
        color: #f8fafc !important;
    }

    body.erpdb-dark .erp-page-reference .trial-page :is(
        p, small, .trial-field span, .trial-status-card span,
        .trial-summary-card span, .trial-summary-card small,
        .trial-table-header span, .trial-state p
    ),
    body.erpdb-dark .erp-page-reference .balance-sheet-page :is(
        p, small, .balance-sheet-field span, .balance-sheet-status-card span,
        .balance-sheet-summary-card span, .balance-sheet-summary-card small,
        .balance-sheet-card-header span, .balance-sheet-line div span,
        .balance-sheet-metric span, .balance-sheet-state p
    ),
    body.erpdb-dark .erp-page-reference .trade-report-page :is(
        p, small, .filters span, .filter-grid label > span,
        .kpis span, .report-card header span
    ) {
        color: #a8b3c7 !important;
    }

    body.erpdb-dark .erp-page-reference .trial-page :is(
        .trial-field input, .trial-field select, .search-field
    ),
    body.erpdb-dark .erp-page-reference .balance-sheet-page .balance-sheet-field input,
    body.erpdb-dark .erp-page-reference .trade-report-page :is(
        .filters input, .filters select, .filter-grid input, .filter-grid select,
        .filter-control, .filter-search-control, .search-box
    ) {
        color: #f8fafc !important;
        border-color: #3a4960 !important;
        background: #111c30 !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .trial-table-header, .balance-sheet-card-header,
        .trial-table th, .trade-report-page th,
        .balance-sheet-column-title, .balance-sheet-subtitle
    ) {
        color: #dbe7f7 !important;
        border-color: #2a394f !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .trial-page :is(
        .trial-table td, .trial-table tfoot td, .trial-table tbody tr
    ),
    body.erpdb-dark .erp-page-reference .trade-report-page :is(
        td, tr, .table-wrap, .report-card > header
    ),
    body.erpdb-dark .erp-page-reference .balance-sheet-page :is(
        .balance-sheet-column, .balance-sheet-line, .balance-sheet-subtitle
    ) {
        border-color: #223047 !important;
        background-color: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .trial-table tbody tr:hover,
    body.erpdb-dark .erp-page-reference .trade-report-page .clickable:hover,
    body.erpdb-dark .erp-page-reference .trade-report-page .clickable.selected {
        background: #17233a !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .trial-empty, .balance-sheet-empty, .trade-report-page .state
    ) {
        color: #a8b3c7 !important;
        border-color: #3a4960 !important;
        background: #111c30 !important;
    }

    body.erpdb-dark .erp-page-reference .balance-sheet-page :is(
        .balance-sheet-progress, .asset-title, .liability-title,
        .asset-total, .liability-total
    ) {
        border-color: #3a4960 !important;
        background-color: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .treasury-report-page :is(
        .treasury-report-card__header, .treasury-resource-item,
        .treasury-cheque-summary > div, .treasury-report-table-wrap,
        .treasury-report-table th, .treasury-report-table td,
        .treasury-report-table tfoot td, .treasury-report-empty
    ) {
        border-color: #223047 !important;
        background-color: #0f172a !important;
    }

    body.erpdb-dark .erp-page-reference .treasury-report-page :is(
        .treasury-report-card__header, .treasury-report-table th
    ) {
        color: #dbe7f7 !important;
        background: #172033 !important;
    }

    body.erpdb-dark .erp-page-reference .treasury-report-page :is(
        .treasury-resource-item strong, .treasury-resource-item b,
        .treasury-cheque-summary strong, .treasury-cheque-summary b,
        .treasury-report-table td, .treasury-report-count
    ) {
        color: #f8fafc !important;
    }

    body.erpdb-dark .erp-page-reference .treasury-report-page :is(
        .treasury-resource-item small, .treasury-cheque-summary span,
        .treasury-report-card__header p, .treasury-report-empty
    ) {
        color: #a8b3c7 !important;
    }

    body.erpdb-dark .erp-page-reference .treasury-report-table tbody tr:nth-child(even) td {
        background: #111c30 !important;
    }

    body.erpdb-dark .erp-page-reference .treasury-report-table tbody tr:hover td {
        background: #17233a !important;
    }

    /* Restore semantic status colors after the typography bridge. */
    body.erpdb-dark .erp-page-reference :is(
        .trial-validation, .balance-sheet-validation,
        .trial-state.error, .balance-sheet-state.error,
        .trade-report-page .state.error, .treasury-report-state.error
    ) {
        color: #fecaca !important;
        border-color: #7f1d1d !important;
        background: #2b1118 !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .trial-btn.secondary, .balance-sheet-btn.secondary,
        .treasury-report-btn.secondary, .treasury-report-clear,
        .movement-card header button, .clear-filters
    ) {
        color: #f8fafc !important;
        border-color: #3a4960 !important;
        background: #172033 !important;
    }
}


/* Safe route-scoped dark coverage: color only, never layout. */
@media screen {
body.erpdb-dark .erp-page-reference .sale-pro-page{--sale-text:#f8fafc;--sale-muted:#a8b3c7;--sale-border:#334155;color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .sale-pro-page :is(.sale-pro-hero,.sale-card,.sale-summary,.sale-suspended-panel,.sale-suspended-item,.sale-invoice-type-panel,.sale-invoice-type-option,.sale-picker-panel,.sale-selected-info,.sale-scan-box,.sale-product-search-wrap,.sale-product-panel,.sale-add-item-panel,.sale-product-preview,.sale-product-preview>div,.sale-empty-modern,.sale-empty-visual,.sale-items-table-wrap,.sale-items-footer>div,.sale-payment-modal-shell){color:#f8fafc!important;border-color:#2a394f!important;background-color:#0f172a!important}
body.erpdb-dark .erp-page-reference .sale-pro-page .sale-pro-hero{background:linear-gradient(135deg,#0f172a,#111c30)!important}
body.erpdb-dark .erp-page-reference .sale-pro-page :is(h1,h2,h3,strong,label,.sale-picker-item strong,.sale-product-cell-main strong){color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .sale-pro-page :is(p,small,.sale-shortcuts span,.sale-picker-item span,.sale-picker-empty,.sale-selected-info span,.sale-product-preview span,.sale-product-cell-main small,.sale-items-footer span,.sale-summary-row span,.sale-suspended-main span){color:#a8b3c7!important}
body.erpdb-dark .erp-page-reference .sale-pro-page :is(input,select,textarea,.form-control,.form-select,.sale-readonly-box){color:#f8fafc!important;border-color:#3a4960!important;background-color:#111c30!important}
body.erpdb-dark .erp-page-reference .sale-pro-page .sale-items-table thead th{color:#dbe7f7!important;border-color:#2a394f!important;background-color:#172033!important}
body.erpdb-dark .erp-page-reference .sale-pro-page .sale-items-table tbody td{color:#f8fafc!important;border-color:#223047!important;background-color:transparent!important}
body.erpdb-dark .erp-page-reference .sale-pro-page :is(.erp-btn-print,.erp-btn-suspend){color:#f8fafc!important;border-color:#3a4960!important;background:#172033!important}

body.erpdb-dark .erp-page-reference .woo-page{color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .woo-page :is(.woo-hero,.woo-kpis article,.woo-tabs,.woo-state,.woo-panel,.check-card,.connection-footer,.mapping-builder,.woo-hint,.table-wrap){color:#f8fafc!important;border-color:#2a394f!important;background-color:#0f172a!important}
body.erpdb-dark .erp-page-reference .woo-page .woo-hero{background:linear-gradient(135deg,#0f172a,#111c30)!important}
body.erpdb-dark .erp-page-reference .woo-page :is(h1,h2,h3,strong,b,label,td){color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .woo-page :is(p,small,.woo-hint){color:#a8b3c7!important}
body.erpdb-dark .erp-page-reference .woo-page :is(input,select,textarea){color:#f8fafc!important;border-color:#3a4960!important;background-color:#111c30!important}
body.erpdb-dark .erp-page-reference .woo-page th{color:#dbe7f7!important;border-color:#2a394f!important;background-color:#172033!important}
body.erpdb-dark .erp-page-reference .woo-page td{border-color:#223047!important;background-color:transparent!important}
body.erpdb-dark .erp-page-reference .woo-page :is(button.secondary,button.neutral,.actions button){color:#f8fafc!important;border-color:#3a4960!important;background-color:#172033!important}

body.erpdb-dark .erp-page-reference .erp-ai-dashboard-v2{color:#f8fafc!important;background-color:transparent!important}
body.erpdb-dark .erp-page-reference .erp-ai-dashboard-v2 :is(.erp-ai-dashboard-v2__management-alerts,.erp-ai-dashboard-v2__copilot,.erp-ai-dashboard-v2__forecast,.erp-ai-dashboard-v2__assistant,.erp-ai-dashboard-v2__status,.erp-ai-alert-empty,.erp-ai-alert-card){color:#f8fafc!important;border-color:#2a394f!important;background-color:#0f172a!important}
body.erpdb-dark .erp-page-reference .erp-ai-dashboard-v2 :is(h1,h2,h3,strong){color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .erp-ai-dashboard-v2 :is(p,small,time){color:#a8b3c7!important}

body.erpdb-dark .erp-page-reference .inventory-report-page{color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .inventory-report-page :is(.inventory-report-hero,.inventory-report-toolbar,.inventory-report-filter-card,.inventory-report-period,.inventory-report-kpis article,.inventory-report-insights article,.inventory-report-card,.inventory-report-state){color:#f8fafc!important;border-color:#2a394f!important;background-color:#0f172a!important}
body.erpdb-dark .erp-page-reference .inventory-report-page .inventory-report-hero{background:linear-gradient(135deg,#0f172a,#111c30)!important}
body.erpdb-dark .erp-page-reference .inventory-report-page :is(h1,h2,h3,strong,.inventory-report-table td){color:#f8fafc!important}
body.erpdb-dark .erp-page-reference .inventory-report-page :is(p,small,.inventory-report-field>span,.inventory-report-toolbar__copy span){color:#a8b3c7!important}
body.erpdb-dark .erp-page-reference .inventory-report-page :is(input,select,.inventory-report-btn.secondary,.inventory-report-clear){color:#f8fafc!important;border-color:#3a4960!important;background-color:#111c30!important}
body.erpdb-dark .erp-page-reference .inventory-report-page :is(.inventory-report-card__header,.inventory-report-table th,.inventory-report-table tfoot td){color:#dbe7f7!important;border-color:#2a394f!important;background-color:#172033!important}
body.erpdb-dark .erp-page-reference .inventory-report-page .inventory-report-table td{border-color:#223047!important;background-color:transparent!important}

body.erpdb-dark .erp-page-reference .reports-page :is(.reports-hero,.summary-card,.reports-section,.report-card,.quick-link),
body.erpdb-dark .erp-page-reference .customer-report-page :is(.customer-report-hero,.customer-report-toolbar,.customer-report-filter-card,.customer-report-period,.customer-report-kpis article,.customer-report-insights article,.customer-report-card){border-color:#2a394f!important;background-color:#0f172a!important}
}

/* Final SaleNew dark palette: exact scoped selectors, color-only. */
@media screen {
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-invoice-type-option:not(.active),
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-shortcuts span,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-tools,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-scan-box,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-search-wrap,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-add-item-panel,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-preview,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-preview > div,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-empty-modern,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-empty-visual,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-items-table-wrap,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-items-footer > div:not(.final),
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-summary-input,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-table-input,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-qty-input {
        color: #f8fafc !important;
        border-color: #334155 !important;
        background: #111c30 !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page :is(
        .sale-section-icon,
        .sale-summary-icon,
        .sale-product-mini-icon,
        .sale-scan-icon,
        .sale-row-index span,
        .sale-badge,
        .sale-total-chip
    ) {
        color: #dbeafe !important;
        border-color: #334b70 !important;
        background: #172a4a !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page :is(
        .sale-product-result-code,
        .sale-stock-pill,
        .sale-status
    ) {
        border-color: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-panel {
        color: #f8fafc !important;
        border-color: #334155 !important;
        background: #0f172a !important;
        box-shadow: 0 18px 48px rgba(0, 0, 0, .38) !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-picker-item,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-result {
        color: #f8fafc !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-picker-item:hover,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-picker-item.active,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-result:hover,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-product-result.selected {
        background: #17233a !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page :is(
        .form-control,
        .form-select,
        .sale-readonly-box,
        .sale-summary-input,
        .sale-table-input,
        .sale-qty-input,
        .sale-barcode-input
    ) {
        color: #f8fafc !important;
        border-color: #3a4960 !important;
        background: #111c30 !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page :is(
        .form-control,
        .form-select,
        .sale-barcode-input
    ):focus {
        color: #fff !important;
        border-color: var(--erp-accent, #7c3aed) !important;
        background: #142038 !important;
        box-shadow: 0 0 0 3px rgba(var(--erp-accent-rgb, 124, 58, 237), .14) !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page input::placeholder {
        color: #94a3b8 !important;
        opacity: 1 !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-items-footer .final,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-summary-final,
    body.erpdb-dark .erp-page-reference .sale-pro-page .sale-invoice-type-option.active {
        color: #fff !important;
        border-color: transparent !important;
        background: linear-gradient(135deg, var(--sale-blue, #2563eb), var(--sale-purple, #7c3aed)) !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page :is(
        .sale-items-footer .final,
        .sale-summary-final,
        .sale-invoice-type-option.active
    ) :is(span, strong, small) {
        color: #fff !important;
    }

    body.erpdb-dark .erp-page-reference .sale-pro-page .erp-btn:disabled {
        color: #94a3b8 !important;
        border-color: #334155 !important;
        background: #172033 !important;
        opacity: .65 !important;
    }
}

/* Customer create form dark-theme contract.
   Scoped to /customers/new so light theme and other customer screens stay unchanged. */
body.erpdb-dark .erp-page-reference .customer-new-page {
    --c-text: var(--erp-theme-text, #f8fafc);
    --c-muted: var(--erp-theme-muted, #a8b3c7);
    --c-border: var(--erp-theme-border, #2a394f);
}

body.erpdb-dark .erp-page-reference .customer-new-page :is(
    .customer-card,
    .customer-summary-card,
    .customer-help-card
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-card-header {
    color: var(--erp-theme-text) !important;
    border-bottom-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-raised) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-card-header h2 {
    color: var(--erp-theme-text) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page :is(
    .customer-card-header p,
    .customer-field small,
    .customer-summary-top span,
    .customer-summary-list span,
    .customer-help-card p
) {
    color: var(--erp-theme-muted) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page :is(
    .customer-summary-top,
    .customer-summary-list > div
) {
    border-color: var(--erp-theme-border-soft) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-switch {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-switch-text {
    color: var(--erp-theme-text-soft) !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-summary-note {
    color: #bfdbfe !important;
    border-color: #294e7a !important;
    background: #102443 !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-help-icon {
    color: #ddd6fe !important;
    background: #2e1f55 !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page :is(
    .customer-btn-light,
    .customer-btn-outline
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: #172033 !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page :is(
    .customer-btn-light,
    .customer-btn-outline
):hover:not(:disabled) {
    color: #fff !important;
    border-color: #4b5f7d !important;
    background: #1d2b43 !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-status-active {
    color: #86efac !important;
    background: #123524 !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-status-inactive {
    color: #fca5a5 !important;
    background: #451a1a !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-alert-error {
    color: #fecdd3 !important;
    border-color: #7f1d1d !important;
    background: #3f121d !important;
}

body.erpdb-dark .erp-page-reference .customer-new-page .customer-alert-error :is(strong, p) {
    color: #fecdd3 !important;
}

/* Global customer overlays live outside MainLayout/.erp-page-reference.
   Give create/edit, SMS and delete dialogs an explicit per-user dark contract. */
body.erpdb-dark .erp-global-overlay-root .customers-global-backdrop {
    --text: #f8fafc;
    --muted: #a8b3c7;
    --border: #2a394f;
    --blue: #93c5fd;
    --purple: #c4b5fd;
    color: var(--text) !important;
    background: rgba(2, 6, 23, .82) !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-global-modal {
    color: var(--text) !important;
    border-color: #334155 !important;
    background: #0f172a !important;
    box-shadow: 0 38px 120px rgba(0, 0, 0, .62) !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-global-modal-body {
    color: var(--text) !important;
    background: #0f172a !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-global-modal-header,
    .customers-global-modal-footer
) {
    color: var(--text) !important;
    border-color: #2a394f !important;
    background: rgba(15, 23, 42, .98) !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-global-modal-header h3 {
    color: #f8fafc !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-global-modal-header span {
    color: #93c5fd !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-global-modal-header > button {
    color: #fda4af !important;
    border: 1px solid #7f1d1d !important;
    background: #3f121d !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-form-grid label > span,
    .person-role-box > span,
    .customers-sms-compose-grid label > span,
    .customers-sms-editor > span,
    .customers-sms-editor small,
    .customers-sms-field small
) {
    color: var(--muted) !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .person-role-box label,
    .customers-active-check > span,
    .customers-delete-message
) {
    color: #dbe7f7 !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-form-grid input:not([type="checkbox"]),
    .customers-form-grid select,
    .customers-form-grid textarea,
    .customers-sms-compose-grid select,
    .customers-sms-editor textarea,
    .customers-sms-field textarea
) {
    color: #f8fafc !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
    box-shadow: none !important;
    color-scheme: dark;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-form-grid input:not([type="checkbox"]),
    .customers-form-grid select,
    .customers-form-grid textarea,
    .customers-sms-compose-grid select,
    .customers-sms-editor textarea,
    .customers-sms-field textarea
):focus {
    color: #fff !important;
    border-color: var(--erp-accent, #7c3aed) !important;
    background: #142038 !important;
    box-shadow: 0 0 0 3px rgba(var(--erp-accent-rgb, 124, 58, 237), .14) !important;
    outline: none !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-form-grid input,
    .customers-form-grid textarea,
    .customers-sms-editor textarea,
    .customers-sms-field textarea
)::placeholder {
    color: #8492a8 !important;
    opacity: 1 !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-form-grid input,
    .customers-form-grid select,
    .customers-form-grid textarea
):disabled {
    color: #91a0b6 !important;
    border-color: #334155 !important;
    background: #172033 !important;
    opacity: .72 !important;
}

body.erpdb-dark .erp-global-overlay-root .person-role-box {
    color: #dbe7f7 !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-modal-cancel,
    .customers-sms-templates button
) {
    color: #dbe7f7 !important;
    border-color: #3a4960 !important;
    background: #172033 !important;
}

body.erpdb-dark .erp-global-overlay-root :is(
    .customers-sms-audience-summary,
    .customers-sms-recipients
) {
    color: #86efac !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-alert.error {
    color: #fecdd3 !important;
    border-color: #7f1d1d !important;
    background: #3f121d !important;
}

body.erpdb-dark .erp-global-overlay-root .customers-alert.success {
    color: #bbf7d0 !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

/* Settings and SMS residual dark-theme surfaces. */
body.erpdb-dark .erp-page-reference .settings-modern-v3 :is(
    .currency-preview,
    .template-actions,
    .logo-preview
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .04) !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 :is(
    .btn.secondary,
    .mini-btn
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 :is(
    .btn.secondary,
    .mini-btn
):hover:not(:disabled) {
    color: #fff !important;
    border-color: #5a6f91 !important;
    background: #1d2b43 !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .mini-btn.danger {
    color: #fda4af !important;
    border-color: #7f1d1d !important;
    background: #3f121d !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .mini-btn.success {
    color: #86efac !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .template-actions button:not(.selected):not(.danger):not(.personalize-channels-btn) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .template-actions button.selected,
body.erpdb-dark .erp-page-reference .settings-modern-v3 .template-actions .personalize-channels-btn {
    color: #fff !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .template-actions button.danger {
    color: #fda4af !important;
    border-color: #7f1d1d !important;
    background: #3f121d !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .template-chips button {
    color: #c4b5fd !important;
    border-color: #4c3f85 !important;
    background: #211a43 !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .template-chips button:hover {
    color: #fff !important;
    border-color: #7c6bf2 !important;
    background: #34266e !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .section-badge {
    color: #c4b5fd !important;
    background: #251b4d !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .directory-stats span {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 :is(
    .directory-stats span.ok,
    .status-pill.active,
    .default-bank-pill
) {
    color: #86efac !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 :is(
    .directory-stats span.blocked,
    .status-pill.inactive
) {
    color: #fda4af !important;
    border-color: #7f1d1d !important;
    background: #3f121d !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 :is(
    .user-card-actions,
    .bank-account-actions
) {
    border-color: var(--erp-theme-border) !important;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .logo-panel input[type="file"] {
    color: var(--erp-theme-muted) !important;
    border: 1px solid #3a4960 !important;
    border-radius: 12px;
    background: var(--erp-theme-surface-raised) !important;
    padding: 7px;
    color-scheme: dark;
}

body.erpdb-dark .erp-page-reference .settings-modern-v3 .logo-panel input[type="file"]::file-selector-button {
    margin-inline-end: 10px;
    padding: 8px 12px;
    color: var(--erp-theme-text-soft);
    border: 1px solid #465875;
    border-radius: 9px;
    background: var(--erp-theme-surface-soft);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

body.erpdb-dark .erp-page-reference .sms-page {
    color-scheme: dark;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .sms-loading,
    .sms-status
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .22) !important;
}

body.erpdb-dark .erp-page-reference .sms-page .sms-status.enabled {
    border-color: #236047 !important;
    background: linear-gradient(135deg, #103528, #10243a) !important;
}

body.erpdb-dark .erp-page-reference .sms-page button.secondary {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .sms-card-head,
    .template-title
) {
    border-color: var(--erp-theme-border) !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: linear-gradient(180deg, #111c30, #0f172a) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .18) !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider:hover:not(:disabled) {
    border-color: #6658a8 !important;
    background: #172033 !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider.selected {
    color: #f5f3ff !important;
    border-color: #8b5cf6 !important;
    background: linear-gradient(145deg, #251b4d, #172554) !important;
    box-shadow: 0 12px 30px rgba(79, 70, 229, .20) !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider:not(.selected) .provider-mark {
    color: #c4b5fd !important;
    background: #1e293b !important;
    box-shadow: inset 0 0 0 1px #3a4960 !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider:not(.selected) > i {
    color: #64748b !important;
    border-color: #3a4960 !important;
    background: #0b1425 !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .provider-selected-strip,
    .approval-guide,
    .template-item,
    .template-summary-line,
    .template-details-toggle
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider-selected-strip strong {
    color: #c4b5fd !important;
}

body.erpdb-dark .erp-page-reference .sms-page .compact-template.expanded {
    border-color: #6d5aa8 !important;
    background: linear-gradient(180deg, #181c35, #111a2a) !important;
}

body.erpdb-dark .erp-page-reference .sms-page .template-details-toggle:hover {
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .security-note,
    .api-help
) {
    color: #a7f3d0 !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .security-note b,
    .api-help strong
) {
    color: #86efac !important;
}

body.erpdb-dark .erp-page-reference .sms-page .api-help code {
    color: #bfdbfe !important;
    background: #172554 !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider-hint-box {
    color: #bfdbfe !important;
    border-color: #294d7a !important;
    background: #102442 !important;
}

body.erpdb-dark .erp-page-reference .sms-page .provider-hint-box strong {
    color: #93c5fd !important;
}

body.erpdb-dark .erp-page-reference .sms-page .variables span {
    color: #86efac !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .template-warning,
    .template-missing-code,
    .approval-legend .pending,
    .approval-pill.pending
) {
    color: #fcd34d !important;
    border-color: #854d0e !important;
    background: #3a2a0d !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .approval-legend .approved,
    .approval-pill.approved
) {
    color: #86efac !important;
    border-color: #236047 !important;
    background: #103528 !important;
}

body.erpdb-dark .erp-page-reference .sms-page :is(
    .approval-legend .not-required,
    .approval-pill.normal
) {
    color: #cbd5e1 !important;
    border-color: #475569 !important;
    background: #1e293b !important;
}

body.erpdb-dark .erp-page-reference .sms-page .approval-pill.rejected {
    color: #fda4af !important;
    border-color: #7f1d1d !important;
    background: #3f121d !important;
}

/* Tax submissions paging and residual dark-theme surfaces. */
body.erpdb-dark .erp-page-reference .tax-page .tax-stats article {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: 0 16px 38px rgba(0, 0, 0, .22) !important;
}

body.erpdb-dark .erp-page-reference .tax-page .tax-stats span,
body.erpdb-dark .erp-page-reference .tax-page .tax-settings-grid label > span,
body.erpdb-dark .erp-page-reference .tax-page :is(
    .tax-state,
    .tax-empty,
    .tax-inline-loading,
    .tax-pagination span
) {
    color: var(--erp-theme-muted) !important;
}

body.erpdb-dark .erp-page-reference .tax-page .tax-stats strong,
body.erpdb-dark .erp-page-reference .tax-page details summary {
    color: #5eead4 !important;
}

body.erpdb-dark .erp-page-reference .tax-page :is(
    .tax-settings-grid input,
    .tax-settings-grid select,
    .tax-settings-grid textarea,
    .mapping-search,
    .mapping-input
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    color-scheme: dark;
}

body.erpdb-dark .erp-page-reference .tax-page th {
    color: var(--erp-theme-muted) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .tax-page td {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
}

body.erpdb-dark .erp-page-reference .tax-page tbody tr:hover {
    background: rgba(45, 212, 191, .07) !important;
}

body.erpdb-dark .erp-page-reference .tax-page .tax-button.outline {
    color: #5eead4 !important;
    border-color: #287c76 !important;
    background: #102a2c !important;
}

body.erpdb-dark .erp-page-reference .tax-page .tax-pagination {
    border-color: var(--erp-theme-border-soft) !important;
    background: #0d1728 !important;
}

body.erpdb-dark .erp-page-reference .tax-page .tax-pagination button {
    color: #99f6e4 !important;
    border-color: #285b59 !important;
    background: #123133 !important;
}

body.erpdb-dark .erp-page-reference .tax-page .tax-pagination button:hover:not(:disabled) {
    color: #fff !important;
    border-color: #2dd4bf !important;
    background: #14534f !important;
}


/* Purchase and supplier dark-theme completion. */
body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-empty-modern {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background:
        radial-gradient(circle at 50% 0%, rgba(var(--erp-accent-rgb, 124, 58, 237), .14), transparent 260px),
        var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-empty-modern :is(strong, span) {
    color: var(--erp-theme-text-soft) !important;
}

body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-empty-visual {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .purchase-list-page :is(
    .purchase-filter-input,
    .purchase-payment-grid input,
    .purchase-payment-grid select,
    .purchase-payment-grid textarea
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    color-scheme: dark;
}

body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-payment-dialog {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
}

body.erpdb-dark .erp-page-reference .purchase-list-page :is(
    .purchase-payment-head,
    .purchase-payment-actions
) {
    border-color: var(--erp-theme-border-soft) !important;
}

body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-payment-head button,
body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-payment-summary span {
    color: var(--erp-theme-muted) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
}

body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-payment-summary b,
body.erpdb-dark .erp-page-reference .purchase-list-page .purchase-payment-grid label {
    color: var(--erp-theme-text-soft) !important;
}

body.erpdb-dark .erp-page-reference .purchase-pro-page :is(
    .purchase-card,
    .purchase-cost-panel,
    .purchase-add-item-panel-final,
    .purchase-empty-modern,
    .purchase-summary-card,
    .purchase-shortcuts
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .purchase-pro-page :is(
    h3, h4, strong, .purchase-readonly-box, .purchase-total-chip
) {
    color: var(--erp-theme-text) !important;
}

body.erpdb-dark .erp-page-reference .purchase-pro-page :is(
    p, label, small, .purchase-product-search-state, .purchase-empty-modern span
) {
    color: var(--erp-theme-muted) !important;
}

body.erpdb-dark .erp-page-reference .purchase-pro-page :is(
    input,
    select,
    textarea,
    .purchase-readonly-box
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
    color-scheme: dark;
}

body.erpdb-dark .erp-page-reference .suppliers-page .supplier-overlay {
    background: rgba(2, 6, 23, .82) !important;
}

body.erpdb-dark .erp-page-reference .suppliers-page .supplier-dialog {
    color: var(--erp-theme-text) !important;
    border-color: #334155 !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: 0 32px 100px rgba(0, 0, 0, .62) !important;
}

body.erpdb-dark .erp-page-reference .suppliers-page :is(
    .dialog-header,
    .dialog-body,
    .dialog-footer
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
}

body.erpdb-dark .erp-page-reference .suppliers-page :is(
    .dialog-header h2,
    .switch-copy strong,
    .delete-content p
) {
    color: var(--erp-theme-text) !important;
}

body.erpdb-dark .erp-page-reference .suppliers-page :is(
    .dialog-header p,
    .form-field > span,
    .switch-copy small,
    .delete-content small
) {
    color: var(--erp-theme-muted) !important;
}

body.erpdb-dark .erp-page-reference .suppliers-page :is(
    .form-field input,
    .form-field textarea,
    .secondary-button
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: #111c30 !important;
    color-scheme: dark;
}


/* Operational pages: complete dark-theme surfaces and controls. */
body.erpdb-dark .erp-page-reference :is(
    .products-page,
    .product-create-page,
    .erp-warehouse-page,
    .inventory-return-report,
    .assets-page,
    .installments-page,
    .accounts-page,
    .accounting-page,
    .pnl-page
) {
    color-scheme: dark;
}

/* Product directory and create form */
body.erpdb-dark .erp-page-reference .products-page :is(
    .products-stat-card,
    .products-card,
    .products-tools-card,
    .products-filter-card,
    .products-table-card,
    .products-state,
    .products-modal-card
),
body.erpdb-dark .erp-page-reference .product-create-page :is(
    .product-state-card,
    .product-section,
    .lookup-card,
    .metric-field,
    .toggle-card,
    .variant-section,
    .warranty-section,
    .warranty-card,
    .product-action-bar,
    .quick-unit-dialog
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .products-page :is(
    .products-tool-btn,
    .products-btn:not(.primary),
    .products-action,
    .products-pagination-actions button,
    .products-modal-actions button:not(.primary)
),
body.erpdb-dark .erp-page-reference .product-create-page :is(
    .hero-back-button,
    .inline-action,
    .lookup-add-button,
    .secondary-button,
    .variant-remove-button,
    .warranty-add-button,
    .warranty-remove-button,
    .quick-unit-close,
    .quick-unit-footer button:not(.primary-button)
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .products-page :is(
    .products-input,
    .products-select,
    .products-search-box,
    .products-price-input
),
body.erpdb-dark .erp-page-reference .product-create-page :is(
    .control,
    .select-control,
    .metric-input,
    .variant-money-input,
    .warranty-date-input,
    .description-control,
    .lookup-search input,
    .quick-unit-body input,
    .quick-unit-body select,
    .quick-unit-body textarea
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .products-page :is(
    .products-section-head,
    .products-table th
),
body.erpdb-dark .erp-page-reference .product-create-page :is(
    .section-header,
    .lookup-head,
    .warranty-card-header,
    .warranty-card-footer,
    .quick-unit-header,
    .quick-unit-footer
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-raised) !important;
}

/* Warehouses and returns */
body.erpdb-dark .erp-page-reference .erp-warehouse-page :is(
    .warehouse-summary-grid article,
    .erp-filter-card,
    .erp-state-card,
    .erp-table-card,
    .erp-modal-card,
    .warehouse-detail-summary > div
),
body.erpdb-dark .erp-page-reference .inventory-return-report :is(
    .report-header,
    .summary-grid > *,
    .filters,
    .table-shell,
    .report-message:not(.error)
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .erp-warehouse-page :is(
    .erp-input,
    .erp-select,
    .erp-secondary-btn
),
body.erpdb-dark .erp-page-reference .inventory-return-report :is(
    .filters input,
    .filters select,
    .report-btn.secondary
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .erp-warehouse-page :is(
    .erp-table th,
    .erp-modal-card header,
    .erp-modal-card footer
),
body.erpdb-dark .erp-page-reference .inventory-return-report :is(
    th,
    .filters
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .erp-warehouse-page .erp-table td,
body.erpdb-dark .erp-page-reference .inventory-return-report td {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
}

/* Assets and installments */
body.erpdb-dark .erp-page-reference .assets-page :is(
    .stats > div,
    .toolbar,
    .table-card,
    .asset-overlay-panel,
    .asset-dialog-body
),
body.erpdb-dark .erp-page-reference .installments-page :is(
    .stats article,
    .card,
    .installment-dialog,
    .contract-summary
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .assets-page :is(
    .toolbar input,
    .toolbar select,
    .form input,
    .form select,
    .form textarea,
    .dialog-close,
    .asset-dialog-footer .secondary
),
body.erpdb-dark .erp-page-reference .installments-page :is(
    .card header input,
    .form-grid input,
    .form-grid select,
    .form-grid textarea,
    .close-inline,
    .cancel,
    .installment-dialog header button
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .assets-page :is(
    th,
    .asset-dialog-header,
    .asset-dialog-footer
),
body.erpdb-dark .erp-page-reference .installments-page :is(
    th,
    .card > header,
    .installment-dialog > header,
    .installment-dialog > footer
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .assets-page :is(
    .stats span,
    .form label,
    .asset-dialog-header span
),
body.erpdb-dark .erp-page-reference .installments-page :is(
    .stats span,
    .card p,
    .form-grid label span,
    .installment-dialog p,
    .contract-summary span
) {
    color: var(--erp-theme-muted) !important;
}

/* Accounts and accounting documents */
body.erpdb-dark .erp-page-reference .accounts-page :is(
    .accounts-hero,
    .accounts-stat-card,
    .accounts-card,
    .accounts-toolbar,
    .accounts-table-wrap,
    .erp-modal
),
body.erpdb-dark .erp-page-reference .accounting-page :is(
    .acc-summary > *,
    .acc-card,
    .acc-toolbar,
    .table-wrap,
    .acc-state
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .accounts-page :is(
    .accounts-btn:not(.primary):not(.danger),
    .accounts-search,
    .accounts-filter,
    .page-size select,
    .icon-btn,
    .page-buttons button,
    .modal-close,
    .form-field input,
    .form-field select,
    .form-field textarea,
    .switch-item
),
body.erpdb-dark .erp-page-reference .accounting-page :is(
    .acc-btn:not(.primary),
    .acc-search,
    .acc-filter,
    .page-size select,
    .action-btn,
    .page-buttons button
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .accounts-page :is(
    .accounts-table th,
    .erp-modal-header,
    .erp-modal-footer
),
body.erpdb-dark .erp-page-reference .accounting-page :is(
    .acc-table th,
    .acc-card-header
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-soft) !important;
}

body.erpdb-dark .erp-page-reference .accounts-page .accounts-table td,
body.erpdb-dark .erp-page-reference .accounting-page .acc-table td {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
}

/* Profit and loss statement */
body.erpdb-dark .erp-page-reference .pnl-page :is(
    .pnl-filter-card,
    .pnl-period-card,
    .pnl-summary-card,
    .pnl-statement-card,
    .pnl-analysis-card,
    .pnl-state
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .pnl-page :is(
    .pnl-field input,
    .pnl-field select,
    .pnl-btn.secondary
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference .pnl-page :is(
    .pnl-card-header,
    .pnl-line:not(.net),
    .pnl-metric
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: var(--erp-theme-border-soft) !important;
    background: var(--erp-theme-surface-raised) !important;
}

/* Purchase shortcuts, disabled actions, and supplier dialog chrome */
body.erpdb-dark .erp-page-reference .purchase-pro-page :is(
    .purchase-shortcuts button,
    .purchase-inline-add,
    .purchase-inline-tool,
    .purchase-lookup-add,
    .erp-btn-print,
    .erp-btn-refresh
),
body.erpdb-dark .erp-page-reference .purchase-list-page :is(
    .purchase-btn:not(.primary):not(.danger),
    .purchase-pagination button
),
body.erpdb-dark .erp-page-reference .suppliers-page :is(
    .dialog-close,
    .secondary-button,
    .action-button
) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
    box-shadow: none !important;
}

body.erpdb-dark .erp-page-reference :is(
    .purchase-pro-page,
    .purchase-list-page,
    .products-page,
    .product-create-page,
    .erp-warehouse-page,
    .inventory-return-report,
    .assets-page,
    .installments-page,
    .accounts-page,
    .accounting-page,
    .pnl-page,
    .suppliers-page
) button:disabled {
    color: #77869c !important;
    border-color: #334155 !important;
    background: #172033 !important;
    opacity: .72 !important;
    box-shadow: none !important;
}


/* ERPPlus legacy operational surfaces: exact dark-theme and typography coverage. */
.erp-page-reference,
.erp-page-reference :is(button, input, select, textarea, option, table, label) {
    font-family: "ERPFont", "Segoe UI", Tahoma, Arial, sans-serif !important;
}

.erp-page-reference :is(button, input, select, textarea) {
    line-height: 1.55;
}

.erp-page-reference :is(h1, h2, h3, h4, h5, h6) {
    font-family: "ERPFont", "Segoe UI", Tahoma, Arial, sans-serif !important;
    line-height: 1.45;
    letter-spacing: 0;
}

/* Supplier dialogs live in an overlay and use fixed light colors. */
body.erpdb-dark .erp-page-reference .suppliers-page :is(
    .supplier-dialog,
    .dialog-header,
    .dialog-body,
    .dialog-footer,
    .switch-field
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
}
body.erpdb-dark .erp-page-reference .suppliers-page :is(.dialog-header p, .field span, .switch-copy small) {
    color: var(--erp-theme-muted) !important;
}
body.erpdb-dark .erp-page-reference .suppliers-page :is(.dialog-close, .secondary-button) {
    color: var(--erp-theme-text-soft) !important;
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-raised) !important;
}

/* Product tool tiles and modal. */
body.erpdb-dark .erp-page-reference .products-page :is(
    .products-tool-btn,
    .products-modal-card
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface-raised) !important;
}
body.erpdb-dark .erp-page-reference .products-page .products-tool-btn :is(strong, small) {
    color: inherit !important;
}
body.erpdb-dark .erp-page-reference .products-page .products-tool-btn > span {
    border-color: #3a4960 !important;
    background: var(--erp-theme-surface-soft) !important;
}

/* Person ledger uses BEM names which the generic suffix bridge cannot detect. */
body.erpdb-dark .erp-page-reference .person-ledger :is(
    .person-ledger__hero,
    .person-ledger__filters,
    .person-ledger__state,
    .person-ledger__summary article,
    .person-ledger__card,
    .person-ledger__identity span
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22) !important;
}
body.erpdb-dark .erp-page-reference .person-ledger :is(
    .person-ledger__hero p,
    .person-ledger__field span,
    .person-ledger__state,
    .person-ledger__summary span
) {
    color: var(--erp-theme-muted) !important;
}

/* Fiscal, payroll and commission summary surfaces. */
body.erpdb-dark .erp-page-reference :is(
    .fiscal-page .fiscal-modal,
    .payroll-page .payroll-summary article,
    .payroll-page .payroll-card,
    .payroll-page .payroll-loading,
    .payroll-page .payroll-dialog,
    .payroll-page .dialog-head,
    .payroll-page .dialog-actions,
    .commission-page .kpis .kpi,
    .commission-page .status-overview-item,
    .commission-page .dialog-card
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .20) !important;
}
body.erpdb-dark .erp-page-reference :is(
    .payroll-page .payroll-summary article span,
    .payroll-page .payroll-summary article small,
    .commission-page .kpi span,
    .commission-page .kpi small,
    .commission-page .status-overview-item span
) {
    color: var(--erp-theme-muted) !important;
}

/* Treasury list pages and their shared modal system. */
body.erpdb-dark .erp-page-reference :is(
    .treasury-list-page .summary-grid > *,
    .treasury-list-page .filter-panel,
    .treasury-list-page .data-panel,
    .received-page .received-summary > *,
    .received-page .received-filters,
    .received-page .received-panel,
    .issued-page .issued-summary > *,
    .issued-page .issued-panel,
    .transfer-page .transfer-summary > *,
    .transfer-page .transfer-filter,
    .transfer-page .transfer-table-card,
    .cb-page .cb-kpis > *,
    .cb-page .cb-editor,
    .cb-page .cb-list-panel,
    .treasury-dialog-card
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .20) !important;
}
body.erpdb-dark .erp-page-reference :is(
    .treasury-list-page .summary-grid span,
    .treasury-list-page .summary-grid small,
    .received-page .received-summary span,
    .received-page .received-summary small,
    .issued-page .issued-summary span,
    .issued-page .issued-summary small,
    .transfer-page .transfer-summary span,
    .transfer-page .transfer-summary small,
    .cb-page .cb-kpis span,
    .cb-page .cb-kpis small
) {
    color: var(--erp-theme-muted) !important;
}
body.erpdb-dark .erp-page-reference :is(
    .treasury-dialog-header,
    .treasury-dialog-body,
    .treasury-dialog-footer,
    .treasury-switch-field
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
}

/* Keep AI dashboard inside the active application theme. */
body.erpdb-dark .erp-page-reference .erp-ai-dashboard-v2 {
    color: var(--erp-theme-text) !important;
    background: var(--erp-theme-bg) !important;
}
body.erpdb-dark .erp-page-reference .erp-ai-dashboard-v2 :is(
    .erp-ai-dashboard-v2__management-alerts,
    .erp-ai-dashboard-v2__copilot,
    .erp-ai-dashboard-v2__forecast,
    .erp-ai-dashboard-v2__assistant,
    .erp-ai-dashboard-v2__status
) {
    color: var(--erp-theme-text) !important;
    border-color: var(--erp-theme-border) !important;
    background: var(--erp-theme-surface) !important;
}

/* Disabled controls stay visibly disabled without becoming unreadable. */
body.erpdb-dark .erp-page-reference :is(button, input, select, textarea):disabled {
    color: #94a3b8 !important;
    -webkit-text-fill-color: #94a3b8;
    border-color: #334155 !important;
    background-color: #172033 !important;
    opacity: .72 !important;
}


/* =========================================================
   Dark-theme control contract.
   Keeps interactive controls and clickable option tiles on the active
   application palette instead of leaking fixed white component colors.
   Screen-only: printable documents remain paper-white.
   ========================================================= */
@media screen {
    /* Secondary/neutral actions, including links rendered as buttons. */
    body.erpdb-dark .erp-page-reference :is(
        .btn-outline-secondary,
        .btn-outline-primary,
        .barcode-pro-btn:not(.primary),
        .product-label-btn:not(.primary):not(.danger),
        .print-queue-btn:not(.primary):not(.danger),
        .products-btn:not(.primary):not(.danger),
        .journal-btn.secondary,
        .ledger-btn.secondary,
        .pnl-btn.secondary,
        .balance-sheet-btn.secondary,
        .cb-btn:not(.primary):not(.danger),
        .commission-page .secondary,
        .zoom-controls button,
        .product-label-zoom button,
        .barcode-pro-zoom button,
        .barcode-pro-toolbar button
    ) {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-raised, #111c30) !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .btn-outline-secondary,
        .btn-outline-primary,
        .barcode-pro-btn:not(.primary),
        .product-label-btn:not(.primary):not(.danger),
        .print-queue-btn:not(.primary):not(.danger),
        .products-btn:not(.primary):not(.danger),
        .journal-btn.secondary,
        .ledger-btn.secondary,
        .pnl-btn.secondary,
        .balance-sheet-btn.secondary,
        .cb-btn:not(.primary):not(.danger),
        .commission-page .secondary,
        .zoom-controls button,
        .product-label-zoom button,
        .barcode-pro-zoom button,
        .barcode-pro-toolbar button
    ):hover {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-primary, #2563eb) !important;
        background: var(--erp-theme-surface-soft, #172033) !important;
    }

    /* Primary actions always use the currently selected brand theme. */
    body.erpdb-dark .erp-page-reference :is(
        .btn-primary,
        .btn-outline-primary,
        .primary-action,
        .erp-btn-primary,
        .barcode-pro-btn.primary,
        .product-label-btn.primary,
        .print-queue-btn.primary,
        .products-btn.primary,
        .journal-btn.primary,
        .journal-filter-submit,
        .ledger-btn.primary,
        .ledger-filter-submit,
        .pnl-btn.primary,
        .pnl-filter-submit,
        .balance-sheet-btn.primary,
        .balance-sheet-filter-submit,
        .cb-btn.primary,
        .commission-page .btn-primary
    ) {
        color: var(--erp-on-brand, #fff) !important;
        border-color: var(--erp-primary, #2563eb) !important;
        background: linear-gradient(
            135deg,
            var(--erp-primary, #2563eb),
            var(--erp-accent, #7c3aed)
        ) !important;
        box-shadow: 0 10px 24px rgba(var(--erp-primary-rgb, 37, 99, 235), .22) !important;
    }

    /* Product label and barcode designer option controls. */
    body.erpdb-dark .erp-page-reference .barcode-pro-page :is(
        .barcode-pro-check,
        .barcode-pro-slider-card,
        .barcode-pro-mode,
        .barcode-pro-zoom span
    ),
    body.erpdb-dark .erp-page-reference .product-label-page :is(
        .product-label-option-row label,
        .product-label-item,
        .product-label-preview-toolbar,
        .product-label-preview-toolbar span,
        .product-label-zoom span
    ),
    body.erpdb-dark .erp-page-reference .label-canvas-shell :is(
        .label-canvas-toolbar,
        .view-controls,
        .view-controls label,
        .zoom-value
    ) {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-raised, #111c30) !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .barcode-pro-check,
        .product-label-option-row label,
        .view-controls label
    ):has(input:checked) {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-primary, #2563eb) !important;
        background: rgba(var(--erp-primary-rgb, 37, 99, 235), .14) !important;
    }

    /* Clickable statistics and toggles are controls, not white cards. */
    body.erpdb-dark .erp-page-reference .print-queue-page :is(
        .auto-refresh-toggle,
        .print-queue-summary-card
    ),
    body.erpdb-dark .erp-page-reference .products-page :is(
        button.products-stat-card,
        .products-tool-btn
    ),
    body.erpdb-dark .erp-page-reference .journal-page button.journal-summary-card {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface, #0f172a) !important;
        box-shadow: 0 12px 30px rgba(0, 0, 0, .18) !important;
    }

    /* Residual fixed-light surfaces visible around the reported controls. */
    body.erpdb-dark .erp-page-reference :is(
        .product-form-page .product-form-header,
        .product-form-page .product-form-card,
        .journal-page .journal-status-card,
        .ledger-page .ledger-state,
        .ledger-page .ledger-empty,
        .pnl-page .pnl-insight,
        .balance-sheet-page .balance-sheet-insight,
        .balance-sheet-page .balance-sheet-empty,
        .commission-page label:has(input[type="checkbox"]),
        .commission-page label:has(input[type="radio"])
    ) {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-raised, #111c30) !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .product-form-page .product-form-header,
        .product-form-page .product-form-card,
        .journal-page .journal-status-card,
        .ledger-page .ledger-state,
        .ledger-page .ledger-empty,
        .pnl-page .pnl-insight,
        .balance-sheet-page .balance-sheet-insight,
        .balance-sheet-page .balance-sheet-empty
    ) :is(h1, h2, h3, h4, h5, strong, b) {
        color: var(--erp-theme-text, #f8fafc) !important;
    }

    body.erpdb-dark .erp-page-reference :is(
        .product-form-page .product-form-header,
        .product-form-page .product-form-card,
        .journal-page .journal-status-card,
        .ledger-page .ledger-state,
        .ledger-page .ledger-empty,
        .pnl-page .pnl-insight,
        .balance-sheet-page .balance-sheet-insight,
        .balance-sheet-page .balance-sheet-empty
    ) :is(p, small, span) {
        color: var(--erp-theme-muted, #a8b3c7) !important;
    }

    /* Disabled actions must not fall back to a white Bootstrap surface. */
    body.erpdb-dark .erp-page-reference :is(button, a[class*="btn"]):disabled,
    body.erpdb-dark .erp-page-reference button[disabled] {
        color: #91a0b6 !important;
        border-color: var(--erp-theme-border-soft, #223047) !important;
        background: var(--erp-theme-surface-soft, #172033) !important;
        box-shadow: none !important;
    }
}


/* Exact dark-theme coverage for the sales commission workspace. */
@media screen {
    body.erpdb-dark .erp-page-reference .commission-page {
        color: var(--erp-theme-text, #f8fafc) !important;
        background:
            radial-gradient(circle at 18% 0%, rgba(var(--erp-accent-rgb, 124, 58, 237), .10), transparent 340px),
            linear-gradient(180deg, #020617 0%, #07101f 48%, #020617 100%) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .panel,
        .loading-card,
        .kpi,
        .salesperson-card,
        .plan-card,
        .analytics-card,
        .status-overview-item,
        .empty-state,
        .mini-empty,
        .detail-dialog,
        .detail-grid > div,
        .dialog-card,
        .commission-dialog,
        .rules-table-wrap
    ) {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface, #0f172a) !important;
        box-shadow: 0 14px 36px rgba(0, 0, 0, .20) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .advanced-filter-bar,
        .bulk-toolbar,
        .pagination,
        .commission-dialog__head,
        .commission-dialog__footer,
        .table-wrap tfoot td,
        .rules-table th
    ) {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-soft, #172033) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .advanced-filter-bar input,
        .advanced-filter-bar select,
        .date-filter,
        .date-filter input,
        .salesperson-card select,
        .field,
        .table-field
    ) {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: #3a4960 !important;
        background: var(--erp-theme-surface-raised, #111c30) !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .empty-state strong,
        .mini-empty strong,
        .plan-card strong,
        .person-info strong,
        .status-overview-item strong,
        .bar-item strong,
        .pagination b,
        .detail-grid strong,
        .section-title strong,
        .commission-amount
    ) {
        color: var(--erp-theme-text, #f8fafc) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .empty-state,
        .empty-state span,
        .mini-empty,
        .plan-card p,
        .plan-meta span,
        .person-info small,
        .status-overview-item small,
        .bar-item span,
        .bulk-note,
        .bulk-toolbar > div span,
        .pagination,
        .detail-grid span,
        .section-title small,
        .footer-note
    ) {
        color: var(--erp-theme-muted, #a8b3c7) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .secondary,
        .edit-button,
        .edit-button.subtle,
        .recalculate-action,
        .add-rule,
        .icon-button
    ) {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-raised, #111c30) !important;
        box-shadow: none !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .secondary,
        .edit-button,
        .recalculate-action,
        .add-rule,
        .icon-button
    ):hover {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-primary, #2563eb) !important;
        background: rgba(var(--erp-primary-rgb, 37, 99, 235), .14) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .primary {
        color: var(--erp-on-brand, #fff) !important;
        border-color: var(--erp-primary, #2563eb) !important;
        background: linear-gradient(
            135deg,
            var(--erp-primary, #2563eb),
            var(--erp-accent, #7c3aed)
        ) !important;
        box-shadow: 0 10px 24px rgba(var(--erp-primary-rgb, 37, 99, 235), .22) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .primary:hover {
        filter: brightness(1.08);
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .payroll-note,
        .calculation-details
    ) {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: rgba(var(--erp-primary-rgb, 37, 99, 235), .38) !important;
        background: rgba(var(--erp-primary-rgb, 37, 99, 235), .12) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .payroll-note strong,
        .payroll-note span,
        .calculation-details p
    ) {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .bar-track,
        .plan-meta span,
        .bulk-toolbar > div strong
    ) {
        border-color: var(--erp-theme-border-soft, #223047) !important;
        background: var(--erp-theme-surface-soft, #172033) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .table-wrap table {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface, #0f172a) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .table-wrap th {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-soft, #172033) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .table-wrap td {
        color: var(--erp-theme-text, #f8fafc) !important;
        border-color: var(--erp-theme-border-soft, #223047) !important;
        background: transparent !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .table-wrap tbody tr:hover {
        background: rgba(var(--erp-primary-rgb, 37, 99, 235), .08) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .commission-dialog__body,
        .empty-rules
    ) {
        color: var(--erp-theme-muted, #a8b3c7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-bg, #020617) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .switch-card {
        color: var(--erp-theme-text-soft, #dbe7f7) !important;
        border-color: var(--erp-theme-border, #2a394f) !important;
        background: var(--erp-theme-surface-raised, #111c30) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page .switch-card:has(input:checked) {
        border-color: var(--erp-primary, #2563eb) !important;
        background: rgba(var(--erp-primary-rgb, 37, 99, 235), .14) !important;
    }

    body.erpdb-dark .erp-page-reference .commission-page :is(
        .primary,
        .secondary,
        .edit-button,
        .approve-action,
        .recalculate-action,
        .add-rule
    ):disabled {
        color: #91a0b6 !important;
        border-color: var(--erp-theme-border-soft, #223047) !important;
        background: var(--erp-theme-surface-soft, #172033) !important;
        box-shadow: none !important;
        filter: none !important;
    }
}
