/* iTG Trakvyn web — design system. Colours follow the phone app's theme. */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3fa;
  --surface-3: #e3ebf6;
  --border: #d9e2ee;
  --border-strong: #c3d0e2;
  --text: #0b2245;
  --muted: #526279;
  --faint: #8090a6;
  --accent: #0754a8;
  --accent-hover: #06478f;
  --on-accent: #ffffff;
  --accent-soft: #dcebfa;
  --fill: #0754a8;
  --fill-hover: #06478f;
  --on-fill: #ffffff;
  --cyan: #00c8f0;
  --success: #0b7a53;
  --success-soft: #dcf3e9;
  --warning: #9a5b00;
  --warning-soft: #fcefd8;
  --danger: #c11f31;
  --danger-soft: #fbe4e6;
  --info: #0754a8;
  --info-soft: #dcebfa;
  --neutral: #66768c;
  --neutral-soft: #e8edf4;
  --nav-bg: #061836;
  --nav-bg-2: #0b2a55;
  --nav-text: #a5b6cd;
  --nav-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(11, 34, 69, .06);
  --shadow: 0 4px 16px rgba(11, 34, 69, .08);
  --shadow-lg: 0 16px 48px rgba(6, 24, 54, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --st-moving: #12a26b;
  --st-idle: #e09a14;
  --st-parked: #3b7dd8;
  --st-offline: #8b9db5;
  --st-over: #e0384b;
  --map-filter: none;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #121a2b;
  --surface-2: #182236;
  --surface-3: #202c43;
  --border: #243149;
  --border-strong: #33425f;
  --text: #e7ecf5;
  --muted: #9ba8bf;
  --faint: #6c7a93;
  --accent: #7ab4ff;
  --accent-hover: #9ac6ff;
  --on-accent: #0b1120;
  --accent-soft: rgba(122, 180, 255, .13);
  --fill: #2f6fed;
  --fill-hover: #4682f2;
  --on-fill: #ffffff;
  --success: #4ad295;
  --success-soft: rgba(74, 210, 149, .13);
  --warning: #f3b65a;
  --warning-soft: rgba(243, 182, 90, .12);
  --danger: #ff7b88;
  --danger-soft: rgba(255, 123, 136, .13);
  --info: #7ab4ff;
  --info-soft: rgba(122, 180, 255, .13);
  --neutral: #8e9bb2;
  --neutral-soft: rgba(142, 155, 178, .14);
  --nav-bg: #0d1424;
  --nav-bg-2: #0d1424;
  --nav-text: #9ba8bf;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  --map-filter: brightness(.78) contrast(1.08) saturate(.55) hue-rotate(190deg) invert(.9);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #121a2b;
    --surface-2: #182236;
    --surface-3: #202c43;
    --border: #243149;
    --border-strong: #33425f;
    --text: #e7ecf5;
    --muted: #9ba8bf;
    --faint: #6c7a93;
    --accent: #7ab4ff;
    --accent-hover: #9ac6ff;
    --on-accent: #0b1120;
    --accent-soft: rgba(122, 180, 255, .13);
    --fill: #2f6fed;
    --fill-hover: #4682f2;
    --on-fill: #ffffff;
    --success: #4ad295;
    --success-soft: rgba(74, 210, 149, .13);
    --warning: #f3b65a;
    --warning-soft: rgba(243, 182, 90, .12);
    --danger: #ff7b88;
    --danger-soft: rgba(255, 123, 136, .13);
    --info: #7ab4ff;
    --info-soft: rgba(122, 180, 255, .13);
    --neutral: #8e9bb2;
    --neutral-soft: rgba(142, 155, 178, .14);
    --nav-bg: #0d1424;
    --nav-bg-2: #0d1424;
    --nav-text: #9ba8bf;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
    --map-filter: brightness(.78) contrast(1.08) saturate(.55) hue-rotate(190deg) invert(.9);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.spacer { flex: 1; }
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  color: var(--nav-text); display: flex; flex-direction: column; padding: 18px 14px; gap: 4px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; filter: drop-shadow(0 4px 10px rgba(0, 200, 240, .25)); }
.brand b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand small { display: block; font-size: 11px; color: var(--nav-text); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #5f7596; padding: 12px 12px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px;
  color: var(--nav-text); font-weight: 600; text-decoration: none; position: relative;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(0, 200, 240, .13); color: var(--nav-active); }
.nav-link.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cyan); }
.nav-link .ic { opacity: .9; }
.nav-link .count { margin-left: auto; background: #e0384b; color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.org-card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 10px 12px; font-size: 12px; }
.org-card b { color: #fff; display: block; font-size: 13px; }
.org-select { background: rgba(255,255,255,.07); color: #fff; border-color: rgba(255,255,255,.14); }
.org-select option { color: #0b2245; background: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .title { min-width: 0; }
.topbar .title h1 { font-size: 19px; }
.topbar .title p { color: var(--muted); font-size: 12.5px; }
.content { padding: 24px 28px 40px; flex: 1; min-width: 0; }
.content.flush { padding: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* Map pages fill exactly the space under the top bar, whatever banners sit above them. */
.main.fit { height: 100vh; overflow: hidden; }
.btn.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); font: inherit; }
.user-chip:hover { border-color: var(--border-strong); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 13px; color: #fff; background: linear-gradient(135deg, #0754a8, #00c8f0); flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.user-chip .who { line-height: 1.15; text-align: left; }
.user-chip .who b { font-size: 13px; display: block; }
.user-chip .who span { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0;
  background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

.banner { display: flex; align-items: center; gap: 12px; padding: 10px 28px; background: var(--warning-soft); color: var(--text); font-size: 13px; border-bottom: 1px solid var(--border); }
.banner .ic { color: var(--warning); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid transparent; background: var(--fill); color: var(--on-fill);
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--fill-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.07); background: var(--danger); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 31px; }
.btn.block { width: 100%; }
.btn .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 0; }
label.field .hint { font-weight: 500; color: var(--faint); }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.sm { height: 33px; font-size: 13px; border-radius: 8px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.switch { position: relative; width: 40px; height: 23px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + span { background: var(--fill); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-error { color: var(--danger); font-size: 12.5px; font-weight: 600; min-height: 0; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 0; }
.card-head h2 { flex: 1; min-width: 0; }
.card-head p { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 0; }
.card + .card { margin-top: 18px; }
.grid > .card + .card, .kpis > .card + .card, .stack > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.section-gap { margin-top: 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(142px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; display: flex; gap: 13px; align-items: center; box-shadow: var(--shadow-sm); min-width: 0; text-decoration: none; color: var(--text); }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }
.kpi > div:last-child { min-width: 0; }
.kpi .kpi-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.kpi .kpi-ic.moving { background: color-mix(in srgb, var(--st-moving) 16%, transparent); color: var(--st-moving); }
.kpi .kpi-ic.idle { background: color-mix(in srgb, var(--st-idle) 18%, transparent); color: var(--st-idle); }
.kpi .kpi-ic.parked { background: color-mix(in srgb, var(--st-parked) 16%, transparent); color: var(--st-parked); }
.kpi .kpi-ic.offline { background: var(--neutral-soft); color: var(--neutral); }
.kpi .kpi-ic.danger { background: var(--danger-soft); color: var(--danger); }
.kpi strong { white-space: nowrap; display: block; font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi span { color: var(--muted); font-size: 12.5px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi { gap: 11px; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.moving { background: color-mix(in srgb, var(--st-moving) 15%, transparent); color: var(--st-moving); }
.pill.idle { background: color-mix(in srgb, var(--st-idle) 17%, transparent); color: var(--st-idle); }
.pill.parked { background: color-mix(in srgb, var(--st-parked) 15%, transparent); color: var(--st-parked); }
.pill.offline, .pill.pending { background: var(--neutral-soft); color: var(--neutral); }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.moving .dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 50% { box-shadow: 0 0 0 4px transparent; } }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Chips / segmented ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .75; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { height: 30px; padding: 0 12px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button, .tabs a { height: 42px; padding: 0 14px; border: 0; background: none; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.tabs button.active, .tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Tables & lists ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 750; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--surface-2); }
.table td.actions { text-align: right; white-space: nowrap; }
.cell-title { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--muted); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
a.list-item { color: var(--text); text-decoration: none; }
a.list-item:hover, button.list-item:hover { background: var(--surface-2); text-decoration: none; }
button.list-item { width: 100%; border: 0; border-top: 1px solid var(--border); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.icon-tile { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.icon-tile.danger { background: var(--danger-soft); color: var(--danger); }
.icon-tile.warning { background: var(--warning-soft); color: var(--warning); }
.icon-tile.success { background: var(--success-soft); color: var(--success); }
.icon-tile.neutral { background: var(--neutral-soft); color: var(--neutral); }
.day-head { padding: 14px 18px 6px; font-size: 12px; font-weight: 750; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .icon-tile { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 4px; }
.empty b { color: var(--text); font-size: 15px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Status meter & bars ---------- */
.donut { width: 132px; height: 132px; border-radius: 50%; position: relative; flex: none; }
.donut::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: var(--surface); }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; text-align: center; line-height: 1.1; }
.donut .center b { font-size: 26px; font-weight: 800; display: block; }
.donut .center span { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.legend { display: flex; flex-direction: column; gap: 9px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--fill), var(--accent)); }

/* ---------- Map ---------- */
.map { width: 100%; height: 100%; min-height: 280px; background: var(--surface-2); border-radius: inherit; z-index: 0; }
.map .leaflet-tile-pane { filter: var(--map-filter); }
.map.satellite .leaflet-tile-pane { filter: none; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; width: 34px !important; height: 34px !important; line-height: 34px !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.map-tools { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 500; }
.map-tool { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.map-tool:hover { background: var(--surface-2); }
.map-tool.active { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }
.map-card { position: relative; overflow: hidden; }
.map-legend { position: absolute; left: 12px; bottom: 22px; z-index: 500; display: flex; gap: 12px; padding: 7px 12px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--border); font-size: 11.5px; font-weight: 700; box-shadow: var(--shadow-sm); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.vmark { position: relative; width: 44px; height: 44px; }
.vmark .halo { position: absolute; inset: 4px; border-radius: 50%; background: var(--c); opacity: .22; }
.vmark.moving .halo { animation: halo 1.8s ease-out infinite; }
@keyframes halo { 0% { transform: scale(.7); opacity: .45; } 100% { transform: scale(1.5); opacity: 0; } }
.vmark .body { position: absolute; inset: 9px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 3px 10px rgba(6, 24, 54, .35); display: grid; place-items: center; }
.vmark .body svg { width: 14px; height: 14px; fill: #fff; stroke: none; transition: transform .4s; }
.vmark.sel .body { inset: 6px; border-width: 3px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), 0 4px 14px rgba(6, 24, 54, .4); }
.vmark .label { position: absolute; top: 42px; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 2px 8px; border-radius: 7px; font-size: 11px; font-weight: 800; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.pin-mark { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #fff; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; box-shadow: 0 3px 8px rgba(0,0,0,.3); }

/* ---------- Live page ---------- */
.live { display: grid; grid-template-columns: 360px 1fr; flex: 1; min-height: 0; }
.live-list { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.live-list .filters { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.live-list .items { overflow-y: auto; flex: 1; }
.vrow { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; width: 100%; background: none; border-left: 3px solid transparent; border-top: 0; border-right: 0; font: inherit; color: inherit; text-align: left; }
.vrow:hover { background: var(--surface-2); }
.vrow.sel { background: var(--accent-soft); border-left-color: var(--accent); }
.vrow .vic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); }
.vrow .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vrow .speed { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.vrow .speed small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.live-map { position: relative; min-width: 0; }
.live-map .map { border-radius: 0; }
.detail { position: absolute; left: 16px; bottom: 16px; width: 380px; max-height: calc(100% - 32px); overflow-y: auto; z-index: 600; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.detail-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 12px; }
.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-stats > div { padding: 12px 14px; border-left: 1px solid var(--border); min-width: 0; }
.detail-stats > div:first-child { border-left: 0; }
.detail-stats b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.detail-stats span { font-size: 11.5px; color: var(--muted); font-weight: 650; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; padding: 14px 16px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; text-align: right; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.detail-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 16px 16px; }
.action-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer; text-decoration: none; }
.action-tile:hover { border-color: var(--border-strong); text-decoration: none; background: var(--surface-3); }
.action-tile.on { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }
.address { padding: 0 16px 12px; display: flex; gap: 8px; color: var(--muted); font-size: 12.5px; }

/* ---------- History ---------- */
.history { display: grid; grid-template-columns: 380px 1fr; flex: 1; min-height: 0; }
.history-side { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.history-side .controls { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.history-side .scroll { overflow-y: auto; flex: 1; }
.trip { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; width: 100%; background: none; border-left: 3px solid transparent; border-top: 0; border-right: 0; font: inherit; color: inherit; text-align: left; }
.trip:hover { background: var(--surface-2); }
.trip.sel { background: var(--accent-soft); border-left-color: var(--accent); }
.trip .rail { display: flex; flex-direction: column; align-items: center; padding-top: 4px; }
.trip .rail i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--success); background: var(--surface); }
.trip .rail i:last-child { border-color: var(--danger); background: var(--danger); }
.trip .rail span { width: 2px; flex: 1; min-height: 16px; background: var(--border-strong); margin: 3px 0; }
.trip .stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.trip .stats b { color: var(--text); }
.history-map { position: relative; min-width: 0; display: flex; flex-direction: column; }
.history-map .map { flex: 1; border-radius: 0; }
.player { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border); }
.player input[type=range] { flex: 1; accent-color: var(--accent); min-width: 80px; }
.player .readout { min-width: 150px; text-align: right; font-variant-numeric: tabular-nums; }
.player .readout b { display: block; font-size: 16px; font-weight: 800; }
.player .readout span { font-size: 12px; color: var(--muted); font-weight: 600; }
.play-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--fill); color: var(--on-fill); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: var(--shadow); }
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border-bottom: 1px solid var(--border); }
.summary-strip > div { background: var(--surface); padding: 10px 12px; }
.summary-strip b { display: block; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary-strip span { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Modal, drawer, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(6, 24, 54, .55); backdrop-filter: blur(3px); z-index: 1000; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: 18px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal.wide { width: min(820px, 100%); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 0; }
.modal-head h2 { font-size: 18px; flex: 1; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }
.steps { display: flex; gap: 8px; padding: 14px 22px 0; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-3); }
.steps span.on { background: linear-gradient(90deg, var(--fill), var(--accent)); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-weight: 600; animation: rise .2s; }
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: var(--success); }
.toast.err .ic { color: var(--danger); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--info-soft); color: var(--text); font-size: 13px; }
.callout .ic { color: var(--info); margin-top: 1px; }
.callout.warning { background: var(--warning-soft); }
.callout.warning .ic { color: var(--warning); }
.callout.danger { background: var(--danger-soft); }
.callout.danger .ic { color: var(--danger); }
.codebox { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.9; word-break: break-all; }

/* ---------- Vehicle cards ---------- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.vcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none; }
a.vcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.vcard .top { display: flex; gap: 12px; align-items: center; }
.vcard .vic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); flex: none; }
.vcard .facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.vcard .facts div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.vcard .facts b { display: block; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.vcard .facts span { font-size: 11px; color: var(--muted); font-weight: 650; }
.plate { display: inline-block; padding: 1px 7px; border-radius: 5px; border: 1.5px solid var(--border-strong); font-weight: 800; font-size: 11.5px; letter-spacing: .05em; background: var(--surface); color: var(--text); }

/* ---------- Hero (vehicle detail) ---------- */
.hero { border-radius: 18px; padding: 22px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #0b4a8f 0%, #061836 60%); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; border: 36px solid rgba(0, 200, 240, .08); }
.hero .muted { color: #a5b6cd; }
.hero .plate { background: #fff; color: #061836; border-color: #fff; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 18px; position: relative; z-index: 1; }
.hero-stats div { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .09); border-radius: 12px; padding: 10px 12px; }
.hero-stats b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-stats span { font-size: 11.5px; color: #a5b6cd; font-weight: 650; }

/* ---------- Score ring ---------- */
.ring { --p: 0; --c: var(--success); width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); display: grid; place-items: center; flex: none; }
.ring > div { width: 94px; height: 94px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring b { font-size: 28px; font-weight: 800; }
.ring span { font-size: 11px; color: var(--muted); font-weight: 700; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; background: radial-gradient(110% 90% at 85% 15%, #0b4a8f 0%, #061836 58%, #040f24 100%); }
.auth-hero .roads { position: absolute; inset: 0; opacity: .5; }
.auth-hero .brand { padding: 0; position: relative; z-index: 1; }
.auth-hero .brand img { width: 48px; height: 48px; }
.auth-hero .brand b { font-size: 20px; }
.auth-copy { margin-top: auto; position: relative; z-index: 1; max-width: 480px; }
.auth-copy h2 { font-size: 38px; line-height: 1.12; font-weight: 800; letter-spacing: -.02em; }
.auth-copy h2 em { font-style: normal; background: linear-gradient(90deg, #00c8f0, #5fb6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-copy p { color: #a5b6cd; font-size: 15px; margin-top: 14px; }
.auth-points { display: flex; gap: 22px; margin-top: 28px; flex-wrap: wrap; }
.auth-points div { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13px; color: #d7e3f4; }
.auth-points .ic { color: #00c8f0; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(410px, 100%); }
.auth-card h1 { font-size: 26px; }
.auth-card .sub { color: var(--muted); margin: 6px 0 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .foot { margin-top: 22px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-card .mobile-brand { display: none; margin-bottom: 26px; }
.alert-box { padding: 11px 13px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.alert-box.err { background: var(--danger-soft); color: var(--danger); }
.alert-box.ok { background: var(--success-soft); color: var(--success); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid.side { grid-template-columns: 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(6,24,54,.5); z-index: 35; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 32px; }
  .banner { padding: 10px 16px; }
  .main.fit { height: auto; overflow: visible; }
  .live, .history { grid-template-columns: 1fr; grid-template-rows: 50vh auto; flex: none; }
  .live-list .items, .history-side .scroll { max-height: none; overflow: visible; }
  .live-map, .history-map { order: -1; min-height: 50vh; }
  .live-list, .history-side { border-right: 0; border-top: 1px solid var(--border); }
  .detail { position: fixed; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 62vh; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .mobile-brand { display: flex; }
  .user-chip .who { display: none; }
  .topbar .title p { display: none; }
}
@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .topbar .title h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar > .btn:not(.icon) { width: 38px; padding: 0; }
  .topbar > .btn:not(.icon) span, .topbar > .pill { display: none; }
  .banner { font-size: 12px; gap: 8px; }
  .banner .grow { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px; gap: 10px; }
  .kpi .kpi-ic { width: 36px; height: 36px; }
  .kpi strong { font-size: 19px; }
  .detail-actions { grid-template-columns: repeat(4, 1fr); }
  .player { flex-wrap: wrap; }
  .player .readout { min-width: 0; text-align: left; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
}
@media print {
  .sidebar, .topbar, .banner { display: none !important; }
  .shell { display: block; }
}

/* Dark theme: the sidebar is a flat panel separated by a hairline; the brand gradient stays for light. */
:root[data-theme="dark"] .sidebar { border-right: 1px solid var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sidebar { border-right: 1px solid var(--border); } }
:root[data-theme="dark"] .nav-link.active { background: rgba(122, 180, 255, .12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav-link.active { background: rgba(122, 180, 255, .12); } }

/* Password fields with a show/hide button. */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
