/* ==========================================================================
   BAF ERP Admin Portal — Dark Theme & Toggle Button
   Default remains light; enabled when <html data-theme="dark">.
   ========================================================================== */

.baf-auth-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .28);
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease;
}
.baf-auth-theme-btn:hover {
    background: rgba(255, 255, 255, .26);
    color: #fff;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --baf-dk-bg: #11131b;
    --baf-dk-surface: #181b26;
    --baf-dk-surface-2: #202434;
    --baf-dk-border: #2c3145;
    --baf-dk-text: #e6e7f0;
    --baf-dk-muted: #9da3ba;
    --baf-dk-accent: #9d7fe0;
}

html[data-theme="dark"] body,
html[data-theme="dark"] body.mod-bg-1,
html[data-theme="dark"] .page-wrapper,
html[data-theme="dark"] .page-inner,
html[data-theme="dark"] .page-content-wrapper,
html[data-theme="dark"] .page-content,
html[data-theme="dark"] #bafPageLoader {
    background-color: var(--baf-dk-bg) !important;
    color: var(--baf-dk-text) !important;
}

/* Header, footer & sidebar */
html[data-theme="dark"] .page-header,
html[data-theme="dark"] .page-footer {
    background-color: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35) !important;
}

html[data-theme="dark"] .page-header .header-icon:not(.btn) > [class*="fa-"],
html[data-theme="dark"] .page-header .header-icon:not(.btn) > .ni,
html[data-theme="dark"] .page-header .header-btn {
    color: #cfd4e6 !important;
}

html[data-theme="dark"] .page-sidebar {
    background-color: #141221 !important;
}

/* Panels, cards, modals, dropdowns, prompt search panel */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .panel-container,
html[data-theme="dark"] .panel-content,
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .prompt-panel,
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .save-filter-card,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-faded {
    background-color: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .panel-hdr,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .subheader {
    background-color: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .subheader-title,
html[data-theme="dark"] .panel-hdr h2,
html[data-theme="dark"] label,
html[data-theme="dark"] .text-dark {
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .onoffswitch-title-desc,
html[data-theme="dark"] .breadcrumb-item,
html[data-theme="dark"] .breadcrumb-item a {
    color: var(--baf-dk-muted) !important;
}

/* Tables & DataTables */
html[data-theme="dark"] table,
html[data-theme="dark"] .table,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th,
html[data-theme="dark"] table.dataTable tbody tr {
    background-color: var(--baf-dk-surface) !important;
    color: var(--baf-dk-text) !important;
    border-color: var(--baf-dk-border) !important;
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] table.dataTable thead th {
    background-color: var(--baf-dk-surface-2) !important;
    color: #f0f1f8 !important;
}

html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd),
html[data-theme="dark"] table.dataTable.stripe tbody tr.odd {
    background-color: #1c202e !important;
}

html[data-theme="dark"] .table-hover tbody tr:hover,
html[data-theme="dark"] table.dataTable.hover tbody tr:hover {
    background-color: #24293b !important;
}

/* Forms & inputs */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select,
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-dropdown {
    background-color: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] .btn-default,
html[data-theme="dark"] .btn-light {
    background-color: #252a3d !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

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

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--baf-dk-surface-2) !important;
}

html[data-theme="dark"] .nav-tabs {
    border-bottom-color: var(--baf-dk-border) !important;
}

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

html[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) var(--baf-dk-border) var(--baf-dk-surface) !important;
    color: #fff !important;
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-left,
html[data-theme="dark"] .border-right,
html[data-theme="dark"] hr {
    border-color: var(--baf-dk-border) !important;
}

/* Auth / Login card (baf-auth-theme.css) */
html[data-theme="dark"] .su-card {
    background: linear-gradient(145deg, #171a27 0%, #1e1b30 100%) !important;
    border-color: rgba(157, 127, 224, .28) !important;
    color: var(--baf-dk-text) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .6) !important;
}

html[data-theme="dark"] .su-title,
html[data-theme="dark"] .su-check label,
html[data-theme="dark"] .su-meta a {
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .su-form .form-control {
    background: #121521 !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

/* Fields the browser filled in (saved password, saved e-mail): app.bundle.css covers the browser's own autofill
   tint with a white inset shadow, which left a white box with light, unreadable ink in dark. Same trick, dark
   fill. The generator does not twin it (a shadow, not a colour rule). */
html[data-theme="dark"] input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--baf-dk-surface-2) inset !important;
    -webkit-text-fill-color: var(--baf-dk-text) !important;
    caret-color: var(--baf-dk-text);
}

html[data-theme="dark"] .su-form input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #121521 inset !important;
}

html[data-theme="dark"] .baf-country-links {
    background: rgba(24, 27, 38, .92) !important;
    border-color: var(--baf-dk-border) !important;
}

/* Theme + offline switch in the card footer (_CardThemeToggle): back to the band's glass look on the dark card */
html[data-theme="dark"] .su-foot-tools .baf-auth-theme-btn {
    color: var(--baf-dk-text);
    border-color: rgba(157, 127, 224, .35);
    background: rgba(255, 255, 255, .08);
}

html[data-theme="dark"] .su-foot-tools .baf-auth-theme-btn:hover {
    background: rgba(255, 255, 255, .16);
}

/* "Powered by" mark: no white tile in dark, the artwork is brightened instead (it has no black in it) */
html[data-theme="dark"] .su-powered img,
html[data-theme="dark"] .page-footer img {
    background: transparent;
    filter: brightness(1.7) saturate(.9);
}

/* High-specificity overrides for baf-button-tab.css (tabs, forms, DataTables, breadcrumbs) */
html[data-theme="dark"] #js-page-content :is(#myButton, #myTab) li:not(.active) > a {
    background: #1d2131 !important;
    border: 1px solid var(--baf-dk-border) !important;
    border-bottom: 0 !important;
    color: #cfd4e6 !important;
}

html[data-theme="dark"] #js-page-content :is(#myButton, #myTab) li:not(.active) > a::after {
    display: none !important;
}

html[data-theme="dark"] #js-page-content .DataItems .frame-wrap .input-group-text,
html[data-theme="dark"] #js-page-content .DataItems .frame-wrap .has-length .input-group-text:not([class^="bg-"]):not([class*=" bg-"]) {
    background: #1f2334 !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] #js-page-content .DataItems .frame-wrap .input-group > .input-group-prepend > .input-group-text:first-child:has(> i) {
    background: #26203b !important;
    color: #c4b5fd !important;
}

html[data-theme="dark"] #js-page-content .DataItems .frame-wrap :is(.form-control, .custom-select):not(.is-invalid):not(.is-valid) {
    background-color: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] #js-page-content .baf-form-actions {
    background-color: var(--baf-dk-surface) !important;
    border-top-color: var(--baf-dk-border) !important;
}

html[data-theme="dark"] #js-page-content .btn-secondary,
html[data-theme="dark"] #js-page-content .clsUploadRow [data-baf-form-action="upload"],
html[data-theme="dark"] #js-page-content :is(#myButton, #myTab) #bafmpFavoriteModule,
html[data-theme="dark"] #js-page-content :is(#myButton, #myTab) .baf-page-favorite {
    background: #24293d !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .dataTables_wrapper,
html[data-theme="dark"] .dataTables_info,
html[data-theme="dark"] .dataTables_length,
html[data-theme="dark"] .dataTables_filter,
html[data-theme="dark"] .page-link {
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] .page-link {
    background-color: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
}

html[data-theme="dark"] .page-item.active .page-link {
    background-color: #7453a6 !important;
    border-color: #7453a6 !important;
    color: #fff !important;
}

/* ── Page sweep 2026-11-23: what the first pass left light, by shared piece ── */

/* Forms. SmartAdmin paints every .frame-wrap white; in dark the field rows sit on the card. */
html[data-theme="dark"] .frame-wrap {
    background-color: transparent !important;
}

html[data-theme="dark"] .baf-form-section > summary,
html[data-theme="dark"] details.baf-form-section > summary,
html[data-theme="dark"] .baf-form-section > .baf-form-section-title {
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .baf-form-section > summary::before,
html[data-theme="dark"] details.baf-form-section > summary::before {
    color: #c4b5fd !important;
}

html[data-theme="dark"] .baf-user-heading p,
html[data-theme="dark"] .zs-multi-placeholder {
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] .custom-file-label,
html[data-theme="dark"] .clsUploadThumb,
html[data-theme="dark"] .zs-multi-box,
html[data-theme="dark"] .chosen-container .chosen-choices,
html[data-theme="dark"] .chosen-container .chosen-single,
html[data-theme="dark"] .chosen-container .chosen-drop,
html[data-theme="dark"] .baf-acting-form-picker,
html[data-theme="dark"] .baf-ai-task-history,
html[data-theme="dark"] .baf-ai-task-review,
html[data-theme="dark"] .baf-ai-task-chips button {
    background: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .custom-file-label::after {
    background: #252a3d !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .baf-acting-form-picker .baf-acting-form-label,
html[data-theme="dark"] .chosen-container .chosen-results li,
html[data-theme="dark"] .chosen-container .chosen-single span {
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .chosen-container .chosen-results li.highlighted {
    background: #7453a6 !important;
    color: #fff !important;
}

html[data-theme="dark"] .chosen-container-multi .chosen-choices li.search-choice {
    background: #2c3145 !important;
    border-color: #3a4160 !important;
    color: var(--baf-dk-text) !important;
}

/* Lists: grid footer, tree rows, themed heads, colour-named cell links */
html[data-theme="dark"] .dt-toolbar-footer.baf-grid-footer,
html[data-theme="dark"] .thead-themed,
html[data-theme="dark"] .clsCacheTable > thead > tr > th {
    background: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] .thead-themed {
    background: var(--baf-dk-surface-2) !important;
    color: #f0f1f8 !important;
}

/* tree rows keep their pastel level colours, so their text must stay dark */
html[data-theme="dark"] .tt .content,
html[data-theme="dark"] .tt .content * {
    color: #1f2334 !important;
}

html[data-theme="dark"] [class*="baf-lt-color-maroon"],
html[data-theme="dark"] [class*="baf-lt-color-red"],
html[data-theme="dark"] .alertify-message {
    color: #f87171 !important;
}

html[data-theme="dark"] [class*="baf-lt-color-blue"] {
    color: #7cb7ff !important;
}

html[data-theme="dark"] [class*="baf-lt-color-green"] {
    color: #4ade80 !important;
}

html[data-theme="dark"] [class*="baf-lt-color-6e54a0"] {
    color: #c4b5fd !important;
}

html[data-theme="dark"] .progress {
    background-color: #2c3145 !important;
}

/* Header search box */
html[data-theme="dark"] .page-header .prompt-bar,
html[data-theme="dark"] .page-header .prompt-bar .search-input-wrapper {
    background: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .page-header .prompt-bar input {
    background-color: transparent !important;
}

/* Report hub */
html[data-theme="dark"] .baf-report-hub,
html[data-theme="dark"] .baf-report-hub .report-heading h2 {
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .baf-report-hub .report-card,
html[data-theme="dark"] .baf-report-hub .report-empty {
    background-color: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) !important;
}

html[data-theme="dark"] .baf-report-hub .report-field input,
html[data-theme="dark"] .baf-report-hub .report-field select,
html[data-theme="dark"] .baf-report-hub .report-tag {
    background-color: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .baf-report-hub .report-field label,
html[data-theme="dark"] .baf-report-hub .report-heading p,
html[data-theme="dark"] .baf-report-hub #report-count,
html[data-theme="dark"] .baf-report-hub .report-card p,
html[data-theme="dark"] .baf-report-hub .report-empty {
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] .baf-report-hub .report-reset,
html[data-theme="dark"] .baf-report-hub .report-open,
html[data-theme="dark"] .zdash-module-open {
    color: #c4b5fd !important;
}

/* Alertify dialogs */
html[data-theme="dark"] .alertify {
    background: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .alertify-cover {
    background: #000 !important;
}

/* Sign-in pages: links, outline button, release notes, flag pill */
html[data-theme="dark"] .su-card a:not(.btn):not([class*="su-btn"]),
html[data-theme="dark"] .su-mod-caret {
    color: #c4b5fd !important;
}

html[data-theme="dark"] .su-card .btn-outline-primary,
html[data-theme="dark"] .su-card .su-btn-outline {
    border-color: #9d7fe0 !important;
    color: #d9ccf7 !important;
}

html[data-theme="dark"] .rn-post {
    background: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .rn-votes {
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] .baf-country-links a[aria-current="true"],
html[data-theme="dark"] .baf-country-links a.active {
    background: #2c3145 !important;
    box-shadow: 0 0 0 1px rgba(157, 127, 224, .6) !important;
}

/* Developer-build pills (environment badge, tier switch) */
html[data-theme="dark"] .zs-env-pill,
html[data-theme="dark"] .zs-tier-switch {
    background: rgba(24, 27, 38, .96) !important;
    color: var(--baf-dk-text) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .5) !important;
}

html[data-theme="dark"] .zs-env-link,
html[data-theme="dark"] .zs-env-toggle,
html[data-theme="dark"] .zs-tier-switch label {
    color: #cfd4e6 !important;
}

html[data-theme="dark"] .zs-env-sep {
    color: #6b7394 !important;
}

html[data-theme="dark"] .zs-tier-switch button {
    background: #252a3d !important;
    border-color: #4a5170 !important;
    color: var(--baf-dk-text) !important;
}

/* Standalone pages that load no portal shell: error status, No Access, Subscription Expired.
   Each links this file and baf-theme.js (not the generated sheet); their own sheets only set the
   light palette. */
html[data-theme="dark"]:has(> body > .wrapper > main.card),
html[data-theme="dark"]:has(> body > .na-wrapper) {
    --baf-1: #b79df0;
    --baf-2: #d9ccf7;
    --baf-ink: #e6e7f0;
    --baf-soft: #9da3ba;
    --baf-line: #2c3145;
}

html[data-theme="dark"] body:has(> .na-wrapper) {
    background: var(--baf-dk-bg) !important;
}

html[data-theme="dark"] .na-card,
html[data-theme="dark"] main.card {
    background: var(--baf-dk-surface) !important;
    border-color: var(--baf-dk-border) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .6) !important;
}

html[data-theme="dark"] main.card > code.path,
html[data-theme="dark"] .na-page,
html[data-theme="dark"] .na-due {
    background: var(--baf-dk-surface-2) !important;
    border-color: var(--baf-dk-border) !important;
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] .na-msg,
html[data-theme="dark"] .na-foot,
html[data-theme="dark"] .na-due .lbl,
html[data-theme="dark"] .na-due .sub {
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] main.card a.primary,
html[data-theme="dark"] .na-btn-primary,
html[data-theme="dark"] .na-icon {
    background: linear-gradient(135deg, #7453a6, #5b3f8f) !important;
    color: #fff !important;
}

html[data-theme="dark"] .na-btn-ghost,
html[data-theme="dark"] main.card a.secondary {
    border-color: rgba(183, 157, 240, .45) !important;
}

/* Left menu: the logo band, the chat strip and the "Set As Default" block are the light theme's
   purple. On the dark rail they read as three unrelated light bars with a hole between the last
   two, so they take the rail's own tone and a hairline instead. */
html[data-theme="dark"] .page-sidebar .page-logo,
html[data-theme="dark"] .page-sidebar .nav-footer,
html[data-theme="dark"] .page-sidebar .baf-sidebar-defaults {
    background-color: #1a1730 !important;
    background-image: none !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .page-sidebar .nav-footer,
html[data-theme="dark"] .page-sidebar .baf-sidebar-defaults {
    border-top: 1px solid #2a2646 !important;
}

html[data-theme="dark"] .page-sidebar .page-logo {
    border-bottom: 1px solid #2a2646 !important;
}

/* Colours that views still carry on the element itself (data-baf-css-value is written back as an
   inline style at runtime, so no generated rule reaches them). Named by their value: dark inks
   that vanish on the dark page. "color:black" also matches "background-color:black", where light
   text is right as well. */
html[data-theme="dark"] :is([data-baf-css-value*="color:black"], [data-baf-css-value*="color: black"], [data-baf-css-value*="color:#000"], [data-baf-css-value*="color: #000"]),
html[data-theme="dark"] ol.breadcrumb[data-baf-css-value] > li {
    color: var(--baf-dk-text) !important;
}

html[data-theme="dark"] :is([data-baf-css-value*="color:#555"], [data-baf-css-value*="color:#666"], [data-baf-css-value*="color:#777"], [data-baf-css-value*="color: #555"], [data-baf-css-value*="color: #666"], [data-baf-css-value*="color: #777"]) {
    color: var(--baf-dk-muted) !important;
}

html[data-theme="dark"] :is([data-baf-css-value*="color:maroon"], [data-baf-css-value*="color: maroon"], [data-baf-css-value*="color:darkred"], [data-baf-css-value*="color: darkred"]) {
    color: #f87171 !important;
}

html[data-theme="dark"] :is([data-baf-css-value*="color:#4b2e83"], [data-baf-css-value*="color:#14245c"], [data-baf-css-value*="color:#6e54a0"], [data-baf-css-value*="color: #4b2e83"], [data-baf-css-value*="color: #14245c"], [data-baf-css-value*="color: #6e54a0"]) {
    color: #c4b5fd !important;
}
