@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800&display=swap');
/* =========================================================================
   FleetLive — clean light design system
   ========================================================================= */
:root {
  --bg: #F3F0E8;
  --surface: #FFFFFF;
  --surface-2: #F8F6F0;
  --border: #E2DCCF;
  --border-strong: #CFC8B8;
  --text: #1C1B17;
  --text-2: #5A564C;
  --muted: #6E695D;
  --primary: #1F4E46;
  --primary-hover: #163A34;
  --primary-50: #E6EFEC;
  --primary-100: #CFE0DA;
  --accent: #E8622C;
  --success: #276B43;
  --success-50: #E6F1E9;
  --warn: #9A5B06;
  --warn-50: #FBF1DD;
  --danger: #B42318;
  --danger-50: #FBEAE7;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgb(28 27 23 / 0.06);
  --shadow: 0 1px 3px rgb(28 27 23 / 0.08), 0 4px 12px rgb(28 27 23 / 0.05);
  --shadow-lg: 0 10px 30px rgb(28 27 23 / 0.14), 0 2px 6px rgb(28 27 23 / 0.06);
  --font: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --topbar-h: 60px;
  --tabbar-h: 0px;
  --success-border: #C4DFCC;
  --warn-border: #F0D9A8;
  --danger-border: #F2C6BF;
  --map-bg: #E8E3D6;
  --row-hover: #FAF8F3;
  color-scheme: light;
}

/* ---------- dark theme ---------- */
[data-theme='dark'] {
  --bg: #14130F;
  --surface: #1E1D18;
  --surface-2: #26251F;
  --border: #34322A;
  --border-strong: #48453A;
  --text: #F3F0E8;
  --text-2: #C2BCAE;
  --muted: #9A9484;
  --primary: #5FAE9C;
  --primary-hover: #74C0AE;
  --primary-50: #1C2E2A;
  --primary-100: #24443D;
  --accent: #F07A45;
  --success: #5DBB7E;
  --success-50: #17291D;
  --success-border: #2B4A35;
  --warn: #E2A54A;
  --warn-50: #2E2310;
  --warn-border: #5A4214;
  --danger: #F0796B;
  --danger-50: #331614;
  --danger-border: #5E2620;
  --map-bg: #1C1B16;
  --row-hover: #23221C;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 3px rgb(0 0 0 / 0.45), 0 4px 12px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.55), 0 2px 6px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}
[data-theme='dark'] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9) saturate(0.6); }
[data-theme='dark'] .leaflet-container { background: var(--map-bg); }
[data-theme='dark'] .leaflet-control-attribution { background: rgb(30 29 24 / 0.8) !important; color: var(--text-2); }
[data-theme='dark'] .leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
[data-theme='dark'] .leaflet-popup-content-wrapper, [data-theme='dark'] .leaflet-popup-tip { background: var(--surface); color: var(--text); }
[data-theme='dark'] .toast { background: #26251F; border: 1px solid var(--border-strong); }
[data-theme='dark'] .user-chip .avatar { background: #5A564C; }
[data-theme='dark'] .tflag { background: #26251F; }
[data-theme='dark'] dialog { background: var(--surface); }
[data-theme='dark'] select.input option { background: var(--surface); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.subtle { color: var(--muted); font-size: 12px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--primary); color: #fff;
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:focus-visible, .input:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-100); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #9B1C14; }
.btn-ghost-danger { background: transparent; color: var(--danger); border-color: var(--danger-border); }
.btn-ghost-danger:hover { background: var(--danger-50); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.active { background: var(--warn); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-50); border-color: var(--danger-border); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 14px var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--primary); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 0; }

/* ---------- pills / avatars ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.online { background: var(--success-50); color: var(--success); border-color: var(--success-border); }
.pill.offline { color: var(--muted); }
.pill.dispatch { background: var(--warn-50); color: var(--warn); border-color: var(--warn-border); }
.pill.live .dot { animation: pulse 1.6s infinite; }
.pill.on-duty { color: var(--primary); }
.pill.off-duty { background: var(--warn-50); color: var(--warn); border-color: var(--warn-border); }
.driver-item .top .pill.off-duty { height: 20px; padding: 0 7px; font-size: 11px; margin-left: auto; }
.driver-item .top .plate + .pill.off-duty { margin-left: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  font-weight: 700; font-size: 13px; color: #fff; letter-spacing: 0.02em;
  position: relative;
}
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.avatar .status { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--muted); }
.avatar .status.on { background: var(--success); }

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 24px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative; z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgb(232 98 44 / 0.35); }
.brand-mark .icon { width: 17px; height: 17px; }
.tabs { display: flex; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.tab:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tab.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--border); }
.user-chip .avatar { width: 32px; height: 32px; font-size: 12px; background: #48453A; }
.user-chip .who { line-height: 1.2; }
.user-chip .who strong { display: block; font-size: 13px; }
.user-chip .who span { font-size: 12px; color: var(--muted); }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 520px;
  padding: 11px 16px; border-radius: 10px; background: #1C1B17; color: #fff;
  font-weight: 500; box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success .icon { color: #7FD09A; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(460px, calc(100vw - 32px)); color: var(--text);
}
dialog::backdrop { background: rgb(28 27 23 / 0.45); backdrop-filter: blur(2px); }
dialog[open] { animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 4px; }
.dialog-head h2 { font-size: 18px; }
.dialog-head p { margin: 4px 0 0; color: var(--text-2); }
.dialog-body { padding: 16px 22px 4px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }

/* =========================================================================
   Login page
   ========================================================================= */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; padding: 48px; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 10% 10%, #1F4E46 0%, transparent 60%), linear-gradient(160deg, #163A34, #1C1B17);
}
.auth-hero .brand { color: #fff; }
.auth-hero .brand-mark { background: rgb(255 255 255 / 0.15); box-shadow: none; }
.auth-hero h2 { font-size: 34px; line-height: 1.15; max-width: 440px; font-weight: 800; letter-spacing: -0.03em; }
.auth-hero p { color: #BCD3CC; max-width: 420px; font-size: 15px; margin-top: 14px; }
.auth-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-hero li { display: flex; align-items: center; gap: 10px; color: #CFE0DA; }
.auth-hero li .icon { color: #9FCBBF; }
.hero-grid { position: absolute; inset: 0; opacity: 0.12; background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 70% 60%, #000 20%, transparent 70%); }
.hero-route { position: absolute; right: -40px; bottom: 60px; width: 420px; opacity: 0.5; }
.auth-hero > *:not(.hero-grid):not(.hero-route) { position: relative; }
.auth-main { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-form { width: min(380px, 100%); }
.auth-form h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.auth-form .lead { color: var(--text-2); margin: 6px 0 26px; }
.auth-form .btn { height: 44px; margin-top: 6px; }
.auth-foot { margin-top: 22px; font-size: 12px; color: var(--muted); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* =========================================================================
   Live map (dashboard)
   ========================================================================= */
body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 380px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); min-height: 0; }
.sidebar-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.stat b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--text-2); }
.stat.green b { color: var(--success); }
.stat.blue b { color: var(--primary); }
.segmented { display: flex; gap: 2px; padding: 3px; margin-top: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { flex: 1; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font: 500 13px var(--font); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.segmented button span { color: var(--muted); font-weight: 500; margin-left: 3px; }

.driver-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.driver-item {
  display: flex; gap: 12px; padding: 12px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid transparent; transition: background 0.12s, border-color 0.12s;
}
.driver-item:hover { background: var(--surface-2); }
.driver-item.selected { background: var(--primary-50); border-color: var(--primary-100); }
.driver-item .info { flex: 1; min-width: 0; }
.driver-item .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.driver-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-item .meta { display: flex; gap: 10px; margin-top: 3px; font-size: 12px; color: var(--text-2); }
.driver-item .meta span { display: inline-flex; align-items: center; gap: 4px; }
.driver-item .dest { margin-top: 8px; padding: 7px 9px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.driver-item .dest .icon { color: var(--primary); }
.driver-item .dest .where { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-item .dest .eta { font-weight: 700; color: var(--primary); white-space: nowrap; }

.empty { text-align: center; padding: 40px 24px; color: var(--text-2); }
.empty .empty-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* detail panel */
.detail { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
.detail-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0; }
.detail-profile { display: flex; align-items: center; gap: 14px; padding: 12px 18px 16px; }
.detail-profile h2 { font-size: 18px; }
.detail-profile .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 16px 16px; }
.kv div { padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.kv b { display: block; font-size: 15px; font-weight: 700; }
.kv span { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.section { padding: 16px; border-top: 1px solid var(--border); }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); font-weight: 700; margin-bottom: 10px; }
.trip-card { border: 1px solid var(--primary-100); background: var(--primary-50); border-radius: var(--radius); padding: 12px 14px; }
.trip-card .to { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
.trip-card .to .icon { color: var(--primary); margin-top: 1px; }
.trip-card .addr { font-size: 12px; color: var(--text-2); font-weight: 400; margin-top: 2px; }
.trip-card .figures { display: flex; gap: 18px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--primary-100); }
.trip-card .figures b { display: block; font-size: 18px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.trip-card .figures span { font-size: 12px; color: var(--text-2); }
.no-trip { padding: 14px; border-radius: var(--radius); border: 1px dashed var(--border-strong); color: var(--text-2); text-align: center; font-size: 13px; }
.dispatch-form { display: flex; gap: 8px; }
.dispatch-form .input-icon { flex: 1; }
.dispatch-actions { display: flex; gap: 8px; margin-top: 8px; }
.dispatch-actions .btn { flex: 1; }

/* map */
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }
.map-tools { position: absolute; top: 14px; right: 14px; z-index: 900; display: flex; gap: 8px; }
.map-tools .btn { box-shadow: var(--shadow); }
.pick-banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 950;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 999px;
  background: #1C1B17; color: #fff; font-weight: 500; box-shadow: var(--shadow-lg);
}
.pick-banner button { background: rgb(255 255 255 / 0.15); color: #fff; border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer; font: 600 12px var(--font); }
#map.picking { cursor: crosshair; }
.conn { display: inline-flex; }

/* map markers */
.vmarker { position: relative; width: 40px; height: 40px; }
.vmarker .bubble {
  position: absolute; inset: 4px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font: 700 11px var(--font); border: 3px solid #fff;
  box-shadow: 0 2px 8px rgb(28 27 23 / 0.35); transition: transform 0.15s;
}
.vmarker.offline .bubble { filter: grayscale(1); opacity: 0.7; }
.vmarker.selected .bubble { transform: scale(1.18); box-shadow: 0 0 0 4px rgb(232 98 44 / 0.35), 0 2px 8px rgb(28 27 23 / 0.35); }
.vmarker .arrow { position: absolute; inset: 0; transform-origin: 50% 50%; }
.vmarker .arrow::before {
  content: ''; position: absolute; left: 50%; top: -3px; transform: translateX(-50%);
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid var(--text);
}
.vmarker .label {
  position: absolute; top: 42px; left: 50%; transform: translateX(-50%);
  padding: 2px 7px; border-radius: 6px; background: var(--surface); color: var(--text);
  font: 600 11px var(--font); white-space: nowrap; box-shadow: var(--shadow);
}
.dmarker { width: 30px; height: 40px; }
.dmarker svg { width: 30px; height: 40px; filter: drop-shadow(0 2px 3px rgb(28 27 23 / 0.35)); }
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 10px 14px; font: 13px var(--font); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-control-zoom a { color: var(--text) !important; }

@media (max-width: 760px) {
  .layout { flex-direction: column-reverse; }
  .sidebar { width: 100%; height: 48%; border-right: 0; border-top: 1px solid var(--border); }
  .user-chip .who { display: none; }
  .topbar { gap: 12px; padding: 0 12px; }
  .tab span { display: none; }
}

/* =========================================================================
   Drivers page
   ========================================================================= */
body.page { overflow-y: auto; }
.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .input-icon { width: 300px; max-width: 100%; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
.who-cell { display: flex; align-items: center; gap: 12px; }
.who-cell strong { display: block; }
.who-cell span { font-size: 12px; color: var(--text-2); }
.who-cell .owner-tag { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--muted); }
.who-cell .owner-tag .icon { width: 12px; height: 12px; }
.who-cell .no-email { color: var(--warn); font-style: normal; font-weight: 600; }
.plate { display: inline-block; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.num { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .hide-sm { display: none; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---------- autocomplete ---------- */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1200;
  list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.ac-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ac-list li .icon { color: var(--muted); margin-top: 2px; }
.ac-list li strong { display: block; font-weight: 600; font-size: 13px; }
.ac-list li span { display: block; font-size: 12px; color: var(--text-2); }
.ac-list li:hover, .ac-list li.active { background: var(--primary-50); }
.ac-list li.active .icon { color: var(--primary); }

/* ---------- map legend ---------- */
.legend {
  position: absolute; left: 14px; bottom: 24px; z-index: 900;
  display: flex; gap: 12px; padding: 7px 12px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-size: 12px; font-weight: 600; color: var(--text-2);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.traffic-note { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.traffic-note.slow { color: var(--warn); }
.traffic-note.jam { color: var(--danger); }
.traffic-note.clear { color: var(--success); }
#traffic-btn.active { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.toolbar .spacer { flex: 1; }

/* =========================================================================
   Trips
   ========================================================================= */
.container.wide { max-width: 1320px; }
.nowrap { white-space: nowrap; }
.ellipsis { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate.sm { padding: 1px 6px; font-size: 11px; }
table.clickable tbody tr { cursor: pointer; }
td.chev { width: 28px; color: var(--muted); }
.icon.flip { transform: scaleX(-1); }
.filters { flex-wrap: wrap; }
.filters .segmented { margin-top: 0; }
.field-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.field-inline select { width: auto; min-width: 200px; height: 36px; }

.trip-totals, .trip-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-card span { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-card small { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.stat-card.live b { color: var(--success); }
.stat-card.warn { border-color: var(--warn-border); background: var(--warn-50); }
.stat-card.warn small { color: var(--warn); font-weight: 600; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; margin-bottom: 14px; }
.back-link .icon { width: 16px; height: 16px; }
.trip-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.trip-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.trip-head .sub { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--text-2); margin-top: 4px; }
.trip-grid { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.trip-map-card { position: relative; height: 560px; overflow: hidden; padding: 0; }
.trip-map-card #map { position: absolute; inset: 0; }
.timeline-card { padding: 18px; max-height: 560px; overflow-y: auto; }
.timeline-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin-bottom: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 13px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: 12px; padding: 8px 6px 8px 0; border-radius: 10px; }
.timeline li[data-i] { cursor: pointer; }
.timeline li[data-i]:hover { background: var(--surface-2); }
.tl-dot { position: relative; z-index: 1; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--font); color: #fff; background: var(--muted); border: 3px solid var(--surface); }
.tl-start .tl-dot { background: var(--success); }
.tl-end .tl-dot { background: var(--danger); }
.tl-stop .tl-dot { background: #E8A33D; }
.tl-dest .tl-dot { background: var(--primary); }
.tl-dest-clear .tl-dot { background: var(--border-strong); }
.tl-now .tl-dot { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-100); }
.tl-body { flex: 1; min-width: 0; padding-top: 3px; }
.tl-top { display: flex; justify-content: space-between; gap: 8px; }
.tl-text { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.tpin { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 11px var(--font); border: 3px solid #fff; box-shadow: 0 2px 6px rgb(28 27 23 / 0.35); box-sizing: border-box; }
.tflag { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #1C1B17; color: #E8A33D; border: 2px solid #fff; box-shadow: 0 2px 6px rgb(28 27 23 / 0.35); }
.tflag .icon { width: 15px; height: 15px; }
@media (max-width: 980px) {
  .trip-grid { grid-template-columns: 1fr; }
  .trip-map-card { height: 420px; }
  .timeline-card { max-height: none; }
}
.shift-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.shift-row .btn { margin-left: auto; }
.segmented button { white-space: nowrap; padding: 0 10px; }
.who-cell .avatar { color: #fff; font-size: 13px; }

/* ---------- logo + theme toggle ---------- */
.brand-logo { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 2px 6px rgb(232 98 44 / 0.35); }
.auth-hero .brand-logo { box-shadow: 0 0 0 2px rgb(255 255 255 / 0.35); }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 18px; box-shadow: 0 6px 18px rgb(232 98 44 / 0.35); }
.auth-theme { position: absolute; top: 16px; right: 16px; }
.auth-main { position: relative; }
@media (min-width: 861px) { .auth-logo { display: none; } }

/* ---------- location alerts ---------- */
.stat.red b { color: var(--danger); }
.stat.red { border-color: var(--danger-border); background: var(--danger-50); }
.pill.alert { background: var(--danger-50); color: var(--danger); border-color: var(--danger-border); }
.pill.alert .icon { width: 13px; height: 13px; }
.alert-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.driver-item.has-alert { background: var(--danger-50); border-color: var(--danger-border); }
.alert-banner {
  display: flex; gap: 10px; margin: 0 16px 14px; padding: 12px; border-radius: var(--radius);
  background: var(--danger-50); border: 1px solid var(--danger-border); color: var(--text); font-size: 13px;
}
.alert-banner > .icon { color: var(--danger); flex: none; margin-top: 1px; }
.alert-banner strong { color: var(--danger); }
.alert-banner div div { color: var(--text-2); margin-top: 3px; }
.alert-banner a { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; font-weight: 600; }
.vmarker .ring { position: absolute; inset: -4px; border-radius: 50%; border: 3px solid var(--danger); animation: ring 1.4s infinite; }
@keyframes ring { 0% { transform: scale(0.85); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
.vmarker .warn-badge {
  position: absolute; right: -2px; top: -2px; z-index: 2; width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger); color: #fff; font: 800 11px/16px var(--font); text-align: center; border: 2px solid #fff;
}
.tl-warn .tl-dot { background: var(--danger); }
.tl-ok .tl-dot { background: var(--success); }
.tl-warn .tl-top strong { color: var(--danger); }

/* ---------- arrivals ---------- */
.driver-item .dest.reached { border-color: var(--success-border); background: var(--success-50); }
.driver-item .dest.reached .icon, .driver-item .dest.reached .eta { color: var(--success); }
.trip-card.reached { border-color: var(--success-border); background: var(--success-50); }
.trip-card.reached .to .icon { color: var(--success); }
.trip-card.reached .figures { border-top-color: var(--success-border); }
.trip-card.reached .figures b { color: var(--success); }
.trip-card .figures b.late { color: var(--warn); }
.tl-arrived .tl-dot { background: var(--success); box-shadow: 0 0 0 4px var(--success-50); }
.tl-arrived .tl-top strong { color: var(--success); }
.tarrived { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--success); color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgb(28 27 23 / 0.35); }
.tarrived .icon { width: 15px; height: 15px; stroke-width: 3; }

/* =========================================================================
   Mobile first: bottom tab bar, big touch targets, tables as cards
   ========================================================================= */
@media (max-width: 760px) {
  :root { --tabbar-h: 68px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .user-chip { border-left: 0; padding-left: 0; }

  /* the page tabs move to a thumb-friendly bar at the bottom of the screen */
  .topbar .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0;
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgb(28 27 23 / 0.06);
  }
  .topbar .tab {
    height: 100%; padding: 0; border-radius: 0; flex-direction: column; justify-content: center; gap: 4px;
    font-size: 12px; font-weight: 600; color: var(--text-2); background: none;
  }
  .topbar .tab span { display: inline; }
  .topbar .tab .icon { width: 56px; height: 30px; padding: 5px 18px; border-radius: 15px; box-sizing: border-box; }
  .topbar .tab.active { background: none; color: var(--primary); font-weight: 800; }
  .topbar .tab.active .icon { background: var(--primary-50); }
  .topbar .tab:hover { background: none; }

  body.page { padding-bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
  body.app .layout { margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

  /* live map: drivers in a bottom sheet over the map */
  body.app .sidebar { border-radius: 20px 20px 0 0; box-shadow: 0 -8px 24px rgb(28 27 23 / 0.12); border-top: 0; position: relative; z-index: 2; }

  /* touch targets + no iOS zoom on focus */
  .btn { height: 48px; }
  .btn-sm { height: 40px; }
  .icon-btn { width: 44px; height: 44px; }
  .input, select.input { height: 48px; font-size: 16px; }

  .container { padding: 18px 14px 32px; }
  .page-head { margin-bottom: 14px; }
  .page-head h1 { font-size: 26px; }
  .page-head > .btn { flex: 1 0 100%; justify-content: center; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .input-icon { width: 100%; }

  /* tables read as stacked cards on a phone */
  .table-wrap table, .table-wrap tbody { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 14px; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { display: block; padding: 0; border: 0; }
  .table-wrap td:first-child { flex: 1 0 100%; }
  .table-wrap td:last-child { margin-left: auto; }
  .table-wrap tbody tr:hover td { background: none; }
}
