/* Shared palette. Components use roles so public pages and the workspace stay in sync. */
:root {
    color-scheme:light;
    --bg:#f5f7f8;
    --panel:#ffffff;
    --panel-soft:#f0f4f5;
    --hover:#eaf0f2;
    --border:#dde5e9;
    --border-strong:#bdcbd3;
    --input-border:#bdcbd3;
    --text:#243640;
    --muted:#5b707b;
    --muted-strong:#455e6b;
    --placeholder:#617580;
    --primary:#237c80;
    --primary-hover:#1b686c;
    --on-primary:#ffffff;
    --accent-text:#216f75;
    --primary-soft:#e6f2f1;
    --accent-border:#c1ddda;
    --success:#286c50;
    --success-bg:#eaf4ee;
    --success-border:#cee3d6;
    --warning:#865c24;
    --warning-bg:#fbf3e6;
    --warning-border:#eadcbe;
    --danger:#a13e4b;
    --danger-bg:#fbefef;
    --danger-border:#ebced3;
    --info:#386984;
    --info-bg:#edf4f8;
    --info-border:#d0e0ea;
    --chrome:rgb(255 255 255 / 95%);
    --shadow:0 2px 8px rgb(29 51 64 / 3%);
    --shadow-float:0 16px 48px rgb(29 51 64 / 12%);
    --backdrop:rgb(19 30 40 / 40%);
    --chart:#579b9c;
    --chart-strong:#347e83;
    --chart-soft:#95c0bf;
    --radius:14px;
}

:root[data-theme="dark"] {
    color-scheme:dark;
    --bg:#121a21;
    --panel:#19232c;
    --panel-soft:#202d37;
    --hover:#293944;
    --border:#2d3c47;
    --border-strong:#465b68;
    --input-border:#485d69;
    --text:#e0e8ed;
    --muted:#a0b2bd;
    --muted-strong:#bed0d9;
    --placeholder:#91a5b1;
    --primary:#8bc9c5;
    --primary-hover:#a1d5d1;
    --on-primary:#152c31;
    --accent-text:#92cdc9;
    --primary-soft:#203c40;
    --accent-border:#35575a;
    --success:#9acdb1;
    --success-bg:#20392f;
    --success-border:#355447;
    --warning:#dbbe87;
    --warning-bg:#373226;
    --warning-border:#544a35;
    --danger:#e4a5af;
    --danger-bg:#3c2b34;
    --danger-border:#60414c;
    --info:#a5c6dc;
    --info-bg:#233643;
    --info-border:#3c5464;
    --chrome:rgb(25 35 44 / 95%);
    --shadow:0 2px 8px rgb(0 0 0 / 8%);
    --shadow-float:0 18px 50px rgb(0 0 0 / 24%);
    --backdrop:rgb(5 12 18 / 64%);
    --chart:#649fa0;
    --chart-strong:#91c8c4;
    --chart-soft:#436c72;
}

/* One compact, keyboard-accessible switch; its selected icon indicates the mode. */
.theme-toggle {
    position:relative; display:inline-flex; flex:0 0 auto; align-items:center;
    height:38px; padding:3px; gap:2px; border:1px solid var(--border);
    border-radius:10px; background:var(--panel-soft); color:var(--muted);
}
.theme-toggle::before {
    content:""; position:absolute; top:3px; left:3px; width:30px; height:30px;
    border:1px solid var(--border); border-radius:7px; background:var(--panel);
    box-shadow:var(--shadow); transition:transform 180ms ease;
}
.theme-toggle-option { position:relative; display:grid; place-items:center; width:30px; height:30px; }
.theme-toggle-option svg { width:17px; height:17px; }
.theme-toggle-sun { color:var(--accent-text); }
[data-theme="dark"] .theme-toggle::before { transform:translateX(32px); }
[data-theme="dark"] .theme-toggle-sun { color:var(--muted); }
[data-theme="dark"] .theme-toggle-moon { color:var(--accent-text); }
.theme-toggle:hover { border-color:var(--border-strong); }
.theme-toggle--mobile { display:none; }
.login-header { display:flex; align-items:center; justify-content:space-between; gap:18px; margin-bottom:45px; }
.login-header .login-brand { margin:0; }
@media(max-width:1100px) {
    .theme-toggle--desktop { display:none; }
    .theme-toggle--mobile { display:inline-flex; margin-left:auto; }
    .mobile-topbar-row .mobile-nav { margin-left:0; }
}
@media(max-width:480px) {
    .public-header { gap:10px; }
    .public-body .public-header nav { gap:8px; flex-wrap:nowrap; justify-content:flex-end; min-width:0; }
    .public-header .brand { gap:0; flex-shrink:0; }
    .public-header .brand strong { display:none; }
    .public-header .brand-mark { width:34px; height:34px; flex-basis:34px; border-radius:9px; font-size:10px; }
    .public-header .btn-primary { padding:9px 12px; min-height:38px; }
    .public-header .btn-primary .ui-icon { display:none; }
    .mobile-topbar-row .mobile-brand-title { font-size:12px; }
    .mobile-topbar-row { gap:8px; }
    .mobile-nav summary span { display:none; }
    .mobile-nav summary { min-width:38px; min-height:38px; padding:8px; justify-content:center; }
    .login-header { margin-bottom:24px; }
}
@media(max-width:360px) {
    .public-body .public-header { flex-wrap:wrap; row-gap:14px; }
    .public-body .public-header nav { gap:8px; flex:1 0 100%; justify-content:space-between; }
    .public-header .brand { gap:8px; }
    .public-header .brand-mark { width:32px; height:32px; flex-basis:32px; }
    .public-header .brand strong { display:block; width:auto; max-width:none; flex-shrink:0; font-size:12px; }
}
@media(prefers-reduced-motion:reduce) { .theme-toggle::before { transition:none; } }
@media print { .theme-toggle { display:none!important; } }

/* Browser printing always uses a light, legible paper palette. */
@media print {
    :root, :root[data-theme="dark"] {
    color-scheme:light;
    --bg:#f5f7f8;
    --panel:#ffffff;
    --panel-soft:#f0f4f5;
    --hover:#eaf0f2;
    --border:#dde5e9;
    --border-strong:#bdcbd3;
    --input-border:#bdcbd3;
    --text:#243640;
    --muted:#5b707b;
    --muted-strong:#455e6b;
    --placeholder:#617580;
    --primary:#237c80;
    --primary-hover:#1b686c;
    --on-primary:#ffffff;
    --accent-text:#216f75;
    --primary-soft:#e6f2f1;
    --accent-border:#c1ddda;
    --success:#286c50;
    --success-bg:#eaf4ee;
    --success-border:#cee3d6;
    --warning:#865c24;
    --warning-bg:#fbf3e6;
    --warning-border:#eadcbe;
    --danger:#a13e4b;
    --danger-bg:#fbefef;
    --danger-border:#ebced3;
    --info:#386984;
    --info-bg:#edf4f8;
    --info-border:#d0e0ea;
    --chrome:rgb(255 255 255 / 95%);
    --shadow:0 2px 8px rgb(29 51 64 / 3%);
    --shadow-float:0 16px 48px rgb(29 51 64 / 12%);
    --backdrop:rgb(19 30 40 / 40%);
    --chart:#579b9c;
    --chart-strong:#347e83;
    --chart-soft:#95c0bf;
    --radius:14px;
    }
}

/* Accounting: calm, compact handover workspace using the shared palette. */
.accounting-workspace { display:grid; gap:24px; min-width:0; }
.accounting-workspace .page-heading { margin:0; }
.accounting-period { margin:0; }
.accounting-filter-grid { display:grid; grid-template-columns:minmax(150px,1fr) minmax(145px,1fr) minmax(125px,1fr) auto; gap:16px; align-items:end; }
.accounting-filter-grid [hidden] { display:none; }
.accounting-filter-grid .btn-primary { min-height:44px; }
.accounting-period-caption { margin:16px 0 0; }
.accounting-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); }
.accounting-metrics>div { padding:22px 24px; min-width:0; }
.accounting-metrics>div+div { border-left:1px solid var(--border); }
.accounting-metrics span,.accounting-metrics small { display:block; color:var(--muted); font-size:12px; line-height:1.6; }
.accounting-metrics strong { display:block; font-size:25px; letter-spacing:-.7px; line-height:1.5; font-weight:650; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.accounting-metrics strong small { display:inline; font-size:15px; font-weight:500; }
.accounting-export-grid { display:grid; grid-template-columns:1fr 1fr; gap:24px; align-items:start; min-width:0; }
.accounting-export-grid .page-card { margin:0; min-width:0; }
.accounting-export-grid h2 { font-size:21px; margin:18px 0 8px; letter-spacing:-.4px; }
.accounting-export-grid p { color:var(--muted); line-height:1.65; font-size:13px; }
.accounting-card-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.accounting-card-icon { width:40px; height:40px; display:grid; place-items:center; border:1px solid var(--border); background:var(--panel-soft); border-radius:11px; color:var(--accent-text); }
.accounting-card-icon .ui-icon { width:21px; height:21px; }
.accounting-package-list { margin:22px 0; }
.accounting-package-list>div { display:flex; justify-content:space-between; gap:20px; padding:10px 0; border-bottom:1px solid var(--border); font-size:13px; }
.accounting-package-list dt { color:var(--muted); }
.accounting-package-list dd { margin:0; font-weight:600; text-align:right; }
.accounting-preflight { border:1px solid var(--border); border-radius:10px; padding:16px; margin:18px 0; background:var(--panel-soft); font-size:13px; color:var(--muted-strong); }
.accounting-preflight ul { margin:10px 0; padding-left:18px; line-height:1.7; }
.accounting-preflight summary { font-weight:600; color:var(--text); cursor:pointer; }
.accounting-checks { max-height:310px; overflow-y:auto; }
.accounting-checks>li+li { margin-top:16px; }
.accounting-consent { display:flex; align-items:flex-start; gap:10px; line-height:1.6; font-size:12px; color:var(--muted-strong); margin:16px 0; }

.accounting-handover .btn-primary { width:100%; justify-content:center; }
.accounting-download-row { display:flex; gap:18px; align-items:center; justify-content:space-between; padding:17px 0; border-bottom:1px solid var(--border); text-decoration:none; color:var(--text); }
.accounting-download-row:last-of-type { border-bottom:0; padding-bottom:0; }
.accounting-download-row>span:first-child { min-width:0; }
.accounting-download-row strong { font-size:13px; font-weight:600; display:block; }
.accounting-download-row small { color:var(--muted); font-size:12px; line-height:1.5; display:block; margin-top:4px; }
.accounting-download-row:hover strong { color:var(--accent-text); }
.accounting-format { flex-shrink:0; display:flex; gap:8px; align-items:center; font-size:10px; font-weight:600; letter-spacing:.6px; color:var(--muted); }
.accounting-format .ui-icon { width:17px; height:17px; }
.accounting-inline-note { margin:16px 0 0; padding:12px 16px; background:var(--panel-soft); border-radius:8px; }
.accounting-empty { padding:30px 24px; color:var(--muted); font-size:13px; }
.accounting-empty strong { color:var(--text); font-weight:500; }
.accounting-scope { color:var(--muted); font-size:12px; line-height:1.8; }
.accounting-scope summary { cursor:pointer; color:var(--muted-strong); }
.accounting-hash { display:block; overflow-wrap:anywhere; white-space:normal; font-size:12px; }
.accounting-document-info { display:flex; justify-content:space-between; align-items:center; gap:20px; margin-bottom:24px; }
.accounting-document-info p { color:var(--muted); font-size:13px; margin:8px 0; }
.accounting-document-info .btn-secondary { flex-shrink:0; }
@media(max-width:1200px) { .accounting-metrics>div { padding:18px 16px; } .accounting-metrics strong { font-size:22px; } }
@media(max-width:1000px) {
  .accounting-export-grid { grid-template-columns:1fr; }
  .accounting-filter-grid { grid-template-columns:1fr 1fr; }
  .accounting-metrics { grid-template-columns:1fr 1fr; }
  .accounting-metrics>div:nth-child(3) { border-left:0; }
  .accounting-metrics>div:nth-child(n+3) { border-top:1px solid var(--border); }
}
@media(max-width:540px) {
  .accounting-workspace { gap:18px; }
  .accounting-filter-grid { grid-template-columns:1fr; gap:14px; }
  .accounting-card-heading { align-items:flex-start; }
  .accounting-card-heading .status-badge { white-space:normal; text-align:right; }
  .accounting-metrics strong { font-size:20px; }
  .accounting-metrics>div { padding:16px 12px; }
  .accounting-metrics span { min-height:38px; }
  .accounting-document-info { flex-direction:column; align-items:flex-start; }
  .accounting-package-list>div { flex-wrap:wrap; gap:5px 14px; }
  .accounting-package-list dd { overflow-wrap:anywhere; }
}

.revenue-bar.revenue-bar-negative { background:var(--warning); }

.accounting-history-pages { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; padding:18px; font-size:12px; color:var(--muted); }
.accounting-download-row[aria-disabled="true"] { opacity:.5; cursor:default; }

/* Reporting controls share the existing light/dark tokens. */
.revenue-workspace { display:grid; gap:var(--space-6,24px); min-width:0; }
.revenue-workspace .page-heading,.revenue-workspace .metric-grid { margin:0; }
.revenue-controls { display:flex; align-items:center; flex-wrap:wrap; gap:16px; justify-content:space-between; }
.revenue-year-form { display:flex; align-items:center; gap:10px; }
.revenue-year-form label { color:var(--muted); font-size:13px; }
.revenue-year-form select { width:100px; min-height:42px; }
.revenue-legacy summary { cursor:pointer; font-weight:650; color:var(--text); line-height:1.6; }
.revenue-legacy p { color:var(--muted); font-size:13px; line-height:1.7; margin-top:12px; }
.revenue-legacy-list { display:grid; gap:12px; margin-top:18px; }
.revenue-legacy-list>div { display:flex; gap:16px; align-items:center; flex-wrap:wrap; padding-top:12px; border-top:1px solid var(--border); }
.revenue-legacy-list strong { margin-left:auto; font-size:14px; }
.revenue-year-form button { white-space:nowrap; }
.revenue-workspace .metric-value { overflow-wrap:anywhere; }
form[aria-busy="true"] button[data-submitting] { cursor:progress; }
@media(max-width:600px) {
    .revenue-controls { align-items:stretch; }
    .revenue-controls>nav:first-child { width:100%; display:flex; }
    .revenue-controls>nav:first-child a { flex:1; text-align:center; padding:9px 10px; }
    .revenue-legacy-list>div { gap:10px; }
    .revenue-legacy-list .btn-secondary { width:100%; justify-content:center; }
}
/* Fade only new content; navigation stays steady and form submits stay native. */
@keyframes content-arrive { from { opacity:.8; } to { opacity:1; } }
main.content { animation:content-arrive 140ms ease-out; }
@media(prefers-reduced-motion:reduce) {
    main.content { animation:none; }
}

/* A visible scanner entry without an overlay on the workspace. */
.sidebar .scanner-nav,.mobile-nav-panel .scanner-nav{background:var(--primary-soft);border:1px solid var(--border);margin-top:10px;color:var(--primary)}
.scanner-nav span{font-size:12px}.scanner-nav small{font-size:8px;letter-spacing:.07em;margin-left:auto;font-weight:700}.sidebar .scanner-nav .ui-icon{flex-shrink:0}

.vehicle-technical { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.vehicle-technical summary { color: var(--text); font-weight: 600; cursor: pointer; }
.vehicle-technical[open] summary { margin-bottom: 1.25rem; }

/* Legal navigation wraps consistently, including narrow login and public pages. */
.app-footer>span:last-child,.public-footer nav,.auth-footer,.legal-page-nav{flex-wrap:wrap;row-gap:10px}
