:root {
  --ink: #111111;
  --muted: #6b7280;
  --brand: #0b6e4f;
  --brand-dark: #095c42;
  --field: #f3f4f6;
  --field-border: #e5e7eb;
  --route: #22c55e;
  --sos: #ff3b30;
  --moving: #16a34a;
  --idle: #d97706;
  --stopped: #2563eb;
  --offline: #dc2626;
  --stale: #ca8a04;
  --glass: rgba(255, 255, 255, 0.72);
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
  --map-fab-size: 48px;
  --map-fab-gap: 19px;
  --map-edge: 12px;
  --map-fab-strip: calc(var(--map-edge) + var(--map-fab-size) + var(--map-fab-gap));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "DM Sans", system-ui, sans-serif;
  --font-ui: Inter, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* Skeleton */
.sk {
  background: linear-gradient(90deg, #e8eee9 0%, #f4f7f5 45%, #e8eee9 90%);
  background-size: 200% 100%;
  animation: sk-shine 1.2s ease-in-out infinite;
  border-radius: 12px;
}
.sk-block { width: 100%; height: 100%; border-radius: 0; }
.sk-map { min-height: 100%; }
.sk-pill { width: 118px; height: 36px; border-radius: 14px; }
.sk-pill--sm { width: 72px; }
.sk-pill--user { width: 100%; height: 96px; border-radius: 16px; }
.sk-fab { width: 48px; height: 48px; border-radius: 16px; }
.sk-fab--top { flex-shrink: 0; }
.sk-row { height: 66px; margin-bottom: 10px; border-radius: 14px; }
.sk-list { padding: 8px 0; }
@keyframes sk-shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Boot skeleton */
.boot {
  min-height: 100%;
  height: 100%;
  background: #eef6f1;
}
.boot--skeleton { padding: 0; }
.boot-skeleton {
  position: relative;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}
.boot-skeleton__top {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center;
}
.boot-skeleton__top .sk-pill--sm { margin-left: auto; }
.boot-skeleton__user {
  position: absolute;
  left: var(--map-edge);
  right: var(--map-fab-strip);
  bottom: calc(18px + var(--safe-bottom));
  z-index: 1;
}
.boot-skeleton__fabs {
  position: absolute;
  right: 12px;
  bottom: calc(18px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 10px;
}

.app {
  min-height: 100%;
  height: 100%;
  width: 100%;
}

/* Login */
.login {
  min-height: 100%;
  display: flex;
  justify-content: center;
  background: #f3f4f6;
}
.login__phone {
  width: 100%;
  max-width: 430px;
  min-height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.login__banner {
  height: clamp(190px, 32vh, 240px);
  position: relative;
  overflow: hidden;
  background: transparent;
}
.login__banner::after { display: none; }
.login-page__bg {
  position: relative;
  overflow: hidden;
  pointer-events: none;
}
.login-map {
  position: absolute;
  inset: 0;
}
.login-map-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(255, 255, 255, 0.55) 78%, #ffffff 100%);
  pointer-events: none;
}
.login-page__bg .map-base {
  position: absolute;
  inset: 0;
  background-color: #eef6f1;
  background-image:
    linear-gradient(rgba(22, 163, 74, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 163, 74, 0.045) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px;
  animation: login-grid-drift 28s linear infinite;
}
.login-page__bg .map-roads {
  position: absolute;
  inset: 0;
  opacity: 0.55;
}
.login-page__bg .road {
  position: absolute;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 1px rgba(11, 15, 13, 0.04);
}
.login-page__bg .road-h { height: 10px; left: 0; right: 0; }
.login-page__bg .road-h1 { top: 34%; }
.login-page__bg .road-h2 { top: 62%; height: 8px; opacity: 0.8; }
.login-page__bg .road-v { width: 10px; top: 0; bottom: 0; }
.login-page__bg .road-v1 { left: 38%; }
.login-page__bg .road-v2 { left: 68%; width: 8px; }
.login-page__bg .road-d {
  width: 9px;
  height: 120%;
  top: -10%;
  left: 52%;
  transform: rotate(28deg);
  transform-origin: center;
  background: rgba(255, 255, 255, 0.72);
}
.login-page__bg .map-trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.login-page__bg .map-city {
  opacity: 0;
  animation: login-fade-up 0.9s 0.2s ease forwards;
}
.login-page__bg .map-building {
  fill: rgba(120, 140, 130, 0.2);
  stroke: rgba(11, 15, 13, 0.06);
  stroke-width: 1;
}
.login-page__bg .map-building.is-tall { fill: rgba(95, 115, 105, 0.28); }
.login-page__bg .map-building.is-soft { fill: rgba(148, 168, 158, 0.14); }
.login-page__bg .map-lot {
  fill: rgba(255, 255, 255, 0.35);
  stroke: rgba(11, 15, 13, 0.05);
  stroke-width: 1;
  stroke-dasharray: 3 2;
}
.login-page__bg .map-park {
  fill: rgba(22, 163, 74, 0.12);
  stroke: rgba(22, 163, 74, 0.1);
  stroke-width: 1;
}
.login-page__bg .map-park-inner {
  fill: rgba(22, 163, 74, 0.16);
  stroke: none;
}
.login-page__bg .trail-soft {
  fill: none;
  stroke: rgba(22, 163, 74, 0.14);
  stroke-width: 14;
  stroke-linecap: round;
}
.login-page__bg .trail-soft--alt {
  stroke: rgba(22, 163, 74, 0.07);
  stroke-width: 10;
}
.login-page__bg .trail-main {
  fill: none;
  stroke: #16a34a;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: login-trail-draw 2.4s 0.35s ease forwards;
  filter: drop-shadow(0 0 8px rgba(22, 163, 74, 0.35));
}
.login-page__bg .trail-node {
  fill: #fff;
  stroke: #16a34a;
  stroke-width: 2;
  opacity: 0;
  animation: login-fade-up 0.5s 1.6s ease forwards;
}
.login-page__bg .trail-car,
.login-page__bg .car-label {
  opacity: 0;
  animation: login-car-appear 0.45s 0.85s ease forwards;
}
.login-page__bg .trail-car--b,
.login-page__bg .car-label--b { animation-delay: 1.1s; }
.login-page__bg .trail-car--c { animation-delay: 1.25s; }
.login-page__bg .trail-car--d { animation-delay: 1.35s; }
.login-page__bg .trail-car--e { animation-delay: 1.45s; }
.login-page__bg .trail-car-img { pointer-events: none; }
.login-page__bg .car-label rect {
  fill: rgba(255, 255, 255, 0.94);
  stroke: rgba(11, 15, 13, 0.08);
  stroke-width: 1;
}
.login-page__bg .car-label text {
  fill: #0b0f0d;
  font-family: var(--font), system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.login-page__bg .car-label--b text { font-size: 10px; }
.login-page__bg .map-hub {
  position: absolute;
  right: 14%;
  top: 16%;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  animation: login-fade-up 0.6s 1.4s ease both;
}
.login-page__bg .hub-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(22, 163, 74, 0.35);
  animation: login-pulse-ring 2.8s ease-out infinite;
}
.login-page__bg .hub-core {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.18);
}
@keyframes login-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes login-grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 48px, 48px 48px; }
}
@keyframes login-trail-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes login-car-appear {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}
@keyframes login-pulse-ring {
  0% { transform: scale(0.7); opacity: 0.7; }
  100% { transform: scale(1.55); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .login-page__bg .map-city,
  .login-page__bg .trail-node,
  .login-page__bg .trail-car,
  .login-page__bg .car-label,
  .login-page__bg .map-hub { opacity: 1; animation: none; }
  .login-page__bg .trail-main { stroke-dashoffset: 0; animation: none; }
  .login-page__bg .map-trail animateMotion { display: none; }
}
.login__body { padding: 0 24px calc(24px + var(--safe-bottom)); }
.login__logo-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.login__logo-row img { width: 36px; height: 36px; object-fit: contain; }
.login__logo-row strong { font-size: 18px; letter-spacing: -0.03em; }
.login__logo-row strong em { font-style: normal; color: var(--brand); }
.login h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.login__sub { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.field__control {
  display: flex; align-items: center;
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  overflow: hidden;
}
.field__control:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.12);
}
.field input {
  flex: 1; border: 0; background: transparent;
  padding: 14px 14px; outline: none; font-size: 15px;
}
.field__toggle { padding: 0 14px; color: var(--muted); font-weight: 700; font-size: 13px; }
.login__error {
  background: #fef2f2; color: #b91c1c;
  border-radius: 12px; padding: 12px 14px;
  font-size: 14px; font-weight: 600; margin-bottom: 12px;
}
.login__forgot {
  display: block; margin: 4px 0 18px; color: var(--brand);
  font-weight: 700; font-size: 14px; text-align: right;
}
.btn-primary {
  width: 100%; height: 48px; border-radius: 12px;
  background: var(--brand); color: #fff;
  font-weight: 700; font-size: 16px;
}
.btn-primary:disabled { opacity: 0.65; }
.btn-primary:active { background: var(--brand-dark); }

/* Sheets / modal */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35);
  z-index: 40; display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: min(100%, 480px);
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 12px 22px calc(22px + var(--safe-bottom));
  box-shadow: var(--shadow);
}
.sheet__grab {
  width: 40px; height: 4px; border-radius: 99px;
  background: #e5e7eb; margin: 0 auto 18px;
}
.sheet h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.sheet p { margin: 0 0 20px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.sheet--glass {
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.sheet-backdrop--glass .sheet {
  transform: translateY(100%);
  transition: transform .28s ease;
}
.sheet-backdrop--glass.is-open .sheet {
  transform: translateY(0);
}
.sheet__countdown {
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
}
.sheet__countdown strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.btn-secondary--glass {
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.pwa-install-backdrop {
  z-index: 60;
}
.pwa-install-backdrop .sheet {
  transform: translateY(100%);
  transition: transform .28s ease;
}
.pwa-install-backdrop.is-open .sheet {
  transform: translateY(0);
}
.pwa-install-sheet__head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}
.pwa-install-sheet__head h2 { margin: 0 0 4px; }
.pwa-install-sheet__head p { margin: 0; }
.pwa-install-sheet__icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}
.pwa-install-sheet__steps {
  margin: 0 0 20px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
}
.pwa-install-sheet__steps li + li { margin-top: 6px; }

/* Map home */
.map-page {
  position: relative;
  height: 100%;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: #eef6f1;
}
.live-map,
#live-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: #eef6f1;
}
.map-skeleton {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: opacity .28s ease;
}
.map-skeleton.is-done { opacity: 0; }
.map-skeleton__chrome {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center;
}
.map-skeleton__chrome .sk-pill--sm { margin-left: auto; }
.map-skeleton__user {
  position: absolute;
  left: var(--map-edge);
  right: var(--map-fab-strip);
  bottom: calc(18px + var(--safe-bottom));
  z-index: 1;
}
.map-skeleton__fabs {
  position: absolute;
  right: 12px;
  bottom: calc(18px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.map-error {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px; text-align: center;
  color: var(--muted); font-weight: 600; background: #eef6f1;
}

/* Subpages (fleet / history / drivers) */
.subpage {
  min-height: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.subpage__top {
  background: #fff;
  color: var(--ink);
  padding: calc(8px + var(--safe-top)) 12px 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
  min-height: 0;
}
.subpage__top-text {
  min-width: 0;
  flex: 1;
}
.subpage__back {
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.subpage__top h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.subpage__top p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  opacity: 1;
}
.subpage__body {
  flex: 1;
  overflow: auto;
  padding: 12px 12px calc(20px + var(--safe-bottom));
}
.subpage__empty {
  color: var(--muted);
  font-weight: 600;
  padding: 24px 8px;
  text-align: center;
}
.driver-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 8px;
}
.driver-card__meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.driver-card__actions { display: flex; gap: 8px; }
.driver-card__btn {
  text-decoration: none;
  background: var(--field);
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 10px;
}
.driver-card__btn--call { background: #ecf8f2; color: var(--brand); }

.subpage--history .history-page__controls {
  display: grid;
  gap: 10px;
  padding: 12px 12px 0;
}
.history-page__controls label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}
.history-page__controls select,
.history-page__controls input[type="date"] {
  border: 1px solid var(--field-border);
  border-radius: 12px;
  padding: 12px 12px;
  background: #fff;
}
.history-page__meta {
  margin: 10px 12px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.history-page__map {
  margin: 12px;
  margin-bottom: calc(12px + var(--safe-bottom));
  height: min(52vh, 420px);
  border-radius: 16px;
  overflow: hidden;
  background: #eef6f1;
  position: relative;
}
.sheet__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.btn-secondary {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
}
.btn-primary--danger {
  background: #dc2626;
}
.btn-primary--danger:active {
  background: #b91c1c;
}
.history-page__loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.map-top {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px; right: 12px;
  z-index: 5;
  display: flex; gap: 8px; align-items: center;
  pointer-events: none;
}
.map-brand, .map-pill, .glass-fab, .map-user {
  pointer-events: auto;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.map-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 14px;
  font-family: var(--font-ui); font-weight: 700; font-size: 13px;
}
.map-brand img { width: 22px; height: 22px; object-fit: contain; }
.map-brand em { font-style: normal; color: var(--brand); }
.map-user {
  position: absolute;
  left: var(--map-edge);
  right: var(--map-fab-strip);
  bottom: calc(18px + var(--safe-bottom));
  z-index: 5;
  border-radius: 16px;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
}
.map-user__ad {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px;
  background: rgba(11, 110, 79, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}
.map-user__ad-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
  background: rgba(11, 110, 79, 0.14);
  padding: 4px 7px;
  border-radius: 6px;
}
.map-user__ad-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-user__ad--slot,
.map-user__ad--live {
  min-height: 50px;
  padding: 0;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}
.map-user__ad--slot .adsbygoogle,
.map-user__ad--live .adsbygoogle {
  display: block;
  width: 100%;
  min-height: 50px;
}
.map-user__info {
  display: grid;
  gap: 4px;
  padding: 12px 14px 14px;
}
.map-user__info strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-user__info span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-pill {
  margin-left: auto;
  padding: 8px 12px; border-radius: 999px;
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.map-pill__dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
}
.map-pill.is-socket .map-pill__dot { background: var(--moving); }
.map-pill.is-poll .map-pill__dot { background: var(--idle); }
.map-pill.is-connecting .map-pill__dot { background: var(--stopped); animation: pulse 1s infinite; }
.map-pill.is-offline .map-pill__dot { background: var(--offline); }
@keyframes pulse { 50% { opacity: 0.35; } }

.map-fabs {
  position: absolute;
  right: 12px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 11;
  display: flex; flex-direction: column; gap: 10px;
}
.glass-fab {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
}
#btn-logout.glass-fab {
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.glass-fab svg { width: 22px; height: 22px; }
.glass-fab.is-active { color: var(--brand); box-shadow: 0 0 0 2px rgba(11,110,79,.25), var(--shadow); }
.glass-fab--sos { background: rgba(255, 59, 48, 0.92); color: #fff; border-color: transparent; }

.fleet-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  height: 42%;
  max-height: 70%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.16);
  display: flex; flex-direction: column;
  transform: translateY(110%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .28s ease, visibility 0s linear .28s;
}
.fleet-sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform .28s ease, visibility 0s;
}
.fleet-sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(15, 23, 42, 0.28);
  border: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, visibility 0s linear .28s;
}
.fleet-sheet-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .28s ease, visibility 0s;
}
.fleet-sheet__handle {
  padding: 12px 16px 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.fleet-sheet__handle span {
  width: 40px; height: 4px; border-radius: 99px; background: #e5e7eb;
}
.fleet-sheet__head {
  padding: 0 12px 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.fleet-sheet__head h2 { margin: 0; font-size: 17px; font-weight: 800; }
.fleet-sheet__meta { color: var(--muted); font-size: 12px; font-weight: 600; margin-right: auto; margin-left: 8px; }
.fleet-sheet__close {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--field); color: var(--ink);
  font-size: 18px; font-weight: 700; line-height: 1;
  display: grid; place-items: center; flex-shrink: 0;
}
.fleet-list {
  overflow: auto;
  padding: 0 10px calc(16px + var(--safe-bottom));
  flex: 1;
}
.fleet-item {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  width: 100%;
  text-align: left;
}
.fleet-item:active, .fleet-item.is-selected { background: #f3f4f6; }
.fleet-item__accent { width: 6px; height: 42px; border-radius: 99px; background: var(--offline); }
.fleet-item__accent--moving { background: var(--moving); }
.fleet-item__accent--idle { background: var(--idle); }
.fleet-item__accent--stopped { background: var(--stopped); }
.fleet-item__accent--stale { background: var(--stale); }
.fleet-item__accent--offline { background: var(--offline); }
.fleet-item__title { font-weight: 750; font-size: 14px; }
.fleet-item__sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.fleet-item__pill {
  font-size: 11px; font-weight: 700; padding: 5px 8px; border-radius: 999px;
  text-transform: capitalize;
}
.fleet-item__pill--moving { color: var(--moving); background: #f0fdf4; }
.fleet-item__pill--idle { color: var(--idle); background: #fffbeb; }
.fleet-item__pill--stopped { color: var(--stopped); background: #eff6ff; }
.fleet-item__pill--stale { color: var(--stale); background: #fefce8; }
.fleet-item__pill--offline { color: var(--offline); background: #fef2f2; }
.fleet-item__pill--sos { color: var(--sos); background: #fef2f2; }

.history-bar {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(84px + var(--safe-bottom));
  z-index: 5;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-family: var(--font-ui);
}
.history-bar__row { display: flex; gap: 8px; align-items: center; }
.history-bar input[type="date"] {
  flex: 1; border: 1px solid var(--field-border); border-radius: 10px;
  padding: 8px 10px; background: #fff;
}
.history-bar__meta { margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }

.panel {
  position: absolute;
  right: 68px;
  bottom: calc(170px + var(--safe-bottom));
  z-index: 8;
  width: min(280px, calc(100% - 92px));
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px;
  font-family: var(--font-ui);
}
.panel-backdrop {
  position: absolute;
  inset: 0;
  z-index: 6;
  border: 0;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.panel-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel__close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.panel__option {
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.panel__option-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.panel__option-thumb {
  width: 56px;
  height: 40px;
  border-radius: 8px;
  background-color: #d7e4dc;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid rgba(11, 15, 13, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}
.panel__option.is-active { background: rgba(11, 110, 79, 0.1); color: var(--brand); }
.panel__option.is-active .panel__option-thumb {
  border-color: rgba(11, 110, 79, 0.55);
  box-shadow:
    0 0 0 2px rgba(11, 110, 79, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* Markers */
.live-marker-wrap {
  background: none !important;
  border: 0 !important;
  pointer-events: auto !important;
  cursor: pointer;
}
.live-marker {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
  pointer-events: auto;
}
.live-marker.is-selected {
  filter:
    drop-shadow(0 0 0 3px rgba(11, 110, 79, 0.42))
    drop-shadow(0 2px 4px rgba(0,0,0,.35));
}
.live-marker svg { width: 36px; height: 36px; pointer-events: none; }
.live-marker--moving { color: var(--moving); }
.live-marker--idle { color: var(--idle); }
.live-marker--stopped { color: var(--stopped); }
.live-marker--stale { color: var(--stale); }
.live-marker--offline { color: var(--offline); }
.live-marker--sos { color: var(--sos); animation: pulse 1s infinite; }

.vehicle-popup-shell .leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.vehicle-popup-shell .leaflet-popup-content {
  margin: 10px 12px;
  line-height: 1.35;
  font-family: var(--font-ui);
  background: transparent;
}
.vehicle-popup-shell .leaflet-popup-tip-container {
  filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.08));
}
.vehicle-popup-shell .leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: none;
}
.vehicle-popup-shell .leaflet-popup-close-button {
  width: 24px;
  height: 24px;
  font-size: 18px;
  color: var(--muted);
  padding: 4px;
  top: 6px;
  right: 6px;
}
.vehicle-popup-shell .leaflet-popup-close-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.35);
  border-radius: 8px;
}
.vehicle-popup {
  min-width: 10rem;
  font-size: 12px;
  color: var(--ink);
}
.vehicle-popup.is-sos { min-width: 12rem; }
.vehicle-popup__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.vehicle-popup__identity {
  min-width: 0;
  flex: 1;
}
.vehicle-popup__title {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}
.vehicle-popup__sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.vehicle-popup__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.vehicle-popup__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.vehicle-popup__status--moving {
  color: var(--moving);
  background: rgba(22, 163, 74, 0.14);
  border-color: rgba(22, 163, 74, 0.22);
}
.vehicle-popup__status--idle {
  color: var(--idle);
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(217, 119, 6, 0.22);
}
.vehicle-popup__status--stopped {
  color: var(--stopped);
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.22);
}
.vehicle-popup__status--stale {
  color: var(--stale);
  background: rgba(202, 138, 4, 0.14);
  border-color: rgba(202, 138, 4, 0.22);
}
.vehicle-popup__status--offline {
  color: var(--offline);
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.2);
}
.vehicle-popup__status--sos {
  color: var(--sos);
  background: rgba(255, 59, 48, 0.14);
  border-color: rgba(255, 59, 48, 0.24);
  animation: pulse 1s infinite;
}
.vehicle-popup__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}
.vehicle-popup__stat {
  font-size: 12px;
  color: #374151;
}
.vehicle-popup__stat strong {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 4px;
}
.vehicle-popup__sos {
  display: inline-flex;
  margin-bottom: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.14);
  color: #b91c1c;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.vehicle-popup__line {
  margin-top: 4px;
  font-size: 12px;
  color: #374151;
}
.vehicle-popup__line--sos {
  color: #991b1b;
  font-weight: 600;
}
.vehicle-popup__phone {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}
.vehicle-popup__ack {
  margin-top: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 8px;
  background: rgba(254, 226, 226, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #991b1b;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

/* Settings */
.settings {
  min-height: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings__hero {
  flex-shrink: 0;
  background: #fff;
  color: var(--ink);
  padding: calc(8px + var(--safe-top)) 12px 10px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  gap: 10px;
  align-items: center;
}
.settings__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.settings__body .sk-list { padding: 8px 12px 0; }
.settings__back {
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 4px;
  margin: 0 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.settings__back-sk {
  margin-left: auto;
  height: 28px;
  width: 56px;
  border-radius: 8px;
}
.settings__hero-text { min-width: 0; flex: 1; }
.settings__hero h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.settings__hero p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  opacity: 1;
}
.settings__card {
  margin: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  border: 0;
}
.settings__row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #f3f4f6;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.settings__row:last-child { border-bottom: 1px solid #f3f4f6; }
.settings__row--static { cursor: default; }
.settings__row--static:active { background: transparent; }
.settings__row strong { display: block; font-size: 14px; font-weight: 700; }
.settings__row span { color: var(--muted); font-size: 12px; font-weight: 500; }
.settings__section {
  margin: 16px 16px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.settings__danger { color: #b91c1c; }
.settings__danger strong { color: #b91c1c; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 12px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 600; z-index: 80;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}

.sos-banner {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(64px + var(--safe-top));
  z-index: 5;
  background: rgba(255, 59, 48, 0.95);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center;
}
.sos-banner strong { display: block; font-size: 14px; }
.sos-banner span { font-size: 12px; opacity: 0.92; }
.sos-banner button {
  margin-left: auto; background: #fff; color: var(--sos);
  font-weight: 800; font-size: 12px; padding: 8px 10px; border-radius: 10px;
}

.driver-list { max-height: 50vh; overflow: auto; }
.driver-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 12px 0; border-bottom: 1px solid #f3f4f6;
}
.driver-item:last-child { border-bottom: 0; }
.driver-item__actions { display: flex; gap: 8px; }
.driver-item__actions a {
  text-decoration: none; background: var(--field); color: var(--ink);
  font-weight: 700; font-size: 12px; padding: 8px 10px; border-radius: 10px;
}
