/* Time-based screen theme. Printed documents retain their light appearance. */
@media screen {
    :root[data-theme="dark"] {
        color-scheme: dark;
        --bg: #111318;
        --panel: #1b1e25;
        --text: #edf0f5;
        --muted: #a4adbc;
        --line: #373e4c;
        --accent: #71d8c6;
        --accent-dark: #a2e9dc;
        --danger: #ffaaa4;
        --danger-bg: #3a2227;
        --success-bg: #19332c;
        --success: #89dfb2;
    }

    html[data-theme="dark"] :is(.dashboard, .static-page, .todo-page, .accounting-page) {
        background: var(--bg);
        color: var(--text);
    }

    html[data-theme="dark"] :is(button, input, textarea, select, .todo-back-link,
        .team-member, .recurring-todo-item, .accounting-import-diagnostics,
        .accounting-inline-editable.is-editing, .accounting-manual-button, .accounting-import-button,
        .accounting-attachment-item button, .relationship-table-wrap, .kitchen-keys-table-wrap,
        .kitchen-key-comment-input, .database-table, .keyboard-shortcuts kbd) {
        background: var(--panel);
        color: var(--text);
        border-color: var(--line);
    }

    html[data-theme="dark"] :is(.dashboard-hero h1, .dashboard-card, .dashboard-card strong,
        .static-content p, .static-content li, .capital-card h3, .capital-block h3, .capital-faq h3,
        .team-member-content h3, .team-member-content dd, .team-member-content dd a,
        .todo-bullet, .recurring-todo-check strong, label, .accounting-verification-metadata dd,
        .accounting-attachment-dropzone span, .kitchen-keys-header h1, .gift-key-panel h2,
        .gift-key-created code, .kitchen-keys-summary strong, .relationship-stats-heading h2,
        .relationship-stats-grid strong, .relationship-hit, .config-help, .config-help pre,
        .kitchen-keys-section-title, .database-dump h2, .kitchen-keys-table code,
        .table-amount, .database-table summary, .database-table-grid pre,
        .swish-content h3, .swish-details summary, .swish-env-item h6) {
        color: var(--text);
    }

    html[data-theme="dark"] :is(.dashboard-hero p, .dashboard-card span, .recurring-todo-form p,
        .dashboard-recurring-todos h2, .static-content h2, .todo-editor h2,
        .todo-later-panel > summary, .todo-later-panel > summary small,
        .recurring-todos-section h2, .team-member-content dt,
        .kitchen-keys-summary span, .kitchen-keys-summary small, .relationship-stats-grid span,
        .relationship-table th, .relationship-hit small, .kitchen-keys-table th,
        .kitchen-key-comment-status, .kitchen-key-comment-status[data-state="saving"],
        .table-meta, .database-dump-heading code, .database-table summary strong,
        .database-table-grid th, .capital-table th, .swish-details > .swish-section-summary,
        .swish-quick-links h2, .swish-environments span) {
        color: var(--muted);
    }

    html[data-theme="dark"] :is(.dashboard-card, .capital-card, .capital-block, .capital-faq article,
        .todo-notes, .todo-inline-edit-form, .todo-editor, .accounting-import-section,
        .accounting-import-diagnostics-details, .capital-table th, .capital-table td,
        .relationship-table th, .relationship-table td, .kitchen-keys-table th, .kitchen-keys-table td,
        .database-table-grid th, .database-table-grid td, .swish-quick-links, .swish-env-item,
        .swish-env-item pre, .swish-flow-variants article, .swish-logo-rules article) {
        border-color: var(--line);
    }

    html[data-theme="dark"] :is(.capital-card, .capital-block, .capital-faq article, .list-pane,
        .todo-notes, .todo-inline-edit-form, .todo-dropzone, .dropzone,
        .migration-checklist li, .migration-prompt, .accounting-attachment-dropzone,
        .accounting-balance-summary span, .accounting-attachment-links a,
        .kitchen-keys-summary article, .relationship-stats-grid article, .relationship-table th,
        .config-help, .kitchen-keys-table th, .database-table summary, .swish-env-item pre,
        .email-checks li, .team-member-photo) {
        background: var(--panel);
        color: var(--text);
    }

    html[data-theme="dark"] :is(button:hover, button.secondary:hover, .dashboard-card:hover,
        .todo-bullet.is-file-drag-over > details, .todo-dropzone:hover, .todo-dropzone.dragging,
        .dropzone:hover, .dropzone.dragging, .accounting-manual-button:hover,
        .accounting-manual-button:focus-visible, .accounting-import-button:hover,
        .accounting-import-button:focus-visible, .accounting-attachment-links a:hover,
        .accounting-attachment-dropzone:hover, .accounting-attachment-dropzone:focus-within,
        .accounting-attachment-dropzone.is-file-drop-target, .accounting-table tr.is-attachment-drop-target) {
        background: #29303c;
    }

    html[data-theme="dark"] :is(.recurring-todo-item.is-completed, .accounting-table tr.is-handled,
        .gift-key-panel, .gift-key-created, .retention-card, .source-pill.is-admin) {
        background: var(--success-bg);
        border-color: #345a49;
    }

    html[data-theme="dark"] :is(.status-pill.is-idle, .source-pill.is-order) {
        background: #2c293c;
        color: var(--text);
    }

    html[data-theme="dark"] :is(.todo-notes, .source-pill.is-admin) { color: var(--text); }
    html[data-theme="dark"] .accounting-balance-action button { background: #354353; color: var(--text); }
    html[data-theme="dark"] .accounting-inline-editable.has-save-error { background: var(--danger-bg); }
    html[data-theme="dark"] button.danger { background: var(--danger-bg); color: var(--danger); }
    html[data-theme="dark"] button.danger:hover { background: #522c33; }
    html[data-theme="dark"] .email-form button { color: #111318; }
    html[data-theme="dark"] .email-notice-error { background: #3a3020; border-color: #b68b50; }
    html[data-theme="dark"] .swish-quick-links a { color: var(--accent); }
    html[data-theme="dark"] .swish-quick-links a:hover { color: var(--accent-dark); }
    html[data-theme="dark"] :is(#oversikt[open], .swish-content h5) { border-color: var(--line); }
    html[data-theme="dark"] .swish-order-toggle { background: #606979; border-color: #929bab; box-shadow: 0 0 0 4px var(--panel); }
    html[data-theme="dark"] .swish-order-toggle:hover { background: #778297; }

    html[data-theme="dark"] .dashboard-bookkeeping-link {
        min-height: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: #fff;
    }
    html[data-theme="dark"] .dashboard-bookkeeping-link:hover {
        background: transparent;
        text-decoration: underline;
        text-underline-offset: 4px;
    }

    html[data-theme="dark"] :is(.admin-back-arrow, .todo-back-link) { color: var(--muted); }
    html[data-theme="dark"] :is(.admin-back-arrow:hover, .todo-back-link:hover) { color: var(--text); }
    html[data-theme="dark"] :is(input, textarea, select):focus-visible { outline-color: var(--accent); }
    html[data-theme="dark"] .annual-wheel-checklist li::before { background: var(--panel); }
    html[data-theme="dark"] .mileage-print { background: var(--panel); color: var(--text); }
    html[data-theme="dark"] :is(.mileage-print-subtitle, .mileage-print-meta span,
        .mileage-print-details span, .mileage-signature span) { color: var(--muted); }
    html[data-theme="dark"] :is(.mileage-print-table th, .mileage-print-table td,
        .mileage-print-table tfoot th, .mileage-notes p, .mileage-signature) { border-color: var(--line); }

}
