/* Semantic dark values; legacy declarations retain their exact light fallback. */
@media screen {
html[data-theme="dark"] {
    color-scheme: dark;
    --fl-color-canvas: #101722;
    --fl-color-surface: #1b2533;
    --fl-color-surface-subtle: #253244;
    --fl-color-text: #edf2f8;
    --fl-color-text-muted: #b9c6d8;
    --fl-color-border: #53647b;
    --fl-color-border-strong: #8093ad;
    --fl-color-primary: #8bdfd3;
    --fl-color-primary-hover: #acebe2;
    --fl-color-primary-soft: #183f3d;
    --fl-color-on-primary: #102724;
    --fl-color-success: #8ce4b7;
    --fl-color-success-surface: #173a2b;
    --fl-color-warning: #f5d585;
    --fl-color-warning-surface: #3b3019;
    --fl-color-danger: #ffb4b4;
    --fl-color-danger-hover: #ffd1d1;
    --fl-color-on-danger: #35151a;
    --fl-color-danger-surface: #45282d;
    --fl-color-info: #aed3ff;
    --fl-color-info-surface: #20364f;
    --fl-focus-color: #b7dcff;
    --fl-focus-ring: 0 0 0 3px #b7dcff;
    --fl-shadow-sm: 0 1px 4px #0006;
    --fl-shadow-md: 0 10px 28px #0006;
    --fl-dark-surface: var(--fl-color-surface);
    --fl-dark-subtle: var(--fl-color-surface-subtle);
    --fl-dark-text: var(--fl-color-text);
    --fl-dark-muted: var(--fl-color-text-muted);
    --fl-dark-border: var(--fl-color-border);
    --fl-dark-success: var(--fl-color-success);
    --fl-dark-success-surface: var(--fl-color-success-surface);
    --fl-dark-warning: var(--fl-color-warning);
    --fl-dark-warning-surface: var(--fl-color-warning-surface);
    --fl-dark-danger: var(--fl-color-danger);
    --fl-dark-danger-surface: var(--fl-color-danger-surface);
    --fl-dark-info: var(--fl-color-info);
    --fl-dark-info-surface: var(--fl-color-info-surface);
    --public-soft: var(--fl-color-canvas);
    --public-ink: var(--fl-color-text);
    --public-navy: var(--fl-color-text);
    --public-muted: var(--fl-color-text-muted);
    --public-line: var(--fl-color-border);
    --public-blue: #aed3ff;
    --public-shadow: var(--fl-shadow-md);
    --text: var(--fl-color-text);
    --soft: var(--fl-color-text-muted);
    --border: var(--fl-color-border);
    --bg: var(--fl-color-canvas);
    --shadow: var(--fl-shadow-md);
    --client-bg: var(--fl-color-canvas);
    --client-card: var(--fl-color-surface);
    --client-sidebar: var(--fl-color-surface);
    --client-border: var(--fl-color-border);
    --client-border-strong: var(--fl-color-border-strong);
    --client-text: var(--fl-color-text);
    --client-text-soft: var(--fl-color-text-muted);
    --client-text-muted: var(--fl-color-text-muted);
    --client-primary-soft: var(--fl-color-info-surface);
    --client-success-soft: var(--fl-color-success-surface);
    --client-danger-soft: var(--fl-color-danger-surface);
    --client-danger: var(--fl-color-danger);
    --client-success: var(--fl-color-success);
    --client-shadow: var(--fl-shadow-sm);
    --client-shadow-hover: var(--fl-shadow-md);
    --cerfa-bg: var(--fl-color-canvas);
    --cerfa-card: var(--fl-color-surface);
    --cerfa-border: var(--fl-color-border);
    --cerfa-border-strong: var(--fl-color-border-strong);
    --cerfa-text: var(--fl-color-text);
    --cerfa-soft: var(--fl-color-text-muted);
    --cerfa-primary-soft: var(--fl-color-info-surface);
    --cerfa-shadow: var(--fl-shadow-sm);
    --p-bg: var(--fl-color-canvas);
    --p-card: var(--fl-color-surface);
    --p-border: var(--fl-color-border);
    --p-text: var(--fl-color-text);
    --p-soft: var(--fl-color-text-muted);
    --p-shadow: var(--fl-shadow-sm);
    --onboarding-soft: var(--fl-color-surface-subtle);
    --onboarding-border: var(--fl-color-border);
    background: var(--fl-color-canvas);
    color: var(--fl-color-text);
}
html[data-theme="dark"] body { background: var(--fl-color-canvas); color: var(--fl-color-text); }
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),select,textarea) {
    background-color: var(--fl-color-surface); color: var(--fl-color-text); border-color: var(--fl-color-border);
}
html[data-theme="dark"] ::placeholder { color: var(--fl-color-text-muted); opacity: 1; }
html[data-theme="dark"] :focus-visible { outline: 3px solid var(--fl-focus-color); outline-offset: 3px; }
html[data-theme="dark"] :disabled { opacity: .65; cursor: not-allowed; }
html[data-theme="dark"] :is(.form-section,.public-auth-card,.week-card,.day-panel,.empty-state) {
    background: var(--fl-color-surface); color: var(--fl-color-text); border-color: var(--fl-color-border); box-shadow: var(--fl-shadow-sm);
}
html[data-theme="dark"] .public-auth-form label { color: var(--fl-color-text); }
html[data-theme="dark"] .public-form-alert { background: var(--fl-color-danger-surface); color: var(--fl-color-danger); border-color: currentColor; }
html[data-theme="dark"] .form-table :is(th,td) { border-color: var(--fl-color-border); }
/* Brand colors remain exact accents. Neutral foreground avoids low contrast brand text on dark surfaces. */
html[data-theme="dark"] :is(.dashboard-shortcut,.dashboard-section-link,.company-tab,.mobile-section-nav a,.current-week,.nav-button) {
    color: var(--fl-color-text); text-decoration-color: var(--company-secondary, currentColor);
}
html[data-theme="dark"] .mobile-header { background: var(--fl-color-surface); color: var(--fl-color-text); border-bottom: 3px solid var(--brand-primary); }
html[data-theme="dark"] .mobile-header a { color: inherit; }
html[data-theme="dark"] :is(.brand-logo,.brand-mark) { background: #fff; }
html[data-theme="dark"] .day-button.is-selected { background: var(--fl-color-surface-subtle); color: var(--fl-color-text); outline: 2px solid var(--brand-primary); font-weight: 800; }
html[data-theme="dark"] .day-button.is-today:not(.is-selected) { background: var(--fl-color-surface-subtle); color: var(--fl-color-text); text-decoration: underline; }
html[data-theme="dark"] .site-navigation-link { opacity: 1; }
html[data-theme="dark"] :is(.step-number,.type-badge,.type-badge.service,.filter-buttons button.is-active,.products-eyebrow,.product-category) { color: var(--fl-color-info); }
html[data-theme="dark"] .dashboard-page :focus-visible { outline: 3px solid var(--fl-focus-color); outline-offset: 3px; }
html[data-theme="dark"] :is(.dashboard-alert-list a,.dashboard-overdue-heading,.dashboard-overdue-expand summary) { color: var(--fl-color-warning); }
html[data-theme="dark"] .dashboard-alert-list a { background: var(--fl-color-warning-surface); }
html[data-theme="dark"] .dashboard-card.is-alert strong { color: var(--fl-color-danger); }
html[data-theme="dark"] .dashboard-revenue-bar { outline: 1px solid var(--fl-color-text-muted); }
html[data-theme="dark"] .dashboard-badge { background: var(--fl-color-success-surface); color: var(--fl-color-success); }
html[data-theme="dark"] .dashboard-badge-muted { background: var(--fl-color-surface-subtle); color: var(--fl-color-text-muted); }
@media (max-width: 1400px) {
    html[data-theme="dark"] .site-navigation-link:is(:hover,:focus-visible) { color: var(--fl-color-info); }
}
/* Paper previews keep light fallback values, also when viewed on a dark screen. */
html[data-theme="dark"] :is(.preview-page,.invoice-document,.cerfa-preview) {
    color-scheme: light;
    --fl-dark-surface: initial; --fl-dark-subtle: initial;
    --fl-dark-text: initial; --fl-dark-muted: initial; --fl-dark-border: initial;
    --fl-dark-success: initial; --fl-dark-success-surface: initial;
    --fl-dark-warning: initial; --fl-dark-warning-surface: initial;
    --fl-dark-danger: initial; --fl-dark-danger-surface: initial;
    --fl-dark-info: initial; --fl-dark-info-surface: initial;
}
}
