/* Screen-only theme: printed documents, QR codes and signature canvases stay white. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1220;
    --panel: #162133;
    --ink: #e5edf6;
    --muted: #a5b4c8;
    --line: #344258;
    --nav: #0d1727;
    --nav2: #162133;
    --brand2: #60a5fa;
    --shadow: 0 8px 28px rgba(0, 0, 0, .24);
    --surface-raised: #202e43;
    --border: var(--line);
    --text: var(--ink);
    --team-border: var(--line);
    --team-muted: var(--muted);
    --team-text: var(--ink);
    background: var(--bg);
}
:root[data-theme="dark"] .team-page {
    --team-border: var(--line);
    --team-muted: var(--muted);
    --team-text: var(--ink);
}
:root[data-theme="dark"] .sa-page {
    --border: var(--line);
    --text: var(--ink);
    --muted: inherit;
    --green-dark: #6ee7b7;
    --red-dark: #fda4af;
}
:root[data-theme="dark"] .platform-dashboard {
    --pd-text: var(--ink);
    --pd-muted: var(--muted);
    --pd-border: var(--line);
    --pd-surface: var(--panel);
}
:root[data-theme="dark"] .tenant-dashboard {
    --td-text: var(--ink);
    --td-muted: var(--muted);
    --td-border: var(--line);
}
:root[data-theme="dark"] :is(
    .topbar, .page-footer, .mobile-nav, .metric, table, .item-card, .login-card,
    .job-list-card, .job-export-mobile-card, .job-accordion, .job-accordion-toggle,
    .settings-section, .settings-section-toggle, .question-card, .setting-item-row,
    .jump-results, .search-select-button, .search-select-menu, .search-select-search-wrap,
    .schedule-add, .schedule-event, .upgrade-dialog, .pd-button, .pd-eyebrow,
    .pd-panel, .td-panel, .td-stat, .td-button, .photo-grid a,
    .inventory-row, .inventory-accordion, .inventory-accordion-toggle, .inventory-danger-zone,
    .team-summary-card, .team-panel, .team-modal-card, .team-modal-head, .team-modal-close,
    .team-check, .team-edit-button, .sa-super-badge, .sa-button, .sa-metric, .sa-tabs,
    .sa-panel, .sa-modal-card, .sa-modal-head, .sa-modal-close
) { background: var(--panel); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(input, select, textarea, .search-select-search,
    .sa-field input, .sa-field select, .sa-jump select,
    .team-field input[type="text"], .team-field input[type="email"],
    .team-field input[type="password"], .team-field input[type="tel"], .team-field select) {
    background: #101b2d; color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"] :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme="dark"] :is(.button, .icon-button, .mobile-logout-button, .quick-filter) {
    background: var(--panel); color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"] :is(.button.primary, .pd-button.primary, .td-button.primary, .sa-button.primary, .team-save, .mobile-nav .mobile-new) {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
:root[data-theme="dark"] :is(.button.primary:hover, .pd-button.primary:hover, .td-button.primary:hover) { background: var(--brand-hover, #1e40af); }
:root[data-theme="dark"] :is(
    th, .mobile-job-list, .company-brand-preview, kbd, .job-detail-item,
    .calendar-weekdays, .calendar-cell.outside-month, .question-edit,
    .question-card.editing .question-summary, .system-hidden-info, .pd-mini-summary,
    .job-accordion.open .job-accordion-toggle, .settings-section.open .settings-section-toggle,
    .inventory-accordion.open .inventory-accordion-toggle, .inventory-location-chip,
    .team-section, .sa-delete-stat
) { background: var(--surface-raised); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] td { border-bottom-color: var(--line); }
:root[data-theme="dark"] :is(
    tbody tr:hover, .button:not(.primary):not(.danger):not(.success):hover,
    .icon-button:hover, .mobile-logout-button:hover, .job-accordion-toggle:hover,
    .settings-section-toggle:hover, .search-select-button:hover,
    .inventory-handle:hover, .inventory-accordion-toggle:hover, .sa-button:not(.primary):hover
) { background: var(--surface-raised); }
:root[data-theme="dark"] :is(.search-select-option, .field label, .job-list-meta-value,
    .customer-preview-item span, .td-pipeline-name, .td-pipeline-total, .td-activity-table td,
    .mobile-nav a, .pd-table td, .pd-company, .pd-number, .pd-activity-title,
    .team-name, .team-check, .team-check strong, .team-field label.team-label,
    .sa-company-name, .sa-number, .sa-plan-name, .sa-check, .sa-tab) { color: var(--ink); }
:root[data-theme="dark"] :is(.search-select-value.placeholder, .search-select-arrow,
    .job-accordion-arrow, .settings-section-arrow, .customer-preview-item strong,
    .system-hidden-info, .locked-note, .td-empty, .pd-secondary, .td-secondary,
    .pd-activity-meta, .pd-activity-time, .inventory-handle, .inventory-accordion-arrow,
    .team-secondary, .team-section-head p, .team-check small, .team-help, .team-empty,
    .sa-storage-text, .sa-toggle-label) { color: var(--muted); }
:root[data-theme="dark"] :is(.job-number, .schedule-job, .schedule-edit, .tab.active, .pd-link, .td-job-link) { color: #5eead4; }
:root[data-theme="dark"] :is(.search-select.disabled .search-select-button) { background: var(--surface-raised); }
:root[data-theme="dark"] :is(
    .quick-filter.active, .quick-filter:hover, .search-select-option:hover,
    .search-select-option.keyboard-active, .search-select-option.selected,
    .jump-results a:hover, .jump-results [aria-selected="true"],
    .calendar-cell.today, .job-accordion-icon,
    .inventory-accordion-icon, .inventory-row.dragging, .sa-tab.active
) { background: #123c3a; color: #99f6e4; border-color: #2a6d64; }
:root[data-theme="dark"] .settings-jump-links > a.active { background: var(--brand); color: #fff; }
:root[data-theme="dark"] :is(.badge.standard, .badge.neutral, .qtag, .qtag.inactive, .pd-badge, .td-priority, .team-badge, .sa-badge) {
    background: var(--surface-raised); color: #cbd5e1; border-color: var(--line);
}
:root[data-theme="dark"] :is(.badge.high, .qtag.required, .flash.warning, .callout.warn, .pd-badge.warn, .td-priority.high, .team-badge.no-login, .sa-badge.warn) {
    background: #3c2c14; color: #fde68a; border-color: #947032;
}
:root[data-theme="dark"] :is(.badge.emergency, .badge.stale, .qtag.sensitive,
    .button.danger, .flash.error, .callout.danger, .status-overdue, .pd-badge.bad, .td-priority.emergency,
    .team-badge.disabled, .sa-badge.bad, .sa-delete-warning, .sa-button.danger) {
    background: #3d1e2a; color: #fda4af; border-color: #9f4760;
}
:root[data-theme="dark"] :is(.badge.ok, .qtag.active, .button.success, .flash.success, .status-completed, .pd-badge.good, .team-badge.login, .sa-badge.good) {
    background: #12392e; color: #a7f3d0; border-color: #387c62;
}
:root[data-theme="dark"] :is(.callout, .qtag.system, .status-in_progress, .team-permission, .sa-button.edit) {
    background: #173449; color: #bae6fd; border-color: #386c91;
}
:root[data-theme="dark"] :is(.plan-badge, .sa-badge.super) { background: #35264d; color: #ddd6fe; }
:root[data-theme="dark"] :is(.danger-text, .movement-negative, .inventory-danger-zone h2) { color: #fda4af; }
:root[data-theme="dark"] :is(.success-text, .movement-positive, .team-full-access) { color: #6ee7b7; }
:root[data-theme="dark"] .warning-text { color: #fde68a; }
/* Keep configurable status colours on the border; use legible text on dark surfaces. */
:root[data-theme="dark"] .status-badge { color: var(--ink) !important; }
:root[data-theme="dark"] :is(.progress-track, .td-pipeline-track) { background: var(--line); }
:root[data-theme="dark"] .responsive-table tbody tr { background: var(--panel); }
:root[data-theme="dark"] .dispatch-block { background: #203b5b; color: var(--ink); }
:root[data-theme="dark"] :is(.dispatch-block.internal, .dispatch-slot.occupied) { background: var(--surface-raised); }
:root[data-theme="dark"] .dispatch-block.status-completed { background: #12392e; }
:root[data-theme="dark"] :is(.dispatch-slot.overbooked, .dispatch-block.overbooked) { background: #3d1e2a; }
:root[data-theme="dark"] :is(.dispatch-slot.drag-over, .pod-drop.drag-over) { background: #12392e; }
:root[data-theme="dark"] .drop-active { background: #123c3a !important; }

:root[data-theme="dark"] :is(.team-edit-button, .mobile-header-logout-button) { color: #bae6fd; }
:root[data-theme="dark"] .mobile-header-logout-button:hover { background: var(--surface-raised); }
:root[data-theme="dark"] :is(input:focus, select:focus, textarea:focus, .search-select-button:focus,
    .search-select.open .search-select-button, .team-field input:focus, .team-field select:focus) { border-color: #5eead4; }
:root[data-theme="dark"] :is(button, a, summary):focus-visible { outline: 2px solid #5eead4; outline-offset: 3px; }
/* Native controls on white signing surfaces must keep their light colour scheme. */
:root[data-theme="dark"] :is(.signature-pad, .pod-canvas, .qr-box, .pod-signature) { color-scheme: light; }
