/* ==========================================================================
   Movra — design tokens, reset and shared primitives
   Night navy ink, mint for motion and confirmation, amber for parcels & offers.
   Brand colours are overridable from Admin → Settings → Appearance (printed as CSS variables in <head>).
   ========================================================================== */
:root {
  --ink: #0B1324; --ink-2: #172136; --ink-3: #27324A; --ink-rgb: 11, 19, 36;
  --brand: #12B886; --brand-600: #0CA678; --brand-700: #087F5B; --brand-50: #E8FBF4; --brand-100: #C6F4E2; --brand-rgb: 18, 184, 134;
  --accent: #FFB23F; --accent-600: #F59F00; --accent-700: #B86E00; --accent-50: #FFF5E3; --accent-rgb: 255, 178, 63;
  --text: #0F182A; --text-2: #465167; --muted: #778298; --faint: #A7B0C0;
  --line: #E6EAF1; --line-2: #D6DCE6;
  --bg: #F3F5F9; --surface: #FFFFFF; --surface-2: #F7F9FC; --surface-3: #EDF1F6;
  --blue: #3E7BFA; --blue-50: #EDF3FF; --violet: #7B61FF; --violet-50: #F2EFFF;
  --red: #EF4444; --red-50: #FEF0F0; --red-700: #B42318; --green: #12B886; --green-50: #E8FBF4; --green-700: #087F5B;
  --amber: #F59F00; --amber-50: #FFF5E3; --amber-700: #B86E00;
  --font: 'Manrope', 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Manrope', system-ui, sans-serif;
  --r-xs: 8px; --r-sm: 12px; --r: 16px; --r-lg: 22px; --r-xl: 28px;
  --sh-1: 0 1px 2px rgba(var(--ink-rgb), .06);
  --sh-2: 0 8px 24px -12px rgba(var(--ink-rgb), .22), 0 2px 6px -2px rgba(var(--ink-rgb), .06);
  --sh-3: 0 24px 60px -20px rgba(var(--ink-rgb), .35), 0 4px 12px -4px rgba(var(--ink-rgb), .08);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: "tnum" 0; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); line-height: 1.15; margin: 0 0 .35em; letter-spacing: -.02em; font-weight: 700; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
::selection { background: rgba(var(--brand-rgb), .35); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.ic { flex-shrink: 0; }
small .ic, p .ic, b .ic, .muted .ic, .hint .ic { display: inline-block; vertical-align: -3px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* ---------- buttons ---------- */
.btn { --bh: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--bh); padding: 0 18px; border-radius: 13px; font-weight: 700; font-size: 14.5px; letter-spacing: -.005em; white-space: nowrap; transition: transform .15s var(--ease), background .2s, box-shadow .2s, color .2s, border-color .2s; user-select: none; position: relative; }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-2); }
.btn-brand { background: var(--brand); color: var(--ink); }
.btn-brand:hover { background: color-mix(in srgb, var(--brand) 88%, #fff); box-shadow: 0 8px 22px -10px rgba(var(--brand-rgb), .8); }
.btn-accent { background: var(--accent); color: var(--ink); }
.btn-soft { background: var(--surface-3); color: var(--ink); }
.btn-soft:hover { background: var(--line); }
.btn-line { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn-line:hover { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-soft { background: var(--red-50); color: var(--red-700); }
.btn-lg { --bh: 54px; font-size: 16px; border-radius: 16px; padding: 0 22px; }
.btn-sm { --bh: 34px; font-size: 13px; padding: 0 12px; border-radius: 10px; }
.btn-xs { --bh: 28px; font-size: 12px; padding: 0 10px; border-radius: 8px; gap: 5px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--bh); padding: 0; }
.btn .spinner { width: 18px; height: 18px; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.25) rgba(255,255,255,.25); animation: spin .7s linear infinite; }
.btn-brand.is-loading::after, .btn-soft.is-loading::after, .btn-line.is-loading::after { border-color: var(--ink) rgba(var(--ink-rgb), .2) rgba(var(--ink-rgb), .2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.error-text { font-size: 12.5px; color: var(--red-700); font-weight: 600; }
.input, .select, .textarea { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; outline: none; font-size: 15px; }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23778298' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(var(--ink-rgb), .07); }
.input.is-invalid { border-color: var(--red); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ic { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input-group > .input { padding-left: 42px; }
.input-affix { position: absolute; right: 8px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.switch { position: relative; display: inline-flex; width: 46px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .25s var(--spring); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.no-dot::before { display: none; }
.badge-green, .badge-completed, .badge-approved, .badge-paid, .badge-resolved, .badge-available, .badge-active { background: var(--green-50); color: var(--green-700); }
.badge-red, .badge-cancelled, .badge-no_driver, .badge-rejected, .badge-suspended, .badge-blocked, .badge-urgent, .badge-open-sos { background: var(--red-50); color: var(--red-700); }
.badge-amber, .badge-searching, .badge-pending, .badge-scheduled, .badge-high { background: var(--amber-50); color: var(--amber-700); }
.badge-blue, .badge-in_progress, .badge-on_trip, .badge-acknowledged, .badge-open { background: var(--blue-50); color: #2554C7; }
.badge-teal, .badge-accepted, .badge-arrived { background: var(--brand-50); color: var(--brand-700); }
.badge-violet { background: var(--violet-50); color: #5B3FD9; }
.badge-ink { background: var(--ink); color: #fff; }
.badge-offline, .badge-closed, .badge-low, .badge-normal { background: var(--surface-3); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 99px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 700; font-size: 13.5px; color: var(--text-2); white-space: nowrap; transition: all .15s; }
.chip:hover { box-shadow: inset 0 0 0 1.5px var(--line-2); color: var(--ink); }
.chip.is-active { background: var(--ink); color: #fff; box-shadow: none; }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; }
.avatar-lg { width: 56px; height: 56px; }
.avatar-xl { width: 76px; height: 76px; }

.stars { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 13px; color: var(--ink); }
.stars .ic { color: var(--accent); fill: var(--accent); }

.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line-2); font-size: 11px; font-weight: 700; color: var(--muted); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 9999; left: 50%; top: 16px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--sh-3); pointer-events: auto; animation: toastIn .35s var(--spring); }
.toast .ic { color: var(--brand); }
.toast.is-error .ic { color: #FF8A8A; }
.toast.is-leaving { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- map primitives (Leaflet overrides) ---------- */
.leaflet-container { font-family: var(--font); background: #EDF0F2; }
.mv-tiles-soft { filter: saturate(.42) contrast(.93) brightness(1.05) hue-rotate(-6deg); }
.mv-tiles-dark { filter: invert(1) hue-rotate(186deg) saturate(.45) brightness(.86) contrast(.92); }
.leaflet-container:has(.mv-tiles-dark) { background: #1B2230; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.7) !important; border-radius: 6px 0 0 0; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--sh-2) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 36px !important; color: var(--ink) !important; border-color: var(--line) !important; }
.mv-marker { background: none; border: 0; }
.mv-vehicle { width: 44px; height: 44px; display: grid; place-items: center; transition: transform .9s linear; will-change: transform; }
.mv-vehicle svg { width: 44px; height: 44px; filter: drop-shadow(0 3px 4px rgba(11, 19, 36, .35)); }
.mv-pin { position: relative; width: 22px; height: 22px; }
.mv-pin i { position: absolute; inset: 0; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px #fff, 0 6px 14px rgba(11, 19, 36, .35); }
.mv-pin i::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
.mv-pin.is-drop i { border-radius: 6px; background: var(--ink); }
.mv-pin.is-drop i::after { border-radius: 2px; }
.mv-pin.is-parcel i { background: var(--accent); }
.mv-pin-label { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 9px; white-space: nowrap; box-shadow: var(--sh-2); }
.mv-pin-label b { color: var(--brand); font-weight: 800; margin-right: 4px; }
.mv-pin-label::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px; background: var(--ink); transform: translateX(-50%) rotate(45deg); border-radius: 1px; }
.mv-pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px #fff, 0 2px 8px rgba(0,0,0,.25); position: relative; }
.mv-pulse::before { content: ""; position: absolute; inset: -14px; border-radius: 50%; background: rgba(62, 123, 250, .22); animation: pulse 2s ease-out infinite; }
@keyframes pulse { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.mv-radar { width: 240px; height: 240px; border-radius: 50%; position: relative; pointer-events: none; }
.mv-radar::before, .mv-radar::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(var(--brand-rgb), .55); background: rgba(var(--brand-rgb), .08); animation: radar 2.4s ease-out infinite; }
.mv-radar::after { animation-delay: 1.2s; }
@keyframes radar { from { transform: scale(.1); opacity: 1; } to { transform: scale(1); opacity: 0; } }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
