/* Opt-in, screen-only theme. Printed receipts, PDFs and public menu are unchanged. */
.hero-theme-menu { position: relative; margin: 0 .25rem; }
.hero-theme-menu > summary {
    align-items: center;
    border-radius: .375rem;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    height: 32px;
    justify-content: center;
    list-style: none;
    width: 32px;
    font-size: .75rem;
}
.hero-theme-menu > summary::-webkit-details-marker { display: none; }
.hero-theme-menu > summary:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.hero-theme-menu > summary:focus-visible,
.hero-theme-toggle:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.hero-theme-panel {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1050;
    margin-top: .5rem;
    padding: .25rem;
    width: 176px;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    background: #fff;
    box-shadow: 0 10px 15px rgba(0, 0, 0, .1);
}
.hero-theme-toggle {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: .375rem;
    color: #334155;
    cursor: pointer;
    display: flex;
    gap: .75rem;
    min-height: 36px;
    padding: .5rem .75rem;
    text-align: left;
    width: 100%;
    font-size: .875rem;
    transition: background-color .15s;
}
.hero-theme-toggle.hero-theme-icon {
    justify-content: center;
    padding: 0;
    min-height: 32px;
    width: 32px;
    color: #cbd5e1;
}
.hero-theme-toggle.hero-theme-icon:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.hero-theme-toggle:hover { background: #f1f5f9; }
.hero-theme-entry { position: absolute; right: 1rem; top: 1rem; z-index: 10; }
.hero-theme-entry summary { color: #64748b; }
.hero-theme-entry summary:hover { background: rgba(100, 116, 139, .1); color: #334155; }
@media screen {
    html[data-theme="dark"] .hero-theme-panel { background: #1e293b; border-color: #475569; }
    html[data-theme="dark"] .hero-theme-toggle { color: #e2e8f0; }
    html[data-theme="dark"] .hero-theme-toggle:hover { background: #334155; }
    html[data-theme="dark"] .hero-theme-entry summary { color: #cbd5e1; }
}

@media screen and (max-width: 991.98px) {
    .navbar-collapse .hero-theme-panel { left: 0; right: auto; }
}

@media print {
    .hero-theme-menu, .hero-theme-toggle, .hero-theme-entry { display: none; }
}

@media screen {
    html[data-theme="dark"] {
        color-scheme: dark;
        --bs-body-bg: #0f172a;
        --bs-body-color: #e2e8f0;
        --bs-border-color: #334155;
    }
    html[data-theme="dark"] body,
    html[data-theme="dark"] .login-page {
        background: #0f172a;
        color: #e2e8f0;
    }
    html[data-theme="dark"] :is(.card, .modal-content, .dropdown-menu, .popover, .list-group-item, .login-shell, .permission-card, .permission-option, .swal2-popup, .ui-widget-content) {
        background-color: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }
    html[data-theme="dark"] :is(.bg-white, .bg-light, .card-header, .card-footer, .modal-header, .modal-footer, .input-group-text, .breadcrumb, .custom-dropdown-header) {
        background-color: #1e293b !important;
        border-color: #334155 !important;
        color: #e2e8f0;
    }
    html[data-theme="dark"] :is(.border, .border-top, .border-bottom, .border-left, .border-right, .dropdown-divider) {
        border-color: #334155 !important;
    }
    html[data-theme="dark"] :is(.text-dark, .text-body, .login-card h2, .login-brand-copy h1, .login-card label, .permission-card h2) {
        color: #f1f5f9 !important;
    }
    html[data-theme="dark"] :is(.text-muted, .text-secondary, .login-card p, .login-brand-copy p, .permission-card p) {
        color: #94a3b8 !important;
    }
    html[data-theme="dark"] .login-brand-panel {
        background: linear-gradient(145deg, #1e293b, #172554);
        border-color: #334155;
    }
    html[data-theme="dark"] a:not(.btn):not(.badge):not(.nav-link):not(.dropdown-item):not(.text-white),
    html[data-theme="dark"] :is(.text-primary, .btn-link) {
        color: #93c5fd !important;
    }
    html[data-theme="dark"] :is(.form-control, .custom-select, .swal2-input, .swal2-textarea, .swal2-select, .page-link) {
        background-color: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    html[data-theme="dark"] :is(.form-control, .custom-select):disabled,
    html[data-theme="dark"] .form-control[readonly] {
        background-color: #334155;
        color: #cbd5e1;
    }
    html[data-theme="dark"] .form-control::placeholder { color: #94a3b8; }
    html[data-theme="dark"] :is(.form-control, .custom-select):focus {
        border-color: #60a5fa;
        box-shadow: 0 0 0 .2rem rgba(96, 165, 250, .2);
    }
    html[data-theme="dark"] :is(.dropdown-item, .close, .popover-body, .swal2-title, .swal2-html-container) { color: #e2e8f0; }
    html[data-theme="dark"] :is(.dropdown-item:hover, .dropdown-item:focus, .page-link:hover, .list-group-item-action:hover) {
        background-color: #334155;
        color: #f8fafc;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] :is(.card-settings .card-header h5, .setting-title) {
        color: #f1f5f9;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] .setting-desc { color: #94a3b8; }
    html[data-theme="dark"] [data-fiscal-tabs-root] .nav-settings .nav-link {
        color: #cbd5e1;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] .nav-settings .nav-link:is(:hover, :focus) {
        background-color: #334155;
        color: #f8fafc;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] .nav-settings .nav-link.active {
        background-color: #172554;
        color: #f8fafc;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] .nav-settings .nav-link:focus-visible {
        outline: 2px solid #60a5fa;
        outline-offset: 2px;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] .fiscal-loading-overlay { background: rgba(15, 23, 42, .72); }
    html[data-theme="dark"] [data-fiscal-tabs-root] .fiscal-loading-card {
        background-color: #1e293b;
        border-color: #475569;
        color: #e2e8f0;
    }
    html[data-theme="dark"] [data-fiscal-tabs-root] .fiscal-loading-spinner {
        border-color: #475569;
        border-top-color: #60a5fa;
    }
    html[data-theme="dark"] .nav-tabs { border-bottom-color: #475569; }
    html[data-theme="dark"] .nav-tabs .nav-link {
        color: #cbd5e1 !important;
        background-color: transparent;
    }
    html[data-theme="dark"] .nav-tabs .nav-link:not(.disabled):hover,
    html[data-theme="dark"] .nav-tabs .nav-link:not(.disabled):focus {
        color: #f8fafc !important;
        border-color: #475569;
        background-color: #334155;
    }
    html[data-theme="dark"] .nav-tabs :is(.nav-link.active, .nav-item.show .nav-link) {
        color: #f8fafc !important;
        background-color: #1e293b;
        border-color: #475569 #475569 #1e293b;
        font-weight: 600;
    }
    html[data-theme="dark"] .nav-tabs .nav-link:focus-visible {
        outline: 2px solid #60a5fa;
        outline-offset: 2px;
    }
    html[data-theme="dark"] .nav-tabs .nav-link.disabled { color: #64748b !important; }
    html[data-theme="dark"] .nav-tabs .badge-warning { color: #422006 !important; }
    html[data-theme="dark"] .table {
        --bs-table-color: #e2e8f0;
        --bs-table-bg: #1e293b;
        --bs-table-striped-color: #e2e8f0;
        --bs-table-striped-bg: rgba(148, 163, 184, .08);
        --bs-table-hover-color: #f8fafc;
        --bs-table-hover-bg: rgba(148, 163, 184, .12);
        color: #e2e8f0;
    }
    html[data-theme="dark"] .table :is(td, th) { border-color: #334155; }
    html[data-theme="dark"] :is(.table .thead-light th, .cashier-summary-table thead th, .cashier-summary-table .thead-dark th) {
        background: #334155 !important;
        color: #f1f5f9 !important;
    }
    html[data-theme="dark"] :is(.cashier-summary-table tbody tr, .cashier-summary-table tbody tr.bg-light td) {
        background: #1e293b !important;
        color: #e2e8f0;
    }
    html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(148, 163, 184, .08); }
    html[data-theme="dark"] .table-hover tbody tr:hover { background-color: #334155; color: #f8fafc; }
    html[data-theme="dark"] :is(.alert-success, .table-success, .table-success > td, .table-success > th) { background-color: #052e16; border-color: #166534; color: #86efac; }
    html[data-theme="dark"] :is(.alert-danger, .table-danger, .table-danger > td, .table-danger > th) { background-color: #450a0a; border-color: #991b1b; color: #fca5a5; }
    html[data-theme="dark"] :is(.alert-warning, .table-warning, .table-warning > td, .table-warning > th) { background-color: #422006; border-color: #854d0e; color: #fde047; }
    html[data-theme="dark"] :is(.alert-info, .alert-primary, .table-info, .table-info > td, .table-info > th) { background-color: #172554; border-color: #1e40af; color: #93c5fd; }
    /* Bootstrap 4 paints variant cells directly; its Bootstrap 5 tokens are insufficient. */
    html[data-theme="dark"] :is(.table-light, .table-light > td, .table-light > th, .table-secondary, .table-secondary > td, .table-secondary > th, .table-active, .table-active > td, .table-active > th) {
        background-color: #1e293b;
        color: #e2e8f0;
    }
    html[data-theme="dark"] :is(.table-primary, .table-primary > td, .table-primary > th) {
        background-color: #172554;
        color: #93c5fd;
    }
    html[data-theme="dark"] .bg-canceled {
        background-color: #450a0a !important;
        color: #fca5a5;
    }
    html[data-theme="dark"] .table-hover :is(.table-light, .table-secondary, .table-active):hover,
    html[data-theme="dark"] .table-hover :is(.table-light, .table-secondary, .table-active):hover > :is(td, th) {
        background-color: #334155;
        color: #f8fafc;
    }
    html[data-theme="dark"] .table-hover .table-success:hover,
    html[data-theme="dark"] .table-hover .table-success:hover > :is(td, th) { background-color: #064e3b; color: #86efac; }
    html[data-theme="dark"] .table-hover .table-danger:hover,
    html[data-theme="dark"] .table-hover .table-danger:hover > :is(td, th) { background-color: #7f1d1d; color: #fca5a5; }
    html[data-theme="dark"] .table-hover .table-warning:hover,
    html[data-theme="dark"] .table-hover .table-warning:hover > :is(td, th) { background-color: #713f12; color: #fde047; }
    html[data-theme="dark"] .table-hover :is(.table-info, .table-primary):hover,
    html[data-theme="dark"] .table-hover :is(.table-info, .table-primary):hover > :is(td, th) { background-color: #1e3a8a; color: #93c5fd; }
    html[data-theme="dark"] .text-success { color: #86efac !important; }
    html[data-theme="dark"] .text-danger { color: #fca5a5 !important; }
    html[data-theme="dark"] .text-warning { color: #fde047 !important; }
    html[data-theme="dark"] .text-info { color: #67e8f9 !important; }
    html[data-theme="dark"] .btn-outline-primary:not(:hover):not(:active) { color: #93c5fd !important; border-color: #60a5fa !important; }
    html[data-theme="dark"] :is(.btn-light, .btn-outline-dark):not(:hover):not(:active) { background-color: #334155; color: #e2e8f0; border-color: #64748b; }
    html[data-theme="dark"] :is(.select2-container--default .select2-selection--single, .select2-container--default .select2-selection--multiple, .select2-dropdown, .select2-search__field) {
        background-color: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    html[data-theme="dark"] :is(.select2-container--default .select2-selection__rendered, .select2-results__option, .select2-selection__choice__remove) { color: #e2e8f0; }
    html[data-theme="dark"] .select2-container--default .select2-selection__choice { background-color: #334155; border-color: #475569; }
    html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected=true] { background-color: #334155; }
    html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] { background-color: #1e40af; color: #fff; }
    /* The monthly flow uses local tokens instead of Bootstrap surfaces. */
    html[data-theme="dark"] .monthly-financial-flow {
        --flow-ink: #e2e8f0;
        --flow-muted: #94a3b8;
        --flow-border: #334155;
        --flow-primary: #a5b4fc;
        --flow-success: #86efac;
        --flow-success-soft: #052e16;
        --flow-danger: #fca5a5;
        --flow-danger-soft: #450a0a;
        --flow-summary: #93c5fd;
        --flow-summary-soft: #172554;
        background: #0f172a;
    }
    html[data-theme="dark"] .monthly-financial-flow :is(.flow-filter-card, .flow-table-card, .flow-updating, .flow-secondary-button) {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }
    html[data-theme="dark"] .monthly-financial-flow :is(.flow-secondary-button:hover, .flow-secondary-button:focus) { background: #334155; color: #f8fafc; }
    html[data-theme="dark"] .monthly-financial-flow :is(label, .table thead th) { color: #cbd5e1; }
    html[data-theme="dark"] .monthly-financial-flow .flow-primary-button { background: #4f46e5; }
    html[data-theme="dark"] .monthly-financial-flow :is(.flow-summary-group > *, .flow-summary-profit th, .flow-summary-total th) {
        background: #172554;
        color: #c7d2fe;
        border-color: #475569;
    }
    html[data-theme="dark"] .monthly-financial-flow :is(.flow-table-card tbody tr:hover td, .flow-table-card tbody tr:last-child th, .flow-detail-record, .flow-fee-item, .modal-header) {
        background: #334155;
        color: #e2e8f0;
    }
    html[data-theme="dark"] .monthly-financial-flow .flow-accordion-detail > td { background: #0f172a !important; }
    html[data-theme="dark"] .monthly-financial-flow :is(.flow-detail-record strong, .modal-body) { color: #cbd5e1; }
    html[data-theme="dark"] .monthly-financial-flow .flow-table-title--demonstrative th { background: #052e16; color: #86efac; }
    html[data-theme="dark"] .monthly-financial-flow .flow-value-unavailable { color: #fca5a5 !important; }
    /* Keep canvas labels readable without changing chart configurations. */
    html[data-theme="dark"] canvas { background-color: #fff; border-radius: .375rem; }
}
