/* FleetOps UI ---------------------------------------------------------------------------------------------
   Tokens: light on :root; dark via device preference (unless the user chose light) or an explicit choice.
   Layout: desktop full sidebar (collapsible) · tablet icon-only sidebar + 2-column grids · mobile bottom nav. */

:root {
  color-scheme: light;
  --bg: #f3f5f9; --panel: #ffffff; --panel-2: #f7f9fc; --text: #0f172a; --text-2: #475569; --muted: #64748b;
  --line: #e2e8f0; --line-2: #edf1f6;
  --brand: #1d4ed8; --brand-2: #1e40af; --brand-ink: #ffffff; --brand-soft: #e8efff; --focus: #2563eb;
  --red: #b42318; --red-soft: #fdecea; --amber: #a15c07; --amber-soft: #fef4e2;
  --green: #067647; --green-soft: #e6f6ee; --blue: #175cd3; --blue-soft: #e8f0fd; --grey-soft: #f1f4f8;
  --side: #0b1a33; --side-2: #12264a; --side-ink: #b6c3da; --side-mute: #7183a3; --side-active: #1b3769; --side-accent: #7cb4ff;
  --s1: #2a78d6; --s1-wash: rgba(42,120,214,.10); --grid: #e9edf3; --crit: #d03b3b; --good: #0ca30c; --warn: #fab219; --serious: #ec835a;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
  --shadow-lg: 0 14px 34px rgba(15,23,42,.16), 0 2px 6px rgba(15,23,42,.08);
  --radius: 12px; --radius-sm: 8px;
  --side-w: 256px; --side-w-mini: 76px; --appbar-h: 64px; --bottom-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120; --panel: #121a2b; --panel-2: #172033; --text: #e8edf5; --text-2: #c2cad8; --muted: #94a0b4;
    --line: #26314a; --line-2: #1e283d;
    --brand: #6ea8ff; --brand-2: #8fbcff; --brand-ink: #071226; --brand-soft: #172a4f; --focus: #8fbcff;
    --red: #f97066; --red-soft: #3a1d1b; --amber: #fdb022; --amber-soft: #3a2c12;
    --green: #47cd89; --green-soft: #15342a; --blue: #84adff; --blue-soft: #1a2a48; --grey-soft: #1c263a;
    --side: #070f21; --side-2: #0f1d38; --side-ink: #a9b8d3; --side-mute: #61739a; --side-active: #18325f;
    --s1: #3987e5; --s1-wash: rgba(57,135,229,.16); --grid: #222d43;
    --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120; --panel: #121a2b; --panel-2: #172033; --text: #e8edf5; --text-2: #c2cad8; --muted: #94a0b4;
  --line: #26314a; --line-2: #1e283d;
  --brand: #6ea8ff; --brand-2: #8fbcff; --brand-ink: #071226; --brand-soft: #172a4f; --focus: #8fbcff;
  --red: #f97066; --red-soft: #3a1d1b; --amber: #fdb022; --amber-soft: #3a2c12;
  --green: #47cd89; --green-soft: #15342a; --blue: #84adff; --blue-soft: #1a2a48; --grey-soft: #1c263a;
  --side: #070f21; --side-2: #0f1d38; --side-ink: #a9b8d3; --side-mute: #61739a; --side-active: #18325f;
  --s1: #3987e5; --s1-wash: rgba(57,135,229,.16); --grid: #222d43;
  --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.side :focus-visible, .bottom-nav :focus-visible { outline-color: var(--side-accent); }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; font-weight: 700; }
h2 { font-size: 16px; margin: 28px 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 12px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }
kbd { font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace; padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); }

/* ---------- Shell ---------- */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .18s ease; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 12px 12px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 17px; font-weight: 600; padding: 6px 8px 18px; letter-spacing: .2px; white-space: nowrap; }
.brand b { color: var(--side-accent); font-weight: 700; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: inline-grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); flex: none; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-mute); padding: 4px 10px 8px; font-weight: 600; white-space: nowrap; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side a { display: flex; align-items: center; gap: 12px; color: var(--side-ink); padding: 10px 12px; border-radius: 9px; font-weight: 500; white-space: nowrap; min-height: 42px; }
.side a .ic { opacity: .85; }
.side a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.side a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--side-accent); }
.side a.active .ic { opacity: 1; color: var(--side-accent); }
.side-collapse { margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 42px; border: 0; border-radius: 9px;
  background: transparent; color: var(--side-mute); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.side-collapse:hover { background: var(--side-2); color: #fff; }
.side-collapse .ic { transition: transform .18s ease; }
.side-close { margin-left: auto; color: var(--side-ink); }
.icon-btn.side-close { display: none; }
.scrim { display: none; }

/* Collapsed (desktop, remembered) and tablet share the icon-only rail */
.side-collapsed .layout { grid-template-columns: var(--side-w-mini) minmax(0, 1fr); }
.side-collapsed .side .side-text, .side-collapsed .side .brand-text, .side-collapsed .side .side-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.side-collapsed .side a, .side-collapsed .side-collapse { justify-content: center; padding: 10px 0; }
.side-collapsed .brand { justify-content: center; padding: 6px 0 22px; }
.side-collapsed .side-collapse .ic { transform: scaleX(-1); }

.shell { min-width: 0; display: flex; flex-direction: column; }
.appbar { position: sticky; top: 0; z-index: 30; height: var(--appbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.appbar-mark { display: none; width: 32px; height: 32px; }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--grey-soft); color: var(--text); }
.theme-sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-sun { display: inline-grid; } :root:not([data-theme="light"]) .theme-moon { display: none; } }
:root[data-theme="dark"] .theme-sun { display: inline-grid; } :root[data-theme="dark"] .theme-moon { display: none; }

.search { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.search input { margin: 0; padding: 10px 40px 10px 38px; border-radius: 10px; background: var(--panel-2); border-color: var(--line); height: 42px; }
.search input::-webkit-search-cancel-button { display: none; }
.search-ic { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.search-kbd { position: absolute; right: 10px; pointer-events: none; }
.search input:focus + .search-kbd, .search input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.search-mobile { display: none; }
.search-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 70vh; overflow-y: auto; padding: 6px; z-index: 60; }
.sp-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px 4px; }
.search-pop a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 8px; color: var(--text); min-height: 44px; justify-content: center; }
.search-pop a:hover, .search-pop a[aria-selected="true"] { background: var(--brand-soft); text-decoration: none; }
.sp-title { font-weight: 600; font-size: 13px; }
.sp-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pop .sp-all { color: var(--brand); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; }
.search-page-form { display: flex; gap: 10px; align-items: center; }
.search-page-form input { margin: 0; }
.result-list { padding: 6px; }
.result { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.result:hover { background: var(--panel-2); text-decoration: none; }
.result-title { font-weight: 600; }
.result-sub { font-size: 12px; color: var(--muted); }

.bell-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--crit);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--panel); }
.avatar-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--text); padding: 4px 8px 4px 4px; min-height: 42px;
  border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; }
.avatar-btn:hover { background: var(--grey-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--side-active); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .3px; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

.dd { position: relative; }
.dd-panel { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; }
.dd.open .dd-panel { display: block; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.notif-panel { width: 380px; }
.profile-panel { width: 290px; padding-bottom: 6px; }
.dd-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dd-head form { margin: 0; }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px 0; }
.notif-list { max-height: 400px; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 11px 16px; color: var(--text); border-bottom: 1px solid var(--line-2); min-height: 44px; }
.notif:hover { background: var(--panel-2); text-decoration: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif.unread .notif-dot { background: var(--s1); }
.notif.unread .notif-msg { font-weight: 600; }
.notif-msg { display: block; font-size: 13px; line-height: 1.4; }
.notif-time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.dd-foot { display: block; text-align: center; padding: 12px; font-size: 13px; font-weight: 600; border-top: 1px solid var(--line); }
.profile-card { display: flex; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.profile-name { font-weight: 650; }
.profile-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 16px 0; font-size: 12px; color: var(--text-2); }
.profile-row .ic { margin-top: 1px; color: var(--muted); }
.dd-sep { height: 1px; background: var(--line); margin: 12px 0 6px; }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--text); font-weight: 500; min-height: 44px; }
.dd-item:hover { background: var(--panel-2); text-decoration: none; }
.dd-item.danger { color: var(--red); }

.main { padding: 24px 28px 56px; min-width: 0; max-width: 1480px; width: 100%; }
.main:focus { outline: none; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.bottom-nav { display: none; }

/* ---------- Feedback ---------- */
.banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.banner.imp { background: var(--red); color: #fff; font-weight: 600; }
.banner.imp a { color: #fff; text-decoration: underline; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.flash.error { background: var(--red-soft); color: var(--red); border-color: transparent; }
.flash.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.notice { background: var(--amber-soft); color: var(--amber); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; }

/* ---------- Surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 6px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.grid.stretch { align-items: stretch; }
.section-gap { margin-top: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; }

/* Greeting */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hero h1 { font-size: 26px; display: flex; align-items: center; gap: 10px; }
.hero .greet-ic { width: 26px; height: 26px; color: var(--amber); }
.hero .date { color: var(--muted); font-weight: 500; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--text);
  display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
a.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.kpi.warn .kpi-ic { background: var(--amber-soft); color: var(--amber); }
.kpi.bad .kpi-ic { background: var(--red-soft); color: var(--red); }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 12px; padding: 1px 7px 1px 5px; border-radius: 999px; }
.delta.good { background: var(--green-soft); color: var(--green); }
.delta.bad { background: var(--red-soft); color: var(--red); }
.delta.flat { background: var(--grey-soft); color: var(--muted); }

/* Attention tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); display: flex;
  gap: 12px; align-items: flex-start; box-shadow: var(--shadow); min-width: 0; min-height: 44px; }
a.tile:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); transition: transform .12s; }
.tile .ti { width: 36px; height: 36px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.tile.warn .ti { background: var(--amber-soft); color: var(--amber); }
.tile.bad .ti { background: var(--red-soft); color: var(--red); }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.tile .l { color: var(--muted); font-size: 12px; font-weight: 500; }
.tile.zero { opacity: .72; box-shadow: none; }

.vehicle-strip { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: linear-gradient(120deg, var(--side) 0%, #173a73 100%);
  color: #e6eefc; border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.vehicle-strip .plate { font-size: 20px; font-weight: 700; letter-spacing: .5px; background: #fff; color: #111; padding: 4px 12px; border-radius: 6px;
  border: 2px solid #111; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.vehicle-strip .vs-meta { display: flex; gap: 22px; flex-wrap: wrap; }
.vehicle-strip .vs-meta div { font-size: 12px; color: #a9bbdb; }
.vehicle-strip .vs-meta strong { display: block; color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
.vehicle-strip a { color: #a9cbff; margin-left: auto; font-weight: 600; }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.quick a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 48px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.quick a:hover { border-color: var(--brand); text-decoration: none; color: var(--brand); }
.quick a .ic { color: var(--brand); }

.reminders { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; margin-bottom: 20px; }
.reminder { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); color: var(--text); display: block; }
a.reminder:hover { text-decoration: none; border-color: var(--brand); }
.reminder.warn { border-left-color: var(--warn); }
.reminder.bad { border-left-color: var(--crit); }
.reminder .r-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.reminder .r-big { font-size: 24px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.reminder .r-big small { font-size: 13px; font-weight: 500; color: var(--muted); }
.reminder .r-sub { font-size: 12px; color: var(--text-2); }
.status-ic { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.status-ic.good { color: var(--green); } .status-ic.warn { color: var(--amber); } .status-ic.bad { color: var(--red); }
.meter { display: block; height: 6px; background: var(--grey-soft); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--good); }
.meter.warn > span { background: var(--warn); } .meter.bad > span { background: var(--crit); }

/* Attention list (middle-row side panel) */
.alist { display: grid; gap: 2px; }
.aitem { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 8px; color: var(--text); min-height: 44px; }
a.aitem:hover { background: var(--panel-2); text-decoration: none; }
.aitem .ai-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.aitem.warn .ai-ic { background: var(--amber-soft); color: var(--amber); }
.aitem.bad .ai-ic { background: var(--red-soft); color: var(--red); }
.aitem .ai-label { flex: 1; min-width: 0; font-weight: 500; }
.aitem .ai-count { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.aitem.zero { color: var(--muted); }
.aitem.zero .ai-count { color: var(--muted); font-weight: 600; }

.aclear { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.aclear summary { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--green); min-height: 32px; list-style: none; }
.aclear summary::-webkit-details-marker { display: none; }
.aclear div { padding: 4px 0 2px 21px; }
.middle > .card { display: flex; flex-direction: column; }
.middle > .card > .chart { flex: 1; display: flex; flex-direction: column; }

/* Request tracker ("currently with") */
.tracker { display: grid; gap: 10px; }
.track { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text); }
a.track:hover { border-color: var(--brand); text-decoration: none; }
.track .tk-title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.track .tk-kind { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.track .tk-with { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.track .tk-with strong { color: var(--text); }
.pips { grid-column: 1 / -1; display: flex; gap: 3px; margin-top: 4px; }
.pips i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.pips i.done { background: var(--brand); } .pips i.now { background: var(--warn); } .pips i.bad { background: var(--crit); }
.with { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.with::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.with.done::before { background: var(--good); }
.with.bad::before { background: var(--crit); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); white-space: nowrap; position: sticky; top: 0; border-bottom: 1px solid var(--line); }
table tr:hover > td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--panel-2); }
.empty { padding: 20px; color: var(--muted); text-align: center; }
.card table th { position: static; }
.plate-link { font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; letter-spacing: .3px; white-space: nowrap; }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--crit); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.grey { background: var(--grey-soft); color: var(--muted); }

/* ---------- Forms ---------- */
form.inline { display: inline; }
.form { display: grid; gap: 14px; max-width: 680px; }
.form.wide { max-width: none; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); align-items: end; }
label { display: block; font-weight: 600; font-size: 13px; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; background: var(--panel);
  color: var(--text); margin-top: 5px; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 24%, transparent); }
input[readonly] { background: var(--grey-soft); color: var(--text-2); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; margin: 0 6px 0 0; accent-color: var(--brand); vertical-align: middle; }
textarea { min-height: 76px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin: 0; }
legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 8px; margin-top: 6px; }
.choice { display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 500;
  cursor: pointer; background: var(--panel); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.field-note { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; min-height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--brand-2); border-color: var(--brand-2); text-decoration: none; }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { padding: 5px 11px; font-size: 12px; min-height: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label { font-weight: 500; font-size: 12px; color: var(--muted); }
.filters select, .filters input { width: auto; min-width: 150px; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.seg a { padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--text-2); border-right: 1px solid var(--line); display: inline-flex; align-items: center; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--brand-soft); color: var(--brand); }
.seg a:hover { text-decoration: none; background: var(--panel-2); }

/* ---------- Timeline / steps / misc ---------- */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 14px 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--panel); }
.timeline li.reject::before { background: var(--red); }
.timeline li.override::before { background: var(--amber); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin: 0; }
.spec div { background: var(--panel); padding: 12px 14px; }
.spec dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.spec dd { margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.steps { display: flex; gap: 0; margin: 8px 0 16px; flex-wrap: wrap; }
.steps span { padding: 7px 13px; background: var(--grey-soft); color: var(--muted); font-size: 12px; font-weight: 600; border-right: 2px solid var(--bg); }
.steps span:first-child { border-radius: 7px 0 0 7px; }
.steps span:last-child { border-radius: 0 7px 7px 0; }
.steps span.done { background: var(--brand-soft); color: var(--brand); }
.steps span.now { background: var(--brand); color: var(--brand-ink); }
.steps span.bad { background: var(--red-soft); color: var(--red); }
.flagtext { color: var(--red); white-space: pre-line; font-size: 12px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.lock { color: var(--blue); font-size: 12px; font-weight: 600; }
details summary { cursor: pointer; font-weight: 600; }
.comment { background: var(--blue-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; }
.comment .who { font-size: 12px; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel-2); }
.photo-grid img { width: 100%; height: 120px; object-fit: cover; display: block; }
.photo-grid figcaption { font-size: 12px; padding: 6px 8px; }

/* ---------- Charts ---------- */
.chart { margin: 0; min-width: 0; }
.chart figcaption { margin-bottom: 12px; }
.chart-title { font-weight: 650; }
.chart-sub { font-size: 12px; color: var(--muted); }
.chart-empty { color: var(--muted); padding: 40px 0; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.cplot { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); }
.yaxis { position: relative; }
.yaxis span { position: absolute; right: 8px; transform: translateY(50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cplot-area { position: relative; border-bottom: 1px solid var(--muted); }
.grid-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--grid); }
.ref-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px solid var(--crit); z-index: 2; }
.ref-line b { position: absolute; right: 0; bottom: 2px; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--panel); padding: 0 4px; }
.cols { position: absolute; inset: 0; display: grid; gap: 2px; align-items: end; }
.col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.col:hover .bar, .col:focus .bar { filter: brightness(1.15); }
.bar { display: block; width: 100%; max-width: 24px; background: var(--s1); border-radius: 4px 4px 0 0; min-height: 0; }
.col-val { position: absolute; transform: translateY(-4px); font-size: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.xaxis { display: grid; margin-left: 44px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.xaxis span { text-align: center; white-space: nowrap; overflow: visible; }
.xaxis.rel { position: relative; height: 16px; display: block; }
.xaxis.rel span { position: absolute; transform: translateX(-50%); }
.xaxis.rel span:first-child { transform: none; }
.xaxis.rel span:last-child { transform: translateX(-100%); }
.lplot { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lplot .ln { fill: none; stroke: var(--s1); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.lplot .area { fill: var(--s1-wash); stroke: none; }
.dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--s1); box-shadow: 0 0 0 2px var(--panel); z-index: 3; }
.dot::after { content: ""; position: absolute; inset: -8px; }
.dot.below { background: var(--crit); }
.dot:hover, .dot:focus { transform: scale(1.3); }
.end-val { position: absolute; transform: translate(-100%, -150%); font-size: 11px; font-weight: 700; color: var(--text); background: var(--panel); padding: 0 3px; border-radius: 3px; z-index: 4; }
.chart-table { margin-top: 10px; font-size: 12px; }
.chart-table summary { font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px 0; }
.chart-table table { margin-top: 6px; }
.chart-table td, .chart-table th { padding: 4px 8px; }
.hbars { display: grid; gap: 8px; }
.hrow { display: grid; grid-template-columns: 22px minmax(90px, 42%) minmax(0, 1fr) 44px; align-items: center; gap: 10px; padding: 2px 0; border-radius: 6px; }
.hrow:hover { background: var(--panel-2); }
.hrank { width: 22px; height: 22px; border-radius: 50%; background: var(--grey-soft); color: var(--text-2); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.hrow:nth-child(1) .hrank { background: var(--brand); color: var(--brand-ink); }
.hlabel { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hlabel small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.htrack { height: 14px; background: var(--grey-soft); border-radius: 0 4px 4px 0; }
.hbar { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.hval { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.tip { position: fixed; z-index: 100; pointer-events: none; background: #0f172a; color: #fff; font-size: 12px; font-weight: 500; padding: 6px 9px; border-radius: 6px;
  box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .08s; max-width: 280px; }
.tip.on { opacity: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tip { background: #e8edf5; color: #0f172a; } }
:root[data-theme="dark"] .tip { background: #e8edf5; color: #0f172a; }

/* ---------- Public pages ---------- */
.login { max-width: 400px; margin: 9vh auto; padding: 0 16px; }
.login .brand { color: var(--text); justify-content: center; font-size: 22px; padding-bottom: 20px; }
.login .brand b { color: var(--brand); }
.demo td { padding: 4px 8px; font-size: 12px; }

/* ---------- Tablet: icon-only rail, 2-column grids ---------- */
@media (min-width: 641px) and (max-width: 1024px) {
  .layout { grid-template-columns: var(--side-w-mini) minmax(0, 1fr); }
  .side .side-text, .side .brand-text, .side .side-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .side a { justify-content: center; padding: 10px 0; min-height: 46px; }
  .brand { justify-content: center; padding: 6px 0 22px; }
  .side-collapse { display: none; }
  .appbar { padding: 0 16px; }
  .main { padding: 20px 20px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three, .grid.wide-left { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.wide-left > * { grid-column: 1 / -1; }
  .middle .alist { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .grid.three > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .avatar-name { display: none; }
  .icon-btn, .avatar-btn { min-width: 44px; min-height: 44px; }
}

/* ---------- Mobile: bottom navigation, stacked cards, 44px targets ---------- */
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100vh; transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg); z-index: 70; }
  .side-collapsed .side .side-text, .side-collapsed .side .brand-text, .side-collapsed .side .side-label { position: static; width: auto; height: auto; clip: auto; }
  .side-collapsed .side a { justify-content: flex-start; padding: 10px 12px; }
  .side-collapsed .brand { justify-content: flex-start; padding: 6px 8px 18px; }
  .side a { min-height: 48px; }
  .menu-open .side { transform: none; }
  .icon-btn.side-close { display: inline-grid; }
  .side-collapse { display: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 65; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .menu-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-open { overflow: hidden; }

  .appbar { padding: 0 8px 0 12px; gap: 8px; height: 58px; }
  .appbar-mark { display: inline-grid; }
  .search { display: none; position: absolute; left: 8px; right: 8px; top: 8px; max-width: none; z-index: 5; }
  .search-open .search { display: flex; }
  .search-kbd { display: none; }
  .search-mobile { display: inline-grid; }
  .icon-btn { width: 44px; height: 44px; }
  .avatar-btn { min-height: 44px; padding: 4px; }
  .avatar-name, .avatar-chev { display: none; }
  .notif-panel { position: fixed; left: 8px; right: 8px; top: 62px; width: auto; }
  .profile-panel { position: fixed; right: 8px; top: 62px; width: min(300px, calc(100vw - 16px)); }

  .main { padding: 16px 14px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--side); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(2,6,23,.25); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; min-width: 44px;
    color: var(--side-ink); font: 600 11px/1.1 inherit; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: center; padding: 4px 2px; }
  .bottom-nav a span, .bottom-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: #fff; background: var(--side-active); }
  .bottom-nav a.active .ic { color: var(--side-accent); }

  h1 { font-size: 20px; }
  .hero h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .grid.two, .grid.three, .grid.wide-left { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; padding: 8px 12px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }   /* 16px avoids iOS zoom-on-focus */
  .seg a { min-height: 40px; padding: 8px 12px; }
  .link-btn { min-height: 44px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .vehicle-strip a { margin-left: 0; }
  .hrow { grid-template-columns: 22px minmax(70px, 38%) minmax(0, 1fr) 40px; gap: 8px; }
  .topbar .filters select { min-width: 0; width: 100%; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  a.tile:hover, .dot:hover, .dot:focus { transform: none; }
}

@media print {
  .side, .appbar, .scrim, .bottom-nav, .no-print, .flash, .skip-link { display: none !important; }
  .layout { display: block; } .main { padding: 0; }
  .card, .tablewrap, .kpi { box-shadow: none; }
}
