:root {
    --bg: #0f172a;            /* slate-900 page background */
    --bg-2: #111c33;          /* slightly lifted */
    --surface: #1e293b;       /* slate-800 cards */
    --surface-2: #243449;     /* hover / inputs */
    --border: #334155;        /* slate-700 */
    --border-soft: #2a3a52;
    --text: #e2e8f0;          /* slate-200 */
    --text-muted: #94a3b8;    /* slate-400 */
    --text-dim: #64748b;      /* slate-500 */
    --accent: #2563eb;        /* corporate blue-600 */
    --accent-hover: #1d4ed8;  /* blue-700 */
    --accent-soft: rgba(37, 99, 235, .14);
    --accent-bright: #93c5fd; /* blue-300 for text-on-dark */
    --accent-text: #ffffff;   /* text on solid accent */
    --danger: #f43f5e;
    --warning: #f59e0b;
    --success: #22c55e;
    --info: #38bdf8;
    --sidebar-w: 248px;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
    overflow-x: clip;   /* stop stray horizontal scroll */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    letter-spacing: -0.011em;
    font-weight: 600;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { color: #bfdbfe; text-decoration: underline; text-underline-offset: 2px; }

/* Crisp stroke icons (Lucide-style) used via <svg class="ico"><use/></svg> */
.ico, .svg-ico {
    width: 1.05em; height: 1.05em;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    flex: 0 0 auto; vertical-align: -0.16em;
}
.svg-ico-lg { width: 1.4em; height: 1.4em; }

/* ---------------- App shell ---------------- */
/* Sidebar is position:fixed (out of flow), so .app must NOT be flex — otherwise
   .main would be full-width AND margin-left-shifted, overflowing by the sidebar
   width. Keep .main a normal block that fills the space left of its margin. */
.app { height: 100vh; overflow: hidden; }   /* fixed shell — only .content scrolls */

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .2s ease;
}

.sidebar-brand {
    display: block; text-align: center;
    padding: .75rem .6rem .65rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-logo {
    width: 100%; max-width: 100%; height: auto; display: block;
}

/* Show the correct logo for the active theme (dark logo on dark, light on light).
   !important so these always beat the higher-specificity `.sidebar-brand .brand-logo`
   rule above, which sets display:block on both logo <img>s. */
.logo-for-light { display: none !important; }
:root[data-theme="light"] .logo-for-dark { display: none !important; }
:root[data-theme="light"] .logo-for-light { display: block !important; }

.sidebar-nav { padding: .75rem .6rem; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-section {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
    color: var(--text-dim); padding: 1rem .8rem .4rem;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .8rem; border-radius: 9px;
    color: var(--text-muted); font-weight: 500; margin-bottom: 2px;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.sidebar-nav a .ico { width: 20px; text-align: center; font-size: 1rem; opacity: .9; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
/* Red count badge on a nav item (e.g. defects needing action). */
.sidebar-nav a .nav-badge {
    margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
    min-width: 19px; height: 19px; padding: 0 5px;
    background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1;
    border-radius: 999px; box-shadow: 0 0 0 0 rgba(244,63,94,.5); animation: nav-badge-pulse 1.8s ease-in-out infinite;
}
@keyframes nav-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244,63,94,.5); }
    50%      { box-shadow: 0 0 0 5px rgba(244,63,94,0); }
}
@media (prefers-reduced-motion: reduce) { .sidebar-nav a .nav-badge { animation: none; } }
.sidebar-nav a.active {
    background: var(--accent-soft); color: var(--accent-bright);
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav a.active .ico { color: var(--accent-bright); }

/* Buttons pinned to the bottom of the sidebar (Settings for all, Admin for admins). */
.sidebar-foot { margin-top: auto; padding: .75rem .6rem; border-top: 1px solid var(--border); }
.sidebar-foot .foot-link {
    display: flex; align-items: center; gap: .75rem; width: 100%;
    padding: .6rem .8rem; border-radius: 9px;
    color: var(--text-muted); font: inherit; font-weight: 600;
    text-align: left; background: transparent; border: 0; cursor: pointer;
    margin-bottom: 2px;
    transition: background .12s, color .12s;
}
.sidebar-foot .foot-link .ico { width: 20px; text-align: center; font-size: 1rem; opacity: .9; }
.sidebar-foot .foot-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-foot .foot-link.active {
    background: var(--accent-soft); color: var(--accent-bright);
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-foot .foot-link.active .ico { color: var(--accent-bright); }

/* Mobile: dimmed backdrop behind the open slide-out sidebar (tap to close). */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(6, 12, 24, .55); z-index: 1025;
}
.sidebar-backdrop.show { display: block; }

/* ---------------- Main column ---------------- */
.main { margin-left: var(--sidebar-w); height: 100vh; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 62px;
    background: rgba(17, 28, 51, .85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; flex: 0 0 auto; z-index: 1020;
}
.topbar h1 { font-size: 1.15rem; font-weight: 600; margin: 0; color: var(--text); }
.topbar .sidebar-toggle {
    background: none; border: none; color: var(--text); font-size: 1.4rem;
    display: none; margin-right: .5rem;
}

.content { padding: 1.5rem; flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Full-bleed Map page: drop the content padding and let the map fill the whole area. */
.content.content-map { padding: 0; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.content-map .fleet-map { flex: 1 1 auto; min-height: 0; width: 100%; background: var(--bg-2); }
:root[data-theme="light"] .content-map .fleet-map { background: #e8e6e1; }

/* On-shift drivers panel (top-right of the live map): scrollable list, click a driver to follow. */
.map-drivers {
    position: absolute; top: 14px; right: 14px; z-index: 1000; width: 220px; max-height: calc(100% - 28px);
    display: flex; flex-direction: column; overflow: hidden;
    background: rgba(17, 24, 39, .9); color: #fff; border-radius: 12px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .4); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    font-family: "Inter", system-ui, sans-serif;
}
.map-drivers .md-head { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
    color: #cfd6e2; padding: 11px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); flex: 0 0 auto; }
.map-drivers .md-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
    padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; }
.map-drivers .md-list { overflow-y: auto; padding: 6px; flex: 1 1 auto; }
.map-drivers .md-driver { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; cursor: pointer;
    padding: 7px 9px; margin-bottom: 3px; border: 1px solid transparent; border-radius: 8px;
    background: transparent; color: #fff; transition: background .12s, border-color .12s; }
.map-drivers .md-driver:hover { background: rgba(255, 255, 255, .06); border-color: var(--accent); }
.map-drivers .md-driver.active { background: var(--accent-soft); border-color: var(--accent); }
.map-drivers .md-name { font-weight: 600; font-size: 13px; }
.map-drivers .md-sub { color: #9aa4b2; font-size: 11px; }
.map-drivers .md-empty { color: #9aa4b2; font-size: 12px; text-align: center; padding: 14px 8px; }

/* Live driver markers: a heading arrow with the driver's name floating above it. divIcon has no
   default chrome (we replace the leaflet-div-icon class), and the arrow reads on both themes via a
   blue fill + white outline — colour is never the only cue (shape + name label carry it). */
.driver-marker { background: none; border: 0; }
.driver-marker .dm-arrow {
    width: 26px; height: 26px; color: #2563eb;
    transform-origin: 50% 50%;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .55));
    transition: transform .8s ease-out;   /* ease heading changes so the arrow turns smoothly */
}
.driver-marker .dm-arrow svg { display: block; }
.driver-marker .dm-name {
    position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
    white-space: nowrap; font: 600 12px/1 "Inter", system-ui, sans-serif;
    color: #fff; background: rgba(17, 24, 39, .9); padding: 3px 7px; border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4); pointer-events: none;
}

/* Driver detail popup (click a marker). Leaflet's default white bubble reads on both map themes;
   we only lay out the content, with text labels (never colour alone) for the key/value rows. */
.dm-pop { min-width: 150px; font: 13px/1.45 "Inter", system-ui, sans-serif; color: #1f2937; }
.dm-pop-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; color: #0f172a; }
.dm-pop-row { margin-top: 2px; }
.dm-pop-k { color: #6b7280; font-weight: 600; margin-right: 3px; }

/* ---------------------------------------------------------------------------
   Per-driver route replay page: left journeys panel (week scroller + list),
   a full-height map, an admin-only current-status card, and the replay bar.
   --------------------------------------------------------------------------- */
.content.content-routes { padding: 0; overflow: hidden; display: flex; }
.routes-side { flex: 0 0 300px; width: 300px; display: flex; flex-direction: column; min-height: 0;
    background: var(--bg-2); border-right: 1px solid var(--border); }
.routes-side .rs-head { display: flex; align-items: center; gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.routes-side .rs-back { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); }
.routes-side .rs-back:hover { color: var(--accent-bright); border-color: var(--accent); }
.routes-side .rs-driver { font-weight: 700; font-size: 1.05rem; }
.rs-week-block { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.rs-week { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem 1rem; border-bottom: 1px solid var(--border); }
.rs-week-range { font-weight: 600; font-size: .85rem; }
.rs-week-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); }
.rs-week-btn:hover:not(:disabled) { color: var(--accent-bright); border-color: var(--accent); }
.rs-week-btn:disabled { opacity: .35; cursor: default; }
.rs-list { flex: 1; overflow-y: auto; padding: .4rem .6rem 1rem; }
.rs-empty { color: var(--text-dim); font-size: .85rem; text-align: center; padding: 1.5rem .5rem; }
.rs-day { margin-bottom: .3rem; }
.rs-day-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); padding: .6rem .35rem .3rem; }
.rs-journey { display: flex; flex-direction: column; gap: .15rem; width: 100%; text-align: left; cursor: pointer;
    padding: .5rem .6rem; margin-bottom: 4px; border-radius: 9px; border: 1px solid transparent;
    background: var(--surface-2); color: var(--text); transition: border-color .12s, background .12s; }
.rs-journey:hover { border-color: var(--accent); }
.rs-journey.active { background: var(--accent-soft); border-color: var(--accent); }
.rs-journey .rs-j-veh { display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; }
.rs-journey .rs-j-veh .ico { width: 15px; height: 15px; }
.rs-journey .rs-j-time { color: var(--text-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.routes-main { flex: 1; position: relative; min-width: 0; background: var(--bg-2); }
.routes-map { position: absolute; inset: 0; }
.routes-data { position: absolute; top: 14px; right: 14px; z-index: 1000; width: 210px;
    background: rgba(17, 24, 39, .9); color: #fff; border-radius: 12px; padding: 12px 14px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .4); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    font: 13px/1.55 "Inter", system-ui, sans-serif; }
.routes-data .rd-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #9aa4b2; margin-bottom: 6px; }
.routes-data .rd-row { display: flex; justify-content: space-between; gap: 10px; }
.routes-data .rd-k { color: #9aa4b2; }
.routes-replay { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000;
    display: flex; align-items: center; gap: 12px; background: rgba(17, 24, 39, .92); color: #fff;
    padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); width: min(620px, calc(100% - 40px)); box-sizing: border-box; }
.routes-replay .rr-meta { min-width: 110px; }
.routes-replay .rr-title { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.routes-replay .rr-play { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; font-size: 13px; flex: 0 0 auto; }
.routes-replay input[type=range] { flex: 1; accent-color: #f59e0b; cursor: pointer; }
.routes-replay .rr-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; min-width: 46px; text-align: center; }
.routes-replay .rr-speed { border: 0; border-radius: 8px; background: #3b4658; color: #fff; font: 600 12px "Inter", system-ui; padding: 7px 9px; cursor: pointer; flex: 0 0 auto; }
.routes-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 900;
    background: rgba(17, 24, 39, .85); color: #cfd6e2; padding: 10px 16px; border-radius: 10px; font-size: .9rem; }
@media (max-width: 800px) {
    .content.content-routes { flex-direction: column; }
    .routes-side { flex: 0 0 auto; width: 100%; max-height: 45%; border-right: 0; border-bottom: 1px solid var(--border); }
}

.footer {
    padding: 1rem 1.5rem; color: var(--text-dim); border-top: 1px solid var(--border); font-size: .82rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    flex: 0 0 auto;
}

/* Light/dark toggle switch (bottom-right of footer). */
.theme-switch {
    position: relative; flex: 0 0 auto;
    width: 62px; height: 30px; padding: 0;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-2); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: space-between;
    transition: background .15s, border-color .15s;
}
.theme-switch:hover { border-color: var(--accent); }
.theme-switch .ts-ico {
    width: 15px; height: 15px; margin: 0 7px; z-index: 1;
    stroke-width: 2; pointer-events: none;
}
.theme-switch .ts-sun { color: var(--warning); }
.theme-switch .ts-moon { color: var(--accent-bright); }
.theme-switch .ts-knob {
    position: absolute; top: 2px; left: 2px;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.4);
    transition: transform .18s ease;
}
/* Dark = knob left (covers the moon); Light = knob right (covers the sun). */
:root[data-theme="light"] .theme-switch .ts-knob { transform: translateX(32px); }

/* ---------------- User menu ---------------- */
.user-menu .btn-user {
    display: flex; align-items: center; gap: .6rem;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); border-radius: 999px; padding: .35rem .85rem .35rem .4rem; font-weight: 500;
}
.user-menu .btn-user:hover { background: var(--surface-2); }
.user-menu .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.dropdown-menu {
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow); border-radius: 10px; padding: .4rem;
}
.dropdown-menu .dropdown-item { color: var(--text); border-radius: 7px; padding: .5rem .7rem; }
.dropdown-menu .dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-menu .dropdown-divider { border-color: var(--border); }
.dropdown-header { color: var(--text-dim); }

/* ---------------- Cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; padding: .85rem 1.1rem; }
.card-body { padding: 1.1rem; }

/* KPI stat cards */
.stat {
    border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
    padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .15rem;
    position: relative; overflow: hidden; transition: transform .12s, border-color .12s; height: 100%;
}
.stat:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .stat-label { color: var(--text-muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .stat-ico { position: absolute; right: 1rem; top: 1rem; opacity: .35; width: 22px; height: 22px; color: var(--accent-bright); }
.stat.accent { box-shadow: inset 0 -3px 0 var(--accent); }
.stat.danger { box-shadow: inset 0 -3px 0 var(--danger); }
.stat.warning { box-shadow: inset 0 -3px 0 var(--warning); }
.stat.success { box-shadow: inset 0 -3px 0 var(--success); }
.stat.info { box-shadow: inset 0 -3px 0 var(--info); }

/* ---------------- Dashboard ---------------- */
.dash-heading { font-size: 1rem; font-weight: 600; color: var(--text-muted); margin: 1.6rem 0 .6rem; }
.dash-list { display: flex; flex-direction: column; }
.dash-row {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); cursor: pointer;
    transition: background .12s;
}
.dash-row:last-child { border-bottom: 0; }
.dash-row:hover { background: var(--surface-2); }

.incident-map { display: block; width: 100%; max-width: 460px; aspect-ratio: 1 / 1; height: auto; border: 0; border-radius: 8px; }

/* ---------------- Notifications page ---------------- */
.notif-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .notif-layout { grid-template-columns: 1fr; } }
.notif-radio { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.notif-radio input { accent-color: var(--accent); }
.notif-drivers { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; margin-top: .6rem; background: var(--bg); }
.notif-drivers-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.notif-driver-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .35rem .6rem; max-height: 260px; overflow: auto; }
.notif-driver { display: flex; align-items: center; gap: .45rem; cursor: pointer; font-size: .9rem; }
.notif-driver input { accent-color: var(--accent); }
.notif-log { display: flex; flex-direction: column; gap: .7rem; }
.notif-item { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .85rem; background: var(--bg); }
.notif-item-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.notif-item-body { line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.notif-item-meta { color: var(--text-muted); font-size: .75rem; margin-top: .35rem; }

/* ---------------- Walkaround compliance flags ---------------- */
/* Flagged but already opened: a persistent (non-pulsing) red outline stays on the card. */
.card-tile.is-flagged { border-color: #fb7185; box-shadow: 0 0 0 1px #fb7185 inset; }
.card-tile.is-flagged:hover { border-color: #fb7185; }
:root[data-theme="light"] .card-tile.is-flagged { border-color: #dc2626; box-shadow: 0 0 0 1px #dc2626 inset; }
:root[data-theme="light"] .card-tile.is-flagged:hover { border-color: #dc2626; }
.compliance-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.card-tile .compliance-chips { margin-bottom: .5rem; }
.compliance-chips .badge { display: inline-flex; align-items: center; gap: .25rem; }
.compliance-chips .ico { width: 12px; height: 12px; }
.compliance-banner {
    display: flex; align-items: flex-start; gap: .7rem;
    background: rgba(244,63,94,.12); border: 1px solid #fb7185; border-radius: 10px;
    padding: .8rem 1rem; margin-bottom: 1.3rem; color: #fb7185;
}
.compliance-banner > .ico { width: 22px; height: 22px; flex-shrink: 0; margin-top: .1rem; }
.compliance-banner-title { font-weight: 700; margin-bottom: .4rem; }
:root[data-theme="light"] .compliance-banner { background: rgba(220,38,38,.08); border-color: #dc2626; color: #b91c1c; }

/* ---------------- Settings: editable checklists ---------------- */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; }
.seg-btn { padding: .32rem .75rem; border-radius: 7px; font-size: .82rem; font-weight: 500; color: var(--text-muted); text-decoration: none; white-space: nowrap; transition: background .12s, color .12s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: var(--accent-text); }
.settings-heading { font-weight: 600; margin: 1.6rem 0 .7rem; }
.settings-heading:first-of-type { margin-top: .3rem; }
/* Each checklist category is a collapsible dropdown. */
.settings-cat { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6rem; background: var(--bg); overflow: hidden; }
.settings-cat > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: .55rem;
    padding: .7rem 1rem; font-weight: 600; background: var(--bg-2); user-select: none;
}
.settings-cat > summary::-webkit-details-marker { display: none; }
.settings-cat > summary::before { content: "\25B8"; color: var(--text-muted); transition: transform .15s ease; }
.settings-cat[open] > summary::before { transform: rotate(90deg); }
.settings-cat-count { margin-left: auto; color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.settings-cat-body { padding: .9rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.settings-cat-body > form.settings-bulk { display: flex; flex-direction: column; gap: .6rem; }
.settings-cat-rename { padding-bottom: .65rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.settings-flat { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.settings-row { display: flex; gap: .5rem; align-items: center; margin: 0; flex-wrap: wrap; }
.settings-row > .form-control, .settings-row > .form-select { flex: 1; min-width: 120px; }
.settings-row > .btn, .settings-row > .form-check { flex: 0 0 auto; }
.settings-add { margin-top: .2rem; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; font-size: 1.15rem; line-height: 1; }
.btn-icon .ico { width: 15px; height: 15px; }
/* Subtle ghost delete: muted trash icon that turns red on hover (no loud solid squares). */
.btn-del {
    display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    border-radius: 8px; cursor: pointer; transition: background .12s, color .12s;
}
.btn-del:hover { background: rgba(244,63,94,.15); color: var(--danger); }
.btn-del .ico { width: 16px; height: 16px; }
/* Declaration rows: aligned columns (text · type · optional · actions). */
.decl-row { display: grid; grid-template-columns: 1fr 170px auto 52px; gap: .6rem; align-items: center; margin: 0; }
.decl-optional { justify-content: flex-start; gap: .35rem; margin-right: 0 !important; }
.decl-actions { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; }
.decl-actions .btn { flex: 0 0 auto; }
.decl-add { border-top: 1px dashed var(--border); margin-top: .45rem; padding-top: .7rem; }
.decl-add .form-control::placeholder { color: var(--accent-bright); opacity: .75; }
@media (max-width: 760px) { .decl-row { grid-template-columns: 1fr; } .decl-actions { justify-content: flex-start; } }

/* ---------------- Pagination ---------------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.6rem; }
.pager-btn {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 9px; padding: .45rem .9rem; font-weight: 500; cursor: pointer;
    transition: background .12s, border-color .12s;
}
.pager-btn:hover:not(:disabled) { background: var(--border); border-color: var(--accent); }
.pager-btn:disabled { opacity: .45; cursor: default; }
.pager-info { color: var(--text-muted); font-size: .85rem; }
/* ---------------- List filter bar ---------------- */
.list-filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.1rem; }
.list-filters .form-select, .list-filters .form-control { width: auto; }
.list-filters .filter-search { min-width: 220px; flex: 1 1 220px; max-width: 340px; }

/* ---------------- Asset card grid (vehicles, trailers, …) ---------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.1rem;
}
.card-tile {
    position: relative;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .4rem;
    transition: border-color .12s, transform .12s;
}
.card-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-tile.card-clickable { cursor: pointer; }
a.card-tile { color: inherit; text-decoration: none; }
/* Vehicles with unresolved defects: coloured border + an explicit labelled flag
   (label, not colour alone, carries the meaning). */
.card-tile.has-defects { border-color: #fb7185; box-shadow: 0 0 0 1px #fb7185 inset; }
.card-tile.has-defects:hover { border-color: #fb7185; }
/* Defect status borders (paired with the status label, so meaning isn't colour-only). */
.card-tile.is-complete { border-color: #4ade80; box-shadow: 0 0 0 1px #4ade80 inset; }
.card-tile.is-complete:hover { border-color: #4ade80; }
:root[data-theme="light"] .card-tile.is-complete { border-color: #16a34a; box-shadow: 0 0 0 1px #16a34a inset; }
:root[data-theme="light"] .card-tile.is-complete:hover { border-color: #16a34a; }
.card-tile.is-reported { border-color: #fbbf24; box-shadow: 0 0 0 1px #fbbf24 inset; }
.card-tile.is-reported:hover { border-color: #fbbf24; }
:root[data-theme="light"] .card-tile.is-reported { border-color: #d97706; box-shadow: 0 0 0 1px #d97706 inset; }
:root[data-theme="light"] .card-tile.is-reported:hover { border-color: #d97706; }
/* In-progress defects still need actioning, so their red border flashes to draw the eye. */
.card-tile.is-inprogress {
    border-color: #fb7185; border-width: 2px;
    animation: defect-pulse 1.3s ease-in-out infinite;
}
.card-tile.is-inprogress:hover { transform: translateY(-2px); }
@keyframes defect-pulse {
    0%, 100% { border-color: #7f1620; box-shadow: 0 0 0 1px #7f1620 inset, 0 0 0 0 rgba(251,113,133,0); }
    50%      { border-color: #fb7185; box-shadow: 0 0 0 1px #fb7185 inset, 0 0 14px 2px rgba(251,113,133,.75); }
}
@media (prefers-reduced-motion: reduce) {
    .card-tile.is-inprogress { animation: none; border-color: #fb7185; }
}
.tile-defect-flag {
    display: flex; align-items: center; gap: .35rem;
    background: rgba(244,63,94,.16); color: #fb7185;
    font-size: .74rem; font-weight: 600; line-height: 1;
    padding: .35rem .55rem; border-radius: 6px; margin-bottom: .1rem; align-self: flex-start;
}
.tile-defect-flag .ico { width: 14px; height: 14px; }
:root[data-theme="light"] .card-tile.has-defects { border-color: #dc2626; box-shadow: 0 0 0 1px #dc2626 inset; }
:root[data-theme="light"] .card-tile.has-defects:hover { border-color: #dc2626; }
:root[data-theme="light"] .tile-defect-flag { background: rgba(220,38,38,.12); color: #b91c1c; }
/* Edit (gear) button — revealed on hover; always visible on touch devices. */
.card-tile .tile-edit {
    position: absolute; top: .55rem; right: .55rem;
    width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); cursor: pointer; opacity: 0;
    transition: opacity .12s, color .12s, border-color .12s;
}
.card-tile:hover .tile-edit,
.card-tile .tile-edit:focus-visible { opacity: 1; }
.card-tile .tile-edit:hover { color: var(--accent-bright); border-color: var(--accent); }
@media (hover: none) { .card-tile .tile-edit { opacity: 1; } }
.card-tile .tile-head { display: flex; flex-direction: column; gap: .05rem; padding-right: 34px; }
.card-tile .tile-id { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; line-height: 1.2; }
.card-tile .tile-type { color: var(--text-muted); font-size: .8rem; }
.card-tile .tile-img { width: 100%; height: 120px; object-fit: contain; margin: .25rem 0; }
.card-tile .tile-meta { text-align: center; margin-top: auto; }
.card-tile .tile-name { font-weight: 500; }
.card-tile .tile-org { color: var(--accent-bright); font-size: .78rem; font-weight: 500; }
.card-tile .tile-inuse { display: flex; align-items: center; justify-content: center; gap: .3rem; margin-top: .4rem; width: fit-content; margin-left: auto; margin-right: auto; }
.card-tile .tile-inuse .ico { width: 13px; height: 13px; }
.card-tile .tile-tag { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; margin: .4rem auto 0; width: fit-content; }
.card-tile .tile-tag .ico { width: 13px; height: 13px; }

/* Multi-select depot dropdown (Admin → edit user): a native <details> styled like a select. */
.tag-multiselect > summary { list-style: none; cursor: pointer; }
.tag-multiselect > summary::-webkit-details-marker { display: none; }
.tag-multiselect > summary::marker { content: ""; }
.tag-multiselect > summary [data-tag-label] { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-multiselect-menu { margin-top: .35rem; border: 1px solid rgba(148,163,184,.3); border-radius: 6px; max-height: 220px; overflow-y: auto; padding: .25rem; }
.tag-multiselect-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border-radius: 4px; cursor: pointer; margin: 0; }
.tag-multiselect-item:hover { background: rgba(148,163,184,.14); }
.tag-multiselect-item input { margin: 0; flex-shrink: 0; }
/* Key/value lines inside record cards (walkaround checks, defects, incidents). */
.rec-lines { display: flex; flex-direction: column; gap: .25rem; margin-top: .35rem; font-size: .85rem; }
.rec-line { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.rec-line > span:first-child { color: var(--text-muted); flex-shrink: 0; }
.rec-line > span:last-child { text-align: right; }
/* Wrapping variant for long labels (e.g. declaration text): label wraps, value stays right. */
.rec-lines-wrap .rec-line { align-items: flex-start; }
.rec-lines-wrap .rec-line > span:first-child { flex: 1 1 auto; min-width: 0; }
.rec-lines-wrap .rec-line > span:last-child { flex: 0 0 auto; white-space: nowrap; }
.card-tile .rec-note { color: var(--text-muted); font-size: .82rem; margin-top: .4rem;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-tile .tile-photo { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
/* Defect detail: stacked card panels (reuses the .wac-block panel styling below). */
.def-stack { display: flex; flex-direction: column; gap: 1rem; }
.note-box {
    background: var(--bg); color: var(--text); line-height: 1.5;
    border: 1px solid var(--border); border-left: 3px solid var(--accent);
    border-radius: 8px; padding: .7rem .9rem;
}
.note-log { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .8rem; }
.note-entry { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .8rem; }
.note-entry-meta { color: var(--text-muted); font-size: .75rem; margin-bottom: .2rem; }
.note-entry-body { line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
/* Fullscreen walkaround detail: summary head + metadata sidebar + wide checklist. */
.wac-head {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding-bottom: 1rem; margin-bottom: 1.3rem; border-bottom: 1px solid var(--border);
}
.wac-head-reg { font-weight: 700; font-size: 1.35rem; letter-spacing: .02em; }
.wac-head-sub { color: var(--text-muted); font-size: .85rem; margin-top: .1rem; }
.wac-layout { display: flex; gap: 1.4rem; align-items: flex-start; }
.wac-side { flex: 0 0 340px; max-width: 340px; display: flex; flex-direction: column; gap: 1.4rem; }
.wac-main { flex: 1 1 auto; min-width: 0; }
.wac-main .wac-block + .wac-block { margin-top: 1.4rem; }
/* Each section as a card panel, matching the site's .card / .card-header / .card-body. */
.wac-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wac-block > .wac-title {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .7rem 1rem; border-bottom: 1px solid var(--border);
    font-weight: 600; background: var(--bg-2);
}
.wac-block > .wac-body { padding: 1rem; }
.wac-title .wac-title-meta { display: flex; align-items: center; gap: .5rem; }
.wac-title .wac-count { color: var(--text-muted); font-weight: 500; font-size: .8rem; }
/* Breakdown detail top row: Assistance + Details stacked left (fixed column, same width as the
   aside below), Description stretched to match their combined height on the right. */
.incident-top { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.4rem; align-items: stretch; margin-bottom: 1.4rem; }
.incident-top-left { display: flex; flex-direction: column; gap: 1.4rem; }
.incident-top-right { display: flex; }
.incident-top-right > .wac-block { flex: 1 1 auto; display: flex; flex-direction: column; }
.incident-top-right > .wac-block > .wac-body { flex: 1 1 auto; }
@media (max-width: 900px) { .incident-top { grid-template-columns: 1fr; } }
/* Notes beside Photos in an incident's main column. Notes take the whole width when there are no
   photos (.np-single). */
/* Incident lower row: Location then Photos are fixed-width columns (same width), Notes fills the
   rest on the right. Wraps to stacked columns when the row can't hold all three. */
.incident-lower { display: flex; gap: 1.4rem; align-items: flex-start; margin-top: 1.4rem; flex-wrap: wrap; }
.incident-lower .il-col { min-width: 0; }
.incident-lower .il-location, .incident-lower .il-photos { flex: 0 0 340px; max-width: 340px; }
.incident-lower .il-notes { flex: 1 1 340px; }
.incident-lower .il-col > .wac-block { margin-top: 0; }
@media (max-width: 820px) {
    .incident-lower .il-location, .incident-lower .il-photos, .incident-lower .il-notes { flex-basis: 100%; max-width: none; }
}
/* Photos: a fixed 2×2 square grid so the box is always the size it'd be with four photos,
   whatever the actual count (fewer photos just leave empty cells). Overflow (5+) goes to the
   "See all" modal, which uses .photo-modal-grid. */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: .5rem;
    aspect-ratio: 1 / 1;
}
.photo-thumb { width: 100%; height: 100%; min-height: 0; object-fit: cover; border-radius: 8px; display: block; }
.photo-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
/* Checklist items as an aligned grid of equal-height cards. */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .5rem; align-items: stretch; }
.check-item {
    display: flex; justify-content: space-between; align-items: center; gap: .6rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem;
}
.check-item .ci-label { font-size: .85rem; line-height: 1.3; }
.check-item .ci-note { color: var(--text-muted); font-size: .78rem; margin-top: .15rem; }
.check-item .badge { flex-shrink: 0; }
.check-item.is-defect { border-color: #fb7185; }
:root[data-theme="light"] .check-item.is-defect { border-color: #dc2626; }
a.check-item { color: inherit; text-decoration: none; }
.check-item.is-link { cursor: pointer; transition: border-color .12s, transform .12s; }
.check-item.is-link:hover { border-color: #fb7185; transform: translateY(-1px); }
.check-item .ci-link-hint { color: #fb7185; font-size: .74rem; font-weight: 600; margin-top: .2rem; }
:root[data-theme="light"] .check-item .ci-link-hint { color: #b91c1c; }
@media (max-width: 900px) {
    .wac-layout { flex-direction: column; }
    .wac-side { flex-basis: auto; max-width: none; width: 100%; }
}
/* Fullscreen image lightbox. */
img.zoomable { cursor: zoom-in; }
.img-lightbox { position: fixed; inset: 0; z-index: 20000; background: rgba(0,0,0,.85);
    display: none; align-items: center; justify-content: center; padding: 2rem; cursor: zoom-out; }
.img-lightbox.open { display: flex; }
.img-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.55); }
/* Small stat chips (org detail modal). */
.mini-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .4rem; }
.mini-stat .v { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.mini-stat .l { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* Initials avatar used in the driver card's image slot. */
.card-tile .driver-avatar {
    width: 84px; height: 84px; border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1e40af); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 1.7rem;
    margin: .75rem auto; letter-spacing: .02em;
}

/* ---------------- Tables ---------------- */
.table {
    color: var(--text); border-color: var(--border); margin-bottom: 0;
    --bs-table-bg: transparent; --bs-table-color: var(--text);
    --bs-table-striped-bg: rgba(255,255,255,.025); --bs-table-striped-color: var(--text);
    --bs-table-hover-bg: var(--accent-soft); --bs-table-hover-color: var(--text);
    --bs-table-border-color: var(--border-soft);
}
.table thead th {
    color: var(--text-muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .05em;
    font-weight: 600; border-bottom: 1px solid var(--border); background: var(--bg-2); white-space: nowrap;
}
.table td, .table th { padding: .7rem .85rem; vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tbody tr { transition: background .1s; }
.table-card { padding: 0; overflow: hidden; }

/* ---------------- Forms ---------------- */
.form-label { color: var(--text-muted); font-weight: 500; font-size: .83rem; margin-bottom: .3rem; }
.form-control, .form-select {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 9px; padding: .5rem .7rem;
}
/* Restore a visible dropdown caret (the background shorthand above wipes Bootstrap's). */
.form-select {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .6rem center; background-size: 14px;
    padding-right: 2rem; cursor: pointer;
}
.form-control:focus, .form-select:focus {
    background: var(--surface-2); color: var(--text); border-color: var(--accent);
    box-shadow: 0 0 0 .2rem var(--accent-soft);
}
.form-control::placeholder { color: var(--text-dim); }
.form-control:disabled, .form-select:disabled { background: var(--surface); opacity: .6; }
.form-select option { background: var(--surface); color: var(--text); }
.form-check-input { background-color: var(--surface-2); border-color: var(--border); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.input-group-text { background: var(--bg-2); border-color: var(--border); color: var(--text-muted); }
.text-danger, .field-validation-error { color: #fda4af !important; font-size: .82rem; }
.validation-summary-errors { color: #fda4af; }
.validation-summary-errors ul { margin-bottom: 0; }
hr { border-color: var(--border); opacity: 1; }

/* ---------------- Buttons ---------------- */
.btn { border-radius: 9px; font-weight: 500; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-outline-primary { color: var(--accent-bright); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #06230f; }
.btn-success:hover, .btn-success:focus { background: #1aa64b; border-color: #1aa64b; color: #06230f; }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }
.btn-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; }

/* ---------------- Badges ---------------- */
.badge { font-weight: 600; padding: .35em .6em; border-radius: 6px; font-size: .72rem; }
.badge.b-success { background: rgba(34,197,94,.16); color: #4ade80; }
.badge.b-danger  { background: rgba(244,63,94,.16); color: #fb7185; }
.badge.b-warning { background: rgba(245,158,11,.16); color: #fbbf24; }
.badge.b-info    { background: rgba(56,189,248,.16); color: #7dd3fc; }
.badge.b-muted   { background: rgba(148,163,184,.16); color: #cbd5e1; }
.badge.b-accent  { background: var(--accent-soft); color: var(--accent-bright); }

/* ---------------- Modal ---------------- */
.modal-content {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; }
.modal-header .modal-title { font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--border); padding: .85rem 1.25rem; }
.btn-close { filter: invert(1) grayscale(1) brightness(1.6); }
.modal-backdrop.show { opacity: .65; }

/* ---------------- Alerts ---------------- */
.alert { border-radius: 10px; border: 1px solid transparent; }
.alert-success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); color: #86efac; }
.alert-danger { background: rgba(244,63,94,.12); border-color: rgba(244,63,94,.3); color: #fda4af; }
.alert-info { background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.3); color: #bae6fd; }
.alert-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fcd34d; }

/* ---------------- Auth pages ---------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
/* Segmented toggle (register: Account | Organisation) */
.seg-toggle { display: flex; gap: .3rem; padding: .3rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.seg-toggle .seg-btn {
    flex: 1; padding: .5rem .75rem; border: 0; border-radius: 8px; cursor: pointer;
    background: transparent; color: var(--text-muted); font-weight: 600; font-size: .9rem;
    transition: background .12s, color .12s;
}
.seg-toggle .seg-btn:hover { color: var(--text); }
.seg-toggle .seg-btn.active { background: var(--accent); color: var(--accent-text); }
/* Both logos are display:block via the theme swap, so centre them explicitly
   (a block element ignores the parent's text-align). */
.auth-brand img { display: block; margin-left: auto; margin-right: auto; }
/* Light/dark toggle pinned to the bottom-right of the auth pages. */
.auth-theme-toggle { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 10; }
.auth-brand .logo {
    width: 52px; height: 52px; border-radius: 13px; margin: 0 auto .6rem;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    display: grid; place-items: center; font-size: 1.6rem;
}

/* ---------------- Manage (account) nav ---------------- */
.manage-nav .list-group-item { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
.manage-nav .list-group-item.active { background: var(--accent-soft); color: var(--accent-bright); border-color: var(--border); }
.manage-nav .list-group-item:hover { color: var(--text); }

.text-muted, .text-secondary { color: var(--text-muted) !important; }
.spinner-pad { padding: 2.5rem; text-align: center; color: var(--text-muted); }
.page-actions { display: flex; gap: .5rem; align-items: center; }

/* ---------------- Responsive ---------------- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar .sidebar-toggle { display: block; }
}
/* The mobile backdrop must never appear on desktop, even if the .show class lingers. */
@media (min-width: 993px) {
    .sidebar-backdrop { display: none !important; }
}

/* ============================================================
   LIGHT THEME  —  activated by <html data-theme="light">
   Redefines the token palette; a handful of rules that hardcoded
   dark surfaces are re-declared for adequate contrast on light.
   ============================================================ */
:root[data-theme="light"] {
    --bg: #eef2f7;            /* page background */
    --bg-2: #ffffff;          /* sidebar / thead */
    --surface: #ffffff;       /* cards / modals */
    --surface-2: #eef2f7;     /* inputs / hover */
    --border: #d8e0ea;
    --border-soft: #e5eaf1;
    --text: #1e293b;          /* slate-800 */
    --text-muted: #55657a;
    --text-dim: #8593a6;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, .10);
    --accent-bright: #1d4ed8; /* readable blue for text on light */
    --accent-text: #ffffff;
    --shadow: 0 10px 30px rgba(15, 23, 42, .12);
}
:root[data-theme="light"] .topbar { background: rgba(255, 255, 255, .85); }
:root[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }
:root[data-theme="light"] .table { --bs-table-striped-bg: rgba(15, 23, 42, .03); }
:root[data-theme="light"] .btn-close { filter: none; }
:root[data-theme="light"] a:hover { color: var(--accent-hover); }
/* Semantic badges/alerts: darker ink for contrast on pale tints. */
:root[data-theme="light"] .badge.b-success { background: rgba(22, 163, 74, .14); color: #15803d; }
:root[data-theme="light"] .badge.b-danger  { background: rgba(220, 38, 38, .12); color: #b91c1c; }
:root[data-theme="light"] .badge.b-warning { background: rgba(217, 119, 6, .14); color: #b45309; }
:root[data-theme="light"] .badge.b-info    { background: rgba(2, 132, 199, .12); color: #0369a1; }
:root[data-theme="light"] .badge.b-muted   { background: rgba(100, 116, 139, .14); color: #475569; }
:root[data-theme="light"] .alert-success { color: #15803d; }
:root[data-theme="light"] .alert-danger  { color: #b91c1c; }
:root[data-theme="light"] .alert-info    { color: #0369a1; }
:root[data-theme="light"] .alert-warning { color: #b45309; }
:root[data-theme="light"] .text-danger,
:root[data-theme="light"] .field-validation-error,
:root[data-theme="light"] .validation-summary-errors { color: #dc2626 !important; }

/* Artic checklist items record which unit they're on (truck / trailer / ask driver), so a raised
   defect lands against one unit rather than both. Narrow fixed column beside the item text. */
.settings-row > .item-unit { flex: 0 0 132px; min-width: 0; }
@media (max-width: 560px) { .settings-row > .item-unit { flex: 1 1 100%; } }

/* Stop-check events not yet seen by the office — a VOR override is only useful if someone
   notices in time to ring the driver, so unread ones get an accent edge. */
.notif-item.is-new { border-left: 3px solid var(--accent); background: var(--bg-2); }

/* ---------------- VOR (vehicle off road) ---------------- */
/* Amber border + a labelled flag, so the meaning is carried by the label and not colour alone,
   matching how has-defects works. */
.card-tile.is-vor { border-color: #f5a524; box-shadow: 0 0 0 1px #f5a524 inset; }
.card-tile.is-vor:hover { border-color: #f5a524; }
.tile-vor-flag {
    display: flex; align-items: center; gap: .35rem;
    background: rgba(245,165,36,.16); color: #f5a524;
    font-size: .74rem; font-weight: 600; line-height: 1;
    padding: .35rem .55rem; border-radius: 6px; margin-bottom: .1rem; align-self: flex-start;
}
.tile-vor-flag .ico { width: 14px; height: 14px; }
/* Stacked directly under .tile-edit, and hover-revealed the same way so it doesn't crowd the
   defect flag along the top of the tile. */
.card-tile .tile-vor {
    position: absolute; top: calc(.55rem + 36px); right: .55rem;
    width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text-muted); cursor: pointer; opacity: 0;
    transition: opacity .12s, color .12s, border-color .12s;
}
.card-tile:hover .tile-vor,
.card-tile .tile-vor:focus-visible { opacity: 1; }
.card-tile .tile-vor:hover { color: #f5a524; border-color: #f5a524; }
.card-tile.is-vor .tile-vor { color: #f5a524; border-color: #f5a524; }
.card-tile.is-vor .tile-vor:hover { color: var(--accent-bright); border-color: var(--accent); }
.card-tile .tile-vor .ico { width: 15px; height: 15px; }
/* Touch devices can't hover, so keep it reachable there (same rule .tile-edit uses). */
@media (hover: none) { .card-tile .tile-vor { opacity: 1; } }
/* Non-admins get no edit button, so VOR moves up into the top slot. */
.card-tile:not(:has(.tile-edit)) .tile-vor { top: .55rem; }

/* Driver-card "View routes" button — always visible + labelled at the card bottom so it's an
   obvious action, separate from the whole-card click (which opens the edit form). */
.card-tile .tile-routes-btn {
    display: flex; align-items: center; justify-content: center; gap: .4rem;
    margin-top: .7rem; padding: .45rem .6rem; width: 100%; text-decoration: none;
    border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
    color: var(--text-muted); font-weight: 600; font-size: .85rem;
    transition: background .12s, color .12s, border-color .12s;
}
.card-tile .tile-routes-btn .ico { width: 15px; height: 15px; }
.card-tile .tile-routes-btn:hover { color: var(--accent-bright); border-color: var(--accent); background: var(--accent-soft); }

/* Whole driver card opens the edit form (cog removed). */
.card-tile.is-clickable { cursor: pointer; }
.card-tile.is-clickable:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------------------
   Maintenance planner: month calendar of safety inspections + annual tests,
   alongside a "this week" panel. Calendar cells size themselves off the grid so
   a five- or six-row month both fill the card without a fixed height.
   --------------------------------------------------------------------------- */
.mnt-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; margin-bottom: 1.2rem; }
@media (max-width: 1100px) { .mnt-layout { grid-template-columns: 1fr; } }

.mnt-cal-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.mnt-cal-month { font-weight: 600; }
.mnt-cal-nav { display: flex; align-items: center; gap: .35rem; }
.cal-flip { transform: rotate(180deg); }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: .2rem .3rem .35rem; }
.cal-day { min-height: 92px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); padding: .3rem; display: flex; flex-direction: column; gap: 3px; }
.cal-day.is-outside { opacity: .45; }
.cal-day.is-today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; background: var(--accent-soft); }
.cal-day-head { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.cal-daynum { font-size: .75rem; font-weight: 600; color: var(--text-muted); }
.cal-day.is-today .cal-daynum { color: var(--accent-bright); }
.cal-today-tag { font-size: .56rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #fff; background: var(--accent); padding: .05rem .3rem; border-radius: 999px; line-height: 1.5; }

/* Entries are buttons because they open the schedule modal — styled flat so a
   full week doesn't read as a wall of controls. */
.cal-item { display: block; width: 100%; text-align: left; border: 0; border-radius: 5px; padding: .16rem .3rem; font-size: .72rem; line-height: 1.25; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg-2); color: var(--text); }
.cal-item:hover { filter: brightness(1.15); }
.cal-item-kind { font-weight: 700; opacity: .75; margin-right: .15rem; }
.cal-item.is-pmi { background: var(--accent-soft); color: var(--accent-bright); }
.cal-item.is-mot { background: rgba(56, 189, 248, .16); color: #7dd3fc; }
.cal-item.is-loler { background: rgba(167, 139, 250, .18); color: #c4b5fd; }
.cal-item.is-tacho { background: rgba(45, 212, 191, .16); color: #5eead4; }
.cal-item.is-soon { background: rgba(245, 158, 11, .18); color: #fbbf24; }
.cal-item.is-overdue { background: rgba(244, 63, 94, .18); color: #fb7185; }

.cal-key { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .8rem; font-size: .75rem; color: var(--text-muted); }
.cal-key-item { display: inline-flex; align-items: center; gap: .35rem; }
.cal-swatch { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; }
.cal-swatch.is-pmi { background: var(--accent); }
.cal-swatch.is-mot { background: #7dd3fc; }
.cal-swatch.is-loler { background: #c4b5fd; }
.cal-swatch.is-tacho { background: #5eead4; }

.mnt-week-range { margin-bottom: .7rem; }
.mnt-week-group + .mnt-week-group { margin-top: 1rem; }
.mnt-week-heading { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: .4rem; }
.mnt-due { border: 1px solid var(--border); border-left-width: 3px; border-radius: 8px; padding: .5rem .65rem; background: var(--bg); display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.mnt-due + .mnt-due { margin-top: .45rem; }
.mnt-due.is-overdue { border-left-color: #fb7185; }
.mnt-due-main { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.mnt-due-meta { font-size: .78rem; color: var(--text-muted); }

.mnt-unscheduled { margin-bottom: 1.2rem; }
.mnt-chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.mnt-unit { display: flex; align-items: center; gap: .4rem; }
.mnt-actions { white-space: nowrap; }
.mnt-actions .btn + .btn { margin-left: .3rem; }
.mnt-actions-col { width: 1%; }
/* "Mark done today" check button in each fleet-table date cell. The tick + tooltip carry the
   meaning; the green is only reinforcement. */
.mnt-cell-line { display: flex; align-items: center; gap: .4rem; margin-top: .15rem; }
.mnt-done {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; flex: 0 0 auto;
    border: none; border-radius: 6px;
    background: #2563eb; color: #fff; cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: background .12s, transform .12s;
}
.mnt-done:hover { background: #1d4ed8; transform: translateY(-1px); }
.mnt-done .ico { width: 15px; height: 15px; }
.mnt-form-unit { display: flex; flex-direction: column; gap: .1rem; padding-bottom: .7rem; margin-bottom: .9rem; border-bottom: 1px solid var(--border); }

/* Fleet-wide inspection interval, shown above the calendar. */
.mnt-fleet-bar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
                 border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2);
                 padding: .6rem .85rem; margin-bottom: 1rem; }
.mnt-fleet-interval { display: flex; align-items: baseline; gap: .5rem; }

/* Amber "due soon" banner on a vehicle tile, matching .tile-defect-flag's shape. */
.tile-maint-flag {
    display: flex; align-items: center; gap: .35rem;
    background: rgba(245,158,11,.16); color: #fbbf24;
    font-size: .74rem; font-weight: 600; line-height: 1;
    border-radius: 6px; padding: .3rem .45rem; margin-bottom: .4rem;
}
.tile-maint-flag.is-overdue { background: rgba(244,63,94,.16); color: #fb7185; }
.tile-maint-flag .ico { width: 14px; height: 14px; }
.card-tile.is-maint-due { border-color: #fbbf24; box-shadow: 0 0 0 1px #fbbf24 inset; }
.card-tile.is-maint-due:hover { border-color: #fbbf24; }
.card-tile.is-maint-overdue { border-color: #fb7185; box-shadow: 0 0 0 1px #fb7185 inset; }
.card-tile.is-maint-overdue:hover { border-color: #fb7185; }
:root[data-theme="light"] .tile-maint-flag { background: rgba(217,119,6,.14); color: #b45309; }
:root[data-theme="light"] .tile-maint-flag.is-overdue { background: rgba(220,38,38,.12); color: #b91c1c; }
:root[data-theme="light"] .card-tile.is-maint-due { border-color: #d97706; box-shadow: 0 0 0 1px #d97706 inset; }
:root[data-theme="light"] .card-tile.is-maint-overdue { border-color: #dc2626; box-shadow: 0 0 0 1px #dc2626 inset; }

/* ---------------- Walkaround checks: duties ---------------- */
/* A shift reads as one row, not four tiles. The office scans a day by registration and time, so
   the row is a table-like line rather than a card in a grid, and the checks that made up the duty
   (start, each trailer change, end of duty) expand underneath it as a timeline.
   Built on <details>/<summary> — the disclosure behaviour and keyboard support come for free. */
.card-tile .tile-link { display: block; color: inherit; text-decoration: none; }

.duty-list { display: flex; flex-direction: column; gap: .55rem; }
.duty-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.duty-card[open] { border-color: var(--accent); }
.duty-card.is-flagged { border-color: #fb7185; box-shadow: 0 0 0 1px #fb7185 inset; }
.duty-card.is-inprogress { border-color: #fb7185; border-width: 2px; animation: defect-pulse 1.3s ease-in-out infinite; }
:root[data-theme="light"] .duty-card.is-flagged,
:root[data-theme="light"] .duty-card.is-inprogress { border-color: #dc2626; }
@media (prefers-reduced-motion: reduce) { .duty-card.is-inprogress { animation: none; } }

.duty-summary { cursor: pointer; list-style: none; user-select: none; padding: .75rem 0 0; }
.duty-summary::-webkit-details-marker { display: none; }   /* Safari's default triangle */
.duty-summary:hover { background: var(--surface-2); }
.duty-card[open] .duty-summary { background: var(--surface-2); }
.duty-row { display: flex; align-items: center; gap: .9rem; padding: 0 1rem .75rem; }

/* Own marker, so it can sit inline with the row's own spacing and rotate when open. */
.duty-chev {
    flex: none; width: 0; height: 0; margin-left: .15rem;
    border-left: 5px solid var(--text-muted); border-top: 4px solid transparent;
    border-bottom: 4px solid transparent; transition: transform .15s;
}
.duty-card[open] .duty-chev { transform: rotate(90deg); }

.duty-unit { font-weight: 700; font-size: .95rem; min-width: 6.5rem; }
.duty-driver { color: var(--text-muted); min-width: 7.5rem; }
.duty-when { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.duty-when b { color: var(--text); font-weight: 600; }
.duty-kind {
    font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--accent-bright); background: var(--accent-soft);
    padding: .25rem .5rem; border-radius: 6px; white-space: nowrap;
}
.duty-spacer { flex: 1; }
.duty-print { flex: none; }

.duty-chips { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0 1rem .7rem 2.4rem; }
.duty-chips .badge { display: inline-flex; align-items: center; gap: .25rem; }
.duty-chips .ico { width: 12px; height: 12px; }

/* The at-a-glance line, shown only while collapsed — open, the timeline below covers it. */
.duty-facts {
    display: flex; flex-wrap: wrap; gap: 1.1rem;
    padding: 0 1rem .8rem 2.4rem; color: var(--text-muted); font-size: .84rem;
}
.duty-facts b { color: var(--text); font-weight: 600; }
.duty-facts b.is-outstanding { color: #fbbf24; }
:root[data-theme="light"] .duty-facts b.is-outstanding { color: #b45309; }
.duty-facts em { color: var(--text-dim); font-style: italic; }
.duty-card[open] .duty-facts { display: none; }

/* --bg-2, not --bg: in the light theme --bg and --surface-2 are the same grey, so the legs' own
   secondary buttons would sit invisibly on the panel. */
.duty-legs { display: none; border-top: 1px solid var(--border); background: var(--bg-2); padding: .2rem 1rem .5rem; }
.duty-card[open] .duty-legs { display: block; }
.duty-leg {
    display: flex; align-items: center; gap: .8rem;
    padding: .6rem 0 .6rem .35rem; border-bottom: 1px solid var(--border-soft); font-size: .86rem;
}
.duty-leg:last-child { border-bottom: none; }
/* Tree connector drawn in CSS rather than box-drawing characters — those render at wildly
   different widths per font and misalign the column. A continuous spine down the legs with a tick
   into each one; on the last leg the spine stops at the tick so the branch visibly ends. */
.leg-rail { flex: none; position: relative; width: 14px; align-self: stretch; }
.leg-rail::before {
    content: ""; position: absolute; left: 0; top: -.6rem; bottom: -.6rem;
    border-left: 1px solid var(--border);
}
.leg-rail.is-last::before { bottom: 50%; }
.leg-rail::after {
    content: ""; position: absolute; left: 0; top: 50%; width: 100%;
    border-top: 1px solid var(--border);
}
.leg-time { flex: none; width: 3rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.leg-what { flex: 1; min-width: 0; }
.leg-what small { display: block; color: var(--text-muted); font-size: .78rem; margin-top: .1rem; }
.leg-badge { flex: none; }
.leg-acts { flex: none; display: flex; gap: .35rem; }

.duty-org { padding: .5rem 1rem .7rem 2.4rem; color: var(--text-dim); font-size: .78rem; }

/* Narrow screens: the row wraps instead of squeezing, and the per-leg columns stack. */
@media (max-width: 900px) {
    .duty-row { flex-wrap: wrap; gap: .5rem .7rem; }
    .duty-unit, .duty-driver { min-width: 0; }
    .duty-spacer { display: none; }
    .duty-when { white-space: normal; }
    .duty-leg { flex-wrap: wrap; }
    .leg-what { flex: 1 1 60%; }
    .leg-acts { margin-left: auto; }
}

/* Printed check sheet settings. */
.ps-logo-row { display: flex; align-items: flex-start; gap: .8rem; border: 1px solid var(--border);
               border-radius: 10px; padding: .8rem; background: var(--bg); }
.ps-logo-prev { width: 120px; height: 46px; background: #fff; border-radius: 6px; display: flex;
                align-items: center; justify-content: center; overflow: hidden; flex: none; }
.ps-logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ps-logo-fields { flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.ps-swatches { display: flex; gap: .5rem; margin-bottom: .3rem; }
.ps-sw { width: 30px; height: 30px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; display: block; }
/* Selection has to show immediately. The .on class is rendered from the saved value, so without
   :has() a click gave no feedback at all — you'd pick a colour, see nothing change, and reasonably
   conclude it hadn't worked. */
.ps-sw.on, .ps-sw:has(input:checked) { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.ps-sw input { position: absolute; opacity: 0; pointer-events: none; }
.ps-kind { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: .7rem; }
.ps-kind-label { width: 110px; padding-top: .45rem; font-weight: 600; font-size: .9rem; }
.ps-kind-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.ps-sections { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ps-section { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; background: var(--bg);
              border-bottom: 1px solid var(--border); margin: 0; cursor: pointer; }
.ps-section:last-child { border-bottom: none; }
.ps-section input { accent-color: var(--accent); }
.ps-section span { display: flex; flex-direction: column; }
.ps-section small { color: var(--text-muted); font-size: .78rem; }
.ps-section.is-locked { cursor: default; }
.ps-section em { margin-left: auto; color: var(--text-muted); font-size: .78rem; }

/* ---------------- Driver leaderboard ---------------- */
/* Distance per driver for a Monday-to-Sunday week. A bar relative to the leader, so the shape of
   the week reads without comparing numbers. */
.lb-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lb-week { display: flex; align-items: center; gap: .6rem; }
.lb-range { display: flex; flex-direction: column; line-height: 1.25; }
.lb-range b { font-size: .95rem; }
.lb-range span { color: var(--text-muted); font-size: .78rem; }
.lb-total { margin-left: auto; text-align: right; }
.lb-total-v { display: block; font-size: 1.5rem; font-weight: 750; letter-spacing: -.5px; }
.lb-total-k { color: var(--text-muted); font-size: .78rem; }
.btn.is-disabled { opacity: .45; pointer-events: none; }

.lb-list { display: flex; flex-direction: column; gap: .45rem; }
.lb-row {
    display: flex; align-items: center; gap: .9rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .7rem 1rem;
}
.lb-row.is-top { border-color: var(--accent); }
.lb-pos {
    flex: none; width: 1.6rem; height: 1.6rem; display: grid; place-items: center;
    border-radius: 50%; background: var(--surface-2); color: var(--text-muted);
    font-size: .78rem; font-weight: 700;
}
.lb-row.is-top .lb-pos { background: var(--accent); color: var(--accent-text); }
.lb-name { flex: 0 0 11rem; display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.lb-name small { color: var(--text-muted); font-weight: 500; font-size: .74rem; }
/* Fills the space between the name and the figures — the comparison, not a precise readout. */
.lb-bar { flex: 1; height: 7px; background: var(--bg); border-radius: 99px; overflow: hidden; min-width: 3rem; }
.lb-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.lb-duties { flex: none; color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.lb-miles { flex: none; text-align: right; min-width: 6.5rem; line-height: 1.2; }
.lb-miles b { font-size: 1.05rem; font-weight: 700; }
.lb-miles small { display: block; color: var(--text-muted); font-size: .74rem; }
.lb-note { color: var(--text-dim); font-size: .8rem; margin-top: 1rem; }

@media (max-width: 800px) {
    .lb-row { flex-wrap: wrap; gap: .4rem .8rem; }
    .lb-name { flex: 1 1 auto; }
    .lb-bar { flex: 1 1 100%; order: 10; }
    .lb-miles { min-width: 0; }
}

/* ---------------- In-cab tablets ---------------- */
.dev-add { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dev-add .form-control { flex: 1 1 16rem; }
.dev-add .form-select { flex: 0 0 12rem; }
.dev-list { display: flex; flex-direction: column; gap: .5rem; }
.dev-row {
    display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .7rem 1rem;
}
.dev-row.is-revoked { opacity: .6; border-style: dashed; }
.dev-main { flex: 1 1 14rem; min-width: 0; }
.dev-label { font-weight: 600; display: flex; gap: .5rem; align-items: baseline; }
.dev-label small { color: var(--text-dim); font-weight: 500; font-size: .74rem; }
.dev-state { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; flex-wrap: wrap; }
/* The enrolment code gets read out over the phone, so it needs to be unmistakable. */
.dev-code {
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; font-weight: 700;
    letter-spacing: .18em; background: var(--bg); border: 1px solid var(--border);
    border-radius: 7px; padding: .15rem .5rem; color: var(--accent-bright);
}
.dev-seen { color: var(--text-muted); font-size: .78rem; }
/* The unit id is the device's identity — same monospace treatment as a registration so the eye
   picks it out of the row, but quieter than the enrolment code, which is the urgent thing. */
.dev-unit {
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; font-weight: 700;
    letter-spacing: .06em; color: var(--accent-bright);
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; padding: .1rem .45rem;
}
/* An expired code is struck through as well as re-coloured — the state has to survive being read
   by someone who can't tell the two shades apart. */
.dev-code.is-expired { text-decoration: line-through; opacity: .65; }
.dev-row.is-clickable { cursor: pointer; }
.dev-row.is-clickable:hover { border-color: var(--accent); }
/* Add-device dialog: the code is the reason the dialog exists, so it gets the whole top of it. */
.dev-code-panel {
    background: var(--bg); border: 1px dashed var(--border);
    border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 1.25rem; text-align: center;
}
.dev-code-panel.is-used { text-align: left; }
.dev-code-label {
    font-size: .66rem; font-weight: 700; letter-spacing: .14em;
    color: var(--text-dim); margin-bottom: .5rem;
}
.dev-code-value {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 2rem; font-weight: 700; letter-spacing: .22em;
    color: var(--accent-bright); margin-bottom: .6rem; word-break: break-all;
}
.dev-code-help { color: var(--text-muted); font-size: .8rem; line-height: 1.45; }
.dev-bind { display: flex; gap: .4rem; flex: 0 0 auto; }
.dev-bind .form-select { min-width: 10rem; }
.dev-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.dev-actions form { display: inline; }
.dev-note { color: var(--text-dim); font-size: .8rem; margin-top: 1rem; }
