:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e4eaf2;
  --text: #0f1b2d;
  --muted: #62728a;
  --brand: #1466c9;
  --brand-2: #0e8f9a;
  --brand-soft: #e8f1fc;
  --running: #16a34a;
  --idle: #eab308;
  --stopped: #ef4444;
  --offline: #94a3b8;
  --overspeed: #7c3aed;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px -12px rgba(15, 27, 45, .14);
  --top: 60px;
  /* Read-only and disabled fields are always grey (site-wide rule, see "LOCKED FIELDS"). */
  --locked-bg: #eef1f5;
  --locked-fg: #6b7c93;
  --locked-border: #dfe5ed;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
body.booting .view { visibility: hidden; }
button { font: inherit; cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent; }
/* No focus ring on mouse/touch clicks; keep a clear one for keyboard users. */
button:focus, a:focus, [tabindex]:focus { outline: none; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
svg { flex-shrink: 0; }

/* ================= TOP BAR ================= */
.topbar {
  position: relative; z-index: 1000; height: var(--top); display: flex; align-items: center; gap: 28px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: 4px; height: 100%; }
.vendor-mode .tabs { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab svg { width: 18px; height: 18px; fill: currentColor; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.lang { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 4px 0 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.lang:focus-within { border-color: var(--brand); }
.lang svg { width: 17px; height: 17px; fill: currentColor; flex-shrink: 0; }
.lang select { border: 0; outline: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); padding-right: 4px; cursor: pointer; }

/* Google Translate: keep its toolbar, hover tooltips and highlights out of the layout. */
.skiptranslate iframe, iframe.goog-te-banner-frame, .goog-te-banner-frame, #goog-gt-tt, .goog-te-balloon-frame,
.VIpgJd-ZVi9od-ORHb-OEVmcd, .VIpgJd-ZVi9od-aZ2wEe-wOHMyf { display: none !important; }
body { top: 0 !important; }
.goog-text-highlight, font[style] { background: none !important; box-shadow: none !important; }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px; border-radius: 99px; }
.avatar-sm {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.user-name { font-weight: 600; font-size: 14px; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.um-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.um-head b { display: block; font-size: 14px; }
.um-head small { color: var(--muted); text-transform: capitalize; }
.user-menu button { width: 100%; text-align: left; border: 0; background: none; padding: 11px 14px; color: #b42318; font-weight: 600; }
.user-menu button:hover { background: #fef2f2; }

/* Dark blue header (home page and vendor tabs) */
.topbar { background: #0b2e63; border-bottom-color: #0b2e63; color: #fff; }
.topbar .brand { color: #fff; }
.topbar .brand img { border-radius: 10px; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .25); }
.topbar .tab { color: #b7c9e4; }
.topbar .tab:hover { color: #fff; }
.topbar .tab.active { color: #fff; border-bottom-color: #5aa9ff; }
.topbar .lang { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: #b7c9e4; }
.topbar .lang:focus-within { border-color: #5aa9ff; }
.topbar .lang select { color: #fff; }
.topbar .lang option { color: var(--text); background: #fff; }
.topbar .user-btn { color: #fff; }
.topbar .user-btn:hover { background: rgba(255, 255, 255, .1); }
.topbar .avatar-sm { box-shadow: 0 0 0 2px rgba(255, 255, 255, .3); }
.topbar .user-menu { color: var(--text); }
/* Back to home, top right of tabs opened from dashboard cards */
.home-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 99px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .28); color: #fff; font-size: 13.5px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.home-btn:hover { background: rgba(255, 255, 255, .22); }
.home-btn svg { width: 17px; height: 17px; fill: currentColor; flex-shrink: 0; }
.top-right .home-btn { margin-left: 0; }

.view { height: calc(100% - var(--top)); }

/* ================= DASHBOARD ================= */
.dashboard { overflow-y: auto; }
.dash-inner { max-width: 1400px; margin: 0 auto; padding: 28px 24px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 0; }
/* Pages with Download reports / Export CSV / Print (reports, D2D lists): title and description
   take the remaining width and the buttons stay top right on the same row. */
.page-head:has(.rp-actions) { flex-wrap: nowrap; align-items: flex-start; }
.page-head:has(.rp-actions) > div:first-child { flex: 1; min-width: 0; }
.page-head .rp-actions { flex-shrink: 0; }
.clock { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 30px; }
.kpi {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); text-align: left; transition: transform .12s, box-shadow .12s;
}
button.kpi { cursor: pointer; user-select: none; }
button.kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -12px rgba(15, 27, 45, .25); }
button.kpi:active { transform: translateY(0) scale(.98); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--brand)); }
.kpi .k-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .k-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--brand)) 12%, transparent); color: var(--c, var(--brand)); }
.kpi .k-icon svg { width: 17px; height: 17px; fill: currentColor; }
.kpi .k-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.section-tools input {
  width: 240px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.count-badge { background: #fee2e2; color: #b42318; font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 99px; }

.vendor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.vcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.vcard { cursor: pointer; user-select: none; }
.vcard:hover { transform: translateY(-3px); box-shadow: 0 18px 36px -16px rgba(15, 27, 45, .3); border-color: #cddbee; }
.vcard:active { transform: translateY(-1px) scale(.99); }
.vcard:hover .vc-cta { background: var(--brand); color: #fff; border-color: var(--brand); }
.vc-head { display: flex; align-items: center; gap: 12px; }
.vc-avatar {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
  background: linear-gradient(135deg, hsl(var(--h) 70% 48%), hsl(calc(var(--h) + 40) 70% 42%));
  box-shadow: 0 8px 18px -8px hsl(var(--h) 70% 40%);
}
.vc-name { flex: 1; min-width: 0; }
.vc-name h3 { margin: 0 0 2px; font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vc-name small { color: var(--muted); font-size: 12.5px; }
.ring { width: 54px; height: 54px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 800; }
.vc-total { display: flex; align-items: baseline; gap: 8px; }
.vc-total b { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.vc-total span { color: var(--muted); font-size: 14px; }
.vc-total .vc-live { margin-left: auto; font-size: 12.5px; color: var(--running); font-weight: 600; }
.sbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.sbar span { display: block; height: 100%; transition: width .4s; }
.sbar .running { background: var(--running); } .sbar .idle { background: var(--idle); }
.sbar .stopped { background: var(--stopped); } .sbar .offline { background: var(--offline); }
.vc-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.vc-legend div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.vc-legend b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.vc-legend small { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; }
.vc-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.vc-types { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 7px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }
.tchip .glyph { width: 24px; height: 18px; }
.vc-cta {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--brand);
}
.vc-cta:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); margin: 0; }
.type-list { display: grid; gap: 10px; }
.trow { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; }
.trow .t-ic { width: 44px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.trow .t-name { font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.trow .t-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.trow .t-bar span { height: 100%; }
.trow .t-num { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.alert-list { display: grid; gap: 8px; max-height: 340px; overflow-y: auto; }
.arow {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); text-align: left; width: 100%;
}
.arow:hover { background: var(--surface-2); }
.arow .a-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 800; }
.arow .a-main { flex: 1; min-width: 0; }
.arow b { font-size: 14px; }
.arow small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow .a-tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: #fff; background: var(--c); white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; background: var(--surface-2); border-radius: 12px; }

/* ================= LIVE MAP ================= */
.mapview { display: flex; position: relative; }
.sidebar { width: 340px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sb-top { padding: 14px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
/* Zone tab: Zone (read-only) and Ward at the top of the Live map panel */
.sb-area { display: grid; gap: 8px; }
.sb-field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sb-field input, .sb-field select { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font: inherit; font-size: 13.5px; color: var(--text); }
.sb-field .ss-btn { max-width: none; }

/* Vendor tab navigation (replaces the header tabs) */
.vnav { display: grid; gap: 2px; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.vnav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.vnav a:hover { background: var(--surface-2); color: var(--text); }
.vnav-vendor { padding: 2px 10px 8px; font-size: 16px; font-weight: 800; color: #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vnav svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.vnav .vnav-home { color: var(--brand); }
.vnav .vnav-item.active { background: var(--brand-soft); color: var(--brand); }
.rp-nav .vnav { padding: 0 0 12px; margin-bottom: 14px; }

/* Vendor tab: light blue left panel. Re-scoping the tokens recolours everything inside it. */
.vendor-mode .sidebar, .vendor-mode .rp-nav, .vendor-mode .al-side {
  --surface-2: #d3e6fa;
  --border: #bfd7f0;
  --text: #0b2545;
  --muted: #3d5a80;
  --brand: #0d55a8;
  background: #e3f0fc; color: var(--text); border-color: var(--border);
}
.vendor-mode .vnav a { color: var(--text); }
.vendor-mode .vnav a:hover { background: #cfe3f8; }
.vendor-mode .vnav .vnav-home { color: var(--brand); }
.vendor-mode .vnav .vnav-item.active, .vendor-mode .rp-item.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(11, 37, 69, .12); }
/* Zone/ward/vendor tab Live map: a compact top (menu, Zone + Ward side by side, search, chips)
   so the vehicle list starts higher and has more room. */
.vendor-mode .sidebar .vnav { padding: 8px 10px; gap: 0; }
.vendor-mode .sidebar .vnav a { padding: 6px 10px; }
.vendor-mode .sidebar .vnav-vendor { padding: 0 10px 4px; }
.vendor-mode .sb-top { padding: 10px 14px; gap: 8px; }
.vendor-mode .sb-area { grid-template-columns: 1fr 1fr; gap: 8px; }
.vendor-mode .sb-field { min-width: 0; }
.vendor-mode .sb-field input, .vendor-mode .sb-field select, .vendor-mode .sb-field .ss-btn { height: 34px; min-width: 0; width: 100%; text-overflow: ellipsis; }
.vendor-mode .search { height: 36px; }
.vendor-mode .chips { gap: 4px; }
.vendor-mode .chip { padding: 3px 8px; gap: 5px; font-size: 12px; }
.vendor-mode .vendors { padding: 6px 8px; }
.vendor-mode .vg-head { padding: 8px 10px; }

/* Vendor menu: hovering Reports lists every report (positioned by placeFlyout in app.js). */
.vnav-caret { margin-left: auto; font-size: 17px; line-height: 1; opacity: .55; }
.vnav-flyout {
  display: none; position: fixed; z-index: 1500; width: 240px; padding: 8px; background: #fff; color: #0b2545;
  border: 1px solid #bfd7f0; border-radius: 12px; box-shadow: 0 12px 32px rgba(11, 37, 69, .18);
}
.vnav-menu:hover .vnav-flyout, .vnav-menu:has(:focus-visible) .vnav-flyout { display: block; }
.vnav-menu.closed .vnav-flyout { display: none; }
.vnav-flyout h5 { margin: 2px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: #3d5a80; }
.vnav-flyout button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: inherit; text-align: left; cursor: pointer;
}
.vnav-flyout button:hover, .vnav-flyout button:focus-visible { background: #e3f0fc; color: #0d55a8; outline: 0; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.search:focus-within { border-color: var(--brand); background: var(--surface); }
.search svg { width: 18px; height: 18px; fill: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; }
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.running i { background: var(--running); } .chip.idle i { background: var(--idle); }
.chip.stopped i { background: var(--stopped); } .chip.offline i { background: var(--offline); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip.active b { color: #fff; }
.vendor-filter { display: flex; align-items: center; gap: 8px; margin: 10px 14px 0; padding: 8px 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; }
.vendor-filter span { flex: 1; }
.vendor-filter button { border: 0; background: none; color: var(--brand); font-weight: 700; }
.vendors { overflow-y: auto; flex: 1; padding: 8px; }
.vgroup { border-radius: 12px; margin-bottom: 6px; border: 1px solid transparent; }
.vgroup.open { border-color: var(--border); background: var(--surface-2); }
.vg-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; background: none; text-align: left; border-radius: 12px; }
.vg-head:hover { background: var(--surface-2); }
.vg-av { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; background: linear-gradient(135deg, hsl(var(--h) 70% 48%), hsl(calc(var(--h) + 40) 70% 42%)); }
.vg-name { flex: 1; min-width: 0; }
.vg-name b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vg-name .mini-bar { display: flex; height: 4px; border-radius: 99px; overflow: hidden; margin-top: 5px; background: var(--border); }
.vg-name .mini-bar span { height: 100%; }
.vg-count { font-size: 12px; color: var(--muted); font-weight: 600; }
.chev { color: var(--muted); transition: transform .15s; font-size: 11px; }
.vgroup.open .chev { transform: rotate(90deg); }
.vlist { display: none; padding: 0 6px 6px; }
.vgroup.open .vlist { display: block; }
.vrow { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: none; text-align: left; font-size: 13px; border-radius: 9px; }
.vrow:hover { background: var(--surface); }
.vrow.selected { background: var(--surface); box-shadow: inset 3px 0 0 var(--brand); }
.vr-ic { width: 34px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.vr-main { flex: 1; min-width: 0; }
.vr-main b { display: block; font-size: 13px; }
.vr-main small { color: var(--muted); font-size: 11.5px; }
.vr-spd { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; color: var(--muted); }
.vr-spd.over { color: var(--overspeed); }

/* Map on top, playback player docked underneath (never covering the map). */
.map-wrap { flex: 1; position: relative; min-width: 0; display: flex; flex-direction: column; }
#map { position: relative; flex: 1; min-height: 0; background: #e8edf3; }
.sidebar-toggle { display: none; position: absolute; top: 12px; left: 12px; z-index: 500; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 18px; box-shadow: var(--shadow); }

/* markers */
.vmarker { background: none; border: 0; }
.vm { position: relative; width: 40px; height: 40px; }
.vm-body {
  position: absolute; inset: 4px; border-radius: 50%; background: #fff; border: 3px solid var(--c); color: var(--c);
  display: grid; place-items: center; box-shadow: 0 3px 8px rgba(15, 27, 45, .3);
}
.vm-dir { position: absolute; inset: 0; transition: transform .6s linear; }
.vm-dir span { position: absolute; left: 50%; top: -3px; margin-left: -5px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--c); }
.vm-over .vm-body::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2.5px solid var(--overspeed); animation: pulse 1.2s infinite; }
.vm-sel .vm-body { box-shadow: 0 0 0 4px rgba(20, 102, 201, .35), 0 3px 8px rgba(15, 27, 45, .3); }
@keyframes pulse { from { opacity: 1; transform: scale(.85); } to { opacity: 0; transform: scale(1.35); } }

/* tooltips */
.leaflet-tooltip.vtip { padding: 0; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 12px 32px -8px rgba(15, 27, 45, .3); font-family: inherit; }
.tt { min-width: 250px; font-size: 12.5px; }
.tt-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tt-ic { width: 38px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.tt-head b { display: block; font-size: 14px; }
.tt-head small { color: var(--muted); }
.tt-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 10px 12px; }
.tt-grid span:nth-child(odd) { color: var(--muted); }
.tt-grid span:nth-child(even) { font-weight: 600; text-align: right; }
.tt-alerts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px 10px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; color: #fff; text-transform: uppercase; letter-spacing: .02em; }
.badge.running { background: var(--running); } .badge.idle { background: var(--idle); }
.badge.stopped { background: var(--stopped); } .badge.offline { background: var(--offline); }
.badge.overspeed { background: var(--overspeed); } .badge.alert { background: #b91c1c; }

/* legend */
.legend { position: absolute; left: 12px; bottom: 24px; z-index: 450; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); font-size: 12px; max-width: 230px; }
.legend-toggle { border: 0; background: none; padding: 8px 12px; font-weight: 700; font-size: 12px; width: 100%; text-align: left; }
.legend-body { padding: 0 12px 10px; display: grid; gap: 6px; }
.legend.collapsed .legend-body { display: none; }
.lg-row { display: flex; align-items: center; gap: 8px; }
.lg-row .glyph { color: var(--text); }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; }
.lg-sep { height: 1px; background: var(--border); margin: 2px 0; }
.map-wrap.playing .legend { display: none; }

/* ================= PLAYER ================= */
.player {
  position: relative; z-index: 800; flex-shrink: 0; background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -10px 24px -18px rgba(15, 27, 45, .45); padding: 12px 18px 10px;
}
.pl-top { display: flex; align-items: center; gap: 18px; }
.pl-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.pl-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pl-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; }
.pl-legend .k-speed { height: 3px; background: var(--brand); }
.pl-legend .k-over { height: 3px; background: var(--overspeed); }
.pl-legend .k-idle { background: rgba(234, 179, 8, .35); }
.pl-legend .k-stop { background: rgba(239, 68, 68, .28); }
.pl-legend .k-limit { height: 0; border-top: 2px dashed var(--overspeed); }
.pl-controls { display: flex; align-items: center; gap: 6px; }
.pl-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; }
.pl-btn svg { width: 18px; height: 18px; fill: var(--text); }
.pl-btn.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px -6px rgba(20, 102, 201, .6); }
.pl-btn.play svg { fill: #fff; width: 22px; height: 22px; }
.pl-btn.play .i-pause { display: none; }
.player.is-playing .pl-btn.play .i-play { display: none; }
.player.is-playing .pl-btn.play .i-pause { display: block; }
.pl-speed { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.pl-speed button { border: 0; background: none; padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--muted); }
.pl-speed button.on { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(15, 27, 45, .15); }
.pl-readout { display: flex; align-items: center; gap: 14px; min-width: 0; }
.pl-time { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.pl-now { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.pl-now b { color: var(--text); font-variant-numeric: tabular-nums; }
.pl-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.pl-follow {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  white-space: nowrap; padding: 5px 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2);
}
.pl-follow input { margin: 0; accent-color: var(--brand); }
.pl-right { gap: 8px; }
.pl-close { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); }
.pl-close:hover { background: #fee2e2; color: #b42318; }
.pl-chart { position: relative; height: 78px; margin-top: 8px; cursor: pointer; touch-action: none; }
.pl-chart canvas { width: 100%; height: 100%; display: block; }
.pl-hover { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--text); color: #fff; font-size: 11.5px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
.pl-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ================= PANEL ================= */
.panel { width: 380px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ph-icon { width: 52px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.ph-text { flex: 1; min-width: 0; }
.panel-title { font-size: 18px; font-weight: 800; display: flex; gap: 8px; align-items: center; letter-spacing: -.01em; }
.panel-sub { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.close { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; color: var(--muted); }
.panel-body { padding: 16px; overflow-y: auto; flex: 1; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }

.pb-card { border-radius: 14px; padding: 14px; background: linear-gradient(160deg, #eef5fe, #eefaf8); border: 1px solid #d6e6f7; display: grid; gap: 12px; }
.pb-card-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.pb-card-head svg { width: 20px; height: 20px; fill: var(--brand); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { padding: 6px 11px; border-radius: 99px; border: 1px solid #cfdcee; background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.presets button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.custom-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.custom-range label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.custom-range input { padding: 7px 8px; border: 1px solid #cfdcee; border-radius: 9px; font-size: 12.5px; background: var(--surface); min-width: 0; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 0; border-radius: 11px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px -8px rgba(20, 102, 201, .6);
}
.btn-primary svg { width: 18px; height: 18px; fill: #fff; }
.btn-primary:disabled { opacity: .7; cursor: wait; }
.pb-msg { font-size: 13px; color: var(--muted); }
.pb-msg:empty { display: none; }

#pb-result { margin-top: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-grid div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 9px 10px; }
.stat-grid b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat-grid small { color: var(--muted); font-size: 11px; }
.events { position: relative; display: grid; gap: 2px; }
.ev { display: flex; gap: 10px; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 8px; border-radius: 10px; }
.ev:hover { background: var(--surface-2); }
.ev-dot { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--c); }
.ev-main b { font-size: 13px; display: block; }
.ev-main small { color: var(--muted); font-size: 12px; }
.ev-time { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.kv { display: grid; grid-template-columns: 115px 1fr; row-gap: 8px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { font-weight: 600; }

/* playback map pins */
.pin-ev { background: none; border: 0; }
.pin-ev div {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800;
  background: var(--c); border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(15, 27, 45, .35);
}

/* ================= REPORTS ================= */
.link { color: var(--brand); font-weight: 600; font-size: 14px; text-decoration: none; }
.link:hover { text-decoration: underline; }
.reports-home { margin-top: 28px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rcard {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
button.rcard:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.rc-ic, .rp-ic { display: grid; place-items: center; border-radius: 10px; color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 12%, transparent); }
.rc-ic { width: 38px; height: 38px; }
.rc-ic svg { width: 20px; height: 20px; fill: currentColor; }
.rc-text { min-width: 0; }
.rc-text b { display: block; font-size: 14px; margin-bottom: 3px; }
.rc-text small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.rcard.soon { box-shadow: none; background: var(--surface-2); }
.rcard.soon b { color: var(--muted); }
.rcard em, .rp-group.soon h4::after { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--border); color: var(--muted); margin-left: 4px; vertical-align: 1px; }

.reports { display: flex; }
.rp-nav { width: 250px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 16px 10px; }
.rp-group { margin-bottom: 16px; }
.rp-group h4 { margin: 0 0 6px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.rp-none { margin: 0 10px; font-size: 12.5px; color: var(--muted); }
.rp-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: none; border-radius: 10px; font-size: 13.5px; font-weight: 600; text-align: left; }
button.rp-item:hover { background: var(--surface-2); }
.rp-item.on { background: var(--brand-soft); color: var(--brand); }
.rp-ic { width: 30px; height: 30px; }
.rp-ic svg { width: 17px; height: 17px; fill: currentColor; }
.rp-group.soon .rp-item { color: var(--muted); cursor: help; font-weight: 500; }

.rp-main { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 24px 40px; }
.rp-actions { display: flex; gap: 8px; align-self: flex-start; }
/* Download reports, Export CSV and Print share one look. */
.rp-actions .btn-primary { height: 38px; padding: 0 16px; font-size: 13.5px; white-space: nowrap; }
.rp-actions .btn-primary:disabled { opacity: .5; cursor: default; box-shadow: none; }
.rp-dl { position: relative; }
.rp-dl-caret { font-size: 11px; margin-left: 2px; }
.rp-dl-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: 250px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 27, 45, .16);
}
.rp-dl-menu button { width: 100%; display: grid; gap: 2px; padding: 9px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font: inherit; cursor: pointer; }
.rp-dl-menu button:hover, .rp-dl-menu button:focus-visible { background: var(--brand-soft); outline: 0; }
.rp-dl-menu b { font-size: 13.5px; color: var(--text); }
.rp-dl-menu small { font-size: 12px; color: var(--muted); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13.5px;
}
.btn-ghost svg { width: 17px; height: 17px; fill: currentColor; }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-ghost:disabled { opacity: .5; cursor: default; }

.rp-filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 16px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.rp-field { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.rp-field select, .rp-field input { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13.5px; color: var(--text); min-width: 0; }
.rp-field select { max-width: 220px; }
.rp-custom { display: flex; gap: 8px; }
.rp-custom label { display: grid; gap: 5px; }
.rp-filters .presets button { height: 36px; }
.rp-filters .presets button:not(.on) { border-color: var(--border); }
.rp-filters .btn-primary { margin-left: auto; height: 38px; padding: 0 18px; }
.rp-filters .btn-primary.stale { box-shadow: 0 0 0 3px rgba(20, 102, 201, .3); }
.loading .rp-result, .loading .rp-stats { opacity: .5; transition: opacity .2s; }

.rp-period { display: none; }
.rp-note { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #fff7e6; border: 1px solid #fcd9a4; color: #8a4b00; font-size: 13px; }
.rp-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.rp-stats:empty { display: none; }
.rp-stats div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.rp-stats b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.rp-stats small { color: var(--muted); font-size: 12px; font-weight: 600; }

/* No clipping here: dropdowns in the table head (e.g. Region type) must open past a short table.
   The scrolling table area keeps the rounded bottom corners instead. */
.rp-result { padding: 0; overflow: visible; }
.rp-table-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.rp-table-head .search { width: 280px; height: 36px; }
.rp-count { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.rp-table-wrap { overflow: auto; max-height: calc(100vh - 240px); border-radius: 0 0 18px 18px; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rp-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; padding: 9px 12px; white-space: nowrap;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border);
}
.rp-table th.sortable { cursor: pointer; user-select: none; }
.rp-table th.sortable:hover { color: var(--text); }
.rp-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rp-table tbody tr:hover td { background: var(--surface-2); }
.rp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rp-table a { color: var(--brand); text-decoration: none; }
.rp-table a:hover { text-decoration: underline; }
.rp-play { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 3px 9px; font-size: 12px; font-weight: 600; color: var(--brand); }
.rp-play:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.rp-result .empty { margin: 14px; }

/* ================= MOBILE ================= */
/* ================= ALERT POP-UPS ================= */
.toasts { position: fixed; z-index: 2000; top: calc(var(--top) + 12px); right: 16px; width: 340px; max-width: calc(100vw - 32px); display: grid; gap: 10px; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18); padding: 12px 14px; font-size: 13px; animation: toast-in .25s ease-out;
}
.toast.out { opacity: 0; transform: translateX(20px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } }
.t-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.t-ic { width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 800; font-size: 15px; }
.toast.sticky .t-ic { animation: t-pulse 1.2s ease-in-out infinite; }
@keyframes t-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 25%, transparent); } }
.t-title { flex: 1; min-width: 0; }
.t-title b { display: block; font-size: 14.5px; color: var(--c); }
.t-title small { color: var(--muted); }
.t-time { font-size: 12px; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.t-close { border: 0; background: none; color: var(--muted); font-size: 14px; padding: 0 2px; line-height: 1; }
.t-close:hover { color: var(--text); }
.t-grid { display: grid; grid-template-columns: 70px 1fr; gap: 5px 10px; }
.t-grid > span:nth-child(odd) { color: var(--muted); }
.t-grid > span:nth-child(even) { min-width: 0; overflow-wrap: anywhere; }
.t-grid a { color: var(--brand); text-decoration: none; }
.t-grid a:hover { text-decoration: underline; }
.t-map { margin-top: 10px; width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-weight: 600; font-size: 13px; color: var(--brand); }
.t-map:hover { border-color: var(--brand); }






/* ================= ADMIN: Account and Manage region ================= */
.admin-view { overflow-y: auto; }
.ad-main { padding: 24px 24px 40px; max-width: 1500px; margin: 0 auto; }
.ad-table tbody tr { cursor: pointer; }
.ad-table.readonly tbody tr { cursor: default; }
.vm-sub { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.vm-imei { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.vm-actions { display: inline-flex; gap: 6px; }
.vm-act { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--brand); cursor: pointer; }
.vm-act svg { width: 17px; height: 17px; fill: currentColor; }
.vm-act:hover { border-color: var(--brand); background: var(--brand-soft); }
.vm-act.del { color: #b42318; }
.vm-act.del:hover { border-color: #b42318; background: #fef2f2; }
.ad-table tbody tr.vm-new td { animation: vm-new 5s ease-out; }
@keyframes vm-new { 0%, 60% { background: #dcfce7; } 100% { background: transparent; } }
.btn-primary.danger { background: #b42318; box-shadow: 0 8px 18px -8px rgba(180, 35, 24, .6); }
.rg-type { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.rg-type .ss-btn { min-width: 170px; height: 36px; }
/* Regions header: Show Transfer Station / Fuel Station / Parking Lot (open places.html), then
   the Cards/Table switch. */
.rg-head-tools { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.rg-places { display: flex; gap: 8px; flex-wrap: wrap; }
.rg-places .btn-primary { height: 38px; padding: 0 14px; font-size: 13.5px; white-space: nowrap; text-decoration: none; }
.rg-places .btn-primary svg { width: 17px; height: 17px; }
/* places.html: Zone/Ward filters, search and the mapping table. */
.pl-filters { flex-wrap: wrap; }
.pl-filters .rg-type .ss-btn { min-width: 190px; }
.pl-table td.pl-none { color: var(--muted); font-style: italic; }
.pl-table th:first-child, .pl-table td:first-child { width: 64px; }
.ad-rtype { display: inline-block; min-width: 46px; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; text-align: center; }
.ad-rtype.t-city { background: #0b2e63; color: #fff; }
.ad-rtype.t-zone { background: #e8f1fc; color: #0d55a8; }
.ad-rtype.t-ward { background: #ecfdf3; color: #15803d; }
.ad-table tbody tr.sel td { background: var(--brand-soft); }
.ad-table td { white-space: nowrap; }
.ad-pick { width: 34px; text-align: center; }
.ad-pick input { accent-color: var(--brand); cursor: pointer; }
.ad-status { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.ad-status.on { background: #dcfce7; color: #15803d; }
.ad-status.off { background: #f1f5f9; color: #64748b; }
.ad-role { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); }
.ad-role.r-all { background: #0b2e63; color: #fff; border-color: #0b2e63; }
.ad-demo, .ad-you { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 700; vertical-align: 1px; }
.ad-demo { background: #fff7e6; color: #8a4b00; border: 1px solid #fcd9a4; }
.ad-you { background: var(--brand-soft); color: var(--brand); }

.ad-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 64px rgba(15, 27, 45, .35); color: var(--text); }
.ad-dialog::backdrop { background: rgba(11, 37, 69, .45); }
.ad-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.ad-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 12px; border-bottom: 1px solid var(--border); }
.ad-dialog-head h2 { margin: 0; font-size: 18px; }
.ad-x { border: 0; background: none; font-size: 16px; color: var(--muted); cursor: pointer; }
.ad-fields { padding: 16px 22px; overflow-y: auto; display: grid; gap: 14px; }
.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.ad-grid > div, .ad-sub { grid-column: 1 / -1; }
.ad-field { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ad-field input, .ad-field select { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font: inherit; font-size: 14px; font-weight: 500; color: var(--text); min-width: 0; }
.ad-field input:focus, .ad-field select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 102, 201, .15); }
.ad-field small { font-weight: 500; font-size: 11.5px; }
.ad-pw { position: relative; display: grid; }
.ad-pw input { padding-right: 56px; }
.ad-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--brand); font-weight: 700; font-size: 12px; cursor: pointer; }
.ad-note { margin: 0; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.ad-status.inv { background: #fff7e6; color: #8a4b00; }
.ad-done { margin: 0; font-size: 14.5px; }
.ad-warn { padding: 10px 12px; border-radius: 9px; background: #fff7e6; border: 1px solid #fcd9a4; color: #8a4b00; font-size: 13px; }
.ad-copy { display: flex; gap: 8px; }
.ad-copy input { flex: 1; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; font: inherit; font-size: 12.5px; color: var(--text); background: var(--surface-2); }
.ad-link-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); }
.ad-link-row small { color: var(--muted); font-size: 12px; flex: 1; min-width: 200px; }
.ad-set { margin: 0; padding: 12px 14px 14px; border: 1px solid var(--border); border-radius: 12px; }
.ad-set legend { padding: 0 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ad-error { margin: 0 22px; padding: 10px 12px; border-radius: 9px; background: #fef2f2; border: 1px solid #fecaca; color: #b42318; font-size: 13px; font-weight: 600; }
.ad-dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; }
.ad-dialog-foot .btn-primary { height: 38px; padding: 0 22px; }
@media (max-width: 900px) {
  .ad-main { padding: 16px 12px 32px; }
  .ad-grid { grid-template-columns: 1fr; }
  .rp-table-head:has(.rg-type) { flex-wrap: wrap; }
}
/* ================= MAP: clusters and base-map switch ================= */
/* Cluster bubble: vehicle count on white, ring split by status (running / idle / stopped / offline). */
.vcluster { background: none; border: 0; }
.vc-ring { width: 100%; height: 100%; border-radius: 50%; padding: 4px; box-shadow: 0 2px 8px rgba(15, 27, 45, .35); transition: transform .15s; }
.vc-ring span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: #fff;
  color: var(--text); font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums;
}
.vcluster:hover .vc-ring { transform: scale(1.08); }
.basemap-switch { display: flex; overflow: hidden; background: #fff; }
.basemap-switch button { border: 0; background: #fff; padding: 6px 11px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.basemap-switch button + button { border-left: 1px solid var(--border); }
.basemap-switch button.on { background: var(--brand); color: #fff; }
.basemap-switch button:not(.on):hover { background: var(--surface-2); color: var(--text); }
/* ================= SEARCHABLE DROPDOWNS (select.js) ================= */
.ss-native { display: none !important; }
.ss { position: relative; min-width: 0; }
.ss-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-width: 150px; max-width: 220px;
  height: 36px; padding: 0 6px 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); text-align: left; cursor: pointer;
}
.ss-btn:hover, .ss-btn[aria-expanded="true"] { border-color: var(--brand); }
.ss-btn:disabled { opacity: 1; }   /* greyed by the LOCKED FIELDS rule below */
.ss-val { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-btn svg { width: 18px; height: 18px; fill: var(--muted); flex-shrink: 0; }
.ss-pop {
  position: fixed; z-index: 2500; width: max-content; max-width: 320px;   /* top, left, min-width set by select.js */
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 27, 45, .16);
}
.ss-search { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.ss-search svg { width: 16px; height: 16px; fill: var(--muted); flex-shrink: 0; }
.ss-search input { flex: 1; min-width: 0; height: 24px !important; padding: 0 !important; border: 0 !important; outline: 0; background: none !important; font: inherit; font-size: 13px; color: var(--text); }
.ss-list { position: relative; max-height: 280px; overflow-y: auto; padding: 4px; }   /* relative: option offsets measured from the list */
.ss-opt { padding: 7px 10px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; white-space: nowrap; }
.ss-opt:hover, .ss-opt.hi { background: var(--brand-soft); }
.ss-opt.on { color: var(--brand); font-weight: 700; }
.ss-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ss-none { padding: 10px; font-size: 13px; color: var(--muted); }

/* ================= REGIONS: zone / ward cards, zone.html and ward.html ================= */
.rg-switch { display: flex; align-self: flex-start; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.rg-switch button { border: 0; background: none; padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.rg-switch button + button { border-left: 1px solid var(--border); }
.rg-switch button.on { background: var(--brand); color: #fff; }
.rg-summary { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.rg-summary b { color: var(--text); }
.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.rcard {
  display: flex; flex-direction: column; gap: 14px; padding: 16px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  cursor: pointer; text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.rcard:hover, .rcard:focus-visible { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 12px 28px -12px rgba(20, 102, 201, .35); outline: 0; }
.rcard.off { opacity: .65; }
.rc-head { display: flex; align-items: center; gap: 10px; }
.rc-no { min-width: 38px; height: 38px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: #0b2e63; color: #fff; font-weight: 800; font-size: 15px; }
.wcard .rc-no { background: #0e8f9a; }
.rc-title { flex: 1; min-width: 0; }
.rc-title b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-title small { color: var(--muted); font-size: 12px; }
.rc-off { display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 700; background: #f1f5f9; color: #64748b; }
.rc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rc-stat { display: grid; justify-items: center; gap: 2px; padding: 10px 4px; border-radius: 10px; background: var(--surface-2); text-align: center; }
.rc-stat svg { width: 18px; height: 18px; fill: var(--brand); }
.rc-stat b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rc-stat small { font-size: 11px; color: var(--muted); line-height: 1.2; }
.rc-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.rc-open { color: var(--brand); font-weight: 700; }
/* Dashboard zone cards: same card, plus live vehicle status */
.dz-sub { font-size: 13px; }
.dzcard.static { cursor: default; }
.dzcard.static:hover { transform: none; border-color: var(--border); box-shadow: var(--shadow); }
.dz-live { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.dz-live-top { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.dz-live-top b { font-size: 16px; color: var(--text); }
.dz-live-top span { margin-left: auto; font-size: 11.5px; }
.dz-live .mini-bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--border); }
.dz-live .mini-bar span { height: 100%; }
/* "Show all zones/wards" tile: sits beside the last dashboard zone/ward card (a narrower 6th column on wide screens). */
@media (min-width: 1400px) {
  #dash-zones.has-all, #dash-wards.has-all { grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(150px, .7fr); }
}
.zcard-all {
  justify-content: space-between; gap: 10px; color: #fff; border: 0;
  background: linear-gradient(160deg, #0b3a78, #0a2a57);
}
.zcard-all:hover, .zcard-all:focus-visible { border-color: transparent; box-shadow: 0 12px 28px -10px rgba(10, 42, 87, .6); background: linear-gradient(160deg, #0e4590, #0b3168); }
.za-count { display: grid; gap: 2px; }
.za-count b { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.za-count small { font-size: 13px; color: rgba(255, 255, 255, .75); }
.za-label { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.za-label svg { width: 18px; height: 18px; fill: currentColor; transition: transform .12s; }
.zcard-all:hover .za-label svg { transform: translateX(3px); }
.za-sub { font-size: 11.5px; color: rgba(255, 255, 255, .7); line-height: 1.35; }
.rg-page .rp-stats { margin-bottom: 18px; }
.rg-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.rg-block h2, .rg-routes h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.rg-routes h2 { margin: 0; }
.rg-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rg-list li { display: grid; gap: 2px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); font-size: 13.5px; }
.rg-list small { color: var(--muted); }
.rg-list a, .rg-block .kv a { color: var(--brand); text-decoration: none; }
.rg-none { margin: 0; font-size: 13.5px; }
.rg-count { font-size: 12px; background: var(--brand-soft); color: var(--brand); }
/* ================= D2D ROUTE PROGRESS (dashboard tiles + lanes.html) ================= */
.lanes-section { margin-top: -10px; }
.lanes-sub { font-size: 13px; }
.kpis.lanes { grid-template-columns: repeat(4, 1fr); margin-bottom: 8px; }
@media (max-width: 1100px) { .kpis.lanes { grid-template-columns: repeat(2, 1fr); } }
.ln-main { height: calc(100% - var(--top)); overflow-y: auto; padding: 24px 24px 40px; max-width: 1500px; margin: 0 auto; }
.ln-main .rp-table-wrap { max-height: calc(100vh - 290px); }
@media (max-width: 900px) {
  .page-head:has(.rp-actions) { flex-wrap: wrap; }
  .page-head .rp-actions { flex-wrap: wrap; }
  .kpis.lanes { grid-template-columns: 1fr; }
  .ln-main { padding: 16px 12px 32px; }
}
@media print {
  .ln-main { height: auto; overflow: visible; padding: 0; }
  .ln-main .rp-table-wrap { max-height: none; }
}
/* ================= ROUTE COVERAGE DETAIL (route.html) ================= */
.rt-head { display: flex; flex-direction: column; min-width: 0; color: #fff; }
.rt-head b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-head small { color: #b7c9e4; font-size: 12.5px; }
.rt-layout { display: flex; height: calc(100% - var(--top)); }
.rt-side { width: 340px; flex-shrink: 0; overflow-y: auto; padding: 16px; background: var(--surface); border-right: 1px solid var(--border); display: grid; gap: 14px; align-content: start; }
.rt-side h3 { margin: 4px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rt-side .rp-note { margin: 0; }
#rt-map { flex: 1; min-width: 0; }
.rt-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.rt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rt-dot { width: 10px; height: 10px; border-radius: 50%; }
.rt-dot.ok { background: #16a34a; } .rt-dot.miss { background: #dc2626; }
.rt-line { width: 18px; height: 4px; border-radius: 2px; background: #1466c9; opacity: .7; }
.rt-points { display: grid; gap: 2px; }
.rt-pt { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.rt-pt:hover { background: var(--surface-2); }
.rt-num { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 10.5px; font-weight: 700; }
.rt-pin { border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); box-sizing: border-box; }
@media (max-width: 900px) {
  .rt-layout { flex-direction: column-reverse; }
  .rt-side { width: auto; max-height: 45%; border-right: 0; border-top: 1px solid var(--border); }
  #rt-map { min-height: 55%; }
}
/* ================= ALERTS ================= */
.alerts-view { display: flex; }
.al-side { display: none; }
.vendor-mode .al-side { display: block; width: 250px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; padding: 16px 10px; }
.al-side .vnav { padding: 0; border-bottom: 0; }
.al-main { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 24px 40px; }
.al-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.al-head::after { content: ''; position: absolute; left: 0; bottom: -2px; width: 36px; height: 3px; border-radius: 2px; background: #f59e0b; }
.al-head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.al-card { padding: 0; overflow: hidden; }
.al-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px 6px; }
.al-title { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 19px; color: #e8590c; }
.al-title svg { width: 22px; height: 22px; fill: currentColor; }
.al-card-head .search { width: 260px; height: 38px; }
.al-sub { margin: 0; padding: 0 18px 12px; font-size: 13px; }
.al-sub.err { color: #b42318; }
.loading .al-card { opacity: .6; transition: opacity .2s; }
.al-table-wrap { overflow: auto; max-height: calc(100vh - 250px); border-top: 1px solid var(--border); }
.al-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.al-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; padding: 9px 10px; white-space: nowrap;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border);
}
.al-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.al-table tbody tr:hover td { background: var(--surface-2); }
.al-table .num { text-align: center; }
.al-veh { display: inline-flex; color: var(--c); }
.al-reg { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.al-reg:hover { color: var(--brand); text-decoration: underline; }
.al-type { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--c); white-space: nowrap; }
.al-type svg { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }
.al-detail { min-width: 190px; }
.al-time { white-space: nowrap; }
.al-reason, .al-snooze { height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font: inherit; font-size: 12.5px; }
.al-reason { max-width: 190px; padding: 0 6px; }
.al-snooze { width: 72px; padding: 0 8px; }
.al-reason:focus, .al-snooze:focus { outline: 0; border-color: var(--brand); }
.al-reason.err, .al-snooze.err { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.al-action { white-space: nowrap; }
.al-act { font-weight: 700; font-size: 13px; text-decoration: none; }
.al-act:hover { text-decoration: underline; }
.al-act.approve { color: #15803d; }
.al-act.reject { color: #b42318; }
.al-sep { margin: 0 6px; color: var(--muted); }
tr.busy .al-act { pointer-events: none; opacity: .35; }
tr.busy .al-act.chosen { opacity: 1; }
.al-more { display: flex; margin: 14px auto; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .brand-name, .user-name, .lang svg, .home-btn span { display: none; }
  .home-btn { padding: 0 9px; }
  .top-right { gap: 8px; }
  .lang { padding: 0 2px 0 8px; }
  .lang select { max-width: 110px; }
  .topbar { gap: 12px; padding: 0 12px; }
  .tab { padding: 0 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .section-tools input { width: 160px; }
  .sidebar { position: absolute; z-index: 900; height: 100%; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 24px rgba(0, 0, 0, .12); }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: block; }
  .panel { position: absolute; z-index: 950; right: 0; bottom: 0; width: 100%; height: 62%; border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 32px rgba(0, 0, 0, .15); }
  .player { padding: 10px 12px 8px; }
  .pl-top { flex-wrap: wrap; gap: 10px; }
  .pl-readout { order: 3; width: 100%; }
  .pl-legend { display: none; }
  .legend { display: none; }
  .reports { flex-direction: column; }
  .rp-nav { width: auto; display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .rp-group, .rp-list { display: contents; }
  .rp-nav .vnav { display: flex; padding: 0 8px 0 0; margin: 0; border-bottom: 0; border-right: 1px solid var(--border); }
  .rp-group h4, .rp-group.soon, .rp-recent { display: none; }
  .vendor-mode .rp-recent { display: contents; }
  .rp-item { width: auto; white-space: nowrap; padding: 5px 10px 5px 5px; }
  .rp-main { padding: 16px 12px 32px; }
  .rp-filters .btn-primary { margin-left: 0; width: 100%; }
  .rp-field select, .rp-field .ss-btn { max-width: none; }
  .rp-table-head .search { width: auto; flex: 1; }
  .alerts-view { flex-direction: column; }
  .vendor-mode .al-side { width: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .al-side .vnav { display: flex; overflow-x: auto; }
  .al-main { padding: 16px 12px 32px; }
  .al-card-head .search { width: 100%; }
}

@media print {
  @page { size: landscape; margin: 12mm; }
  html, body { height: auto; background: #fff; }
  .topbar, .rp-nav, .rp-filters, .rp-actions, .rp-table-head, .rp-play { display: none !important; }
  .view { height: auto; }
  .reports, .rp-main { display: block; overflow: visible; padding: 0; }
  .rp-period { display: block; margin-bottom: 12px; font-weight: 600; }
  .rp-stats div, .rp-result { box-shadow: none; }
  .rp-table-wrap { max-height: none; overflow: visible; }
  .rp-table { font-size: 10.5px; }
  .rp-table th { position: static; }
  .rp-table td, .rp-table th { padding: 4px 6px; }
  .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ================= LOCKED FIELDS ================= */
/* Site-wide rule: any read-only or disabled field is grey, on every page, so people can see at a
   glance what they can't change. Covers plain inputs, dropdowns, text areas and the searchable
   dropdowns (select.js). Checkboxes, radios and buttons keep their own disabled look. */
input[readonly]:not([type="checkbox"]):not([type="radio"]),
input:disabled:not([type="checkbox"]):not([type="radio"]),
select:disabled,
textarea[readonly],
textarea:disabled,
.ss-btn:disabled {
  background: var(--locked-bg) !important;
  color: var(--locked-fg) !important;
  border-color: var(--locked-border) !important;
  cursor: not-allowed;
  -webkit-text-fill-color: var(--locked-fg);   /* Safari greys disabled text inconsistently */
}
.ss-btn:disabled svg { fill: var(--locked-fg); }
