/* Shared preference control also works on static account pages. */
.theme-switcher { width:min(100%, 24rem); min-width:0; margin:14px auto; text-align:left; }
.theme-switcher label { display:block; margin:0 0 6px; color:inherit; font-size:.875rem; font-weight:750; }
.theme-switcher select { display:block; width:100%; max-width:100%; min-height:44px; padding:10px 12px; border:1px solid var(--fm-control-border,#93877f); border-radius:10px; color:var(--fm-ink,#26211f); background:var(--fm-control,#fff); font:inherit; font-size:1rem; cursor:pointer; }
.theme-switcher small { display:block; margin-top:6px; color:inherit; font-size:.8125rem; line-height:1.5; }
.theme-switcher select:focus-visible { outline:3px solid var(--fm-focus,#176d92); outline-offset:3px; }
.more-panel .theme-switcher { padding:12px 0 0; border-top:1px solid #6f6058; color:#e0d6cf; }
.auth-only > .theme-switcher { margin-top:0; padding-inline:12px; }

/* Screen-only tokens preserve the existing light palette and printed pages.
   No filters or media/image transformations are used. The display route is
   explicitly excluded by theme.js before paint and after navigation. */
@media screen {
    :root[data-theme="dark"] {
        color-scheme:dark;
        --fm-pink-dark:#f5acc9;
        --fm-pink-soft:#f0a8c1;
        --fm-pink-pale:#422832;
        --fm-ink:#f4edeb;
        --fm-ink-soft:#e0d5d0;
        --fm-muted:#bfb0a9;
        --fm-canvas:#181619;
        --fm-surface:#242023;
        --fm-control:#302a2e;
        --fm-control-border:#9e8d96;
        --fm-surface-muted:#302a2e;
        --fm-line:#62535c;
        --fm-focus:#80cdf0;
        --fm-green:#94d8b2;
        --fm-green-pale:#203b2e;
        --fm-amber:#f3ca86;
        --fm-amber-pale:#44341f;
        --fm-blue:#97d5ec;
        --fm-blue-pale:#223943;
        --fm-red:#ffabb6;
        --fm-red-pale:#48282f;
        --fm-cream:var(--fm-surface-muted);
        --fm-background:var(--fm-canvas);
        --fm-shadow-sm:0 7px 24px #0003;
        --fm-shadow-lg:0 20px 60px #0006;
        --bs-body-color:var(--fm-ink);
        --bs-body-color-rgb:244,237,235;
        --bs-body-bg:var(--fm-canvas);
        --bs-body-bg-rgb:24,22,25;
        --bs-emphasis-color:var(--fm-ink);
        --bs-emphasis-color-rgb:244,237,235;
        --bs-secondary-color:var(--fm-muted);
        --bs-secondary-color-rgb:191,176,169;
        --bs-tertiary-color:var(--fm-muted);
        --bs-tertiary-color-rgb:191,176,169;
        --bs-secondary-bg:var(--fm-surface-muted);
        --bs-secondary-bg-rgb:48,42,46;
        --bs-tertiary-bg:var(--fm-surface-muted);
        --bs-tertiary-bg-rgb:48,42,46;
        --bs-border-color:var(--fm-line);
        --bs-link-color:var(--fm-pink-dark);
        --bs-link-color-rgb:245,172,201;
        --bs-link-hover-color:#ffd2e4;
        --bs-link-hover-color-rgb:255,210,228;
        --bs-code-color:var(--fm-pink-dark);
    }

    :root[data-theme="dark"] body { color:var(--fm-ink); background:var(--fm-canvas); }
    :root[data-theme="dark"] .topbar { background:rgb(36 32 35 / 96%); }
    :root[data-theme="dark"] :is(.login-shell,.account-card,.photo-card,.quick-action,.row-chevron,.display-link,.calendar-icon-button,.calendar-today-button,.intake-customer-result,.catalog-suggestions button) { background:var(--fm-control); }
    :root[data-theme="dark"] :is(.login-security,.wizard-step-number,.calendar-view-switch,.calendar-weekdays,.calendar-day.outside-month) { background:var(--fm-surface-muted); }
    :root[data-theme="dark"] .app-version-anonymous { color:var(--fm-muted); }
    :root[data-theme="dark"] :is(.brand-dot,.login-mobile-brand i) { color:var(--fm-pink-dark); border-color:var(--fm-pink-dark); }
    :root[data-theme="dark"] .login-security > span { color:#13291d; }
    :root[data-theme="dark"] :is(.order-row,.customer-row,.staff-row,.definition-row,.calendar-day) { border-color:var(--fm-line); }
    :root[data-theme="dark"] :is(.order-row:hover,.customer-row:hover,.quick-action:hover,.intake-customer-result:hover,.catalog-suggestions button:hover) { background:var(--fm-pink-pale); }
    :root[data-theme="dark"] .status-badge:not(.ready,.collected,.waiting,.awaiting-approval,.awaiting-parts,.repair,.diagnosing,.quality-check,.cancelled) { background:var(--fm-surface-muted); }
    :root[data-theme="dark"] .metric-card::after { background:var(--fm-pink-pale); }
    :root[data-theme="dark"] .timeline-dot { border-color:var(--fm-surface); }

    :root[data-theme="dark"] :is(.form-control,.form-select,input:not([type]),input[type="text"],input[type="password"],input[type="email"],input[type="url"],input[type="tel"],input[type="search"],input[type="number"],input[type="date"],input[type="datetime-local"],textarea,select) {
        color:var(--fm-ink); background-color:var(--fm-control); border-color:var(--fm-control-border);
    }
    :root[data-theme="dark"] :is(input,textarea)::placeholder { color:var(--fm-muted); opacity:1; }
    :root[data-theme="dark"] .form-select { --bs-form-select-bg-img:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23f4edeb' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
    :root[data-theme="dark"] :is(input,textarea,select):disabled { color:var(--fm-muted); background-color:var(--fm-surface-muted); }
    :root[data-theme="dark"] input:autofill { box-shadow:0 0 0 1000px var(--fm-control) inset; -webkit-text-fill-color:var(--fm-ink); caret-color:var(--fm-ink); }
    :root[data-theme="dark"] .form-check-input { background-color:var(--fm-control); border-color:var(--fm-control-border); }
    :root[data-theme="dark"] .form-check-input:checked { background-color:#b82d61; border-color:#f0a8c1; }
    :root[data-theme="dark"] :is(input,textarea,select):focus { border-color:var(--fm-focus); outline-color:var(--fm-focus); }
    :root[data-theme="dark"] :focus-visible { outline-color:var(--fm-focus); }
    :root[data-theme="dark"] #quote-contact-heading:focus { outline-color:var(--fm-focus); }
    :root[data-theme="dark"] .invalid { border-color:var(--fm-red) !important; }
    :root[data-theme="dark"] .valid.modified:not([type=checkbox]) { border-color:var(--fm-green); }
    :root[data-theme="dark"] :is(.fm-button,.btn-primary,.primary-nav a.new-order-link) { border-color:#dd729d; }
    :root[data-theme="dark"] :is(.fm-button:hover,.btn-primary:hover) { color:#fff; background:#a52555; }
    :root[data-theme="dark"] :is(.fm-button.secondary,.btn-secondary,.btn-outline-secondary) { color:var(--fm-ink-soft); background:var(--fm-control); border-color:var(--fm-control-border); }
    :root[data-theme="dark"] :is(.fm-button.secondary:hover,.btn-secondary:hover,.btn-outline-secondary:hover) { color:var(--fm-ink); background:var(--fm-pink-pale); border-color:var(--fm-pink-soft); }
    :root[data-theme="dark"] .fm-button.ghost { color:var(--fm-pink-dark); background:transparent; border-color:transparent; }
    :root[data-theme="dark"] .fm-button.ghost:hover { background:var(--fm-pink-pale); }
    :root[data-theme="dark"] .btn-danger { color:#fff; background:#ac3046; border-color:var(--fm-red); }
    :root[data-theme="dark"] .table { --bs-table-color:var(--fm-ink); --bs-table-bg:var(--fm-surface); --bs-table-border-color:var(--fm-line); --bs-table-striped-color:var(--fm-ink); --bs-table-striped-bg:var(--fm-surface-muted); --bs-table-hover-color:var(--fm-ink); --bs-table-hover-bg:var(--fm-pink-pale); }
    :root[data-theme="dark"] :is(.input-group-text,.dropdown-menu,.modal-content,.card,.list-group-item) { color:var(--fm-ink); background:var(--fm-surface); border-color:var(--fm-line); }
    :root[data-theme="dark"] .dropdown-item { color:var(--fm-ink); }
    :root[data-theme="dark"] .dropdown-item:hover { background:var(--fm-pink-pale); }

    :root[data-theme="dark"] :is(.alert,.device-message.error,.notifications-error,.capture-status.is-error) { color:var(--fm-red); background:var(--fm-red-pale); border-color:var(--fm-red); }
    :root[data-theme="dark"] :is(.alert-success,.device-message.success,.capture-status) { color:var(--fm-green); background:var(--fm-green-pale); border-color:var(--fm-green); }
    :root[data-theme="dark"] .pwa-notice { color:var(--fm-amber); background:var(--fm-amber-pale); border-color:var(--fm-amber); }
    :root[data-theme="dark"] .alert-warning { color:var(--fm-amber); background:var(--fm-amber-pale); border-color:var(--fm-amber); }
    :root[data-theme="dark"] .alert-info { color:var(--fm-blue); background:var(--fm-blue-pale); border-color:var(--fm-blue); }
    :root[data-theme="dark"] :is(.pwa-install,.privacy-note) { color:var(--fm-muted); }
    :root[data-theme="dark"] :is(.delete-dialog,.notifications-dialog,.notifications-panel,.notification-item,#components-reconnect-modal) { color:var(--fm-ink); background:var(--fm-surface); border-color:var(--fm-line); }
    :root[data-theme="dark"] #blazor-error-ui { color-scheme:dark; color:var(--fm-red); background:var(--fm-red-pale); border-color:var(--fm-red); }
    :root[data-theme="dark"] :is(.notifications-dialog,.delete-dialog)::backdrop { background:#0c090bb8; }
    :root[data-theme="dark"] .delete-dialog .fm-button:not(.secondary) { color:var(--fm-canvas); }
    :root[data-theme="dark"] #components-reconnect-modal button:is(:hover,:active) { background:#a52555; }

    :root[data-theme="dark"] .staff-notifications { color:var(--fm-ink); }
    :root[data-theme="dark"] :is(.notifications-trigger,.notification-close) { color:var(--fm-ink-soft); background:var(--fm-control); border-color:var(--fm-control-border); }
    :root[data-theme="dark"] :is(.notifications-dialog-heading,.notification-settings) { border-color:var(--fm-line); }
    :root[data-theme="dark"] .notification-item.is-unread { border-left-color:var(--fm-pink-soft); background:var(--fm-pink-pale); }
    :root[data-theme="dark"] .notification-decision.approved { color:var(--fm-green); background:var(--fm-green-pale); }
    :root[data-theme="dark"] .notification-decision.declined { color:var(--fm-red); background:var(--fm-red-pale); }
    :root[data-theme="dark"] .notification-order { color:var(--fm-ink); }
    :root[data-theme="dark"] :is(.notification-text-button,.notification-unread,.notification-order span,.notification-all-link) { color:var(--fm-pink-dark); }
    :root[data-theme="dark"] .notification-text-button:hover { background:var(--fm-pink-pale); }
    :root[data-theme="dark"] :is(.notifications-summary p,.notification-item-footer,.notification-settings summary span,.notification-settings-body,.notification-privacy) { color:var(--fm-muted); }
    :root[data-theme="dark"] .notifications-empty { color:var(--fm-muted); background:var(--fm-surface-muted); }

    :root[data-theme="dark"] .quote-card { --quote-ink:var(--fm-amber); --quote-tint:var(--fm-amber-pale); --quote-border:var(--fm-amber); color:var(--fm-ink); background:var(--fm-surface); }
    :root[data-theme="dark"] .quote-card.approved { --quote-ink:var(--fm-green); --quote-tint:var(--fm-green-pale); --quote-border:var(--fm-green); }
    :root[data-theme="dark"] .quote-card.declined { --quote-ink:var(--fm-red); --quote-tint:var(--fm-red-pale); --quote-border:var(--fm-red); }
    :root[data-theme="dark"] .quote-card.inactive { --quote-ink:var(--fm-ink-soft); --quote-tint:var(--fm-surface-muted); --quote-border:var(--fm-line); }
    :root[data-theme="dark"] :is(.quote-field-label,.quote-no-comment,.quote-signature small,.quote-terms summary,.quote-terms dt,.contact-help,.quote-empty) { color:var(--fm-muted); }
    :root[data-theme="dark"] :is(.quote-signature,.quote-terms,.danger-disclosure) { border-color:var(--fm-line); }
    :root[data-theme="dark"] .capture-checklist { color:var(--fm-ink); background:var(--fm-surface-muted); border-color:var(--fm-control-border); }
    :root[data-theme="dark"] :is(.file-button,.icon-button) { color:var(--fm-ink); background:var(--fm-control); border-color:var(--fm-control-border); }

    :root[data-theme="dark"] :is(.calendar-backlog,.calendar-day) { background:var(--fm-surface); border-color:var(--fm-line); }
    :root[data-theme="dark"] :is(.calendar-empty-note,.calendar-day.is-today) { background:var(--fm-pink-pale); border-color:var(--fm-line); }
    :root[data-theme="dark"] .calendar-backlog.calendar-overdue { background:var(--fm-red-pale); border-color:var(--fm-red); }
    :root[data-theme="dark"] .calendar-backlog-count { color:var(--fm-canvas); background:var(--fm-ink-soft); }
    :root[data-theme="dark"] .calendar-order { --status-tint:var(--fm-surface-muted); }
    :root[data-theme="dark"] :is(.calendar-order.received,.calendar-status-chip.received) { --status-color:#e1b8a3; --status-tint:#3d302b; }
    :root[data-theme="dark"] :is(.calendar-order.diagnosing,.calendar-order.repair,.calendar-order.quality-check) { --status-tint:var(--fm-blue-pale); }
    :root[data-theme="dark"] .calendar-order.awaiting-approval { --status-tint:var(--fm-amber-pale); }
    :root[data-theme="dark"] :is(.calendar-order.awaiting-parts,.calendar-status-chip.awaiting-parts) { --status-color:#d7b2f2; --status-tint:#392b44; }
    :root[data-theme="dark"] .calendar-order.ready { --status-tint:var(--fm-green-pale); }
    :root[data-theme="dark"] .calendar-overdue .calendar-order.overdue { --status-color:var(--fm-red); --status-tint:var(--fm-red-pale); }
}

@media print {
    :root { color-scheme:light; }
    .theme-switcher { display:none; }
}
