/* Deliberate night palette. Documents/images are never filtered or inverted. */
:root[data-theme=light] { color-scheme:light; }
html[data-theme=dark] :is(.statement-recurring-setup,.statement-recurring-panel,.statement-recurring-panel .statement-workflow-recipient){background:var(--night-panel)!important;color:var(--night-text)!important;border-color:var(--night-border)!important;}
.theme-control {display:inline-flex;align-items:center;gap:7px;letter-spacing:0;text-transform:none;font:600 13px/1.3 Arial,Helvetica,sans-serif;white-space:nowrap;margin:0;}
.theme-control select {width:auto;min-width:96px;min-height:44px;padding:9px 26px 9px 10px;border:1px solid #aebfce;border-radius:8px;font:inherit;color:#294b68;background:#fff;cursor:pointer;}
.theme-control select:focus-visible {outline:3px solid #2470cb;outline-offset:3px;}
:root[data-theme=dark] {color-scheme:dark;--night-bg:#101923;--night-panel:#182532;--night-raised:#213242;--night-input:#101e2a;--night-text:#e6edf4;--night-muted:#afc0d0;--night-border:#43586c;--night-link:#99ccff;--line:#43586c;--muted:#afc0d0;--ink:#e6edf4;--red:#d62b40;background:var(--night-bg);color:var(--night-text);}
html[data-theme=dark] body {background:var(--night-bg);color:var(--night-text);}
html[data-theme=dark] :is(dialog,.board,.topbar,.metrics>div,.reminder-card,.payment-summary,.statement-page,.statement-workflow,.filter-options,.address-suggestions-list,.company-library,.dialog-actions,.record-details-dialog .dialog-head) {background:var(--night-panel)!important;color:var(--night-text)!important;border-color:var(--night-border)!important;}
html[data-theme=dark] dialog::backdrop {background:#030910b8;}
html[data-theme=dark] :is(h1,h2,h3,h4,h5,h6,legend,label,dt,dd,summary,td strong,.topbar b,.empty span,.filter-option,.document-state,.file-evidence,.review-facts strong,.note-list-item,.record-details-fields dd):not(:where(.driver-statement-live *,.statement-final-sheet *)) {color:var(--night-text)!important;}
html[data-theme=dark] :where(small,.muted,.empty,.footnote,.summary-detail,.load-dispatcher,.dispatch-field-label,.route-zip,.history-event p,.history-event details,.address-policy,.address-suggestions-status,.address-google-attribution,.statement-help,.statement-help-text,.statement-list-hint,.statement-pilot-status,.statement-live-caption,#active-filter-count,td::before):not(:where(.driver-statement-live *,.statement-final-sheet *)) {color:var(--night-muted)!important;}
html[data-theme=dark] :where(input:not([type=checkbox]):not([type=radio]),select,textarea,[contenteditable=true]):not(:where(.driver-statement-live *,.statement-final-sheet *)) {background:var(--night-input)!important;color:var(--night-text)!important;border-color:#60788e!important;}
html[data-theme=dark] :is(input,textarea)::placeholder {color:#a5b7c8;opacity:1;}
html[data-theme=dark] :is(input:read-only,input:disabled,select:disabled,textarea:disabled) {background:#24313e!important;color:#acbac8!important;}
html[data-theme=dark] :is(input[type=checkbox],input[type=radio]) {accent-color:#e7465b;}
html[data-theme=dark] input::file-selector-button {background:#293e50;color:#e6edf4;border:1px solid #60788e;border-radius:4px;padding:6px 9px;}
/* Keep the fallback low-specificity so a component's dark semantic state can win. */
html[data-theme=dark] :where(button,.quiet,.icon-button,.paperwork-button):not(:where(.primary,.sidebar button,.driver-statement-live *,.statement-final-sheet *)) {background:var(--night-raised)!important;color:var(--night-text)!important;border-color:#60788e!important;}
html[data-theme=dark] :where(button,.quiet):where(:not(:disabled):hover):not(:where(.primary,.sidebar button,.driver-statement-live *,.statement-final-sheet *)) {background:#2d465b!important;border-color:#8daac3!important;}
html[data-theme=dark] button.primary {background:#cf263b!important;color:#fff!important;border-color:#f06a79!important;}
html[data-theme=dark] button.primary:hover:not(:disabled) {background:#af1e30!important;}
html[data-theme=dark] :is(button[aria-pressed=true],button[aria-current],.accounting-sections button[aria-current],.statement-workflow-steps [aria-current=step]):not(:where(.sidebar button,.summary-card)) {background:#2a5069!important;color:#fff!important;border-color:#8bbadd!important;}
html[data-theme=dark] :is(a,.document-preview-link,.record-profile-link):not(.brand):not(.sign-in):not(:where(.driver-statement-live *,.statement-final-sheet *)) {color:var(--night-link)!important;}
html[data-theme=dark] :is(.record-profile-link,.document-preview-link):not(:hover) {background:transparent!important;}
html[data-theme=dark] #statement-calculation-page .statement-recipient-row button.statement-recipient-name {background:transparent!important;border:0!important;color:var(--night-text)!important;}
html[data-theme=dark] :focus-visible {outline-color:#8dc8ff!important;}
html[data-theme=dark] ::selection {background:#386485;color:#fff;}
html[data-theme=dark] :is(th,.dispatch-comfort th,.statement-workflow-summary th):not(:where(.driver-statement-live *,.statement-final-sheet *)) {background:#213242!important;color:#c7d7e6!important;border-color:var(--night-border)!important;}
html[data-theme=dark] :is(td,tr,fieldset,hr,details,.form-section,.record-details-section,.parser-panel,.parser-field,.company-document-card,.statement-drafts-tabs,.statement-center-editor section,.statement-center-filter-row,.notes-editor details,.statement-document-sheet) {border-color:var(--night-border)!important;}
html[data-theme=dark] tbody tr:hover:not(:where(.driver-statement-live *,.statement-final-sheet *)) {background:#213444;}
html[data-theme=dark] :is(.filter-panel,.load-filter-rule,.load-note-card,#driver-document-checklist,.draft-file-preview,.reminder-preview,.history-event pre,.note-versions section,.statement-help-text,.statement-preview-totals>div,.statement-live-pane,.statement-workflow-steps>*,.statement-document-sheet,.notes-editor form>div:has(>.note-formatted),.document-dropzone,.parser-panel .parser-drop,#template-preview-result:not(:empty)) {background:#1d2e3d!important;color:var(--night-text)!important;border-color:var(--night-border)!important;}
html[data-theme=dark] :is(.document-dropzone.dragging,.document-dropzone:hover,.parser-panel .parser-drop.is-dragging,.parser-panel .parser-drop:focus-within,.address-suggestions-list [role=option]:hover,.address-suggestions-list [aria-selected=true],.statement-recipient-row[aria-selected=true],.statement-recipient-row:hover,.statement-workflow-rail [aria-current]) {background:#29475d!important;}
html[data-theme=dark] :is(.preview-note,.manual-note,.statement-workflow-blocker) {background:#352d1d!important;color:#f1d194!important;border-color:#c39b4e!important;}
html[data-theme=dark] :is(.notice,.load-notes-notice) {color:#9fe0bf;}
html[data-theme=dark] :is(.error,.notice.error,[role=alert]) {color:#ffadb5!important;}
html[data-theme=dark] :is(.badge,.reminder-state,.payment-unpaid,.file-review-missing,#identity) {background:#2b3b4a!important;color:#d2deea!important;}
html[data-theme=dark] :is(.badge.delivered,.file-review-approved,.payment-paid,.reminder-completed,.statement-workflow-result,.note-added) {background:#183e32!important;color:#aff0ce!important;}
html[data-theme=dark] :is(.badge.in_transit,.reminder-upcoming) {background:#233d60!important;color:#b8d7ff!important;}
html[data-theme=dark] :is(.badge.cancelled,.file-review-rejected,.payment-issue,.reminder-deleted,.note-removed) {background:#4a2933!important;color:#ffc2ca!important;}
html[data-theme=dark] :is(.file-review-pending,.payment-pending,.reminder-due,.reminder-missing_date) {background:#493b20!important;color:#f4d99c!important;}
html[data-theme=dark] .payment-warning {color:#f4d99c;}
html[data-theme=dark] .summary-card {--tint:#1d2e3d;--card-border:#43586c;}
html[data-theme=dark] .summary-card[aria-pressed=true] {outline:2px solid #8bbadd;outline-offset:2px;}
html[data-theme=dark] #preview-stage {background:#101923;border-color:var(--night-border);}
/* Keep actual paper previews legible and unchanged, including printed/exported sheets. */
html[data-theme=dark] :is(.driver-statement-live,.statement-final-sheet) {color-scheme:light;background:white;color:#183247;}
html[data-theme=dark] :is(.driver-statement-live,.statement-final-sheet) :is(th,td,strong,small,h1,h2,h3,label,dd,dt) {color:inherit;}
html[data-theme=dark] .driver-statement-live .statement-live-table th {background:#19364b;color:#fff;}
/* Entry page shares the preference, preserving the unmodified photographic asset. */
html[data-theme=light] .shell {color:#183247;background:linear-gradient(90deg,#f3f6f9f5,#f3f6f9dc),url('/images/axxe-night.webp') center/cover no-repeat;}
html[data-theme=light] .shell :is(.brand,footer) {color:#183247;background:#fffffff0;border-color:#becbd7;}
html[data-theme=light] .shell :is(.brand-caption,.header-label,.intro-copy,.entry-copy,.card-eyebrow,.access-note,.preview-label,.eyebrow,.setup-note) {color:#42596e;}
html[data-theme=light] .shell .entry-card {background:#ffffffed;border-color:#becbd7;border-top-color:#ce2230;}
html[data-theme=light] .shell .setup-note strong {color:#725017;}
html[data-theme=light] .shell .sign-in {background:#eaf0f6;color:#183247;border-color:#8ca4b8;}
.shell>.brand {flex-wrap:wrap;}
.shell>.brand .theme-control {margin-left:auto;}
@media(max-width:640px) {.account-controls .theme-control{flex:0 1 auto;width:auto!important;}.theme-control select{min-height:44px;}.shell>.brand .theme-control{font-size:12px;}}
html[data-theme=dark] .reminder-profile-group {background:var(--night-panel)!important;border-color:var(--night-border)!important;}
html[data-theme=dark] .reminder-profile-heading {background:var(--night-raised)!important;}
html[data-theme=dark] .shared-replacement-row {background:#352d1d!important;color:#f1d194!important;}
html[data-theme=dark] :is(.statement-rule-builder .load-filter-rule-controls>span,.statement-selection-bar>span:first-child,.statement-load-identity span) {color:var(--night-muted)!important;}
html[data-theme=dark] .eyebrow {color:#ff9aa8;}
html[data-theme=dark] .note-rich-editor {background:var(--night-input)!important;color:var(--night-text)!important;border-color:#60788e!important;}
html[data-theme=dark] .note-rich-editor:empty:before {color:#afc0d0;}
html[data-theme=dark] button.badge.delivered {background:#183e32!important;color:#aff0ce!important;}
html[data-theme=dark] button.badge.in_transit {background:#233d60!important;color:#b8d7ff!important;}
html[data-theme=dark] button.badge.cancelled {background:#4a2933!important;color:#ffc2ca!important;}
html[data-theme=dark] button.record-profile-link {background:transparent!important;color:#99ccff!important;}

/* Compact appearance picker retains a comfortable pointer/touch target. */
body .theme-control{position:relative;flex:0 0 44px!important;width:44px!important;min-width:44px;margin:0;}
body .theme-control .theme-icon{display:inline-flex;align-items:center;justify-content:center;width:44px!important;min-width:44px;min-height:44px;height:44px;padding:8px!important;border:1px solid #aebfce;border-radius:8px;background:#fff;color:#294b68;cursor:pointer;}
.theme-icon svg{width:28px;height:24px;flex:none;pointer-events:none;}
body .theme-control .theme-menu{position:absolute;z-index:100;top:calc(100% + 8px);right:0;display:grid;gap:4px;width:208px;max-width:calc(100vw - 24px);padding:6px;background:#fff;color:#183247;border:1px solid #aebfce;border-radius:10px;box-shadow:0 8px 28px #06162635;}
body .theme-control .theme-menu[hidden]{display:none;}
body .theme-control .theme-menu button{display:flex;align-items:center;justify-content:flex-start!important;gap:8px;text-align:left!important;min-height:44px;width:100%;padding:8px 10px!important;border:1px solid transparent;border-radius:6px;background:transparent;color:inherit;font:600 14px/1.3 Arial,Helvetica,sans-serif!important;white-space:nowrap!important;cursor:pointer;}
.theme-menu button:before{content:' ';width:16px;flex:none;}
.theme-menu button[aria-checked=true]:before{content:'✓';}
body .theme-control .theme-menu button:hover,body .theme-control .theme-menu button:focus-visible{background:#e9f1f7;}
html[data-theme=dark] body .theme-control .theme-menu{background:#182532;color:#e6edf4;border-color:#60788e;}
html[data-theme=dark] body .theme-control .theme-menu button[aria-checked=true]{background:#2a5069!important;color:#fff!important;}

/* Approved dark Dispatch scorecard palette. Presentation only. */
html[data-theme=dark] #dashboard-summary.dispatch-summary [data-summary=active] { --score-bg:#182f49; --score-hover:#203d5a; --score-accent:#72b7ff; --score-border:#365c82; }
html[data-theme=dark] #dashboard-summary.dispatch-summary [data-summary=completed] { --score-bg:#18372f; --score-hover:#20473d; --score-accent:#79d7aa; --score-border:#326b56; }
html[data-theme=dark] #dashboard-summary.dispatch-summary [data-summary=all] { --score-bg:#2a2943; --score-hover:#383653; --score-accent:#b9a8f5; --score-border:#59527b; }
html[data-theme=dark] #dashboard-summary.dispatch-summary [data-summary=delivered7] { --score-bg:#15363d; --score-hover:#1c4750; --score-accent:#70d2dc; --score-border:#326873; }
html[data-theme=dark] #dashboard-summary.dispatch-summary #dispatch-totals { --score-bg:#382e1e; --score-hover:#382e1e; --score-accent:#ecc47a; --score-border:#75603b; }
html[data-theme=dark] #dashboard-summary.dispatch-summary .summary-card { background:var(--score-bg)!important; border-color:var(--score-border)!important; border-left-color:var(--score-accent)!important; color:#f0f5fb!important; --tone:var(--score-accent); }
html[data-theme=dark] #dashboard-summary.dispatch-summary button.summary-card:hover { background:var(--score-hover)!important; border-color:var(--score-accent)!important; filter:none; }
html[data-theme=dark] #dashboard-summary.dispatch-summary button.summary-card[aria-pressed=true] { background:var(--score-hover)!important; border-color:var(--score-accent)!important; outline:2px solid var(--score-accent); outline-offset:2px; }
html[data-theme=dark] #dashboard-summary.dispatch-summary button.summary-card:focus-visible { outline:3px solid #eef6ff!important; outline-offset:4px; }
html[data-theme=dark] #dashboard-summary.dispatch-summary .summary-value { color:var(--score-accent)!important; }
html[data-theme=dark] #dashboard-summary.dispatch-summary :is(.summary-detail,.load-rpm) { color:#c2cddd!important; }

html[data-theme=dark] #dashboard-summary.dispatch-summary [data-summary=dispatch-fleet-map]{--score-bg:#372745;--score-hover:#49335c;--score-accent:#d4a5ff;--score-border:#70508a}
html[data-theme=dark] .broker-hold-warning{background:#382e1e;color:#f3d69e;border-color:#75603b}
html[data-theme=dark] .load-task-dialog{background:#182532;color:#e6edf4;border-color:#60788e}
html[data-theme=dark] .load-task-dialog :is(input,textarea){background:#101d29;color:#e6edf4;border-color:#60788e}

/* Workspace semantic palette. Form surfaces follow the theme; issued paper does not. */
:root[data-theme=dark] {
 --surface:var(--night-panel);--surface-soft:#1d2e3d;--surface-alt:var(--night-raised);
 --text:var(--night-text);--border:var(--night-border);--link:var(--night-link);
 --status-neutral-bg:#243747;--status-neutral-ink:#d2deea;--status-neutral-border:#60788e;
 --status-blue-bg:#233d60;--status-blue-ink:#b8d7ff;--status-blue-border:#6489b8;
 --status-green-bg:#183e32;--status-green-ink:#aff0ce;--status-green-border:#56947b;
 --status-amber-bg:#493b20;--status-amber-ink:#f4d99c;--status-amber-border:#aa8a4e;
 --status-red-bg:#4a2933;--status-red-ink:#ffc2ca;--status-red-border:#b16a78;
}
html[data-theme=dark] .tone-neutral {--tone:#afc0d0;--tint:#223342;--tone-hover:#2d4457;--card-border:#536d83;}
html[data-theme=dark] .tone-blue {--tone:#72b7ff;--tint:#182f49;--tone-hover:#203d5a;--card-border:#365c82;}
html[data-theme=dark] .tone-green {--tone:#79d7aa;--tint:#18372f;--tone-hover:#20473d;--card-border:#326b56;}
html[data-theme=dark] .tone-teal {--tone:#70d2dc;--tint:#15363d;--tone-hover:#1c4750;--card-border:#326873;}
html[data-theme=dark] .tone-amber {--tone:#ecc47a;--tint:#382e1e;--tone-hover:#493c27;--card-border:#75603b;}
html[data-theme=dark] .tone-red {--tone:#ffadb5;--tint:#422833;--tone-hover:#553440;--card-border:#875465;}
html[data-theme=dark] .tone-violet {--tone:#b9a8f5;--tint:#2a2943;--tone-hover:#383653;--card-border:#59527b;}
html[data-theme=dark] body .summary-card {background:var(--tint)!important;color:var(--night-text)!important;border-color:var(--card-border)!important;border-left-color:var(--tone)!important;}
html[data-theme=dark] body .summary-card:is(:hover,[aria-pressed=true]) {background:var(--tone-hover,var(--tint))!important;border-color:var(--tone)!important;filter:none;}
html[data-theme=dark] body .summary-card[aria-pressed=true] {outline-color:var(--tone);}
html[data-theme=dark] body .summary-card .summary-value {color:var(--tone)!important;}

/* The Services shortcut remains blue; create/save actions retain their red role. */
html[data-theme=dark] #fleet-services {background:#294d63!important;color:#fff!important;border-color:#83b5d1!important;}
html[data-theme=dark] #fleet-services:hover:not(:disabled) {background:#356680!important;border-color:#a7d3eb!important;}
html[data-theme=dark] :is(.statement-edit-paper,.statement-internal-costs,.statement-preparation-allocation,.maintenance-log-editor,.maintenance-log-confirm) {background:var(--night-panel)!important;color:var(--night-text)!important;border-color:var(--night-border)!important;}
html[data-theme=dark] .statement-workflow .statement-internal-costs {background:var(--surface-soft)!important;}
html[data-theme=dark] .statement-internal-costs>p {color:var(--night-muted);}
html[data-theme=dark] :is(.statement-paper-identity,.statement-totals-content dl,.statement-summary-subtotal,.statement-net) {border-color:#668aa3!important;}
html[data-theme=dark] :is(.statement-preparation-note,.workspace-request-wait,.loading-timing-summary,.loading-diagnostics pre,.md-notice) {background:#19374b;color:#cee7fa;border-color:#669cc5;}
html[data-theme=dark] :is(.document-card,.document-access-tree) {border-color:var(--night-border)!important;}

/* Shared status swatches apply equally to interactive buttons and read-only badges. */
html[data-theme=dark] :is(.document-review-collecting,.attention-status,.price-request-status,.badge.planned) {--state-bg:var(--status-neutral-bg);--state-ink:var(--status-neutral-ink);--state-border:var(--status-neutral-border);}
html[data-theme=dark] :is(.badge.in_transit) {--state-bg:var(--status-blue-bg);--state-ink:var(--status-blue-ink);--state-border:var(--status-blue-border);}
html[data-theme=dark] :is(.document-review-ready,.document-review-not_required,.attention-status.completed,.price-request-status.approved,.badge.delivered,.payment-paid) {--state-bg:var(--status-green-bg);--state-ink:var(--status-green-ink);--state-border:var(--status-green-border);}
html[data-theme=dark] :is(.document-review-pending,.document-review-replacement_pending,.attention-status.new,.payment-pending) {--state-bg:var(--status-amber-bg);--state-ink:var(--status-amber-ink);--state-border:var(--status-amber-border);}
html[data-theme=dark] :is(.document-review-needs_changes,.price-request-status.pending,button.has-unread,.badge.cancelled,.payment-issue) {--state-bg:var(--status-red-bg);--state-ink:var(--status-red-ink);--state-border:var(--status-red-border);}
html[data-theme=dark] body :is(.document-review-collecting,.document-review-ready,.document-review-not_required,.document-review-pending,.document-review-replacement_pending,.document-review-needs_changes,.attention-status,.price-request-status,button.has-unread,.badge.planned,.badge.in_transit,.badge.delivered,.badge.cancelled,.payment-paid,.payment-pending,.payment-issue) {background:var(--state-bg)!important;color:var(--state-ink)!important;border-color:var(--state-border)!important;}
html[data-theme=dark] body button:is(.paperwork-button,.badge,.has-unread):hover:not(:disabled) {box-shadow:inset 0 0 0 1px currentColor;}

/* Report actions and record links keep the same meanings in both themes. */
html[data-theme=dark] .rr-report button.rr-primary,
html[data-theme=dark] .manual-documents button.primary {background:#176b78!important;color:#fff!important;border-color:#72b9c2!important;}
html[data-theme=dark] .rr-report button.rr-primary:hover:not(:disabled),
html[data-theme=dark] .manual-documents button.primary:hover:not(:disabled) {background:#125563!important;border-color:#9ad6de!important;}
html[data-theme=dark] body :is(button.rr-text-link,button.analytics-record-link) {background:transparent!important;color:var(--night-link)!important;border-color:transparent!important;}
html[data-theme=dark] body :is(button.rr-text-link,button.analytics-record-link):hover {color:#c6e3ff!important;text-decoration:underline;}
html[data-theme=dark] :is(input,select,textarea)[aria-invalid=true],
html[data-theme=dark] .statement-payment-dialog .statement-payment-amounts input:invalid {border-color:#ff8995!important;box-shadow:0 0 0 1px #ff8995;}
html[data-theme=dark] .statement-payment-validation {color:#ffadb5!important;}
