:root { color-scheme:light; }
.dashboard-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:16px; }
.dashboard-worklist .panel-header,.dashboard-worklist .filters { flex-wrap:wrap; gap:10px; }
.dashboard-worklist .task-row { gap:16px; }
.dashboard-worklist .task-row>div { min-width:0; overflow-wrap:anywhere; }
.theme-setting { display:flex; align-items:center; gap:24px; color:#687386; font-size:13px; }
.theme-toggle { display:flex; position:relative; isolation:isolate; align-items:center; justify-content:space-between; width:104px; height:38px; padding:3px; border:1px solid #e2e6eb; border-radius:22px; background:#e9edf2; color:#465064; cursor:pointer; }
.theme-toggle::before { content:""; position:absolute; z-index:-1; width:48px; top:3px; bottom:3px; left:3px; border-radius:18px; background:white; box-shadow:0 1px 3px #17203318; transition:transform .18s ease; }
.theme-toggle[aria-checked=true]::before { transform:translateX(48px); }
.theme-toggle>span { display:grid; place-items:center; width:48px; }
.theme-toggle svg { width:20px; height:20px; }
.theme-toggle:focus-visible { outline:2px solid #1875f0; outline-offset:3px; }
.theme-toggle[aria-checked=false] .theme-sun,.theme-toggle[aria-checked=true] .theme-moon { color:#152438; }
@media(prefers-reduced-motion:reduce) { .theme-toggle::before { transition:none; } }

html[data-theme=dark] {
    color-scheme:dark;
    --ui-page:#111827; --ui-surface:#1b2535; --ui-raised:#233044; --ui-input:#151f2e;
    --ui-border:#35445b; --ui-text:#e2e9f3; --ui-muted:#a8b7ca; --ui-link:#86baff;
}
html[data-theme=dark] body { background:var(--ui-page); color:var(--ui-text); }
html[data-theme=dark] :where(*) { border-color:var(--ui-border); }
html[data-theme=dark] :is(.sidebar,.topbar,.panel,.stat-card,.detail-card,.record-box,.login-card,.account-form,
    .timeline-dialog,.field-type-dialog,.email-reader,.icon-picker-panel,.status-select-options,.builder-field,
    .field-editor,.record-form-section,.task-card,.task-worklist,.settings-card) { background:var(--ui-surface); color:var(--ui-text); }
html[data-theme=dark] :is(h1,h2,h3,h4,label,.detail-value,.task-row strong,.timeline-event-heading,
    .event-heading,.automation-name,.field-type-list>a,.builder-field-preview,.status-select-button) { color:var(--ui-text); }
html[data-theme=dark] :is(a,.order-link,.back-link,.record-link,.status-summary a,.timeline-attachments a) { color:var(--ui-link); }
html[data-theme=dark] :is(.muted,small,.page-header p,.task-meta,.detail-label,.timeline-date,.timeline-day,
    .timeline-time,.event-time,.timeline-event-time,.record-count,.result-count,.field-help,.theme-setting,
    .account-form .helptext,.empty-state p,.empty-state,.brand small,.search,.automation-table small,
    .timeline-pagination,.record-deadline,.timeline-email-preview,.email-kicker,.timeline-changes,
    .timeline-task-meta,.timeline-change-list,.timeline-event-meta) { color:var(--ui-muted); }
html[data-theme=dark] :is(.form-control,input:where(:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]):not([type=submit])),
    textarea,select,.search,.rich-text-editor,.rich-editor,.status-select-button,.builder-preview-control) {
    background:var(--ui-input); color:var(--ui-text); border-color:var(--ui-border);
}
html[data-theme=dark] :is(input,textarea)::placeholder { color:#91a2ba; opacity:1; }
html[data-theme=dark] :is(.order-table th,.order-table thead,.list-count,.order-count,.table-heading,
    .automation-table-header,.email-metadata,.builder-group,.builder-group>header,.entry-aside,.entry-dialog-header,
    .entry-toolbar,.editor-toolbar,.rich-text-toolbar,.record-save-feedback,.timeline-controls,.task-worklist-header,
    .automation-check-grid label,.automation-help-card code,.field-type-list .builder-preview-control) {
    background:var(--ui-raised); color:var(--ui-muted);
}
html[data-theme=dark] :is(.nav-item,.nav-item span,.icon-option,.icon-picker-trigger,
    .secondary-button,.button-link.secondary,.rich-toolbar button,.editor-toolbar button,.entry-aside button:not(.primary-button)) { color:var(--ui-muted); }
html[data-theme=dark] :is(.secondary-button,.button-link.secondary,.icon-picker-trigger,.icon-picker-close,
    .filename-variables button,.email-attachments a,.rich-toolbar button,.entry-aside button:not(.primary-button),.filters a) { background:var(--ui-raised); border-color:var(--ui-border); }
html[data-theme=dark] :is(.nav-item.active,.nav-item:hover,.status-summary a[aria-current],.filters a.active,
    .filters a:hover,.status-select-option:hover,.status-select-option[aria-selected=true],.icon-option:hover,
    .builder-add-box) { background:#263e5c; color:#a6ccff; }
html[data-theme=dark] :is(.icon-picker-grid .icon-option) { background:var(--ui-surface); color:var(--ui-text); }
html[data-theme=dark] .icon-picker-grid .icon-option:has(input:checked) { background:#1875f0; color:white; }
html[data-theme=dark] .status-select-option { background:var(--ui-surface); color:var(--ui-text); }
html[data-theme=dark] .status-select-option:is(:hover,:focus,[aria-selected=true]) { background:#263e5c; }
html[data-theme=dark] :is(.record-box[open]>summary,.status-summary h2,.status-summary .status-summary-total) { border-color:var(--ui-border); }
html[data-theme=dark] .header-status .status-select-button { background:var(--status-color); color:var(--status-text); }
html[data-theme=dark] .header-status .status-select-button .order-status { color:inherit; }
html[data-theme=dark] :is(.primary-button,.button-link:not(.secondary),.login-button,.brand-mark) { color:white; }
html[data-theme=dark] .stat-card.blue { background:#1b3658; }
html[data-theme=dark] .stat-card.red { background:#462a35; }
html[data-theme=dark] .stat-card.green { background:#1d3c36; }
html[data-theme=dark] .stat-card.gray { background:#2a3345; }
html[data-theme=dark] .stat-label { color:var(--ui-muted); }
html[data-theme=dark] .stat-number { color:var(--ui-text); }
html[data-theme=dark] :is(.errorlist,.field-error,.error,.login-error,.record-deadline.overdue,[data-field-save-error],.automation-error) { color:#ffadb5; }
html[data-theme=dark] :is(.notice.error,.record-save-feedback.error,.login-error) { background:#472b35; border-color:#854455; }
html[data-theme=dark] :is(.has-error .form-control,.form-control.is-invalid) { background:#36222c; border-color:#df7585; }
html[data-theme=dark] :is(.notice.success,.automation-success) { color:#90e5bb; }
html[data-theme=dark] .notice.success { background:#173c32; }
html[data-theme=dark] .theme-toggle { background:#303c50; border-color:var(--ui-border); color:#c5d1e1; }
html[data-theme=dark] .theme-toggle::before { background:#536782; }
html[data-theme=dark] .theme-toggle[aria-checked=true] .theme-moon { color:white; }
html[data-theme=dark] dialog::backdrop { background:#030915b3; }
