/* =============================================================
   VANTX DriveOps — Design System
   Plain CSS — Tailwind utilities live in the build output at
   /css/tailwind.min.css (compiled by `npm run build:css`). This
   file holds bespoke design-system primitives (cards, sidebar,
   modals, kanban, chips, etc.) that aren't worth expressing as
   utility chains.
   ============================================================= */

/* ---------- i18n pre-paint cloak ----------
   `<html class="i18n-pending">` is added by js/i18n-bootstrap.js (loaded
   synchronously in <head>) *before* the body paints. We hide the entire
   document until i18n.apply() runs at DOMContentLoaded and strips the
   class. The page-level cloak (vs per-element) covers everything:
     • `data-i18n` static labels (e.g. "Users" → "משתמשים")
     • the language-toggle chrome (.lang-flag, .lang-label) which i18n
       writes to without a data-i18n attribute
     • Heebo / Inter web-font swap (Hebrew vs English)
     • Heebo font swap on Hebrew pages
   Trade-off: ~50–100 ms of blank canvas before first paint. The win is
   that nothing the user sees ever shows the wrong language. */
html.i18n-pending { visibility: hidden; }

/* ───── Design tokens ────────────────────────────────────────────
   Two layers of variables:
   1. Raw colour tokens (brand + slate scale) that don't change with
      theme. Brand colours are designed to read on either background.
   2. SEMANTIC tokens (--surface, --text-primary, --border, …) which
      DO swap when [data-theme="dark"] is on the html element. Every
      hot-path selector in this file reads the semantic layer so a
      single theme override re-skins the whole app.
   The dark overrides also map the Tailwind utility classes used in
   the HTML (bg-white / bg-slate-50 / text-slate-700 / …) so we don't
   need to retro-fit `dark:` variants into every markup file. */
:root {
  /* Brand — unchanged across themes. Picked to read on both. */
  --vantx-blue: #2563eb;
  --vantx-blue-700: #1d4ed8;
  --vantx-blue-50: #eff6ff;
  --vantx-orange: #f97316;
  --vantx-orange-600: #ea580c;
  --navy-950: #060d24;
  --navy-900: #0b1735;
  --navy-800: #0f1f47;
  --navy-700: #162a5b;

  /* Raw slate scale — exposed because lots of selectors reference
     them directly. Dark mode redefines the same names so anything
     using e.g. var(--slate-700) gets the dark equivalent. */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic tokens — light theme defaults. */
  --bg:                #f4f6fa;
  --surface:           #ffffff;             /* card / modal background */
  --surface-elev:      #ffffff;             /* slightly lifted (popovers) */
  --surface-muted:     var(--slate-50);     /* filter bar, hover row */
  --surface-sunken:    var(--slate-100);    /* kanban col bg, badges */
  --text-primary:      var(--slate-900);
  --text-secondary:    var(--slate-700);
  --text-muted:        var(--slate-500);
  --text-subtle:       var(--slate-400);
  --border:            var(--slate-200);
  --border-strong:     var(--slate-300);
  --focus-ring:        rgba(37,99,235,.20);
  --shadow-card:       0 1px 2px 0 rgba(15,23,42,.04), 0 1px 3px 0 rgba(15,23,42,.05), 0 24px 48px -28px rgba(15,23,42,.10);
  --shadow-modal:      0 10px 30px -10px rgba(15,23,42,.25), 0 20px 60px -20px rgba(15,23,42,.20);
}

/* Dark theme — applied when html carries data-theme="dark". The
   bootstrap script sets this pre-paint from localStorage so the
   user never sees a light flash before the dark colours land. */
[data-theme="dark"] {
  /* Re-map the slate scale so anything using var(--slate-NNN) in
     this file (or implicitly via .text-slate-NNN utilities below)
     gets the inverted shade. Lighter numbers stay near-black so
     "bg-slate-50" still reads as the subtle hover state, just on
     a dark surface. */
  --slate-50:  #1e293b;
  --slate-100: #1c2536;
  --slate-200: #232e44;
  --slate-300: #334155;
  --slate-400: #64748b;
  --slate-500: #94a3b8;
  --slate-600: #cbd5e1;
  --slate-700: #e2e8f0;
  --slate-800: #f1f5f9;
  --slate-900: #f8fafc;

  --bg:                #0b1220;            /* page background */
  --surface:           #131c33;            /* card */
  --surface-elev:      #18223d;            /* modal / popover */
  --surface-muted:     #18223d;            /* filter bar / hover */
  --surface-sunken:    #0e1729;            /* kanban col / sunken panel */
  --text-primary:      #e2e8f0;
  --text-secondary:    #cbd5e1;
  --text-muted:        #94a3b8;
  --text-subtle:       #64748b;
  --border:            #243049;
  --border-strong:     #324063;
  --focus-ring:        rgba(96,165,250,.30);
  --shadow-card:       0 1px 2px 0 rgba(0,0,0,.45), 0 1px 3px 0 rgba(0,0,0,.35), 0 24px 48px -28px rgba(0,0,0,.6);
  --shadow-modal:      0 10px 30px -10px rgba(0,0,0,.65), 0 20px 60px -20px rgba(0,0,0,.55);
  color-scheme: dark;
}
/* The Tailwind utility classes embedded in HTML carry hard-coded
   slate colours. Without these overrides, dark mode would paint
   card chrome onto a still-light bg-white shell. Mapping every
   utility used in the codebase keeps markup files untouched. */
[data-theme="dark"] .bg-white       { background-color: var(--surface) !important; }
[data-theme="dark"] .bg-slate-50    { background-color: var(--surface-muted) !important; }
[data-theme="dark"] .bg-slate-100   { background-color: var(--surface-sunken) !important; }
[data-theme="dark"] .bg-blue-100    { background-color: rgba(37,99,235,.20) !important; }
[data-theme="dark"] .bg-blue-50     { background-color: rgba(37,99,235,.14) !important; }
[data-theme="dark"] .bg-rose-50     { background-color: rgba(244,63,94,.16) !important; }
[data-theme="dark"] .bg-emerald-50  { background-color: rgba(16,185,129,.16) !important; }
[data-theme="dark"] .border-slate-200 { border-color: var(--border) !important; }
[data-theme="dark"] .border-rose-200  { border-color: rgba(244,63,94,.30) !important; }
[data-theme="dark"] .text-slate-300 { color: var(--text-subtle) !important; }
[data-theme="dark"] .text-slate-400 { color: var(--text-subtle) !important; }
[data-theme="dark"] .text-slate-500 { color: var(--text-muted) !important; }
[data-theme="dark"] .text-slate-600 { color: var(--text-muted) !important; }
[data-theme="dark"] .text-slate-700 { color: var(--text-secondary) !important; }
[data-theme="dark"] .text-slate-900 { color: var(--text-primary) !important; }
[data-theme="dark"] .text-rose-600  { color: #fb7185 !important; }
[data-theme="dark"] .text-rose-700  { color: #fda4af !important; }
[data-theme="dark"] .text-emerald-400 { color: #34d399 !important; }
[data-theme="dark"] .text-emerald-600 { color: #34d399 !important; }

html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
  /* Avoid the slow cross-fade on every theme switch — only colour-
     related properties should animate so layout stays snappy. */
  transition: background-color .15s ease, color .15s ease;
}
[dir="rtl"] body { font-family: 'Heebo', 'Inter', system-ui, sans-serif; }

/* Quiet typographic hierarchy across the app. */
h1 { font-weight: 800; letter-spacing: -.02em; }
h2 { font-weight: 700; letter-spacing: -.015em; }
h3, h4 { font-weight: 700; letter-spacing: -.01em; }

/* Quiet, minimal scrollbars that match the design language. */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: padding-box; border: 2px solid transparent; }
.app-sidebar *::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); }
.app-sidebar *::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }

/* ---------- Cards ----------
   "Expensive" depth: 3-stop layered shadow. The bottom one (24px blur, far
   offset) is what gives the card its sense of being lifted off the page. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  transition: box-shadow .2s ease, transform .2s ease,
              background-color .15s ease, border-color .15s ease;
}
.card-md {
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  box-shadow:
    0 4px 12px -2px rgba(15,23,42,.08),
    0 2px 6px -2px rgba(15,23,42,.05),
    0 24px 48px -16px rgba(15,23,42,.10);
}

/* ---------- App shell / sidebar ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 264px;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 1.25rem 1rem;
  z-index: 30;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #cbd5e1;
  border-inline-end: 1px solid rgba(255,255,255,.05);
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* =====================================================================
   Mobile drawer chrome.
   The hamburger button + backdrop are inert HTML on every page; CSS
   reveals them only on small screens. Behaviour is in js/chrome.js.
   `safe-area-inset-*` env() values cover the iPhone notch / Dynamic
   Island so floating chrome never sits under the camera cutout.
   ===================================================================== */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: max(.65rem, env(safe-area-inset-top));
  inset-inline-start: max(.65rem, env(safe-area-inset-left));
  /* Above Leaflet's highest pane (z-index ~800 for popups). */
  z-index: 1100;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--navy-900);
  color: #fff;
  align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 8px 22px -6px rgba(0,0,0,.35);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .15s ease;
}
.mobile-menu-btn:active { transform: scale(.95); }
.mobile-menu-btn [data-lucide] { width: 22px; height: 22px; }
/* When the drawer is open the hamburger lives at the same inline-start
   corner as the drawer brand — they'd visually crash into each other.
   Hide the hamburger entirely; the user dismisses the drawer by tapping
   the backdrop, picking a nav item (auto-closes via chrome.js), or
   pressing Escape. The drawer always has visible backdrop space on the
   inline-end side because it's max 85 vw — never covers the full
   viewport. */
body.nav-open .mobile-menu-btn { display: none; }
.mobile-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  /* Leaflet markers / popups go up to ~800. The backdrop must beat them
     all so the open drawer doesn't get punctured by map layers. */
  z-index: 1050;
}

@media (max-width: 900px) {
  /* Show the hamburger and prep the backdrop. */
  .mobile-menu-btn { display: inline-flex; }
  body.nav-open .mobile-backdrop { display: block; }
  /* Lock background scrolling while the drawer is open. */
  body.nav-open { overflow: hidden; }

  /* Sidebar becomes an off-canvas drawer that slides in. We size it to
     280px and slide via translate so we get GPU-accelerated motion and
     the hidden state isn't focusable. `dvh` units handle the iOS
     address-bar collapse correctly. */
  .app-shell { flex-direction: column; }
  .app-sidebar {
    position: fixed; top: 0; bottom: 0;
    inset-inline-start: 0;
    width: 280px;
    max-width: 85vw;
    height: 100dvh;
    padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    transform: translateX(-105%);  /* off-screen to the start side */
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    /* One above the backdrop. Both must beat Leaflet (~800) so the map
       on the page below can't bleed through the open drawer. */
    z-index: 1060;
    border-inline-end: 1px solid rgba(255,255,255,.08);
    /* Allow the drawer to scroll if the nav + drivers list overflow. */
    overflow-y: auto;
  }
  /* RTL: drawer slides from the inline-start, which is the right edge in
     RTL. translate direction needs to flip too. */
  [dir="rtl"] .app-sidebar { transform: translateX(105%); }
  body.nav-open .app-sidebar { transform: translateX(0); }

  /* Page chrome: app-shell takes the notch padding. The actual page-header
     padding is set in a *later* block (after the base .page-header rule)
     so it wins the cascade — see "Mobile page-header overrides" below. */
  .app-shell { padding-top: env(safe-area-inset-top); }
  .page-header {
    flex-wrap: wrap;
    gap: .5rem;
  }
  .page-header > div:last-child {
    flex-wrap: wrap;
    gap: .4rem;
    /* When the action buttons wrap, push them onto a full-width row so
       they don't crowd the title beside them. */
    width: 100%;
    justify-content: flex-end;
  }

  /* Page body breathing room on phones. */
  .page-body { padding: 1rem; }
}

@media (max-width: 480px) {
  .mobile-menu-btn { width: 40px; height: 40px; border-radius: 10px; }
}

/* ---------- Fleet switcher (pill row above the users table) ----------
   Each pill represents a fleet (plus a virtual "All fleets" pill for
   admins). Click → filters the user list to that fleet. The active pill
   uses the brand blue so the current scope is unmissable; the count chip
   sits on the trailing edge for scanability. */
.fleet-switcher {
  display: flex;
  flex-wrap: nowrap;
  gap: .5rem;
  overflow-x: auto;
  padding: .15rem .15rem .85rem;
  margin-bottom: .85rem;
  border-bottom: 1px solid var(--slate-200);
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.fleet-switcher::-webkit-scrollbar { height: 6px; }
.fleet-switcher::-webkit-scrollbar-thumb { background: rgba(15,23,42,.12); border-radius: 999px; }
.fleet-tab {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .9rem;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--slate-200);
  font-size: .85rem; font-weight: 600;
  color: var(--slate-600);
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: start;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.fleet-tab:hover:not(.active) { background: var(--surface); color: var(--slate-900); border-color: #cbd5e1; }
.fleet-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.fleet-tab.active {
  background: var(--vantx-blue);
  color: #fff;
  border-color: var(--vantx-blue);
  box-shadow: 0 4px 12px -4px rgba(37,99,235,.45);
}
.fleet-tab [data-lucide] { width: 14px; height: 14px; }
.fleet-tab-count {
  font-size: .7rem;
  background: rgba(15,23,42,.06);
  color: var(--slate-600);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .02em;
}
.fleet-tab.active .fleet-tab-count {
  background: rgba(255,255,255,.25);
  color: #fff;
}

/* ---------- Responsive table → card ----------
   At narrow widths the standard table layout overflows the card and
   forces a horizontal scroll users don't notice. `.responsive-table`
   morphs each row into a stacked card, prefixing every cell with its
   column header from the `data-label` attribute. The column-row
   (<thead>) is hidden because each cell carries its own label.
   ----------------------------------------------------------------- */
@media (max-width: 640px) {
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    border: 1px solid var(--slate-200);
    border-radius: 14px;
    padding: .5rem .75rem;
    margin-bottom: .65rem;
    background: var(--surface);
  }
  .responsive-table tr:hover { background: #fff !important; } /* override desktop hover */
  .responsive-table td {
    padding: .35rem 0;
    text-align: start;
    white-space: normal !important;
    border: 0;
    /* Two-column row: label on the start, value on the end. */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
  }
  .responsive-table td:not(:last-child) {
    border-bottom: 1px dashed var(--slate-100);
  }
  .responsive-table td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--slate-500);
    flex-shrink: 0;
  }
  /* The first cell holds avatar + username — let it span full width and
     read like a card header. */
  .responsive-table tr td:first-child {
    border-bottom: 1px solid var(--slate-200);
    padding-bottom: .55rem;
    margin-bottom: .25rem;
    justify-content: flex-start;
  }
  .responsive-table tr td:first-child::before { display: none; }
  /* Action buttons row: align to end, no label needed. */
  .responsive-table tr td:last-child {
    justify-content: flex-end;
    padding-top: .5rem;
    border-top: 1px solid var(--slate-200);
    margin-top: .25rem;
  }
  /* Empty-state row: opt out of the card chrome entirely. The inner
     <td> brings its own .empty-state styling (dashed border + bg);
     without this override the responsive-table rules wrap it in a
     second card and add stray top/bottom borders that look broken. */
  .responsive-table tr.empty-row {
    border: 0 !important;
    padding: 0 !important;
    margin: 0 0 .65rem 0;
    background: transparent !important;
    border-radius: 0;
  }
  .responsive-table tr.empty-row td {
    display: block;
    text-align: center;
    border: 0 !important;
    padding: 2rem 1rem;
    margin: 0;
  }
  .responsive-table tr.empty-row td::before { content: none !important; }
  /* Empty actions cell (advisor role can't edit) — would otherwise render
     as an empty bordered strip at the bottom of each card. */
  .responsive-table tr td:last-child:empty { display: none; }
}

.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: .25rem; margin-bottom: 1.25rem; }
/* Real VANTX brand mark — 512×512 PNG resampled by the browser. Rendered on
   a transparent background so it sits cleanly on both the dark sidebar and
   the light driver header. The exact source image is the same one used by
   the brand's favicon, so visual identity stays 1:1. */
.sidebar-brand .logo {
  width: 40px; height: 40px;
  background-image: url('/icons/brand-mark.png?v=4');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  flex-shrink: 0;
  /* Hide any inline text content ("V" placeholder still in HTML). */
  color: transparent; font-size: 0; line-height: 0;
  /* Subtle drop shadow lifts the mark off the dark sidebar. */
  filter: drop-shadow(0 4px 10px rgba(124, 255, 31, .25));
}
.sidebar-brand .title { color: white; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.sidebar-brand .sub { color: #94a3b8; font-size: 11px; }
/* Full VANTX wordmark — uses the real brand PNG (1254×1254 square).
   The square canvas means a height-based scale renders a square block; we
   embrace that and tune the box size for visual balance. The login top bar
   uses the larger `.login-brand` modifier; the (future) admin/advisor
   sidebars stick with the default for a tighter footprint. */
.vantx-wordmark { display: inline-flex; align-items: center; height: 56px; }
.vantx-wordmark img { height: 100%; width: auto; display: block; object-fit: contain; }
.vantx-wordmark.login-brand { height: 56px; }
.vantx-wordmark.login-brand:hover img { transform: scale(1.02); transition: transform .25s ease; }

.section-label {
  font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: #64748b;
  padding: 0 .65rem;
  margin: 1rem 0 .4rem;
}

.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .8rem;
  border-radius: 12px;
  font-size: .9rem; font-weight: 500;
  color: #cbd5e1;
  text-decoration: none;
  cursor: pointer;
  transition: all .15s ease;
  border: 0; background: transparent; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.10); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-item.active svg { opacity: 1; color: #93c5fd; }

.divider-y { height: 1px; background: rgba(255,255,255,.08); margin: .85rem 0; }

.profile-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .65rem;
  border-radius: 12px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, #f97316, #db2777);
  flex-shrink: 0;
}
.profile-row .name { color: white; font-size: .85rem; line-height: 1.1; }
.profile-row .role { color: #94a3b8; font-size: .7rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  /* Visible footprint stays 32px (the design language is built around
     it), but a transparent ::before extends the actual hit area to
     44×44 px — WCAG 2.5.5 AAA touch-target compliance without changing
     the layout. The pseudo is `pointer-events: auto` because it sits
     on top of the icon glyph but inherits the click → button. */
  position: relative;
  width: 32px; height: 32px; border-radius: 10px;
  color: #94a3b8; background: transparent;
  cursor: pointer; border: 0;
  transition: all .15s ease;
}
.icon-btn::before {
  content: '';
  position: absolute;
  /* 44×44 hit-box: (44-32)/2 = 6px outset on each side. */
  inset: -6px;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Buttons (UNIFIED) ----------
   Every variant — used standalone OR alongside .btn — carries the same
   layout so HTML never needs `class="btn btn-primary"` to look right.
   This is the fix for the "icon at top-left of a square block" bug
   where standalone .btn-primary etc. fell back to default browser layout. */
.btn,
.btn-primary, .btn-orange, .btn-ghost, .btn-outline, .btn-waze, .btn-danger, .btn-danger-outline, .btn-success {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1rem;
  border-radius: 12px;
  font-size: .9rem; font-weight: 600;
  line-height: 1.2;
  transition: background-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease, border-color .15s ease;
  cursor: pointer; border: 0;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  /* Lock icon-then-text order regardless of page direction. Every button
     is authored as `<i></i><span>Label</span>` (icon first), so forcing
     LTR keeps the icon on the visual left in both Hebrew and English.
     The Hebrew label inside the span still renders right-to-left thanks
     to the bidi algorithm — only the icon-vs-label *order* is locked. */
  direction: ltr;
}
.btn:disabled,
.btn-primary:disabled, .btn-orange:disabled, .btn-ghost:disabled,
.btn-outline:disabled, .btn-waze:disabled, .btn-danger:disabled, .btn-danger-outline:disabled, .btn-success:disabled {
  opacity: .5; cursor: not-allowed; transform: none !important;
}
.btn:active,
.btn-primary:active, .btn-orange:active, .btn-ghost:active,
.btn-outline:active, .btn-waze:active, .btn-danger:active, .btn-danger-outline:active, .btn-success:active {
  transform: translateY(0) scale(.985);
}

.btn-primary { background: var(--vantx-blue); color: #fff; box-shadow: 0 6px 18px -10px rgba(37,99,235,.6); }
.btn-primary:hover { background: var(--vantx-blue-700); box-shadow: 0 12px 24px -10px rgba(37,99,235,.7); transform: translateY(-1px); }
.btn-orange  { background: var(--vantx-orange); color: #fff; box-shadow: 0 6px 18px -10px rgba(249,115,22,.6); }
.btn-orange:hover { background: var(--vantx-orange-600); box-shadow: 0 12px 24px -10px rgba(249,115,22,.7); transform: translateY(-1px); }
.btn-ghost   { background: var(--surface-sunken); color: #334155; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-outline { background: var(--surface); color: #334155; border: 1px solid var(--slate-300); }
.btn-outline:hover { background: var(--surface-muted); border-color: #94a3b8; box-shadow: 0 6px 14px -8px rgba(15,23,42,.12); transform: translateY(-1px); }
.btn-danger  { background: #e11d48; color: #fff; box-shadow: 0 6px 18px -10px rgba(225,29,72,.55); }
.btn-danger:hover { background: #be123c; box-shadow: 0 12px 24px -10px rgba(225,29,72,.7); transform: translateY(-1px); }
.btn-success { background: #059669; color: #fff; box-shadow: 0 6px 18px -10px rgba(5,150,105,.55); }
.btn-success:hover { background: #047857; box-shadow: 0 12px 24px -10px rgba(5,150,105,.7); transform: translateY(-1px); }
/* Outline variant of the danger button — used for "destructive but not
   confirmed" actions like the Delete button on the task detail panel.
   Stays neutral until hover, then surfaces the rose accent so the
   user understands the gravity before actually clicking through to
   the modal. */
.btn-danger-outline {
  background: var(--surface);
  color: #be123c;
  border: 1px solid #fecdd3;
}
.btn-danger-outline:hover {
  background: #fff1f2;
  border-color: #fda4af;
  color: #9f1239;
  box-shadow: 0 6px 14px -8px rgba(225,29,72,.25);
  transform: translateY(-1px);
}

/* Waze-branded navigation button. Used on the task detail action toolbar
   ("Open in Waze") and anywhere else we deep-link to waze.com/ul. The
   palette mirrors Waze's primary-action blue (#33ccff family) but with
   our own contrast tuning so it sits next to .btn-outline without
   visually shouting. We deliberately avoid using the literal Waze logo
   to keep brand-guideline compliance simple. */
.btn-waze {
  background: var(--surface);
  color: #0e7490;
  border: 1px solid #a5f3fc;
}
.btn-waze:hover {
  background: #ecfeff;
  border-color: #67e8f9;
  color: #155e75;
  box-shadow: 0 6px 14px -8px rgba(8,145,178,.25);
  transform: translateY(-1px);
}
.btn-waze:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

/* SVG sizing inside any button variant — locks 16px so icons can't push
   text or wrap to a new line (was previously only matching .btn). */
.btn > svg, .btn > [data-lucide],
.btn-primary > svg, .btn-primary > [data-lucide],
.btn-orange  > svg, .btn-orange  > [data-lucide],
.btn-ghost   > svg, .btn-ghost   > [data-lucide],
.btn-outline > svg, .btn-outline > [data-lucide],
.btn-waze    > svg, .btn-waze    > [data-lucide],
.btn-danger  > svg, .btn-danger  > [data-lucide],
.btn-danger-outline > svg, .btn-danger-outline > [data-lucide],
.btn-success > svg, .btn-success > [data-lucide] {
  width: 16px; height: 16px; flex-shrink: 0;
}
.btn-xl > svg, .btn-xl > [data-lucide] { width: 20px; height: 20px; }

/* ---------- Circular icon-only button (chat composer Send, etc.) ---------- */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color .15s ease, transform .12s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn-icon-primary {
  background: var(--vantx-blue);
  color: #fff;
  box-shadow: 0 6px 18px -10px rgba(37,99,235,.6);
}
.btn-icon-primary:hover {
  background: var(--vantx-blue-700);
  box-shadow: 0 12px 24px -10px rgba(37,99,235,.7);
  transform: translateY(-1px);
}
.btn-icon-primary:active { transform: translateY(0) scale(.985); }
.btn-icon > svg, .btn-icon > [data-lucide] { width: 18px; height: 18px; }
[dir="rtl"] .btn-icon > .flip-rtl { transform: scaleX(-1); }
.btn-icon:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-xl {
  padding: 1rem 1.25rem;
  font-size: 1rem;
  min-height: 60px;
  border-radius: 14px;
  font-weight: 700;
}
.btn svg { width: 16px; height: 16px; }
.btn-xl svg { width: 20px; height: 20px; }

/* ---------- Inputs ---------- */
.field {
  width: 100%;
  display: block;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 12px;
  padding: .65rem .85rem;
  font-size: .9rem;
  color: var(--text-primary);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease;
}
.field::placeholder { color: var(--text-subtle); }
.field:hover { border-color: var(--text-subtle); }
.field:focus {
  outline: none;
  border-color: var(--vantx-blue);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.field-lg { padding: .9rem 1rem; font-size: 1rem; border-radius: 12px; }

/* Mobile font-size bump on form controls (Audit U6).
   iOS Safari auto-zooms into any input whose computed font-size is
   below 16 px on focus. The desktop UI uses 14.4 px (.9rem) for
   density; lifting it to 16 px on touch viewports stops the
   distracting zoom without affecting desktop look. */
@media (max-width: 640px) {
  .field,
  input.field,
  select.field,
  textarea.field,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
  }
}
.field-with-icon { padding-inline-start: 2.6rem; }
.input-wrap { position: relative; }
.input-wrap > svg.icon,
.input-wrap > .lucide-icon {
  position: absolute; top: 50%; transform: translateY(-50%);
  inset-inline-start: .9rem; width: 18px; height: 18px;
  color: #94a3b8; pointer-events: none;
}
textarea.field { min-height: 76px; resize: vertical; }
select.field { background-image: none; appearance: auto; }

/* Phone-number inputs in Hebrew (RTL) pages.
   The browser forces `direction: ltr` on `type="tel"` so digits flow
   left-to-right correctly when typed (a phone number is inherently LTR),
   but that leaves the placeholder ("050-1234567") stuck on the left
   edge — wrong for an RTL form where every other field starts on the
   right. We keep the LTR direction (so typed digits stay readable)
   and only flip the text alignment so the placeholder + content sit
   on the right side of the field. */
[dir="rtl"] input[type="tel"].field { text-align: right; }

/* ---------- Badges (pill-shaped status) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .65rem;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 9999px;
  letter-spacing: .01em;
}
.badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; opacity: .85;
}
.badge-pending     { background: #fef3c7; color: #92400e; }
.badge-accepted    { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-arrived     { background: #ede9fe; color: #6d28d9; }
.badge-completed   { background: #d1fae5; color: #065f46; }
.badge-rejected    { background: #fee2e2; color: #b91c1c; }
.badge-cancelled   { background: var(--surface-sunken); color: #475569; }

/* Role chip (sidebar / cards) */
.chip-role {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .55rem; border-radius: 9999px;
  font-size: .68rem; font-weight: 600;
  background: #e0e7ff; color: #3730a3;
}
.chip-role.driver { background: #dcfce7; color: #166534; }
.chip-role.advisor { background: #dbeafe; color: #1e40af; }
/* Ops manager badge — amber/orange, between advisor (blue) and admin (red)
   to communicate the elevated-but-fleet-scoped permission tier visually. */
.chip-role.OM { background: #fef3c7; color: #92400e; }
.chip-role.admin { background: #fee2e2; color: #991b1b; }

/* "New customer" chip — appears next to the name on rows that came in
   via a task auto-create (server source='task'). Vibrant emerald so
   the operator's eye lands on freshly-arrived customers worth
   reviewing. The chip clears once an operator opens-and-saves the
   row from the customers page (server graduates source → 'manual'). */
.chip-new-customer {
  display: inline-flex; align-items: center;
  /* WCAG fix: bumped from .65rem (~10.4px) to .72rem (~11.5px) and
     darkened the foreground to a 7.4:1 ratio. Padding scaled up so
     the chip still reads as a balanced badge. */
  padding: .18rem .6rem;
  border-radius: 9999px;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #d1fae5;
  color: #064e3b;     /* was #065f46 — bumps contrast over green-100 to AAA */
  border: 1px solid #6ee7b7;
}
/* Suspended-account chip — appears next to the username on the users
   page. Slate / neutral colors so it pairs with any role chip without
   competing for attention; the user-row-suspended dim is the primary
   visual signal for the row state. */
.chip-suspended {
  display: inline-flex; align-items: center;
  /* WCAG fix: was 10.4px / 4.0:1 (fails AA). Now 11.5px and a darker
     slate-700 foreground (7.6:1 over slate-100 — AAA). */
  padding: .18rem .55rem;
  border-radius: 9999px;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--surface-sunken);
  color: #334155;     /* was #64748b — slate-700 over slate-100 = AAA */
  border: 1px solid #cbd5e1;
  margin-inline-start: .35rem;
}
/* Suspended row: dim everything except the action buttons so the
   admin can still re-activate without visual fight. We *don't* hide
   the row — admins need to find suspended users in the list to act
   on them. */
.user-row-suspended td:not(:last-child) { opacity: .55; }
.user-row-suspended:hover { background: #fafbfd !important; }

/* ---------- Status dots ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 9999px; }
.dot-online {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16,185,129,.18);
  animation: pulse-soft 2.4s infinite;
}
.dot-offline { background: #94a3b8; }
@keyframes pulse-soft {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* ---------- Driver row (in navy sidebar) ---------- */
.driver-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .65rem;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
  border: 1px solid rgba(255,255,255,.04);
  /* The row is a clickable card (follow / show path / select driver).
     Disable text selection so a quick drag to focus a driver doesn't
     leave the name + status text highlighted — the row should feel
     like a button, not a paragraph. The action buttons inside still
     work normally (selection is per-element, not inherited as
     interaction). */
  user-select: none;
  -webkit-user-select: none;
}
.driver-row:hover { background: rgba(255,255,255,.08); }
.driver-row:active { transform: scale(.99); }
.driver-row .avatar { width: 30px; height: 30px; font-size: 12px; }
.driver-row .row-name { font-size: .85rem; color: #fff; font-weight: 500; line-height: 1.1; }
.driver-row .row-status {
  font-size: .68rem;
  color: #94a3b8;
  margin-top: 2px;
  /* `flex-wrap: wrap` lets the activity badge drop to a second line when the
     row narrows (e.g. "הגיע ליעד" + "מחובר" + dot all competing for the
     ~120 px middle column). Previously this was `inline-flex` which forced
     everything onto one row, and the badge text wrapped letter-by-letter
     instead. */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .4rem;
  min-width: 0;
}
.driver-row .focus-arrow { color: #64748b; }
.driver-row:hover .focus-arrow { color: #cbd5e1; }

/* ---------- Map ---------- */
.map-canvas {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  box-shadow: 0 4px 14px -4px rgba(15,23,42,.06);
  background: #e8eef5;
}
[dir="rtl"] .leaflet-container { direction: ltr; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: white;
  padding: .7rem 1.1rem; border-radius: 12px;
  font-size: .9rem; opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  box-shadow: 0 14px 30px -8px rgba(0,0,0,.35);
}
.toast.show { opacity: 1; transform: translate(-50%, -4px); }
[dir="rtl"] .toast { left: auto; right: 50%; transform: translateX(50%); }
[dir="rtl"] .toast.show { transform: translate(50%, -4px); }

/* ---------- Active task (driver) ---------- */
.active-task {
  position: relative;
  border: 1.5px solid rgba(37,99,235,.45);
  background: linear-gradient(180deg, #ffffff, #eff6ff);
  border-radius: 16px;
  padding: 1.25rem 1.25rem 1.1rem;
  box-shadow: 0 18px 35px -18px rgba(37,99,235,.45);
}
.active-task .label {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .68rem; font-weight: 700;
  color: #1d4ed8; text-transform: uppercase; letter-spacing: .12em;
  margin-bottom: .35rem;
}
.active-task .label .dot { background: #2563eb; box-shadow: 0 0 0 4px rgba(37,99,235,.18); animation: pulse-soft 2s infinite; }

/* ---------- Status row (driver header) ---------- */
.status-row {
  display: flex; align-items: center; gap: 1rem;
  font-size: .75rem; color: var(--slate-500);
}
.status-row .item { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------- Modal ----------
   Leaflet panes/controls stack up to z-index ~800. The backdrop must sit
   above all of them or the map will "swallow" modals. */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--surface-elev); border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  /* Flex column + a viewport-height cap so a TALL form (the New Task
     modal, after the registry fields were added) scrolls its BODY
     instead of growing past the screen and clipping the header + the
     Create/Cancel footer. This used to be gated to phones only, so on
     desktop tall modals overflowed off-screen. */
  display: flex; flex-direction: column;
  max-height: calc(100vh - 2rem);
}
.modal-card header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
/* `min-height: 0` lets the body shrink below its content size inside
   the flex column — without it the scroller never engages. */
.modal-card .body { padding: 1.25rem; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-card .footer { padding: .85rem 1.25rem; background: var(--surface-muted); display: flex; justify-content: flex-end; gap: .5rem; border-top: 1px solid var(--border); flex-shrink: 0; }
/* Modals on phones — fill the viewport with a small inset so the backdrop
   is still visible. The flex/scroll behaviour is now shared from the
   base rule above; phones only need the full-width + footer tweaks. */
@media (max-width: 640px) {
  .modal-backdrop { padding: .5rem; align-items: stretch; }
  .modal-card {
    max-width: 100%;
    max-height: calc(100vh - 1rem);
    border-radius: 14px;
  }
  .modal-card .footer { flex-wrap: wrap; }
  .modal-card .footer > .btn-primary,
  .modal-card .footer > .btn-outline,
  .modal-card .footer > .btn-success,
  .modal-card .footer > .btn-danger { flex: 1; min-width: 120px; }
}

/* ---------- Custom select (replaces native <select>) ----------
   Markup is built by js/ui.js — never authored directly in HTML. */
.vx-select-wrap { position: relative; }
.vx-select-wrap > select { display: none; }
.vx-trigger {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .65rem .85rem;
  border: 1px solid var(--slate-300);
  background: var(--surface);
  border-radius: 12px;
  font-size: .9rem; font-weight: 500;
  color: var(--slate-900);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  text-align: start;
}
.vx-trigger:hover { border-color: #94a3b8; }
.vx-trigger:focus-visible { outline: none; border-color: var(--vantx-blue); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.vx-select-wrap.open .vx-trigger { border-color: var(--vantx-blue); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.vx-trigger .vx-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vx-trigger .vx-label.placeholder { color: #94a3b8; font-weight: 400; }
.vx-trigger .vx-chev { width: 16px; height: 16px; color: #94a3b8; transition: transform .18s ease, color .15s ease; flex-shrink: 0; }
.vx-select-wrap.open .vx-trigger .vx-chev { transform: rotate(180deg); color: var(--vantx-blue); }

.vx-menu {
  /* Anchor to the start edge only; let the menu grow toward the end edge.
     This way a narrow trigger (e.g., one that sits next to a "Recommend"
     button in a flex row) can still pop a wide menu that fits the
     longest option text — driver names like "דני נהג מהר" no longer
     get clipped to "דני נהג…". `min-width: 100%` keeps the menu at
     least as wide as the trigger so it doesn't look detached. */
  position: absolute; top: calc(100% + .35rem); inset-inline-start: 0;
  margin: 0; padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  box-shadow:
    0 10px 24px -8px rgba(15,23,42,.18),
    0 4px 12px -4px rgba(15,23,42,.10);
  z-index: 50;
  min-width: 100%;
  width: max-content;
  max-width: min(360px, calc(100vw - 2rem));
  max-height: 280px;
  overflow-y: auto;
  list-style: none;
  display: none;
}
.vx-select-wrap.open .vx-menu { display: block; animation: vx-pop .14s cubic-bezier(.2,.8,.2,1) both; }
@keyframes vx-pop {
  from { opacity: 0; transform: translateY(-4px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.vx-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .65rem;
  border-radius: 8px;
  font-size: .9rem;
  color: var(--slate-700);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.vx-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vx-item:hover { background: var(--surface-sunken); color: var(--slate-900); }
.vx-item.active {
  background: rgba(37,99,235,.08);
  color: var(--vantx-blue);
  font-weight: 600;
}
.vx-check { color: var(--vantx-blue); opacity: 0; flex-shrink: 0; }
.vx-item.active .vx-check { opacity: 1; }

/* Real checkbox <input> — brand-accented, used in modal forms (e.g.
   the "mark as primary vehicle" toggle). NOTE: distinct from
   `.vx-check` above, which is a checkmark ICON shown on active list
   rows and is `opacity: 0` by default — applying it to a real
   checkbox makes the box invisible. */
.vx-checkbox {
  width: 16px; height: 16px;
  accent-color: var(--vantx-blue);
  flex-shrink: 0;
  cursor: pointer;
}

/* ---------- Segmented button group (replaces native <select> for short lists) ---------- */
.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--surface-sunken);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
  position: relative;
}
.btn-group.full { display: flex; width: 100%; flex-wrap: wrap; }
.btn-group-item {
  /* `flex: 1 0 0` lets each chip grow but allows wrapping when min-content
     would overflow. min-width keeps short labels visually balanced. */
  flex: 1 1 0;
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: .55rem .6rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--slate-600);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
  /* Allow wrap so 4 long role labels don't clip (e.g. "Operations Manager").
     The active chip still reads clearly because the white surface fills the
     entire wrapped row. */
  white-space: normal;
  text-align: center;
  line-height: 1.15;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
/* When the segmented group has 4+ items (e.g. 4 roles), force a 2-up layout
   on narrow screens so each chip has breathing room and reads in full. */
.btn-group.full:has(.btn-group-item:nth-child(4)) .btn-group-item {
  flex: 1 1 calc(50% - 2px);
}
.btn-group-item:hover:not(.active) { color: var(--slate-900); background: rgba(255,255,255,.55); }
.btn-group-item.active {
  background: var(--surface);
  color: var(--vantx-blue);
  box-shadow:
    0 1px 2px rgba(15,23,42,.06),
    0 4px 10px -4px rgba(15,23,42,.10);
}
.btn-group-item:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.btn-group-item svg { width: 14px; height: 14px; }

/* ---------- Language toggle ---------- */
.lang-toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .4rem .85rem;
  border-radius: 9999px;
  border: 1px solid var(--slate-200);
  background: var(--surface);
  color: var(--slate-700);
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .12s ease;
  user-select: none;
  white-space: nowrap;
  line-height: 1;
}
.lang-toggle:hover { border-color: var(--vantx-blue); color: var(--vantx-blue); box-shadow: 0 4px 10px -6px rgba(37,99,235,.25); transform: translateY(-1px); }
.lang-toggle:active { transform: translateY(0) scale(.985); }
.lang-toggle .lang-flag { font-size: 1.05rem; line-height: 1; }
.lang-toggle .lang-label { font-size: .78rem; }
/* Sidebar variant — sits inside the navy header */
.lang-toggle.dark {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.1);
  color: #cbd5e1;
}
.lang-toggle.dark:hover { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.2); }

/* Phone-screen tightening — the English label "English" + flag is wider
   than the Hebrew "עברית" + flag, and on 375 px viewports the extra
   width pushes the page-header's primary action ("+ Add customer")
   onto a second line. Below 640 px we drop the text label and keep
   only the flag — operators still know which language they're in
   from the flag alone, and every button now sits on a single row.
   We also tighten every button's padding inside the page-header so
   the row totals fit in a 320–375 px viewport AND the heights are
   uniform (lang-toggle previously sat 3 px lower than the .btn-*
   siblings because of its smaller default padding). */
@media (max-width: 640px) {
  .lang-toggle { padding: .5rem .65rem; }
  .lang-toggle .lang-label { display: none; }
  .page-header .btn-primary,
  .page-header .btn-outline,
  .page-header .btn-danger,
  .page-header .btn-danger-outline {
    padding: .5rem .7rem;
    font-size: .82rem;
    border-radius: 10px;
  }
  /* Pill-shape lang-toggle next to rounded-rect btn-* — same border-
     radius keeps the row cohesive on mobile rather than one round
     thumb floating beside three rectangles. */
  .page-header .lang-toggle {
    border-radius: 10px;
  }
}

/* ─── Per-user permission overrides (admin.js: openEditUser) ──────
   3-way segment per permission: Default (use the role's value),
   Grant (force-on), Revoke (force-off). Two-track layout: PC keeps
   the row horizontal (info on one side, controls on the other) so an
   admin can scan + flip fast; phone collapses to a vertical card so
   long Hebrew labels don't squeeze the action buttons into 30 px. */
.eu-perm-group {
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: .85rem 1rem 1rem;
  background: var(--surface);
  /* 2-column grid on desktop — the modal is 880 px wide, plenty of
     room for two perm rows side-by-side. Halves the vertical real
     estate of the 34-permission grid, which previously scrolled
     forever. `auto-fit minmax(280px, 1fr)` gracefully degrades to 1
     column when the modal shrinks (mobile) or when an embedded
     viewport renders the modal at < ~620 px wide. The h5 heading
     spans both tracks. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: .25rem .85rem;
  column-gap: .85rem;
}
.eu-perm-group h5 {
  grid-column: 1 / -1;             /* span all tracks */
  font-size: .85rem; font-weight: 700; color: var(--slate-700);
  margin: 0 0 .45rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--slate-100);
}
.eu-perm-group + .eu-perm-group { margin-top: .75rem; }

.eu-perm-row {
  position: relative;
  display: grid;
  /* Inside each grid cell of the parent: name column flexes, controls
     hug their content. The 3-way segment sits on the trailing edge,
     deterministic across rows even when one label wraps to 2 lines. */
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .65rem;
  padding: .45rem 0;
  border-bottom: 1px dashed var(--slate-100);
}
.eu-perm-row:last-child { border-bottom: 0; }
/* When 2-up: the SECOND-to-last and last rows both get last-of-type
   styling stripped via :nth-last-of-type to keep border-bottom on
   anything that has a row visually below it. Simpler approach: keep
   the dashed border on every row except the absolute last in the
   group, OR — easier — show the border on all rows and let the
   group's bottom padding swallow the trailing dash for last row. */

.eu-perm-info { min-width: 0; }
.eu-perm-info .name {
  font-size: .88rem; color: var(--slate-800); font-weight: 500;
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  line-height: 1.3;
}
.eu-perm-info .role-default {
  font-size: .65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: var(--slate-100); color: var(--slate-600);
  white-space: nowrap;
  letter-spacing: .02em;
}
.eu-perm-info .role-default.on  { background: #dcfce7; color: #166534; }
.eu-perm-info .role-default.off { background: #fee2e2; color: #991b1b; }

/* Trailing controls bundle: expiry chip + 3-way segment. */
.eu-perm-actions {
  display: inline-flex; align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

.eu-3way {
  display: inline-flex;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  background: var(--slate-50);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.eu-3way > button {
  font-size: .72rem; font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--slate-500);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.eu-3way > button:hover { color: var(--slate-800); background: rgba(255,255,255,.6); }
.eu-3way > button.active[data-mode="default"] { background: var(--surface); color: var(--slate-800); box-shadow: 0 1px 3px rgba(15,23,42,.10); }
.eu-3way > button.active[data-mode="grant"]   { background: #10b981; color: #fff; box-shadow: 0 1px 3px rgba(16,185,129,.35); }
.eu-3way > button.active[data-mode="revoke"]  { background: #ef4444; color: #fff; box-shadow: 0 1px 3px rgba(239,68,68,.35); }

.eu-expiry-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .68rem; font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--slate-200);
  background: var(--surface);
  color: var(--slate-600);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .12s ease, color .12s ease;
}
.eu-expiry-chip:hover { border-color: var(--vantx-blue); color: var(--vantx-blue); }

/* Phone collapse: at 720 px the .eu-perm-group `auto-fit minmax(280, 1fr)`
   already collapses to 1 column on its own. Inside each row we
   additionally stack the name above the action buttons so the
   3-way segment isn't squeezed into a tight side panel next to a
   long Hebrew label. */
@media (max-width: 720px) {
  .eu-perm-group {
    grid-template-columns: 1fr;     /* explicit single column */
    padding: .75rem .85rem;
  }
  .eu-perm-row {
    grid-template-columns: 1fr;
    gap: .5rem;
    padding: .7rem 0;
  }
  .eu-perm-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .4rem;
  }
  .eu-3way { flex: 1 1 auto; }
  .eu-3way > button { flex: 1 1 0; text-align: center; padding: 6px 10px; }
}

/* Make the overrides section content scroll inside the modal when it
   gets tall, instead of pushing the Save/Cancel footer off-screen.
   The modal-card itself has overflow:auto already, but a hard max-h
   on the grid keeps the modal compact on tall content. */
.eu-overrides-scroll {
  max-height: 60vh;
  overflow-y: auto;
  padding-inline-end: .25rem;  /* leave room for the scrollbar */
}

/* ─── Permission-overrides launcher button ─────────────────────────
   Sits inside the Edit-User modal where the inline <details> used
   to live. Looks like a tappable "menu row" card: icon on the
   start, title + sub stacked in the middle, override-count badge
   + chevron on the end. Hover state matches role-card affordances
   so the operator reads it as "click me to open something". */
.eu-open-overrides {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .75rem .9rem;
  background: var(--surface-muted);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  text-align: start;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.eu-open-overrides:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
.eu-open-overrides:focus-visible {
  outline: none;
  border-color: var(--vantx-blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}
.eu-open-overrides-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #dbeafe;
  color: var(--vantx-blue, #2563eb);
}
.eu-open-overrides-icon i { width: 18px; height: 18px; }
.eu-open-overrides-body {
  display: flex; flex-direction: column;
  flex: 1; min-width: 0;
  gap: 2px;
}
.eu-open-overrides-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--slate-800);
  line-height: 1.2;
}
.eu-open-overrides-sub {
  font-size: .72rem;
  color: var(--slate-500);
  line-height: 1.2;
}
.eu-open-overrides-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--slate-600);
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  padding: 3px 9px;
  min-height: 22px;
  white-space: nowrap;
}
.eu-open-overrides-count:empty { display: none; }

/* ─── Permission-overrides popup ──────────────────────────────────
   Standalone modal launched from .eu-open-overrides. Slightly
   wider than the Edit-User modal (the inner grid is 2-column at
   desktop widths) and the body region scrolls so the footer stays
   pinned with Cancel / Apply always reachable. */
.po-modal {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  /* On desktop the global .modal-card sets overflow:hidden, but it
     doesn't go flex/column there — only at <=640 px. Without flex
     on the card itself the inner body can't get a bounded height
     to scroll inside, so the perm grid silently clips instead of
     scrolling. That's the "feels stuck" symptom. */
}
.po-body {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  overflow: hidden;          /* let .po-grid handle its own scroll */
  flex: 1 1 auto;
  /* CRITICAL for the inner scroll: flex items default to
     min-height: auto, which refuses to shrink below content size.
     Setting min-height: 0 lets the body shrink to whatever space
     the modal has, so the grid below can become overflowed and
     show its own scrollbar. */
  min-height: 0;
}
.po-help {
  margin: 0;
  line-height: 1.45;
  flex-shrink: 0;            /* help text never gets squeezed */
}
.po-grid {
  /* Override the 60vh cap from .eu-overrides-scroll inside this
     popup — the modal already caps overall height at 90vh and the
     footer is pinned, so let the grid take whatever's left. */
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;             /* same min-height trick — required so the
                                inner overflow-y:auto actually engages */
  /* Smoothness fixes:
     - overscroll-behavior:contain stops the rubber-band from
       chaining up to the (now locked) body, which previously
       caused a noticeable "stutter" at the top/bottom of the list.
     - scrollbar-width + ::-webkit-scrollbar give a thin, less
       visually noisy scrollbar so the eye glides over the grid
       instead of catching on a fat default scrollbar.
     - contain:layout style isolates the grid's reflow from the
       rest of the page so wheel events don't trigger upstream
       layout work. */
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(100,116,139,.45) transparent;
  scroll-behavior: smooth;
  contain: layout style;
}
.po-grid::-webkit-scrollbar { width: 8px; }
.po-grid::-webkit-scrollbar-track { background: transparent; }
.po-grid::-webkit-scrollbar-thumb {
  background: rgba(100,116,139,.35);
  border-radius: 8px;
}
.po-grid::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.55); }

/* Drop the global modal-backdrop blur for this specific popup.
   backdrop-filter: blur() re-renders the entire viewport behind
   the modal every paint frame; when content inside the modal
   scrolls, the GPU keeps recomposing that blur, which produces
   the "not smooth" stutter the user sees. A flat dim is just
   as readable and removes the cost completely. */
#perm-overrides-modal.modal-backdrop {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(15,23,42,.62);
}

@media (max-width: 720px) {
  .po-modal { max-height: 100vh; }
}

/* ─── Body scroll lock while a modal is open ──────────────────────
   Without this, scrolling the wheel/trackpad over the modal also
   scrolls the page behind it, which feels disconnected and lets
   the user "lose" the popup off-screen. Toggled by admin.js around
   openOverridesModal / closeOverridesModal. Class is intentionally
   modal-agnostic so future modals can opt in. */
body.modal-lock {
  overflow: hidden;
}

/* ─── Skeleton placeholders while perm data loads ──────────────────
   Shown for the ~100–400 ms between popup open and the two API
   responses landing. Stable height = no layout snap when real
   rows arrive. Subtle pulse hints "this is loading, not stuck". */
.po-skel-bar {
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  height: 14px;
  animation: po-skel-pulse 1.4s linear infinite;
}
.po-skel-bar-head { width: 35%; height: 12px; margin-bottom: .55rem; }
.po-skel-bar-name { width: 70%; }
.po-skel-bar-ctrl { width: 140px; height: 28px; border-radius: 999px; }
.po-skel-row .eu-perm-actions { justify-content: flex-end; }
@keyframes po-skel-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Inline error message when /api/roles or /api/users/.../overrides
   throws — keeps the modal navigable (Cancel still closes) while
   making the failure visible instead of silent. */
.po-error {
  display: flex; align-items: center; gap: .55rem;
  padding: .85rem 1rem;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid rgba(239,68,68,.25);
  color: #991b1b;
  font-size: .82rem;
  font-weight: 500;
}
.eu-expiry-picker {
  position: absolute;
  inset-inline-end: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  box-shadow: 0 8px 24px -8px rgba(15,23,42,.18);
  padding: .65rem .75rem;
  min-width: 240px;
  font-size: .8rem;
}
.eu-expiry-picker .eu-ep-section + .eu-ep-section {
  margin-top: .55rem;
  padding-top: .55rem;
  border-top: 1px dashed var(--slate-200);
}
.eu-expiry-picker .eu-ep-label {
  font-size: .65rem; font-weight: 700;
  color: var(--slate-500);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.eu-expiry-picker .eu-ep-presets {
  display: flex; gap: .35rem; flex-wrap: wrap;
}
.eu-expiry-picker .eu-ep-presets > button {
  font-size: .72rem; font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--slate-200);
  background: var(--surface);
  color: var(--slate-700);
  cursor: pointer;
}
.eu-expiry-picker .eu-ep-presets > button:hover { background: #eff6ff; border-color: var(--vantx-blue); }
.eu-expiry-picker .eu-ep-input {
  width: 100%;
  font-size: .8rem;
  padding: 5px 8px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
}
.eu-expiry-picker .eu-ep-clear {
  width: 100%;
  font-size: .72rem; font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--slate-200);
  background: var(--surface-muted);
  color: var(--slate-700);
  cursor: pointer;
}
.eu-expiry-picker .eu-ep-clear:hover { background: var(--slate-100); }

/* ─── Role-templates picker modal ────────────────────────────────
   Shown after the platform admin creates the first user (= GM) of a
   brand-new fleet. Offers a multi-pick of pre-built role templates.
   Visual: card-grid on PC (two columns on wide modals, one column on
   narrow ones), full-width stacked cards on phone. Each card is the
   click target so taps don't have to land on the tiny checkbox. */
.rt-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  padding: .35rem .15rem .85rem;
  border-bottom: 1px dashed var(--slate-200);
  margin-bottom: .9rem;
}
.rt-select-all {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: .82rem; font-weight: 600; color: var(--slate-700);
  cursor: pointer;
  user-select: none;
}
.rt-select-all input[type="checkbox"] {
  width: 1.05rem; height: 1.05rem;
  accent-color: var(--vantx-blue);
  cursor: pointer;
}
.rt-list {
  display: grid;
  gap: .65rem;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .rt-list { grid-template-columns: 1fr 1fr; }
}
.rt-card {
  position: relative;
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .85rem .95rem;
  border: 1.5px solid var(--slate-200);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.rt-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}
.rt-card.selected {
  border-color: var(--vantx-blue);
  background: #eff6ff;
  box-shadow: 0 6px 18px -10px rgba(37,99,235,.45);
}
.rt-card .rt-check {
  flex-shrink: 0;
  width: 1.2rem; height: 1.2rem;
  border-radius: 6px;
  border: 1.5px solid var(--slate-300);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 2px;
  transition: background .12s ease, border-color .12s ease;
}
.rt-card.selected .rt-check {
  background: var(--vantx-blue);
  border-color: var(--vantx-blue);
}
.rt-card .rt-check::after {
  content: '';
  width: .65rem; height: .35rem;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-2px);
  opacity: 0;
  transition: opacity .12s ease;
}
.rt-card.selected .rt-check::after { opacity: 1; }
.rt-card .rt-body { min-width: 0; flex: 1; }
.rt-card .rt-name {
  font-size: .92rem; font-weight: 700; color: var(--slate-900);
  margin-bottom: .15rem;
}
.rt-card .rt-desc {
  font-size: .78rem; color: var(--slate-600);
  line-height: 1.4;
  margin-bottom: .45rem;
}
.rt-card .rt-meta {
  font-size: .68rem; font-weight: 600; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: .04em;
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--slate-100);
  padding: 3px 8px;
  border-radius: 999px;
}
.rt-card.selected .rt-meta {
  background: rgba(37,99,235,.12);
  color: var(--vantx-blue);
}
/* Native checkbox stays in the DOM for keyboard/a11y but visually we
   render the custom .rt-check tile instead. */
.rt-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%; height: 100%;
  margin: 0;
  cursor: pointer;
}
.rt-count {
  font-variant-numeric: tabular-nums;
}

/* ─── Confirm-danger modal (util.confirmDanger) ───────────────────
   Reusable destructive-action confirmation. Compact card with an
   icon tile, title, message, and two clearly-distinguished buttons.
   Built dynamically by util.js — no markup lives in any HTML file.
   Two tones: `danger` (red, default — Delete) and `warning` (amber). */
.confirm-backdrop {
  /* Slightly stronger backdrop than the regular modals so the operator
     pauses on a destructive action instead of dismissing reflexively. */
  background: rgba(15, 23, 42, .55);
  animation: confirm-fade .14s ease-out;
  /* Sit above the mobile hamburger button (z-index 1100) so the
     destructive-action dialog isn't partially obscured on phone widths. */
  z-index: 1200;
}
.confirm-leaving { opacity: 0; transition: opacity .12s ease-in; }
@keyframes confirm-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.confirm-card {
  max-width: 440px;
  width: 100%;
  padding: 0;
  animation: confirm-zoom .16s cubic-bezier(.16, 1, .3, 1);
}
@keyframes confirm-zoom {
  from { transform: translateY(8px) scale(.96); opacity: 0; }
  to   { transform: none;                       opacity: 1; }
}
.confirm-body {
  display: flex; gap: .9rem;
  padding: 1.25rem 1.25rem 1rem;
  align-items: flex-start;
}
.confirm-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.confirm-danger  .confirm-icon { background: #fee2e2; color: #b91c1c; }
.confirm-warning .confirm-icon { background: #fef3c7; color: #b45309; }
.confirm-info    .confirm-icon { background: #dbeafe; color: #1d4ed8; }
.confirm-icon i { width: 22px; height: 22px; }

.confirm-text { min-width: 0; flex: 1; }
.confirm-title {
  font-size: 1rem; font-weight: 700; color: var(--slate-900);
  margin-bottom: .3rem;
  line-height: 1.35;
}
.confirm-message {
  font-size: .85rem; color: var(--slate-600);
  line-height: 1.5;
}

.confirm-footer {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding: .75rem 1.25rem 1.1rem;
  border-top: 1px solid var(--slate-100);
  background: #fbfcfd;
  border-radius: 0 0 16px 16px;
}
.confirm-footer .btn-outline {
  min-width: 96px;
  justify-content: center;
}
.btn-confirm-danger, .btn-confirm-warning, .btn-confirm-info {
  display: inline-flex; align-items: center; gap: .4rem;
  min-width: 120px;
  justify-content: center;
  padding: .55rem .95rem;
  border-radius: 10px;
  font-weight: 700; font-size: .85rem;
  border: 0;
  cursor: pointer;
  transition: background-color .12s ease, transform .08s ease, box-shadow .15s ease;
}
.btn-confirm-danger {
  background: #dc2626; color: #fff;
  box-shadow: 0 1px 2px rgba(220, 38, 38, .35);
}
.btn-confirm-danger:hover { background: #b91c1c; }
.btn-confirm-danger:active { transform: translateY(1px); }
.btn-confirm-danger:focus-visible {
  outline: 2px solid #fecaca; outline-offset: 2px;
}
.btn-confirm-warning {
  background: #d97706; color: #fff;
  box-shadow: 0 1px 2px rgba(217, 119, 6, .35);
}
.btn-confirm-warning:hover { background: #b45309; }
.btn-confirm-warning:active { transform: translateY(1px); }
/* Info tone — non-destructive dismiss button. Uses the brand blue so
   it visually matches the rest of the UI's primary actions instead
   of standing out like a destructive red/amber button. */
.btn-confirm-info {
  background: var(--vantx-blue, #2563eb); color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .35);
}
.btn-confirm-info:hover { background: #1d4ed8; }
.btn-confirm-info:active { transform: translateY(1px); }
.btn-confirm-info:focus-visible {
  outline: 2px solid #bfdbfe; outline-offset: 2px;
}

/* Phone: shrink padding + stack the footer buttons so they're easy
   to tap without misclicks. The Cancel button stays on top (left in
   RTL) so the destructive action remains the secondary tap target. */
@media (max-width: 480px) {
  .confirm-body { padding: 1rem 1rem .85rem; gap: .7rem; }
  .confirm-icon { width: 40px; height: 40px; }
  .confirm-footer {
    flex-direction: column-reverse;
    gap: .5rem;
    padding: .65rem .9rem 1rem;
  }
  .confirm-footer button { width: 100%; min-width: 0; }
}

/* Keep map controls below modals even when Leaflet stacks high */
.leaflet-pane, .leaflet-top, .leaflet-bottom { z-index: 400 !important; }
.leaflet-popup-pane { z-index: 700 !important; }
.leaflet-tooltip-pane { z-index: 650 !important; }

/* ---------- Global selection policy: opt-in only ----------
   Strict UX rule: NOTHING on the page is selectable as text by default.
   The only exceptions are (a) the live, editable form fields
   (<input> / <textarea> — operators need to edit them) and
   (b) values explicitly tagged with `.selectable` because the operator
   should be able to copy them — customer names, phone numbers, license
   plates, vehicle models, and addresses.
   Anything else (nav, buttons, page headers, table cells, modal text,
   audit log rows, etc.) is locked so a drag-select doesn't leave a
   blue highlight on UI chrome the operator can't actually do anything
   with. To opt a piece of text BACK into selectable, add the
   `.selectable` class to it (or any ancestor — children inherit). */
body {
  user-select: none;
  -webkit-user-select: none;
}
/* Form fields are always selectable so the operator can edit, copy,
   and paste values in any input. textarea + contenteditable too. */
input,
textarea,
[contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}
/* Explicit opt-in for copyable customer data. Apply on the cell / span /
   div wrapping the name, phone, plate, vehicle model, or address. The
   `.selectable *` rule pushes the auto down through children so the
   text node always wins regardless of how the markup nests them.
   No `cursor: text` here — many `.selectable` elements live inside
   clickable cards (kanban .task-card has cursor:pointer), and a
   sub-element with a different cursor breaks the hand-over-card UX. */
.selectable,
.selectable * {
  user-select: text;
  -webkit-user-select: text;
}
/* Specific text inputs that hold only ephemeral typing — not real
   data the operator needs to copy out. The default `input { user-
   select: text }` swept their placeholder/value into stray click-drag
   selections. These behave like buttons: the user can still focus,
   type, and clear via keyboard / mouse cursor (the browser handles
   the in-input caret regardless of `user-select`).
   • `#driver-search`       — live map sidebar driver filter
   • `#map-search-input`    — floating address geocoder
   • `#td-chat-input`       — task-detail chat composer */
#driver-search,
#map-search-input,
#td-chat-input,
#customers-search {
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Helpers ---------- */
.hide { display: none !important; }
.muted { color: var(--slate-500); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; padding: .1rem .35rem; border-radius: 6px; background: var(--surface-sunken); border: 1px solid var(--slate-200); color: #475569; }

/* Tasks list (live-map tasks panel). Compact padding — the operator
   scans a tall column of these alongside the map, so tight cards fit
   more on screen. Was .85rem; trimmed to match the kanban card
   density on tasks.html. */
.task-card {
  border: 1px solid var(--slate-200);
  background: var(--surface);
  border-radius: 12px;
  padding: .55rem .7rem .6rem;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
  cursor: pointer;
}
.task-card:hover { border-color: #93c5fd; box-shadow: 0 6px 18px -8px rgba(37,99,235,.2); }
.task-card .title { font-size: .88rem; font-weight: 600; color: var(--slate-900); }
.task-card .meta { font-size: .74rem; color: var(--slate-500); margin-top: .15rem; line-height: 1.35; }
.task-card.compact { padding: .5rem .65rem; }
/* Footer row — the ETA pill + target-time line share ONE wrapping
   row at the bottom of the card. Previously the ETA pill was stacked
   under the status badge in the header, which made every card a row
   taller. `.meta` inside the footer drops its own top-margin since
   the footer already supplies the gap. */
.task-card-foot {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: .25rem .5rem;
  margin-top: .3rem;
}
.task-card-foot .meta { margin-top: 0; }

.empty-state {
  text-align: center; padding: 2rem 1rem;
  color: var(--slate-500); font-size: .9rem;
  border: 1px dashed var(--slate-300);
  border-radius: 12px;
  background: #fafbfd;
}
[dir="rtl"] .empty-state { text-align: center; }

/* Lucide default sizing */
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; }

/* Header bar */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--slate-200);
  padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.page-header h1 { font-size: 1.25rem; font-weight: 700; color: var(--slate-900); letter-spacing: -.01em; }
.page-header .sub { font-size: .8rem; color: var(--slate-500); }
/* Mobile page-header overrides — placed AFTER the base rule on purpose so
   they win the cascade against `padding: 1rem 1.5rem` shorthand above
   (which sets all four physical sides and would otherwise clobber the
   logical `padding-inline-start` we set for the hamburger clearance).
   Logical properties + physical shorthand share a single cascade per the
   CSS Logical Properties spec — last writer wins. */
@media (max-width: 900px) {
  .page-header {
    padding-inline-start: 5.5rem;
    padding-inline-end: 1rem;
    padding-block-start: max(1.25rem, calc(env(safe-area-inset-top) + .25rem));
    padding-block-end: .85rem;
  }
}
@media (max-width: 480px) {
  .page-header { padding-inline-start: 5rem; }
  .page-header h1 { font-size: 1rem; line-height: 1.2; }
  .page-header .sub { font-size: .72rem; }
}

/* Main content padding */
.page-body { padding: 1.5rem; }
@media (max-width: 640px) { .page-body { padding: 1rem; } }

/* Stat tile */
.stat {
  background: var(--surface); border: 1px solid var(--slate-200);
  border-radius: 12px; padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.stat .v { font-size: 1.5rem; font-weight: 700; color: var(--slate-900); letter-spacing: -.02em; }
.stat .l { font-size: .75rem; color: var(--slate-500); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }

/* RTL flip for arrow icons that imply direction */
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- Signature pad ---------- */
.sig-wrap {
  position: relative;
  border: 2px dashed var(--slate-300);
  border-radius: 12px;
  background: var(--surface-muted);
  overflow: hidden;
  touch-action: none;
}
.sig-wrap canvas {
  display: block;
  width: 100%;
  height: 240px;
  background: var(--surface);
  cursor: crosshair;
}
.sig-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: .9rem; font-style: italic;
  pointer-events: none;
  user-select: none;
}
.sig-wrap.signed .sig-placeholder { display: none; }

/* ---------- Driver page · Waze launch button ----------
   Branded look for the navigation shortcut on the active-task card.
   The inline SVG inside (.waze-icon) inherits currentColor, so we set
   the button's `color` to Waze's signature red-orange. Bigger hit
   target than a stock icon-btn because drivers tap it gloved. */
.waze-launch-btn {
  /* The reference Waze car icon reads best as a black stroke on
     white — same as the user's spec image. We keep a subtle tinted
     ring on hover so the button still feels "tappable" without
     fighting the icon's monochrome character. */
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--surface);
  color: #0f172a;                /* near-black stroke (matches reference) */
  border: 1px solid var(--slate-200);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .12s ease,
              border-color .15s ease, color .15s ease;
  flex-shrink: 0;
}
.waze-launch-btn:hover {
  background: var(--surface-muted);
  border-color: #fb923c;          /* Waze-ish orange ring on hover */
  color: #ea580c;
}
.waze-launch-btn:active { transform: scale(.94); }
.waze-icon { width: 22px; height: 22px; display: block; }

/* ---------- Driver page · Completed tasks list ----------
   Lower visual weight than the queue cards: smaller, with a green
   accent indicating "done". Rendered AFTER the queue so the eye
   reads down: active → todo → done. */
.completed-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: .75rem;
  align-items: center;
  padding: .65rem .85rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--slate-200);
  opacity: .9;
}
.completed-card:hover { opacity: 1; border-color: #cbd5e1; }
.completed-card-icon {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: #ecfdf5;
  color: #047857;
  flex-shrink: 0;
}
.completed-card-icon [data-lucide] { width: 16px; height: 16px; }
.completed-card-body { min-width: 0; }
.completed-card-title {
  font-size: .9rem; font-weight: 700;
  color: var(--slate-800);
  line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.completed-card-sub {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem;
  color: var(--slate-500);
  margin-top: 1px;
}
.completed-card-dot { color: var(--slate-300); }
.completed-card-time {
  display: inline-flex; align-items: center; gap: 3px;
  color: #047857;
  font-weight: 600;
}

.completed-show-more {
  display: inline-flex; align-items: center; gap: .4rem;
  width: 100%;
  justify-content: center;
  margin-top: .75rem;
  padding: .6rem .85rem;
  background: var(--surface-muted);
  border: 1px dashed var(--slate-300);
  border-radius: 10px;
  color: var(--slate-600);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.completed-show-more:hover { background: var(--surface-sunken); border-color: #94a3b8; }
.completed-show-more.hide { display: none; }
.completed-show-more [data-lucide] { width: 16px; height: 16px; }
.completed-show-more-count {
  font-size: .68rem;
  color: var(--slate-500);
  background: var(--slate-200);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 700;
}
.completed-show-more-count:empty { display: none; }

/* ---------- Driver page · Finish-flow modal (3 steps) ----------
   Big multi-step modal that replaces the old single signature modal.
   Steps: walkaround video → dashboard photo → signature. The body
   scrolls if the step content overflows; the footer stays pinned. */
.finish-flow-card {
  max-height: 92vh;
}
.ff-progress {
  display: flex; align-items: center;
  padding: .85rem 1.25rem .25rem;
  gap: .35rem;
}
.ff-progress-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 0 0 auto;
}
.ff-progress-dot {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--slate-500);
  border: 2px solid var(--slate-200);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 800;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.ff-progress-step.done .ff-progress-dot {
  background: var(--vantx-blue, #2563eb);
  border-color: var(--vantx-blue, #2563eb);
  color: #fff;
}
.ff-progress-step.current .ff-progress-dot {
  background: var(--surface);
  border-color: var(--vantx-blue, #2563eb);
  color: var(--vantx-blue, #2563eb);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.ff-progress-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--slate-500);
  margin-top: 4px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.ff-progress-step.done .ff-progress-label,
.ff-progress-step.current .ff-progress-label {
  color: var(--slate-700);
}
.ff-progress-line {
  flex: 1 1 auto;
  height: 2px;
  background: var(--slate-200);
  margin: 0 .25rem;
  border-radius: 2px;
  align-self: center;
  position: relative;
  top: -7px;        /* nudge so the line aligns with dot centres */
}

.ff-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.ff-step {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.ff-step.hide { display: none; }
.ff-step-head {
  display: flex; gap: .65rem; align-items: flex-start;
}
.ff-step-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ff-step-icon [data-lucide] { width: 22px; height: 22px; }
.ff-step-icon-video { background: #dbeafe; color: #1d4ed8; }
.ff-step-icon-photo { background: #fef3c7; color: #b45309; }
.ff-step-icon-sign  { background: #dcfce7; color: #047857; }
.ff-step-title {
  font-size: 1rem; font-weight: 700; color: var(--slate-800);
  line-height: 1.2;
}
.ff-step-desc {
  font-size: .78rem; color: var(--slate-600);
  margin-top: 3px;
  line-height: 1.4;
}

.ff-file-input { display: none; }
.ff-capture-btn {
  display: flex; align-items: center; justify-content: center;
  gap: .55rem;
  width: 100%;
  padding: 1.1rem 1rem;
  border-radius: 14px;
  font-size: 1rem; font-weight: 700;
  border: 2px dashed;
  background: var(--surface-muted);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.ff-capture-btn [data-lucide] { width: 22px; height: 22px; }
.ff-capture-btn-blue  { color: #1d4ed8; border-color: #93c5fd; }
.ff-capture-btn-blue:hover  { background: #eff6ff; border-color: #60a5fa; }
.ff-capture-btn-amber { color: #b45309; border-color: #fcd34d; }
.ff-capture-btn-amber:hover { background: #fef3c7; border-color: #f59e0b; }

.ff-preview-wrap {
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: .65rem;
  background: var(--surface);
  display: flex; flex-direction: column; gap: .55rem;
}
.ff-preview-wrap.hide { display: none; }
.ff-preview-video {
  width: 100%;
  max-height: 280px;
  border-radius: 8px;
  background: #000;
}
.ff-preview-img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-sunken);
}
.ff-preview-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: .65rem;
}
.ff-preview-meta-text {
  font-size: .72rem;
  color: var(--slate-500);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ff-retake-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .7rem;
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  font-size: .72rem; font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.ff-retake-btn:hover { background: #e2e8f0; }
.ff-retake-btn [data-lucide] { width: 14px; height: 14px; }
.ff-error {
  padding: .55rem .75rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: .78rem;
}
.ff-error.hide { display: none; }

.ff-footer {
  flex-wrap: wrap;
  gap: .55rem;
}

/* Phone tweaks — the modal-card already goes full-height under
   640 px (global rule). Just adjust the step body padding so the
   bigger touch targets feel right. */
@media (max-width: 640px) {
  .ff-progress { padding: .65rem 1rem .15rem; }
  .ff-progress-label { font-size: .58rem; }
  .ff-capture-btn { padding: 1.4rem 1rem; font-size: 1.05rem; }
  .ff-preview-video, .ff-preview-img { max-height: 220px; }
}

/* ---------- Chat bubbles ---------- */
/* The wrapper <div> inside a flex .chat-row was getting squeezed to
   min-content (a single character's width), which made `word-wrap` shred
   short messages like "בדיקה" or "test" into one letter per line. The fix
   is to lock down the wrapper's max-width and let the bubble grow inside
   it. min-width:0 prevents flex from blowing out. */
.chat-row {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
}
.chat-row.me   { justify-content: flex-end; }
.chat-row.them { justify-content: flex-start; }
.chat-row > div {
  /* Wrapper that holds meta + bubble (+ optional read receipts). */
  max-width: min(80%, 60ch);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.chat-row.me   > div { align-items: flex-end; }
.chat-row.them > div { align-items: flex-start; }

.chat-bubble {
  display: inline-block;
  /* width fits the text up to the wrapper's cap, so short messages stay
     short and long ones wrap at the boundary instead of mid-letter. */
  width: fit-content;
  max-width: 100%;
  padding: .55rem .8rem;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.35;
  /* `overflow-wrap: anywhere` is the modern replacement for `word-wrap` —
     handles long URLs / CJK gracefully without unnecessarily breaking
     normal words. */
  overflow-wrap: anywhere;
  word-break: normal;
  /* Preserve user-entered line breaks; collapse the rest. */
  white-space: pre-wrap;
}
.chat-row.me   .chat-bubble { background: var(--vantx-blue); color: #fff; border-bottom-right-radius: 4px; }
.chat-row.them .chat-bubble { background: var(--surface); color: var(--slate-900); border: 1px solid var(--slate-200); border-bottom-left-radius: 4px; }
.chat-meta { font-size: .68rem; color: var(--slate-500); margin: .15rem .25rem; }
[dir="rtl"] .chat-row.me   .chat-bubble { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
[dir="rtl"] .chat-row.them .chat-bubble { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }

/* ---------- ETA badge ---------- */
.eta-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .55rem; border-radius: 9999px;
  background: #eff6ff; color: #1d4ed8;
  border: 1px solid rgba(37,99,235,.2);
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
}
.eta-pill .src { opacity: .55; font-weight: 500; }
.eta-pill.eta-delay {
  background: #fee2e2; color: #b91c1c; border-color: rgba(239,68,68,.35);
  animation: eta-flash 1.6s infinite;
}
/* Traffic-tinted ETA pill — applied when the live Google trip
   shows a meaningful delay but the locked target hasn't been
   blown past yet (eta-delay wins over these). Light = neutral
   blue (current default; nothing to override). */
.eta-pill.eta-traffic-bg-moderate {
  background: #fef3c7; color: #92400e; border-color: rgba(217,119,6,.35);
}
.eta-pill.eta-traffic-bg-heavy {
  background: #fee2e2; color: #b91c1c; border-color: rgba(239,68,68,.35);
}
/* "+N min" traffic badge that rides inside the pill (and inside
   the marker popup). Smaller than the pill, color-coded to its
   level so dispatchers can scan a sidebar of tasks and spot
   which are taking longer than usual. */
.eta-traffic {
  display: inline-flex; align-items: center; gap: 2px;
  margin-inline-start: .35rem;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: .62rem; font-weight: 700; letter-spacing: .01em;
  background: rgba(255,255,255,.55);
}
.eta-traffic-light    { color: #047857; background: rgba(16,185,129,.12); }
.eta-traffic-moderate { color: #92400e; background: rgba(245,158,11,.18); }
.eta-traffic-heavy    { color: #b91c1c; background: rgba(239,68,68,.18); }
.task-card.delayed { border-color: #f87171 !important; box-shadow: 0 6px 18px -8px rgba(239,68,68,.35) !important; }
@keyframes eta-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.35); }
  50%      { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* AI recommendation chip in the new-task modal */
.rec-chip {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .6rem;
  border: 1px solid var(--slate-200); border-radius: 12px;
  background: var(--surface);
  font-size: .8rem;
  cursor: pointer;
  transition: all .15s ease;
}
.rec-chip:hover { border-color: var(--vantx-blue); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.rec-chip .rank { width: 22px; height: 22px; border-radius: 9999px; background: var(--vantx-blue); color: white; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; }
.rec-chip .why { color: var(--slate-500); font-size: .72rem; }

/* ---------- Signature view (advisor) ---------- */
.sig-image {
  background: repeating-linear-gradient(45deg, #f8fafc 0 8px, #fff 8px 16px);
  border-radius: 12px;
  padding: 6px;
}
.sig-image img { display: block; width: 100%; border-radius: 8px; }

/* ---------- Pre-signature media (advisor view) ---------- */
/* Walkaround video + dashboard photo blocks inside the task-detail
   modal. Each block has: loading text, the media element, and an
   inline error fallback. Download chip lives in the section header
   on the trailing edge (.td-media-dl). */
.td-media-video {
  display: block;
  width: 100%;
  max-height: 320px;
  border-radius: 10px;
  background: #0f172a;
  outline: 1px solid var(--slate-200);
}
.td-media-img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--surface-sunken);
  outline: 1px solid var(--slate-200);
  cursor: zoom-in;
}
.td-media-loading {
  font-size: .78rem;
  color: var(--slate-500);
  padding: .85rem;
  text-align: center;
  background: var(--surface-muted);
  border-radius: 10px;
  border: 1px dashed var(--slate-200);
}
.td-media-error {
  font-size: .78rem;
  color: #991b1b;
  padding: .55rem .85rem;
  background: #fef2f2;
  border-radius: 8px;
  border: 1px solid #fecaca;
}
.td-media-dl {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .68rem; font-weight: 700;
  color: var(--vantx-blue, #2563eb);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 3px 9px;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.td-media-dl:hover { background: #dbeafe; border-color: #93c5fd; }
.td-media-dl.hide { display: none; }

/* Fullscreen lightbox for the dashboard photo. Click the image →
   it overlays the whole viewport; click outside or the X closes. */
.td-media-lightbox {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  padding: 1rem;
}
.td-media-lightbox.hide { display: none; }
.td-media-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}
.td-media-lightbox-close {
  position: absolute;
  top: 1rem; inset-inline-end: 1rem;
  width: 40px; height: 40px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: #0f172a;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: none;
}
.td-media-lightbox-close:hover { background: var(--surface); }
.td-media-lightbox-close [data-lucide] { width: 18px; height: 18px; }

/* Phone tweaks — keep media smaller so the chat area stays visible. */
@media (max-width: 640px) {
  .td-media-video, .td-media-img { max-height: 220px; }
}

/* ---------- Advisor filter toolbar ---------- */
.filter-bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .85rem;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative; flex: 1; min-width: 220px;
}
.search-wrap > svg, .search-wrap > [data-lucide] {
  position: absolute; top: 50%; transform: translateY(-50%);
  inset-inline-start: .8rem; width: 16px; height: 16px;
  color: #94a3b8; pointer-events: none;
}

/* Compact filter cell — hosts a vx-select dropdown alongside the
   search bar on the users page. Min-width keeps the trigger label
   from clipping ("All fleets (12)" etc.); on phones the cell still
   shrinks to the contents because the parent .filter-bar is
   flex-wrap so cells flow onto their own line if needed. */
.users-filter-cell {
  flex: 0 1 200px;
  min-width: 160px;
}
.users-filter-cell .vx-select { width: 100%; }
@media (max-width: 640px) {
  .users-filter-cell { flex: 1 1 100%; }
}
.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .7rem;
  border-radius: 9999px;
  border: 1px solid var(--slate-200);
  background: var(--surface);
  font-size: .8rem; font-weight: 600; color: #334155;
  cursor: pointer; user-select: none;
  transition: all .15s ease;
}
.filter-chip input { width: 0; height: 0; opacity: 0; position: absolute; }
.filter-chip:has(input:checked) {
  background: var(--surface-muted);
  border-color: var(--vantx-blue);
  color: var(--slate-900);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.filter-chip:hover { border-color: #94a3b8; }
.filter-chip[data-status="idle"]:has(input:checked)       { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.10); }
.filter-chip[data-status="on_mission"]:has(input:checked) { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.filter-chip[data-status="arrived"]:has(input:checked)    { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.12); }

/* ---------- Driver row toggles ---------- */
.row-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
  transition: all .15s ease;
}
.row-toggle:hover { color: #fff; background: rgba(255,255,255,.10); }
.row-toggle.active {
  color: #fff;
  background: rgba(37,99,235,.18);
  border-color: rgba(37,99,235,.5);
}
.row-toggle.active.path { background: rgba(249,115,22,.18); border-color: rgba(249,115,22,.55); }
/* Disabled state for the follow button when the driver is offline. We
   don't gate this on `[data-action="follow"]` so a future disabled state
   on the path toggle would inherit the same look automatically.
   `pointer-events: none` is intentional — combined with the disabled
   attribute it makes the button non-interactive even if a stylesheet
   somewhere else accidentally tried to re-enable hover. */
.row-toggle:disabled,
.row-toggle[aria-disabled="true"] {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}
.row-toggle [data-lucide] { width: 14px; height: 14px; }

/* Status badge inside driver row. `white-space: nowrap` is critical —
   without it, multi-character labels like "הגיע ליעד" would wrap inside
   the pill in the cramped sidebar and render as stacked letters.
   `flex-shrink: 0` keeps the pill at its natural width even when its
   parent (`.row-status`) is short on space — that flex-wraps it to a new
   line, which is the right outcome here. */
.row-status .activity {
  display: inline-flex; align-items: center; gap: 4px;
  /* WCAG fix: was 10px (below readable minimum) on translucent navy
     bg. Bumped to 11.5px and switched to opaque tints with darker
     foreground so the pills sit ≥ 4.5:1 over the navy sidebar. */
  padding: 2px 8px; border-radius: 9999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap;
  flex-shrink: 0;
}
/* Opaque pill backgrounds + darker text — readable both on the navy
   sidebar AND when overlayed on the map cards (light bg). */
.row-status .activity.idle       { background: #d1fae5; color: #064e3b; }
.row-status .activity.on_mission { background: #dbeafe; color: #1e3a8a; }
.row-status .activity.arrived    { background: #fee2e2; color: #7f1d1d; }

/* ---------- Map markers ----------
   Two flavors: driver markers (people) + task markers (places).
   Both use Leaflet `divIcon`, so the visual is pure HTML/CSS. We
   counter-rotate the chrome on RTL pages so the marker doesn't flip
   visually (the leaflet container is force-LTR — see earlier rule). */

/* Driver = avatar circle with status ring + tiny name chip below.
   Replaces the wide pill that crowded the map at city zoom levels. */
.map-driver {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 3px; pointer-events: auto;
  /* CSS variable used inline by JS to set the per-status ring color. */
  --ring: #10b981;
}
.map-driver-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface);
  color: #0f172a;
  border: 3px solid var(--ring);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; letter-spacing: -.01em;
  box-shadow: 0 4px 14px -3px rgba(15, 23, 42, .35);
}
.map-driver-label {
  background: rgba(15, 23, 42, .92);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.map-driver-pulse .map-driver-avatar {
  animation: map-driver-ring-pulse 1.4s infinite;
}
/* When a fleet logo is set, the avatar background flips to white so a
   transparent PNG logo reads cleanly. The img inside fills the circle
   with object-contain so non-square logos don't crop or distort. */
.map-driver.map-driver-with-logo .map-driver-avatar { background: var(--surface); }
.map-driver-avatar-img {
  width: 100%; height: 100%;
  object-fit: contain;
  /* A faint inset so dark logos don't bleed into the white ring. */
  padding: 3px;
  display: block;
}

/* Sidebar avatar — same treatment as the map marker. The .driver-row
   .avatar already enforces a circular clipping container; we just
   need an img helper that fills it without distortion. */
.driver-avatar-logo {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 2px;
  display: block;
  border-radius: inherit;
}
@keyframes map-driver-ring-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55), 0 4px 14px -3px rgba(15,23,42,.35); }
  60%  { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0),   0 4px 14px -3px rgba(15,23,42,.35); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0),     0 4px 14px -3px rgba(15,23,42,.35); }
}

/* "Stalled" alert ring — wraps the driver avatar in an amber halo and
   pulses urgently. Layered on top of the regular status ring so the
   ring color (idle green / mission blue / arrived red) still shows
   through; the halo just signals "operator attention required". */
.map-driver.map-driver-stalled .map-driver-avatar {
  animation: map-driver-stalled-pulse 1.2s ease-in-out infinite;
}
@keyframes map-driver-stalled-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(245, 158, 11, .85),
      0 0 0 8px rgba(245, 158, 11, .25),
      0 4px 14px -3px rgba(15,23,42,.35);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(245, 158, 11, .55),
      0 0 0 10px rgba(245, 158, 11, 0),
      0 4px 14px -3px rgba(15,23,42,.35);
  }
}

/* Sidebar badge that appears next to a stalled driver's status pills.
   Amber to match the marker halo. Compact + chip-shaped so it doesn't
   shove the focus / path icons off the row. */
.driver-row.stalled .row-name { color: #fef3c7; }
.row-stalled {
  display: inline-flex; align-items: center; gap: .25rem;
  /* WCAG fix: was 9px (below readable minimum) and amber-on-amber
     contrast was ~3.3:1 (fail AA). Bumped to 11px + opaque amber
     background with darker text → 7.5:1, AAA. */
  padding: 2px 7px;
  font-size: 11px; font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #78350f;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.row-stalled [data-lucide] { width: 10px; height: 10px; flex-shrink: 0; }

/* ─────────── Floating address-search bar on the live map ───────────
   Centered above the map, narrow enough to leave the zoom + Waze
   controls visible on the same row. The dropdown of results sits
   directly below the input and shares its rounded card aesthetic. */
.map-search-floating {
  position: absolute;
  top: .75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  width: min(380px, 78%);
}
.map-search-input-wrap {
  display: flex; align-items: center; gap: .55rem;
  background: var(--surface);
  border: 1px solid var(--slate-300);
  border-radius: 12px;
  padding: .55rem .85rem;
  box-shadow: 0 6px 18px -4px rgba(15,23,42,.18);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.map-search-input-wrap:focus-within {
  border-color: var(--vantx-blue);
  box-shadow: 0 0 0 4px rgba(37,99,235,.15), 0 6px 18px -4px rgba(15,23,42,.18);
}
.map-search-input-wrap > [data-lucide] {
  width: 16px; height: 16px;
  color: var(--slate-400);
  flex-shrink: 0;
}
.map-search-input-wrap input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font-size: .9rem;
  color: var(--slate-900);
  font-family: inherit;
}
.map-search-input-wrap input::placeholder { color: var(--slate-400); }
/* Hide the browser's native clear-X on `<input type="search">` — we render
   our own #map-search-clear button (so the dropdown was showing TWO X
   glyphs side-by-side: the native one + our themed one). Keeping
   type="search" is still useful for screen-reader semantics and the
   Escape-to-clear behavior, we just don't want the doubled affordance. */
.map-search-input-wrap input::-webkit-search-cancel-button,
.map-search-input-wrap input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.map-search-clear {
  border: 0; background: transparent; cursor: pointer;
  color: var(--slate-400);
  padding: 0; display: flex; align-items: center;
  flex-shrink: 0;
}
.map-search-clear [data-lucide] { width: 14px; height: 14px; }
.map-search-clear:hover { color: var(--slate-700); }
.map-search-results {
  margin-top: .35rem;
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  box-shadow: 0 10px 24px -8px rgba(15,23,42,.18);
  max-height: 280px;
  overflow-y: auto;
}
.map-search-result {
  padding: .65rem .85rem;
  display: flex; gap: .55rem; align-items: center;
  cursor: pointer;
  font-size: .85rem;
  color: var(--slate-700);
  border-bottom: 1px solid var(--slate-100);
  transition: background .12s, color .12s;
}
.map-search-result:last-child { border-bottom: 0; }
.map-search-result:hover { background: var(--slate-50); color: var(--slate-900); }
.map-search-result [data-lucide] {
  width: 14px; height: 14px;
  color: var(--vantx-blue);
  flex-shrink: 0;
}
.map-search-label {
  min-width: 0; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.map-search-empty {
  padding: 1rem;
  text-align: center;
  color: var(--slate-500);
  font-size: .85rem;
}
/* Temporary "you searched here" pin — orange to stand out from driver
   avatars + task pins, larger ring than route markers. */
.map-search-pin {
  width: 22px; height: 22px;
  background: var(--vantx-orange);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .25), 0 6px 14px -3px rgba(15,23,42,.45);
  animation: map-search-pulse 1.6s ease-out infinite;
}
@keyframes map-search-pulse {
  0%   { box-shadow: 0 0 0 4px rgba(249,115,22,.30), 0 6px 14px -3px rgba(15,23,42,.45); }
  70%  { box-shadow: 0 0 0 14px rgba(249,115,22,0),  0 6px 14px -3px rgba(15,23,42,.45); }
  100% { box-shadow: 0 0 0 4px rgba(249,115,22,0),   0 6px 14px -3px rgba(15,23,42,.45); }
}

/* ─────────── Mobile (≤768px) live-map adjustments ───────────────────
   Two changes the user asked for: hide the basemap layer-switcher (the
   Voyager / "ניווט" tile layer is added at boot in map.js, so the map
   still renders correctly — we just suppress the picker UI), and
   reposition the address-search bar so it doesn't fight with the
   Home/Zoom/Waze button column on the left edge. */
@media (max-width: 768px) {
  /* 1. Lock to the Navigation basemap by hiding the switcher. */
  .leaflet-control-layers { display: none !important; }

  /* 2. Search bar mobile layout. Anchored to the right edge with
        ~4 rem of clearance on the left for the topleft button column,
        full width inside that envelope. The 16 px input font-size
        is critical: anything smaller and Mobile Safari auto-zooms
        the page when the field gains focus, which is jarring on
        a mapping UI. The dropdown also gets a tighter max-height
        so it doesn't extend past the bottom of the map on small
        viewports. */
  .map-search-floating {
    left: auto;
    right: .75rem;
    transform: none;
    width: calc(100% - 4rem - .75rem);
    max-width: none;
  }
  .map-search-input-wrap input { font-size: 16px; }
  .map-search-results { max-height: 220px; }
}

/* "Open in Waze" custom Leaflet control. Sits in the top-left corner
   stack next to the zoom buttons. Brand-matches Waze's signature cyan
   so it's instantly recognizable as a Waze deep-link, not a generic
   navigation icon. */
.vx-waze-ctl { margin-top: .6rem !important; }
.vx-waze-ctl a {
  background: #33ccff !important;     /* Waze cyan */
  color: #ffffff !important;
  display: flex !important;
  align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 4px;
}
.vx-waze-ctl a:hover { background: #1ab8e6 !important; }
.vx-waze-ctl a:active { background: #1199cc !important; }


/* "Recenter on Tel Aviv" button — clean white tile, sits at the very
   TOP of the topleft control stack (above the zoom buttons). Slate
   hover so it stays distinct from the cyan Waze button (no two glowing
   controls competing for attention). */
.vx-home-ctl a {
  background: #ffffff !important;
  color: var(--slate-700) !important;
  display: flex !important;
  align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 4px;
}
.vx-home-ctl a:hover  { background: #f1f5f9 !important; color: var(--vantx-blue) !important; }
.vx-home-ctl a:active { background: #e2e8f0 !important; }

/* Layer-switcher polish — match the app's rounded card aesthetic. */
.leaflet-control-layers {
  border-radius: 10px !important;
  box-shadow: 0 4px 12px -2px rgba(15,23,42,.18) !important;
  border: 1px solid rgba(15,23,42,.06) !important;
}
.leaflet-control-layers-toggle {
  width: 32px !important; height: 32px !important;
  background-size: 18px 18px !important;
}
.leaflet-control-layers-expanded { padding: .5rem .75rem !important; }
.leaflet-control-layers label { margin: .15rem 0 !important; cursor: pointer; }

/* Task pin: classic teardrop with a directional arrow inside.
   Pickup = green (going up / outbound). Drop-off = blue (going down /
   inbound). Anchor point is the pin's tip — set in JS via iconAnchor. */
.map-pin {
  position: relative;
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid #fff;
  box-shadow: 0 5px 14px -3px rgba(15, 23, 42, .4);
  color: #fff;
}
.map-pin svg { transform: rotate(45deg); width: 14px; height: 14px; }
.map-pin.pickup  { background: #10b981; }
.map-pin.dropoff { background: #2563eb; }

.dot-arrived { box-shadow: 0 0 0 4px rgba(239,68,68,.18); animation: pulse-soft 1.4s infinite; }

/* ---------- Task popup (Leaflet) ----------
   The popup that appears when a pickup / drop-off pin is clicked.
   White card with a coloured border that reflects assignment state:
     • .no-driver  → red    (still needs a driver)
     • .has-driver → green  (driver assigned, includes name + ETA)
   The whole popup body is clickable: clicking anywhere closes the
   popup and opens the task's inline detail view in the tasks panel
   on the right (see openTaskDetail in map.js). */
.leaflet-popup.task-popup .leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--slate-900);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 12px 28px -10px rgba(15, 23, 42, .25);
  /* Default fallback border. The class toggles below pin a strong
     red / green colour for the actual driver-assignment state. */
  border: 2px solid var(--slate-300);
  transition: border-color .18s ease, box-shadow .15s ease, transform .12s ease;
}
.leaflet-popup.task-popup.no-driver  .leaflet-popup-content-wrapper { border-color: #ef4444; }
.leaflet-popup.task-popup.has-driver .leaflet-popup-content-wrapper { border-color: #10b981; }
.leaflet-popup.task-popup .leaflet-popup-tip {
  background: var(--surface);
  box-shadow: 0 4px 12px -6px rgba(15, 23, 42, .25);
}
.leaflet-popup.task-popup .leaflet-popup-content {
  margin: 0;
  /* Leaflet sets an inline `width: 1px` on the content wrapper that
     forces our chip into a single-character column on Hebrew RTL.
     Override to a roomy auto-width with a sensible floor so short
     addresses like "אלנבי 30 תל אביב" stay on one line. */
  width: auto !important;
  min-width: 200px;
  max-width: 260px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--slate-700);
  word-break: normal;
  overflow-wrap: normal;
  white-space: normal;
}
[dir="rtl"] .leaflet-popup.task-popup .leaflet-popup-content {
  direction: rtl;
  text-align: right;
}

/* Whole-popup click target — hover lifts the card slightly so the
   user knows the popup is interactive, not just informational. */
.task-popup-content {
  padding: 10px 14px 11px;
  cursor: pointer;
  user-select: none;
}
.leaflet-popup.task-popup .leaflet-popup-content-wrapper:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px -10px rgba(15, 23, 42, .28);
}

.task-popup-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.task-popup-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.task-popup-icon svg { width: 12px; height: 12px; }
.task-popup-icon.pickup  { background: rgba(16, 185, 129, .15); color: #059669; }
.task-popup-icon.dropoff { background: rgba(37, 99, 235, .15); color: #2563eb; }
.task-popup-head b {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate-500);
}
.task-popup-addr {
  color: var(--slate-900);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
}
/* Driver line + ETA line. The icon colour distinguishes assigned
   (green check user) vs unassigned (red x user) at a glance. */
.task-popup-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500;
  margin-top: 3px;
  color: var(--slate-600);
}
.task-popup-row [data-lucide],
.task-popup-row svg { flex-shrink: 0; }
.task-popup-row.driver    { color: #059669; }
.task-popup-row.no-driver { color: #dc2626; }
.task-popup-row.eta       { color: var(--slate-500); }
/* "Click for details" footer. Subtle but discoverable hint that the
   whole popup is a button into the task's detail view. */
.task-popup-cta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--slate-100);
  font-size: 11px; font-weight: 700;
  color: var(--vantx-blue);
  letter-spacing: .02em;
}

.leaflet-popup.task-popup a.leaflet-popup-close-button {
  color: var(--slate-400);
  padding: 6px 8px 0 0;
  font-size: 16px;
  font-weight: 700;
}
.leaflet-popup.task-popup a.leaflet-popup-close-button:hover { color: var(--slate-900); }
/* In RTL flip the close button to the inline-end side (= LEFT in RTL)
   so it doesn't crash into the heading text on the inline-start. */
[dir="rtl"] .leaflet-popup.task-popup a.leaflet-popup-close-button {
  right: auto; left: 0;
  padding: 6px 0 0 8px;
}

/* ---------- Task detail action toolbar ---------------------------------
   Sits under the meta strip in the task detail panel. The buttons
   (Show on map / Reassign / Delete) wrap onto multiple rows on phones
   so each tap target stays a comfortable size. Hidden buttons (.hide)
   collapse out of the layout entirely so the bar shrinks gracefully
   for advisors who only see Show-on-map + Delete. */
.td-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
/* ─── Attachments grid on task sheet ──────────────────────────────
   Squares of equal size auto-fill the panel width. Images get cover-
   fit thumbnails; PDFs get a centered icon with the filename below. */
.td-attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: .55rem;
}
.td-attach-grid:empty::before {
  content: attr(data-empty-label);
  color: var(--slate-500);
  font-size: .75rem;
  grid-column: 1 / -1;
  text-align: center;
  padding: 1rem 0;
}
.td-attach-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.td-attach-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.td-attach-tile .td-attach-pdf-icon {
  width: 32px;
  height: 32px;
  color: var(--rose-600, #e11d48);
}
.td-attach-tile .td-attach-tile-name {
  font-size: .65rem;
  color: var(--slate-700);
  padding: .15rem .25rem;
  text-align: center;
  word-break: break-all;
  line-height: 1.1;
  margin-top: 3px;
}
.td-attach-tile-x {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, .82);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s;
}
.td-attach-tile:hover .td-attach-tile-x { opacity: 1; }
.td-attach-add {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .7rem;
  border-radius: 8px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--vantx-blue, #2563eb);
  background: var(--blue-50, #eff6ff);
  border: 1px solid var(--blue-200, #bfdbfe);
  cursor: pointer;
  user-select: none;
}
.td-attach-add:hover { background: var(--blue-100, #dbeafe); }
.td-attach-add input[type="file"] { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.td-action {
  flex: 1 1 calc(50% - .25rem);
  min-width: 8rem;
  padding-block: .55rem !important;
  padding-inline: .85rem !important;
  font-size: .8rem !important;
}
.td-action > [data-lucide] {
  width: 15px !important; height: 15px !important;
}
@media (min-width: 1024px) {
  /* Desktop sidebar — three buttons fit in a single row at this width. */
  .td-action { flex: 1 1 0; min-width: 6.5rem; }
}

/* ---------- Ops "delete request" popup ---------------------------------
   Slides in from the bottom-end of the viewport when an advisor files
   a delete request. The card is opinionated — fixed width on desktop,
   full-width minus a margin on phones — so the operator can always
   read the reason in full and decide. Only one is visible at a time;
   subsequent requests queue inside the JS controller. */
.op-delete-toast {
  position: fixed;
  inset-block-end: 1.25rem;
  inset-inline-end: 1.25rem;
  z-index: 950;             /* above Leaflet (~800), below modals (1000) */
  display: flex;
  pointer-events: none;     /* card itself is the interactive surface */
  animation: opDeleteSlideIn .25s ease-out;
}
.op-delete-toast.hide { display: none; }
@keyframes opDeleteSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.op-delete-card {
  pointer-events: auto;
  width: min(360px, calc(100vw - 2.5rem));
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-inline-start: 4px solid #e11d48;
  border-radius: 16px;
  box-shadow: 0 24px 48px -16px rgba(15, 23, 42, .25);
  overflow: hidden;
}
.op-delete-head {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem .65rem;
}
.op-delete-icon {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: #fff1f2;
  color: #be123c;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.op-delete-icon > [data-lucide] { width: 18px; height: 18px; }
.op-delete-title {
  font-size: .85rem; font-weight: 700; color: var(--slate-900);
  letter-spacing: -.01em;
}
.op-delete-meta {
  font-size: .72rem; color: var(--slate-500);
  margin-top: .15rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.op-delete-task {
  margin: 0 1rem .65rem;
  padding: .6rem .75rem;
  background: var(--surface-muted);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: .78rem;
  color: var(--slate-700);
  line-height: 1.45;
}
.op-delete-reason-block {
  margin: 0 1rem .85rem;
}
.op-delete-reason-label {
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--slate-500);
  margin-bottom: .3rem;
}
.op-delete-reason {
  font-size: .82rem; color: var(--slate-800);
  background: var(--surface);
  border: 1px dashed var(--slate-300);
  border-radius: 10px;
  padding: .55rem .7rem;
  max-height: 6rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.op-delete-actions {
  display: flex; gap: .5rem;
  padding: 0 1rem 1rem;
}
.op-delete-actions > .btn-outline,
.op-delete-actions > .btn-danger {
  padding-block: .55rem !important;
  font-size: .82rem !important;
}
.op-delete-queue {
  font-size: .68rem; color: var(--slate-500);
  text-align: center;
  padding: 0 1rem .85rem;
}
@media (max-width: 640px) {
  .op-delete-toast {
    inset-block-end: .65rem;
    inset-inline-end: .65rem;
    inset-inline-start: .65rem;
  }
  .op-delete-card { width: auto; }
}

/* ---------- Global delete-request popup ----------------------------
   Centered modal that appears on any page admin / ops_manager is on
   when an advisor files a delete request. Sits above Leaflet (~800)
   AND above the page-level modals (1000) so it's never visually
   buried. The .gdrp-urgent class is added after 60 seconds of
   inactivity — it pulses + adds an "URGENT" banner so an operator
   walking away and coming back can't miss it. */
.gdrp-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100;
  backdrop-filter: blur(4px);
  padding: 1rem;
  animation: gdrpFadeIn .2s ease-out;
}
.gdrp-backdrop.hide { display: none; }
@keyframes gdrpFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.gdrp-card {
  width: min(420px, 100%);
  max-height: calc(100vh - 2rem);
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--slate-200);
  border-inline-start: 4px solid #e11d48;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .4);
  overflow-y: auto;
  animation: gdrpScaleIn .25s cubic-bezier(.2,.9,.3,1);
}
@keyframes gdrpScaleIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.gdrp-urgent-banner {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem;
  background: linear-gradient(90deg, #fee2e2 0%, #fecaca 100%);
  color: #9f1239;
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid #fecdd3;
}
.gdrp-urgent-banner.hide { display: none; }
.gdrp-urgent-banner > [data-lucide] { width: 16px; height: 16px; }
.gdrp-urgent .gdrp-card {
  border-inline-start-color: #dc2626;
  box-shadow:
    0 30px 60px -20px rgba(220, 38, 38, .35),
    0 0 0 4px rgba(220, 38, 38, .15);
  animation: gdrpScaleIn .25s cubic-bezier(.2,.9,.3,1),
             gdrpUrgentPulse 1.6s ease-in-out infinite .25s;
}
@keyframes gdrpUrgentPulse {
  0%, 100% { box-shadow: 0 30px 60px -20px rgba(220, 38, 38, .35), 0 0 0 4px rgba(220, 38, 38, .15); }
  50%      { box-shadow: 0 30px 60px -20px rgba(220, 38, 38, .55), 0 0 0 8px rgba(220, 38, 38, .25); }
}
.gdrp-head {
  display: flex; align-items: center; gap: .85rem;
  padding: 1.1rem 1.25rem .65rem;
}
.gdrp-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: #fff1f2;
  color: #be123c;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.gdrp-icon > [data-lucide] { width: 22px; height: 22px; }
.gdrp-head-text { flex: 1; min-width: 0; }
.gdrp-title {
  font-size: 1rem; font-weight: 700; color: var(--slate-900);
  letter-spacing: -.01em;
}
.gdrp-meta {
  font-size: .78rem; color: var(--slate-500);
  margin-top: .15rem;
}
.gdrp-body { padding: 0 1.25rem 1rem; }
.gdrp-task {
  padding: .7rem .85rem;
  background: var(--surface-muted);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  font-size: .85rem;
  color: var(--slate-800);
  line-height: 1.45;
  margin-bottom: .85rem;
}
.gdrp-reason-block {}
.gdrp-reason-label {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--slate-500);
  margin-bottom: .35rem;
}
.gdrp-reason {
  font-size: .88rem; color: var(--slate-800);
  background: var(--surface);
  border: 1px dashed var(--slate-300);
  border-radius: 12px;
  padding: .65rem .8rem;
  max-height: 7rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.gdrp-actions {
  display: flex; gap: .6rem;
  padding: .25rem 1.25rem 1.1rem;
}
.gdrp-actions.hide { display: none; }
.gdrp-actions > button { flex: 1; }
.gdrp-queue {
  font-size: .72rem; color: var(--slate-500);
  text-align: center;
  padding: 0 1rem .85rem;
}
.gdrp-queue.hide { display: none; }

/* ─── Call-customer button (OM popup) ─────────────────────────────
   Lives in the popup body alongside the reason block. Styled as a
   prominent green action so the OM's eye lands on it before the
   destructive Approve button. Hidden when the task has no phone. */
.gdrp-call-btn {
  display: flex; align-items: center; gap: .6rem;
  margin-top: .75rem;
  padding: .65rem .85rem;
  border-radius: 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  font-size: .85rem; font-weight: 600;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.gdrp-call-btn:hover { background: #d1fae5; border-color: #6ee7b7; }
.gdrp-call-btn.hide { display: none; }
.gdrp-call-btn > [data-lucide] { width: 18px; height: 18px; flex-shrink: 0; }
.gdrp-call-label { flex: 1; }
.gdrp-call-num   { font-weight: 700; letter-spacing: .01em; opacity: .9; }

/* ─── Keep-task compose pane (OM popup) ──────────────────────────
   Second step after the OM clicks "Keep task" — they can type a
   short follow-up note for the advisor or skip it. */
.gdrp-compose { padding: 0 1.25rem 1rem; }
.gdrp-compose-help {
  font-size: .78rem; color: var(--slate-600);
  line-height: 1.45;
  margin-bottom: .55rem;
}
.gdrp-compose-input {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  padding: .7rem .85rem;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: .9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--slate-800);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.gdrp-compose-input:focus {
  outline: none;
  border-color: var(--vantx-blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.gdrp-compose-meta {
  display: flex; justify-content: flex-end;
  margin-top: .35rem;
}
.gdrp-compose-count {
  font-size: .68rem;
  color: var(--slate-500);
  font-variant-numeric: tabular-nums;
}

/* ─── Advisor reply card (OM message popup) ──────────────────────
   Distinct visual treatment — info-blue, not alert-amber — so the
   advisor immediately reads it as "informational reply from OM"
   rather than another urgent delete request. */
.gdrp-reply-card { max-width: 460px; }
.gdrp-icon-info {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}
.gdrp-reason-block-reply { margin-top: .35rem; }
.gdrp-reason-quote {
  background: #eff6ff;
  border-inline-start: 3px solid #93c5fd;
  padding: .65rem .85rem;
  border-radius: 8px;
  color: var(--slate-800);
  font-size: .92rem;
  line-height: 1.5;
  white-space: pre-wrap;        /* preserve newlines the OM typed */
  word-break: break-word;
}
@media (max-width: 640px) {
  .gdrp-backdrop { padding: .5rem; }
  .gdrp-card { width: 100%; max-height: calc(100vh - 1rem); border-radius: 16px; }
  .gdrp-head { padding: 1rem 1rem .5rem; gap: .75rem; }
  .gdrp-body { padding: 0 1rem .85rem; }
  .gdrp-actions { padding: .25rem 1rem 1rem; }
}

/* ---------- Pending-delete marker on map task pin ---------------------
   When a delete request is filed against a task, every viewer of the
   live map sees the task pin overlaid with a red X so the advisor
   team knows the task is on the chopping block. The overlay sits as
   an absolutely-positioned ::after on the existing pin marker. */
.task-marker-pending-delete {
  position: relative;
}
.task-marker-pending-delete::after {
  content: '';
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  width: 18px; height: 18px;
  border-radius: 9999px;
  background: #dc2626;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px -1px rgba(220, 38, 38, .55);
  background-image:
    linear-gradient(45deg, transparent 42%, #fff 42%, #fff 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, #fff 42%, #fff 58%, transparent 58%);
  z-index: 2;
  pointer-events: none;
}

/* ───── License-watch chip + badges ────────────────────────────── */
.license-watch-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  font-weight: 700;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: rgba(245,158,11,.10);
  color: #92400e;
  border: 1px solid rgba(245,158,11,.30);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.license-watch-btn:hover { background: rgba(245,158,11,.18); }
.license-watch-btn[aria-pressed="true"] {
  background: #b45309; color: #fff; border-color: #b45309;
}
[data-theme="dark"] .license-watch-btn {
  background: rgba(245,158,11,.16); color: #fbbf24; border-color: rgba(245,158,11,.40);
}
[data-theme="dark"] .license-watch-btn[aria-pressed="true"] {
  background: #d97706; color: #fff; border-color: #d97706;
}
.license-watch-btn .kbd {
  background: rgba(255,255,255,.7); color: inherit; padding: 1px 6px;
  border: 1px solid rgba(0,0,0,.08); font-variant-numeric: tabular-nums;
}
.license-watch-btn[aria-pressed="true"] .kbd {
  background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.15); color: #fff;
}

/* Status pip on a customer row or vehicle card. The 'expired' tone
   is rose, 'expiring' amber. Used both inline on the row and on the
   vehicle card chips. */
.lic-badge {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .68rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.lic-badge-expired {
  background: rgba(244,63,94,.12); color: #be123c; border-color: rgba(244,63,94,.30);
}
.lic-badge-expiring {
  background: rgba(245,158,11,.14); color: #92400e; border-color: rgba(245,158,11,.40);
}
[data-theme="dark"] .lic-badge-expired {
  background: rgba(244,63,94,.20); color: #fb7185; border-color: rgba(244,63,94,.45);
}
[data-theme="dark"] .lic-badge-expiring {
  background: rgba(245,158,11,.18); color: #fbbf24; border-color: rgba(245,158,11,.45);
}

/* Same red-X overlay, but for task list rows (sidebar in map.html
   and the cards on tasks.html). Sits inline next to the title. */
.task-pending-delete-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  margin-inline-start: .35rem;
  flex-shrink: 0;
}
.task-pending-delete-badge > [data-lucide] {
  width: 11px !important; height: 11px !important; stroke-width: 3.5;
}

/* Tasks-page kanban: pending tasks with a delete request still sit in
   the Pending column but are tinted red so the advisor team can spot
   them at a glance. The "Cancellations" column (status=cancelled)
   gets its own subtle red header treatment. */
.task-card.has-pending-delete {
  background: #fff1f2;
  border-color: #fecdd3 !important;
  box-shadow: 0 2px 6px -2px rgba(220, 38, 38, .15);
}
.task-card.has-pending-delete:hover {
  background: #ffe4e6;
}
.kanban-col-cancelled .col-header {
  color: #be123c;
}

/* ─────────── Customer profile + vehicle carousel ───────────────────
   Opened from the eye-icon in the customers list. Contains an identity
   strip at the top followed by a horizontally-scrollable carousel of
   vehicle cards. The track scrolls on touch (swipe) AND via the prev/
   next arrow buttons on the sides. CSS scroll-snap keeps each card
   nicely centered after every nudge. */
.vehicle-extra-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px;
  padding: 0 .4rem;
  background: var(--vantx-blue);
  color: #fff;
  font-size: .7rem; font-weight: 700;
  border-radius: 999px;
  line-height: 1;
}
.pf-identity {
  display: flex; align-items: center; gap: .85rem;
  padding: .9rem 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
  border: 1px solid var(--slate-200);
}
.pf-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--vantx-blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, .4);
}
.pf-name {
  font-size: 1.05rem; font-weight: 700;
  color: var(--slate-900);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-meta { display: flex; flex-wrap: wrap; gap: .85rem; margin-top: .15rem; }
.pf-meta-item {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .82rem; color: var(--slate-600);
}
.pf-meta-item [data-lucide] { width: 14px; height: 14px; color: var(--vantx-blue); }
.pf-meta-item a { color: var(--vantx-blue); font-weight: 500; }
.pf-meta-item a:hover { text-decoration: underline; }

.pf-section { padding: 0; }
.pf-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem;
  margin-bottom: .65rem;
  flex-wrap: wrap;
}

/* Carousel scaffolding. The track is the only scrollable child; arrows
   sit absolutely on top of the panel edges. Cards use scroll-snap-align:
   center so each one parks itself in the middle of the viewport after
   a scroll gesture. */
.pf-carousel {
  position: relative;
  /* Trim the absolute-positioned arrows so they overlay the cards a
     touch and don't get clipped by the rounded modal corner. */
  margin: 0 -.25rem;
}
.pf-track {
  display: flex;
  gap: .85rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  /* Adds a comfortable click-target gutter on each end so the first +
     last cards aren't flush against the viewport edge. */
  padding: .5rem 1.25rem;
  scroll-padding: 0 1.25rem;
  -webkit-overflow-scrolling: touch;
  /* Hide the scrollbar — the dots + arrows are enough affordance, and
     a chrome scrollbar inside a modal looks rough. */
  scrollbar-width: none;
}
.pf-track::-webkit-scrollbar { display: none; }
.pf-card {
  position: relative;
  flex: 0 0 calc(100% - 2.5rem);
  /* On wider modals we let two cards sit side-by-side. The cap keeps a
     single card from ballooning to 600px+ on desktop. */
  max-width: 320px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 4px 12px -6px rgba(15,23,42,.08);
  scroll-snap-align: center;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.pf-card:hover {
  border-color: var(--vantx-blue);
  box-shadow: 0 6px 18px -6px rgba(37,99,235,.18);
}
.pf-card-primary {
  position: absolute;
  top: .55rem;
  inset-inline-end: .55rem;
  display: inline-flex; align-items: center; gap: .25rem;
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: #fff;
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .02em;
  padding: .2rem .5rem;
  border-radius: 999px;
}
.pf-card-primary [data-lucide] { width: 11px; height: 11px; }
.pf-card-plate {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: .04em;
  margin-bottom: .25rem;
}
.pf-card-model {
  font-size: .92rem;
  color: var(--slate-700);
  font-weight: 500;
  margin-bottom: .5rem;
}
.pf-card-chips {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-bottom: .5rem;
}
.pf-card-chip {
  display: inline-block;
  font-size: .7rem;
  padding: .15rem .55rem;
  background: var(--slate-100);
  color: var(--slate-700);
  border-radius: 999px;
  font-weight: 500;
}
.pf-card-notes {
  font-size: .78rem;
  color: var(--slate-500);
  background: var(--slate-50);
  border-radius: 8px;
  padding: .45rem .6rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.pf-card-actions {
  display: flex; gap: .35rem;
  position: absolute;
  bottom: .55rem;
  inset-inline-end: .55rem;
  opacity: 0;
  transition: opacity .12s ease;
}
.pf-card:hover .pf-card-actions,
.pf-card:focus-within .pf-card-actions { opacity: 1; }
/* On touch devices a hover-to-reveal pattern is unusable — always show. */
@media (pointer: coarse) {
  .pf-card-actions { opacity: 1; }
}

.pf-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--slate-200);
  color: var(--slate-700);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px -4px rgba(15,23,42,.18);
  cursor: pointer;
  z-index: 2;
  transition: background .12s, color .12s, transform .1s;
}
.pf-nav:hover { background: var(--vantx-blue); color: #fff; }
.pf-nav:active { transform: translateY(-50%) scale(.94); }
.pf-nav-prev { left: -.15rem; }
.pf-nav-next { right: -.15rem; }
[dir="rtl"] .pf-nav-prev { left: auto; right: -.15rem; }
[dir="rtl"] .pf-nav-next { right: auto; left: -.15rem; }
.pf-nav [data-lucide] { width: 18px; height: 18px; }

/* Phone: shrink the nav buttons a touch + tuck them inside the card
   gutter so they don't push the cards off-screen. The arrows are still
   useful for thumb taps when a user doesn't want to swipe. */
@media (max-width: 640px) {
  .pf-nav { width: 30px; height: 30px; }
  .pf-nav-prev { left: 0; }
  .pf-nav-next { right: 0; }
  [dir="rtl"] .pf-nav-prev { right: 0; left: auto; }
  [dir="rtl"] .pf-nav-next { left: 0; right: auto; }
  .pf-card { flex-basis: calc(100% - 3rem); }
  .pf-card-plate { font-size: 1.2rem; }
}

.pf-dots {
  display: flex; justify-content: center; gap: .35rem;
  margin-top: .75rem;
}
.pf-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--slate-200);
  border: 0;
  cursor: pointer;
  padding: 0;
  transition: background .12s, transform .12s;
}
.pf-dot:hover { background: var(--slate-300); }
.pf-dot.is-active {
  background: var(--vantx-blue);
  transform: scale(1.25);
}

.pf-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--slate-500);
  background: var(--slate-50);
  border: 1px dashed var(--slate-200);
  border-radius: 14px;
}
.pf-empty [data-lucide] {
  width: 36px; height: 36px;
  color: var(--slate-300);
  margin: 0 auto .5rem;
}
.pf-empty p {
  font-weight: 600;
  color: var(--slate-600);
  margin-bottom: .25rem;
}

/* ─────────── Address autocomplete (new task + customer forms) ─────
   Generic dropdown panel — also used by the live-map search bar. The
   floating positioning (top: 100%) is owned by the parent wrapper class
   `.vx-autocomplete-wrap` which sets `position: relative`. */
.vx-autocomplete-wrap {
  position: relative;
}
.vx-autocomplete-panel {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + .25rem);
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  box-shadow: 0 10px 24px -8px rgba(15,23,42,.18);
  max-height: 240px;
  overflow-y: auto;
}
.vx-autocomplete-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .75rem;
  font-size: .85rem;
  color: var(--slate-700);
  border-bottom: 1px solid var(--slate-100);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.vx-autocomplete-item:last-child { border-bottom: 0; }
.vx-autocomplete-item:hover,
.vx-autocomplete-item.is-active {
  background: var(--slate-50);
  color: var(--slate-900);
}
.vx-autocomplete-item [data-lucide] {
  width: 14px; height: 14px;
  color: var(--vantx-blue);
  flex-shrink: 0;
}
.vx-autocomplete-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Muted secondary text inside an autocomplete row — used by the
   customer picker to show "phone · plate" next to the name. */
.vx-autocomplete-sub {
  color: var(--slate-400);
  font-size: .82em;
  font-weight: 500;
}
.vx-autocomplete-empty {
  padding: .75rem 1rem;
  text-align: center;
  color: var(--slate-500);
  font-size: .82rem;
}

/* ─────────── Custom select (vehicle picker) ───────────────────────
   A themed replacement for a native <select> — the browser's open
   list can't be styled, so it clashes with the form. The trigger
   matches `.field`; the panel reuses the `.vx-autocomplete-panel`
   chrome above. Built by js/task-form.js. */
.vx-select { position: relative; }
.vx-select-trigger {
  width: 100%;
  display: flex; align-items: center; gap: .5rem;
  border: 1px solid var(--slate-300);
  background: var(--surface);
  border-radius: 12px;
  padding: .65rem .85rem;
  font-size: .9rem;
  color: var(--slate-900);
  text-align: start;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.vx-select-trigger:hover { border-color: #94a3b8; }
.vx-select-trigger[aria-expanded="true"] {
  border-color: var(--vantx-blue);
  box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}
.vx-select-lead {
  width: 16px; height: 16px;
  color: var(--vantx-blue);
  flex-shrink: 0;
}
.vx-select-value {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vx-select-caret {
  width: 16px; height: 16px;
  color: var(--slate-400);
  flex-shrink: 0;
  transition: transform .15s ease;
}
.vx-select-trigger[aria-expanded="true"] .vx-select-caret { transform: rotate(180deg); }
.vx-select-option { cursor: pointer; }
.vx-select-check {
  width: 14px; height: 14px;
  color: var(--vantx-blue);
  flex-shrink: 0;
}

/* ─────────── Combobox (manufacturer field) ────────────────────────
   A real <input> + a suggestion dropdown. Reuses the
   `.vx-autocomplete-panel` / `.vx-autocomplete-item` chrome; adds only
   the trailing caret. Built by js/combobox.js. */
.vx-combobox { position: relative; }
.vx-combobox .field { padding-inline-end: 2.4rem; }
.vx-combobox-caret {
  position: absolute;
  top: 50%;
  inset-inline-end: .7rem;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--slate-400);
  cursor: pointer;
  transition: transform .15s ease;
  pointer-events: auto;
}
.vx-combobox.is-open .vx-combobox-caret { transform: translateY(-50%) rotate(180deg); }

/* ─────────── Per-fleet manufacturer checklist (admin modal) ────────
   A two-column grid of checkable make rows. Built by js/admin.js. */
.mfr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}
@media (max-width: 520px) { .mfr-grid { grid-template-columns: 1fr; } }
.mfr-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .6rem;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: .85rem;
  color: var(--slate-700);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.mfr-item:hover { background: var(--slate-50); }
.mfr-item.is-on {
  border-color: rgba(37,99,235,.4);
  background: rgba(37,99,235,.05);
  color: var(--slate-900);
}
.mfr-item-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mfr-item-tag {
  font-size: .62rem; font-weight: 800;
  color: var(--vantx-blue);
  background: rgba(37,99,235,.1);
  padding: 1px 6px; border-radius: 999px;
  flex-shrink: 0;
}

/* ─────────── Multi-fleet GM fleet switcher ────────────────────────
   Sits in the (dark) sidebar just under the brand. Shown only for a
   GM who manages 2+ fleets; built by js/fleet-switcher.js. */
.gm-fleet-switcher {
  margin: 0 0 .85rem;
  padding: .6rem .7rem;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
}
.gm-fleet-label {
  display: flex; align-items: center; gap: .35rem;
  font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: rgba(255,255,255,.5);
  margin-bottom: .4rem;
}
.gm-fleet-label [data-lucide],
.gm-fleet-label svg { width: 13px; height: 13px; }
/* Custom dropdown — a native <select>'s open list can't be themed,
   so the switcher is a styled trigger + a panel that opens downward.
   Built by js/fleet-switcher.js. */
.gm-fleet-dd { position: relative; }
.gm-fleet-trigger {
  width: 100%;
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  color: #fff;
  border-radius: 8px;
  padding: .45rem .6rem;
  font-size: .85rem; font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.gm-fleet-trigger:hover { border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.12); }
.gm-fleet-trigger[aria-expanded="true"] { border-color: var(--vantx-blue); }
.gm-fleet-current {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gm-fleet-caret {
  width: 15px; height: 15px; flex-shrink: 0;
  color: rgba(255,255,255,.6);
  transition: transform .15s ease;
}
.gm-fleet-trigger[aria-expanded="true"] .gm-fleet-caret { transform: rotate(180deg); }
.gm-fleet-panel {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + .3rem);
  z-index: 60;
  background: #18233f;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  box-shadow: 0 14px 30px -10px rgba(0,0,0,.6);
  padding: .25rem;
  max-height: 260px;
  overflow-y: auto;
}
.gm-fleet-option {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .55rem;
  border-radius: 7px;
  font-size: .85rem; font-weight: 600;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.gm-fleet-option:hover { background: rgba(255,255,255,.1); color: #fff; }
.gm-fleet-option.is-active { color: #fff; background: rgba(37,99,235,.28); }
.gm-fleet-option-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gm-fleet-check { width: 14px; height: 14px; flex-shrink: 0; color: #fff; }

/* ─────────── Map focus "ping" ──────────────────────────────────────
   A pulsing ring dropped at a point for a few seconds (after
   "Show on map") so the operator's eye lands on it. Built by
   js/map.js — a Leaflet divIcon, hence the transparent wrapper. */
.vx-map-ping-wrap { background: transparent; border: 0; }
.vx-map-ping { position: relative; width: 100%; height: 100%; pointer-events: none; }
.vx-map-ping-core {
  position: absolute; left: 50%; top: 50%;
  width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  background: var(--vantx-blue);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(15,23,42,.5);
}
.vx-map-ping-ring {
  position: absolute; left: 50%; top: 50%;
  width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border: 3px solid var(--vantx-blue);
  border-radius: 50%;
  opacity: 0;
  animation: vx-map-ping 1.5s ease-out infinite;
}
.vx-map-ping-ring:nth-child(2) { animation-delay: .75s; }
@keyframes vx-map-ping {
  0%   { transform: scale(.35); opacity: .9; }
  70%  { opacity: 0; }
  100% { transform: scale(3); opacity: 0; }
}

/* ─────────── Map Waze floating button (new style) ─────────────────
   The old `.vx-waze-ctl` was a solid cyan rectangle. The new style
   matches the white-tile aesthetic of the Home button so the controls
   form a clean monochrome column on the left edge — the brand pop comes
   from the inline Waze car SVG inside, not the button background. */
.vx-waze-fab a {
  background: #ffffff !important;
  color: #0f172a !important;
  display: flex !important;
  align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  box-shadow: 0 4px 10px -4px rgba(15,23,42,.18);
  transition: background .14s, color .14s, transform .1s;
}
.vx-waze-fab a:hover {
  background: var(--vantx-orange) !important;
  color: #ffffff !important;
}
.vx-waze-fab a:active {
  transform: scale(.94);
}
.vx-waze-fab svg {
  width: 22px; height: 22px;
  /* Don't force stroke / fill here — the canonical Waze SVG defined
     in util.js paints its own outlines (stroke=currentColor) and
     filled details (eyes + wheels) via attributes on each sub-shape.
     Re-stating fill:none / stroke-width:1.6 at this level overrode
     the path-level attributes and made the eyes / wheels disappear
     on hover. */
}
.vx-waze-fab { margin-bottom: .35rem !important; }

/* ─── Search-pin popup ──────────────────────────────────────────────
   Bound to the orange pin dropped by the floating map address search.
   Three rows: the resolved address, then two CTA buttons (Waze /
   create-task). The popup re-uses `.leaflet-popup.task-popup` for the
   white card chrome, then we layer the search-specific layout on top
   via the extra `.map-search-popup-wrap` className. */
.leaflet-popup.map-search-popup-wrap .leaflet-popup-content-wrapper {
  /* Search pin is informational, not state-bearing — drop the
     red/green status border the task popups use. */
  border-color: var(--slate-200);
}
.leaflet-popup.map-search-popup-wrap .leaflet-popup-content {
  /* Override the task-popup width caps — the action row needs a bit
     more breathing room than a task tooltip does, and the body sets
     its own max-width via .map-search-popup. */
  max-width: 320px;
  min-width: 220px;
  padding: 0;
}
.map-search-popup {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding: .85rem .9rem;
}
.map-search-popup .msp-addr {
  font-size: .82rem;
  font-weight: 600;
  color: var(--slate-900);
  line-height: 1.35;
  /* Long addresses fold to a second line gracefully instead of
     stretching the popup beyond its maxWidth. */
  word-break: normal;
  overflow-wrap: anywhere;
}
.map-search-popup .msp-actions {
  display: flex;
  gap: .4rem;
  /* On PC the two buttons sit side by side. On phones we stack them
     (see the breakpoint override below) so each button is a clean
     full-width tap target. */
}
.map-search-popup .msp-btn {
  flex: 1;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .45rem .6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease, transform .08s ease;
  white-space: nowrap;
}
.map-search-popup .msp-btn:active { transform: translateY(1px); }
.map-search-popup .msp-btn [data-lucide],
.map-search-popup .msp-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.map-search-popup .msp-btn-primary {
  background: #f97316;        /* Waze orange */
  color: #ffffff;
  border-color: #f97316;
}
.map-search-popup .msp-btn-primary:hover  { background: #ea580c; border-color: #ea580c; }
.map-search-popup .msp-btn-secondary {
  background: var(--surface);
  color: var(--slate-800);
  border-color: var(--slate-300);
}
.map-search-popup .msp-btn-secondary:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
}

/* Mobile / narrow viewports — stack the action buttons so each row
   is a full-width 44px-class tap target (WCAG 2.5.5). Also let the
   popup take 92vw so it doesn't get clipped on small Android screens. */
@media (max-width: 480px) {
  .leaflet-popup.map-search-popup-wrap .leaflet-popup-content {
    max-width: 92vw;
    min-width: 240px;
  }
  .map-search-popup .msp-actions { flex-direction: column; }
  .map-search-popup .msp-btn { min-height: 44px; font-size: .82rem; }
}

/* ─── Task-detail driver route + locked chat ────────────────────────
   The completed-task detail panel (tasks.html) draws the driver's
   GPS breadcrumb trail on a small Leaflet map, and swaps the chat
   composer for a read-only notice. */
.td-route-map {
  height: 240px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
}
.td-route-map .leaflet-container { height: 100%; width: 100%; }
.td-chat-locked {
  display: flex; align-items: center; justify-content: center;
  gap: .5rem;
  padding: .85rem 1rem;
  border-top: 1px solid var(--slate-200);
  background: var(--slate-50);
  color: var(--slate-500);
  font-size: .82rem; font-weight: 600;
}
.td-chat-locked [data-lucide], .td-chat-locked svg { flex-shrink: 0; }

/* ─── Driver route ordering (driver.html) ───────────────────────────
   The driver reorders their open tasks; each queue card carries a
   sequence number + a stacked ▲/▼ control. */
.route-seq {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 999px;
  background: var(--vantx-blue); color: #fff;
  font-size: .72rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.route-reorder {
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;
}
.route-move {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 20px;
  border: 1px solid var(--slate-200);
  background: var(--surface); color: var(--slate-600);
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.route-move:hover:not(:disabled) {
  background: var(--slate-50);
  color: var(--vantx-blue);
  border-color: #cbd5e1;
}
.route-move:active:not(:disabled) { transform: translateY(1px); }
.route-move:disabled { opacity: .35; cursor: not-allowed; }
.route-move [data-lucide], .route-move svg { width: 13px; height: 13px; }
/* "Stop 1 of N" pill on the active-task card. */
.route-stop-pill {
  margin-inline-start: .5rem;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .1);
  color: var(--vantx-blue);
  font-size: .68rem; font-weight: 700;
}

/* ─── Planned-route overlay pins (live map, ops/advisor) ────────────
   Numbered pin for each stop on the driver's chosen route. */
.planned-route-pin {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 999px;
  color: #fff;
  font-size: .72rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px -1px rgba(15,23,42,.4);
}


/* ---- Motion layer (upgrade stage 1) ---- */
button, .btn { transition: transform .35s cubic-bezier(.3,1.6,.5,1), background-color .2s ease-out, box-shadow .2s ease-out; }
button:active:not(:disabled), .btn:active { transform: scale(.95); }
main { animation: jx-fade .35s ease-out both; }
button:focus-visible, a:focus-visible { outline: 2px solid #66f500; outline-offset: 2px; }
h1 { letter-spacing: -.02em; }
@keyframes jx-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.jx-skel { height: 56px; margin: 8px 0; border-radius: 12px; background: linear-gradient(90deg, var(--surface-muted,#eef2f7), var(--surface-sunken,#e2e8f0), var(--surface-muted,#eef2f7)); background-size: 200% 100%; animation: jx-shimmer 1.2s linear infinite; }
@keyframes jx-shimmer { to { background-position: -200% 0; } }
