/* Shared by staff and public pages. Light mode retains the existing palette. */
.theme-switcher {
    position: fixed;
    top: 50%;
    right: max(8px, env(safe-area-inset-right));
    transform: translateY(-50%);
    z-index: 1030; /* Below Bootstrap dialogs and their backdrop. */
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(150, 160, 170, .22);
    border-radius: 24px;
    background: rgba(35, 43, 52, .28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: .65;
    transition: opacity .2s;
}
.theme-switcher:hover, .theme-switcher:focus-within { opacity: 1; }
.theme-switcher button {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}
.theme-switcher button[aria-pressed="true"] { background: rgba(216, 107, 45, .3); border-color: rgba(238, 153, 98, .5); }
.theme-switcher button:hover { background: rgba(255, 255, 255, .16); }
.theme-switcher button:focus-visible { outline: 2px solid #f7a66d; outline-offset: 2px; }
@media (max-width: 767.98px) {
    .theme-switcher { top: auto; bottom: max(80px, env(safe-area-inset-bottom)); transform: none; }
    .theme-switcher button { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .theme-switcher { transition: none; } }
@media print { .theme-switcher { display: none; } }

/* Explicit component overrides keep photographs, icons and status colours intact. */
html[data-theme="dark"] {
    color-scheme: dark;
    /* Page-local styles use these semantic tokens with their original light
       colour as a fallback. Keep tokens undefined in light mode so switching
       back restores the exact existing palette, including inline UI states. */
    --theme-surface: #22272f;
    --theme-surface-raised: #2a323d;
    --theme-control: #354150;
    --theme-text: #edf0f3;
    --theme-muted: #b2becb;
    --theme-line: #465363;
    --theme-line-soft: rgba(166, 185, 204, .2);
    --theme-accent-surface: #493526;
    --theme-accent-text: #ffc08f;
    --theme-accent-line: #826044;
    --theme-warning-surface: #484020;
    --theme-warning-text: #f8db89;
    --theme-warning-line: #82703d;
    --theme-success-surface: #244537;
    --theme-success-text: #a0dfb7;
    --theme-success-line: #48785e;
    --theme-danger-surface: #4c2c34;
    --theme-danger-text: #ffb4bb;
    --theme-danger-line: #87515a;
    --theme-info-surface: #283c53;
    --theme-info-text: #aecff7;
    --theme-info-line: #4b678a;
    --theme-violet-surface: #3d324f;
    --theme-violet-text: #d6c0f2;
    --theme-violet-line: #75608b;
    --surface-white: rgba(25, 30, 37, .95);
    --surface: rgba(25, 30, 37, .95);
    --text-dark: #edf0f3;
    --text-muted: #a4afbd;
    --app-bg: #191d23;
    --app-surface: #22272f;
    --app-surface-strong: #252b33;
    --app-line: #38414c;
    --app-line-strong: #4e443f;
    --app-text: #edf0f3;
    --app-muted: #a4afbd;
    --app-blue: #a7c8f1;
    --app-danger: #ffb4bb;
    --app-success: #a0dfb7;
    --app-shadow: 0 22px 48px rgba(0, 0, 0, .28);
}
html[data-theme="dark"] body { color: #edf0f3; }
html[data-theme="dark"] body::before {
    background-image: linear-gradient(180deg, rgba(12, 17, 23, .8), rgba(12, 17, 23, .9)), url('logo1.avif');
}
html[data-theme="dark"] :is(.container, .page-hero, .toolbar-card, .surface-card, .summary-card, .summary-card__item, .form-panel, .auth-card, .record-card, .empty-state, .card, .card-header, .card-footer, .modal-content, .dropdown-menu, .list-group-item, .suggestions-list, .floating-selection-card) {
    background: #22272f;
    color: #edf0f3;
    border-color: #38414c;
}
html[data-theme="dark"] :is(.page-hero__title, .form-panel__title, .form-panel label, .auth-brand__title, .auth-card label, .section-label, .summary-card__value, .record-total-amount, .record-card__title, .floating-selection-card__head, .floating-selection-card__value, .empty-state strong) { color: #edf0f3; }
html[data-theme="dark"] :is(.text-muted, .record-created-by, .record-index, .record-card__num, .record-card__date) { color: #a4afbd !important; }
html[data-theme="dark"] :is(.form-control, .custom-select, .input-group-text, .page-link, .page-hero__meta, .record-phone-link, .record-phone-link--disabled, .btn-outline-secondary, .btn-light, .suggestion-item) {
    background: #2c3440;
    color: #d9e4ef;
    border-color: #465363;
}
html[data-theme="dark"] :is(.form-control, .custom-select):focus { border-color: #d86b2d; box-shadow: 0 0 0 3px rgba(216, 107, 45, .2); }
html[data-theme="dark"] .form-control::placeholder { color: #acb6c2; }
html[data-theme="dark"] .form-control:disabled, html[data-theme="dark"] .form-control[readonly] { background: #242a32; color: #a4afbd; }
html[data-theme="dark"] .table { color: #edf0f3; background: #20252c; }
html[data-theme="dark"] .table :is(th, td) { border-color: #38414c; }
html[data-theme="dark"] .table thead th { background: #303944; color: #edf0f3; }
html[data-theme="dark"] .table tbody tr { background: #20252c; }
html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) { background: #252b33; }
html[data-theme="dark"] .table tbody tr:hover { background: #343333; color: #fff; }
html[data-theme="dark"] .records-table tbody tr.is-collected :is(td, .record-total-amount) { color: #a4afbd; }
html[data-theme="dark"] :is(.btn-success, .btn-outline-success, .alert-success, .page-status--success) { background: #285444; color: #d5f3df; border-color: #427961; }
html[data-theme="dark"] :is(.btn-outline-danger, .alert-danger, .auth-error, .page-status--error) { background: #512d32; color: #ffced0; border-color: #88454c; }
html[data-theme="dark"] :is(.alert-warning, .table-warning) { background: #514329; color: #ffe0a6; }
html[data-theme="dark"] :is(.alert-info, .table-info) { background: #263f50; color: #c6e8ff; }
html[data-theme="dark"] .dropdown-item { color: #edf0f3; }
html[data-theme="dark"] .dropdown-item:hover { background: #343e49; }
html[data-theme="dark"] .close { color: #edf0f3; text-shadow: none; }
html[data-theme="dark"] :is(.store-topline, .store-topline a, .store-category-link) { color: #d9e4ef; }
html[data-theme="dark"] .bg-white, html[data-theme="dark"] .bg-light { background: #22272f !important; }
html[data-theme="dark"] .text-dark { color: #edf0f3 !important; }
html[data-theme="dark"] :is(.side-card, .catalog-main, .product-card, .product-hero, .related-card, .prod-card) { background: #22272f; border-color: #38414c; }
html[data-theme="dark"] :is(.side-card h3, .side-link, .product-card-name, .product-title, .product-desc, .related-section h4, .related-card-name, .prod-card-name) { color: #edf0f3; }
html[data-theme="dark"] :is(.catalog-count, .product-card-cat, .back-link, .prod-card-cat) { color: #a4afbd; }
html[data-theme="dark"] :is(.category-pill, .product-card-img-placeholder, .product-hero-placeholder, .related-card-placeholder, .badge-unavailable) { background: #303944; color: #c2cbd6; }
html[data-theme="dark"] :is(.product-price, .product-price-big, .related-card-price, .prod-card-price, .product-cat-badge) { color: #f3a470; }
html[data-theme="dark"] .badge-available { background: #285444; color: #d5f3df; }
html[data-theme="dark"] :is(.promo-card, .dept-card, .benefit-card, .info-band) { background: #22272f; border-color: #38414c; }
html[data-theme="dark"] :is(.promo-card strong, .section-head h2, .dept-card, .benefit-card b, .info-band h2) { color: #edf0f3; }
html[data-theme="dark"] :is(.promo-card span, .dept-note, .benefit-card span, .info-band p) { color: #a4afbd; }
html[data-theme="dark"] .store-category-link { background: #303944; border-color: #465363; }
html[data-theme="dark"] .empty-state h3 { color: #edf0f3; }
html[data-theme="dark"] :is(.side-card p, .record-card__master, .records-filter-label, .records-master-filter__group-title, .records-master-filter__empty) { color: #a4afbd; }
html[data-theme="dark"] #filters { background: #22272f; }
html[data-theme="dark"] :is(.records-master-filter__button, .records-master-filter__dropdown, .records-master-filter__action) { background: #2c3440; color: #d9e4ef; border-color: #465363; }
html[data-theme="dark"] .records-master-filter__option { color: #edf0f3; }
html[data-theme="dark"] #mobile-select-all-bar { color: #d9e4ef !important; }
html[data-theme="dark"] .record-phone-link:hover { background: #35483f; color: #d5f3df; }
html[data-theme="dark"] :is(.records-filter-action--secondary, .notify-client-btn.is-pending, .notify-client-btn.is-disabled, .notify-client-btn:disabled) { background: #303944; color: #d9e4ef; border-color: #465363; }

/* Native controls without Bootstrap classes (advances, filters, settings). */
html[data-theme="dark"] :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="hidden"]), select, textarea) {
    background-color: var(--theme-surface-raised);
    color: var(--theme-text);
    border-color: var(--theme-line);
}
html[data-theme="dark"] :where(input, textarea)::placeholder { color: var(--theme-muted); opacity: 1; }
html[data-theme="dark"] .btn-outline-primary { color: var(--theme-accent-text); }
html[data-theme="dark"] .btn-outline-primary:hover { color: #fff; }
html[data-theme="dark"] svg [fill="#09244BFF"] { fill: var(--theme-info-text); }
html[data-theme="dark"] :is(.alert-light, .alert-secondary, .badge-light, .table-light, .table-secondary),
html[data-theme="dark"] :is(.table-light, .table-secondary) > :is(th, td) {
    background-color: var(--theme-surface-raised);
    color: var(--theme-text);
    border-color: var(--theme-line);
}
html[data-theme="dark"] .table-success,
html[data-theme="dark"] .table-success > :is(th, td) { background-color: var(--theme-success-surface); color: var(--theme-success-text); }
html[data-theme="dark"] .table-danger,
html[data-theme="dark"] .table-danger > :is(th, td) { background-color: var(--theme-danger-surface); color: var(--theme-danger-text); }
html[data-theme="dark"] .table-warning > :is(th, td) { background-color: var(--theme-warning-surface); color: var(--theme-warning-text); }
html[data-theme="dark"] .table-primary,
html[data-theme="dark"] :is(.table-info, .table-primary) > :is(th, td) { background-color: var(--theme-info-surface); color: var(--theme-info-text); }
html[data-theme="dark"] .custom-control-label::before { background-color: var(--theme-surface-raised); border-color: var(--theme-line); }
html[data-theme="dark"] .custom-control-input:disabled ~ .custom-control-label::before { background-color: var(--theme-surface-raised); }
