/* Shared palette tokens. Components keep their layout and semantic status colors. */
:root,html[data-theme="dark"] {
  --theme-page:#080d13; --theme-bg:#0b1118; --theme-panel:#111c27;
  --theme-soft:#162735; --theme-raised:#1c3244; --theme-input:#101f2c;
  --theme-text:#e6eef6; --theme-muted:#a7bacb; --theme-line:#334858;
  --theme-accent:#88c8f2; --theme-accent-soft:#1b3b54; --theme-primary:#236fa6;
  --theme-header:#102d49; --theme-header-text:#e9f2fc; --theme-hover:#203b50;
  --theme-success-bg:#123c2e; --theme-success:#95e1ba;
  --theme-warning-bg:#423a22; --theme-warning:#efcf80;
  --theme-danger-bg:#452b31; --theme-danger:#f4b1ac;
  --theme-shadow:0 5px 18px #0002;
}
html[data-theme="light"] {
  --theme-page:#eaf0f7; --theme-bg:#f5f8fc; --theme-panel:#ffffff;
  --theme-soft:#edf4fb; --theme-raised:#e3edf8; --theme-input:#f8fbff;
  --theme-text:#21394f; --theme-muted:#5b7186; --theme-line:#d6e1ed;
  --theme-accent:#1968ac; --theme-accent-soft:#dfedfc; --theme-primary:#216fa8;
  --theme-header:#e5effa; --theme-header-text:#183d60; --theme-hover:#e6f0fb;
  --theme-success-bg:#e2f3e9; --theme-success:#28704b;
  --theme-warning-bg:#fff0cd; --theme-warning:#825e15;
  --theme-danger-bg:#fbe7e5; --theme-danger:#a13f37;
  --theme-shadow:0 5px 18px #274c7010;
}
html[data-theme="comfort"] {
  --theme-page:#100d0b; --theme-bg:#17120e; --theme-panel:#211a14;
  --theme-soft:#2c2119; --theme-raised:#3b2b1e; --theme-input:#1c1510;
  --theme-text:#f0e1cf; --theme-muted:#c5ab90; --theme-line:#56402e;
  --theme-accent:#f0b16c; --theme-accent-soft:#49301b; --theme-primary:#9b5425;
  --theme-header:#2c1e14; --theme-header-text:#f2d6b4; --theme-hover:#3a291d;
  --theme-success-bg:#2b3422; --theme-success:#c0d49c;
  --theme-warning-bg:#49351a; --theme-warning:#edc27b;
  --theme-danger-bg:#472920; --theme-danger:#efb09a;
  --theme-shadow:0 5px 18px #0003;
}

/* The theme is applied to login, workspace, dialogs and vehicle screens alike. */
html[data-theme] body {
  --navy:var(--theme-text); --ink:var(--theme-text); --muted:var(--theme-muted);
  --border:var(--theme-line); --bg:var(--theme-bg); --blue:var(--theme-accent);
  color:var(--theme-text); background:var(--theme-page);
}
html[data-theme] body.portal-open { color-scheme:inherit; }
html[data-theme] #shell { background:var(--theme-bg); border-color:var(--theme-line); }
html[data-theme] #shell :is(.platform-header,.area-nav) { background:var(--theme-header); }
html[data-theme] #shell :is(.platform-wordmark,.platform-wordmark small) { color:var(--theme-header-text); }
html[data-theme] #shell .sidebar { background:var(--theme-panel); border-color:var(--theme-line); }
html[data-theme] #shell :is(.area-button,.icon-button,.switch-user) { color:var(--theme-header-text); }
html[data-theme] #shell .area-button.active { background:var(--theme-panel); color:var(--theme-accent); border-color:var(--theme-line); }
html[data-theme] #shell :is(.area-button,.icon-button,.site-button,.nav-button):hover { color:var(--theme-accent); background:var(--theme-hover); }
html[data-theme] #shell :is(.area-section-title,.nav-subgroup-title) { color:var(--theme-text); }
html[data-theme] #shell #module-nav .site-button,html[data-theme] #shell #document-shortcuts .nav-button { color:var(--theme-muted); }
html[data-theme] #shell #module-nav .site-button.active,html[data-theme] #shell #document-shortcuts .nav-button.active { color:var(--theme-accent); background:var(--theme-accent-soft); }
html[data-theme] #shell .account-avatar { background:var(--theme-accent-soft); color:var(--theme-accent); }
html[data-theme] #shell .library-mark { background:var(--theme-accent-soft); color:var(--theme-accent); }
html[data-theme] :is(.document-panel,.profile-card,.role-card,.folder-card,.metric-card,.vehicle-health-card,.permission-matrix,dialog,.toast,.vehicle-sheet,.vehicle-info-card,.vehicle-summary-card,.vehicle-history) {
  color:var(--theme-text) !important; background:var(--theme-panel) !important; border-color:var(--theme-line) !important;
}
html[data-theme] .vehicle-sheet { --ink:var(--theme-text); --muted:var(--theme-muted); --border:var(--theme-line); }
html[data-theme] :is(.help-box,.welcome-card,.profile-portrait,.device-specification-tooltip,.info-note,.dropzone,.demo-banner,.vehicle-upcoming,.vehicle-more > div) {
  background:var(--theme-soft); color:var(--theme-text); border-color:var(--theme-line);
}
html[data-theme] body :is(input,select,textarea,.search) { color:var(--theme-text); background:var(--theme-input); border-color:var(--theme-line); accent-color:var(--theme-primary); }
html[data-theme] body input::placeholder,html[data-theme] body textarea::placeholder { color:var(--theme-muted); }
html[data-theme] body .search input { background:transparent; }
html[data-theme] body :is(.secondary,.small-button:not(.primary):not(.danger)) { color:var(--theme-accent) !important; background:var(--theme-soft) !important; border-color:var(--theme-line) !important; }
html[data-theme] body .primary { background:var(--theme-primary); color:white; }
html[data-theme] body .primary:hover { filter:brightness(1.1); }
html[data-theme] body :is(.secondary,.small-button:not(.primary):not(.danger)):hover { background:var(--theme-hover) !important; }
html[data-theme] body :is(button,a,summary,input,select,textarea):focus-visible { outline-color:var(--theme-accent); }
html[data-theme] body :is(th,td,.record-details > div,.vehicle-sheet-header,.vehicle-sheet-footer,.vehicle-sheet-expanded,.vehicle-extra,.vehicle-info-card h3,.vehicle-history > h3,.vehicle-summary-card) { border-color:var(--theme-line); }
html[data-theme] body th { background:var(--theme-soft); color:var(--theme-muted); }
html[data-theme] body td { color:var(--theme-text); }
html[data-theme] body tr:hover td { background:var(--theme-hover); }
html[data-theme] :is(#shell,#modal) :is(h1,h2,h3,h4,.record-details dd,.profile-fields dd,.metric-card > strong,.doc-name,.record-name,.library-folder,.history-entry > div:first-child,.permission-matrix td:first-child,.role-card > div:first-child,.vehicle-summary-row,.vehicle-mini-timeline strong) { color:var(--theme-text); }
html[data-theme] :is(#shell,#modal) :is(.breadcrumb,.breadcrumb strong,.portal-label,footer,.table-subtitle,.record-details dt,.profile-fields dt,.profile-identity p,.profile-card-footer p,.profile-role-list strong,.profile-access-note,.profile-devices-note,.profile-no-access,.profile-access-grid ul,.secure-platform,.welcome-card p,.library-title p,.help-box p,.calendar-hint,.calendar-footer,.metric-card > span,.metric-card > small,.modal-intro,.stack-form label,.form-grid label,.roles-fieldset legend,.roles-fieldset > p,.history-entry > p,.role-card > p,.role-card > small,.dashboard-intro,.vehicle-summary-empty,.vehicle-summary-row time,.vehicle-mini-timeline p,.vehicle-notes,.vehicle-sheet-meta,.vehicle-sheet-identity p,.vehicle-sheet-footer) { color:var(--theme-muted); }
html[data-theme] :is(#shell,#modal) :is(.text-button,.path-link,.history-entry summary,.help-box button,.kicker,.welcome-company,.profile-identity small,.profile-access-grid h3,.vehicle-summary-link,.vehicle-sheet-back,.vehicle-sheet h3 .icon,.vehicle-sheet-meta .icon,.fleet-priority-jump) { color:var(--theme-accent); }
html[data-theme] .profile-tabs button { color:var(--theme-muted); }
html[data-theme] .profile-tabs button[aria-selected="true"] { background:var(--theme-accent-soft); color:var(--theme-accent); }
html[data-theme] :is(.profile-tabs button:hover,.vehicle-more button:hover) { background:var(--theme-hover); color:var(--theme-text); }
html[data-theme] .vehicle-more summary { background:var(--theme-soft); color:var(--theme-accent); border-color:var(--theme-line); }
html[data-theme] .vehicle-more button { color:var(--theme-text); }
html[data-theme] .vehicle-sheet-header { background:transparent; }
html[data-theme] .vehicle-extra > summary { color:var(--theme-accent); }
html[data-theme] .vehicle-deadline-row small { background:var(--theme-accent-soft); color:var(--theme-accent); }
html[data-theme] .vehicle-deadline-row small.is-due { background:var(--theme-warning-bg); color:var(--theme-warning); }
html[data-theme] .change-grid pre { color:var(--theme-text); background:var(--theme-soft); }
html[data-theme] .document-preview { background:var(--theme-panel); }
html[data-theme] :is(.status-chip.active,.status-chip.available,.alert-badge.green,.session-status) { background:var(--theme-success-bg); color:var(--theme-success); }
html[data-theme] :is(.status-chip.maintenance,.status-chip.repair,.alert-badge.yellow) { background:var(--theme-warning-bg); color:var(--theme-warning); }
html[data-theme] :is(.status-chip.inactive,.status-chip.retired,.alert-badge.gray) { background:var(--theme-raised); color:var(--theme-muted); }
html[data-theme] :is(.status-chip.out_of_service,.alert-badge.red) { background:var(--theme-danger-bg); color:var(--theme-danger); }
html[data-theme] body :is(.danger-text,.form-error) { color:var(--theme-danger); }
html[data-theme] :is(#shell,#modal) .stack-form > p:not(.form-error) { color:var(--theme-muted); }
html[data-theme] :is(#shell,#modal) .form-error { color:var(--theme-danger); }
html[data-theme] .status-chip.admin { background:var(--theme-accent-soft); color:var(--theme-accent); }

/* Agenda and calendar use the same palette, including their expanded view. */
html[data-theme] .fleet-calendar.is-expanded { background:var(--theme-panel); }
html[data-theme] :is(.calendar-grid-wrap,.calendar-day,.calendar-footer,.fleet-priority-group,.fleet-priority-item,.calendar-day-event) { border-color:var(--theme-line); }
html[data-theme] :is(.calendar-weekdays,.fleet-priority-item,.calendar-day-event) { color:var(--theme-text); background:var(--theme-soft); }
html[data-theme] .calendar-day { background:var(--theme-panel); }
html[data-theme] .calendar-day.outside-month { background:var(--theme-bg); }
html[data-theme] :is(.calendar-weekdays span,.calendar-day-number,.calendar-view-label,.calendar-nav-button,.calendar-more,.fleet-priority-vehicle,.fleet-priority-item time,.fleet-priority-empty) { color:var(--theme-muted); }
html[data-theme] .calendar-view-label { border-color:var(--theme-line); }
html[data-theme] .calendar-day-event span { color:var(--theme-muted); }
html[data-theme] .calendar-day.is-today .calendar-day-number { background:var(--theme-primary); color:white; }
html[data-theme] .calendar-day:hover,html[data-theme] .fleet-priority-item:hover { background:var(--theme-hover); }
html[data-theme] .calendar-event { background:var(--theme-accent-soft); color:var(--theme-accent); }
html[data-theme] :is(.calendar-event.overdue,.calendar-event.urgent) { background:var(--theme-danger-bg); color:var(--theme-danger); }
html[data-theme] .calendar-event.upcoming { background:var(--theme-warning-bg); color:var(--theme-warning); }
html[data-theme] .calendar-event.clear { background:var(--theme-success-bg); color:var(--theme-success); }
html[data-theme] .fleet-priority-heading h3 span { background:var(--theme-raised); color:var(--theme-text); }
html[data-theme] .fleet-priority-status { color:var(--theme-success); }
html[data-theme] :is(.fleet-priority-item.overdue,.fleet-priority-item.urgent) .fleet-priority-status { color:var(--theme-danger); }
html[data-theme] .fleet-priority-item.upcoming .fleet-priority-status { color:var(--theme-warning); }

/* Preference selector next to the account switcher. */
.appearance-picker { position:relative; display:inline-flex; align-items:center; color:var(--theme-accent); }
.appearance-account-controls { display:flex; align-items:center; gap:8px; max-width:100%; }
html[data-theme] #appearance-mode { display:flex; align-items:center; gap:7px; min-height:37px; padding:8px 10px; border:1px solid var(--theme-line); border-radius:7px; background:var(--theme-panel); color:var(--theme-text); font-size:11px; white-space:nowrap; }
.appearance-picker svg { display:block; width:18px; height:18px; flex:0 0 18px; }
.appearance-chevron { color:var(--theme-muted); font-size:10px; margin-left:3px; }
html[data-theme] #appearance-options { position:absolute; right:0; top:calc(100% + 8px); z-index:100; display:grid; gap:4px; min-width:215px; padding:7px; background:var(--theme-panel); color:var(--theme-text); border:1px solid var(--theme-line); border-radius:9px; box-shadow:var(--theme-shadow); }
html[data-theme] #appearance-options[hidden] { display:none; }
html[data-theme] #appearance-options button { display:flex; align-items:center; justify-content:flex-start; gap:10px; padding:11px 9px; border:0; border-radius:6px; background:var(--theme-panel); color:var(--theme-text); font-size:12px; text-align:left; white-space:nowrap; }
html[data-theme] #appearance-options button:hover,html[data-theme] #appearance-options button:focus-visible { background:var(--theme-hover); color:var(--theme-text); }
html[data-theme] #appearance-options button[aria-checked="true"] { background:var(--theme-accent-soft); color:var(--theme-accent); }
.appearance-check { margin-left:auto; visibility:hidden; }
[aria-checked="true"] > .appearance-check { visibility:visible; }
html[data-theme] #shell .header-right { flex-wrap:wrap; justify-content:flex-end; max-width:100%; }

/* Login follows the saved mode, without changing its controls or account flow. */
html[data-theme] .login-screen,html[data-theme] .login-right { background:var(--theme-bg); color:var(--theme-text); }
html[data-theme] .login-brand { background:var(--theme-header); color:var(--theme-header-text); }
html[data-theme] #login .login-brand :is(h1,p,small,.eyebrow,.login-sites span) { color:var(--theme-header-text); }
html[data-theme] #login :is(h2,label) { color:var(--theme-text); }
html[data-theme] #login :is(.login-form > p,.login-form > small) { color:var(--theme-muted); }

/* Vehicle collection: at most three cards per row. */
.document-folders-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; padding:0 24px 20px; }
.document-folder-card { display:flex; flex-direction:column; min-width:0; border:1px solid var(--theme-line); border-radius:10px; background:var(--theme-panel); }
.document-folder-open { display:grid; justify-content:stretch; gap:9px; width:100%; padding:18px; border:0; border-radius:10px; background:transparent; color:var(--theme-text); text-align:left; }
.document-folder-open:hover { background:var(--theme-hover); }
.document-folder-open > .icon { width:32px; height:32px; color:var(--theme-accent); }
.document-folder-open strong { font-size:14px; line-height:1.5; overflow-wrap:anywhere; }
.document-folder-open span { color:var(--theme-muted); font-size:11px; }
.document-folder-actions { display:flex; justify-content:flex-end; gap:4px; padding:0 10px 9px; }
.document-folder-actions .icon-button { width:30px; height:30px; }
.folder-files-heading { padding:0 24px; margin:4px 0 16px; font-size:14px; font-weight:600; }
.folder-browser-empty { padding:0 24px 20px; margin:0; color:var(--theme-muted); font-size:12px; line-height:1.7; }
@media(max-width:1000px) { .document-folders-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) { .document-folders-grid { grid-template-columns:minmax(0,1fr); padding:0 14px 16px; }.folder-files-heading,.folder-browser-empty { padding-left:14px; padding-right:14px; } }

.vehicle-cards-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; padding:0 24px 24px; }
.vehicle-card { min-width:0; border:1px solid var(--theme-line); border-radius:12px; background:var(--theme-panel); box-shadow:var(--theme-shadow); overflow:hidden; padding:16px; }
.vehicle-card-top { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:10px; color:var(--theme-muted); }
.vehicle-card-image { display:block; width:100%; padding:8px 20px; border:0; border-radius:9px; background:radial-gradient(ellipse,var(--theme-soft),transparent 75%); }
.vehicle-brand-logo { display:block; width:150px; max-width:100%; height:76px; object-fit:contain; margin:0 auto; }
html:is([data-theme="dark"],[data-theme="comfort"]) .vehicle-brand-logo { filter:invert(1); }
.vehicle-brand-unknown { display:grid; place-items:center; width:70px; height:70px; margin:3px auto; border:2px solid var(--theme-line); border-radius:50%; color:var(--theme-muted); background:var(--theme-soft); font:500 46px/1 Arial,sans-serif; }
.vehicle-brand-custom { display:block; margin-top:10px; }
.vehicle-brand-custom[hidden] { display:none; }
.vehicle-card-image:hover { background:var(--theme-hover); }
.vehicle-card-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.vehicle-card-heading .doc-name { font-size:21px; font-weight:700; letter-spacing:-.04em; }
.vehicle-card-heading > span { color:var(--theme-muted); font-size:9px; text-align:right; }
.vehicle-card-model { margin:9px 0 5px; font-size:12px; font-weight:600; overflow-wrap:anywhere; }
.vehicle-card-type { color:var(--theme-muted); font-size:10px; margin:0 0 15px; }
.vehicle-card-facts { margin:0; padding:12px 0; border-top:1px solid var(--theme-line); border-bottom:1px solid var(--theme-line); display:grid; gap:9px; }
.vehicle-card-facts > div { display:flex; justify-content:space-between; gap:12px; font-size:10px; }
.vehicle-card-facts dt { color:var(--theme-muted); }
.vehicle-card-facts dd { margin:0; text-align:right; color:var(--theme-text); overflow-wrap:anywhere; }
.vehicle-card-footer { display:flex; align-items:center; justify-content:space-between; gap:8px; padding-top:12px; }
.vehicle-card-footer .text-button { font-size:10px; padding:0; }
.vehicle-card-footer .text-button .icon { width:13px; height:13px; }
.vehicle-card-footer .row-actions { gap:2px; }
.vehicle-card-footer .icon-button { width:29px; height:29px; }
@media(max-width:1150px) { .vehicle-cards-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) {
  .vehicle-cards-grid { grid-template-columns:minmax(0,1fr); padding:0 14px 16px; }
  html[data-theme] #shell .header-right { gap:6px; }
  html[data-theme] #appearance-mode { padding:7px; gap:5px; font-size:10px; }
  html[data-theme] #appearance-options { left:0; right:auto; }
  .appearance-picker svg { width:16px; height:16px; flex-basis:16px; }
}
