@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --text: #1C1B1F;
  --muted: #6B7280;
  --accent: #519AEC;
  --accent-soft: rgba(81, 154, 236, 0.12);
  --heading: #0077BB;
  --ink: #202324;
  --success: #16A34A;
  --danger: #DE4437;
  --border: #E5E7EB;
  --font: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  --nav: calc(68px + env(safe-area-inset-bottom));
  --ring: 0 0 0 3px rgba(81, 154, 236, 0.35);
  --shadow: 0 1px 2px rgba(32, 35, 36, 0.04);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.35; color: var(--heading); font-weight: 700; }
[hidden] { display: none !important; }
.lede, small { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
button, .card, a, input, select { transition: box-shadow .2s ease, background .2s ease, border-color .2s ease; }
.primary:hover, .ghost:hover, .chip:hover, .call:hover { box-shadow: var(--ring); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: none; box-shadow: var(--ring); }
.brand-chip {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: #202324; border-radius: 10px; padding: 6px 8px; line-height: 0; text-decoration: none;
}
.brand-chip img { height: 26px; width: auto; display: block; }
.primary, .ghost, .icon-btn {
  min-height: 44px; border-radius: 12px; border: 1px solid transparent; padding: 0 16px;
}
.primary { background: var(--accent); color: white; font-weight: 700; }
.primary:hover { background: var(--accent); }
.ghost { background: white; border-color: var(--border); color: var(--text); }
.wide { width: 100%; }
.icon-btn { width: 44px; padding: 0; background: white; border-color: var(--border); display: grid; place-items: center; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; display: block; }
.avatar {
  width: 36px; height: 36px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 800; flex: none;
}

.login {
  height: 100dvh; display: grid; grid-template-rows: 1fr auto; background: white;
}
.login-card { padding: 18px 20px 22px; display: grid; gap: 8px; align-content: center; justify-items: center; max-width: 460px; margin: 0 auto; width: 100%; overflow: auto; scrollbar-width: none; }
.login-card::-webkit-scrollbar { display: none; }
.login-brand { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; text-align: center; }
.login-brand .brand-chip img { height: 34px; }
.login-brand strong { color: var(--ink); letter-spacing: 0; font-size: 17px; }
.login h1, .login .lede { text-align: center; width: 100%; }
.login form { display: grid; gap: 8px; margin-top: 4px; width: 100%; text-align: right; }
.login form label { direction: rtl; text-align: right; }
.login form input { text-align: right; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; background: white; color: var(--text); text-align: right;
}
input[type="radio"], input[type="checkbox"] {
  width: 18px; height: 18px; min-width: 18px; min-height: 18px; margin: 0; padding: 0;
  accent-color: var(--accent); flex: none; border-radius: 50%;
}
textarea { min-height: 88px; resize: none; }
.hero { height: min(30dvh, 240px); min-height: 140px; overflow: hidden; background: #d7e6f5; }
.hero img { width: 100%; height: 100%; object-fit: cover; object-position: center 62%; display: block; }

.shell { height: 100dvh; display: flex; background: var(--bg); }
.side {
  display: none; width: 228px; flex: none; background: var(--ink); color: #fff;
  padding: 22px 14px; border-left: 0;
}
.side .brand-chip { align-self: center; }
.profile { display: flex; gap: 10px; align-items: center; margin: 28px 0 18px; color: #fff; }
.profile strong, .profile small { color: #fff; }
.profile small { opacity: .72; }
.side .avatar { background: rgba(255,255,255,.12); color: #fff; }
.side-nav { display: grid; gap: 4px; }
.side-nav button {
  text-align: right; background: transparent; color: rgba(255,255,255,.82); border: 0; border-radius: 10px;
  min-height: 42px; padding: 0 12px; font-weight: 500;
}
.side-nav button.on { background: rgba(81, 154, 236, 0.22); color: #fff; box-shadow: none; }
.side-nav button:hover { background: rgba(255,255,255,.08); color: #fff; box-shadow: none; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.deskbar { display: none; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: white;
  border-bottom: 1px solid var(--border); flex: none; min-height: 60px;
}
.who-block { flex: 1; min-width: 0; text-align: right; }
.offline-status { display: block; margin-top: 3px; color: #198754; font-size: 10px; line-height: 1.2; }
.offline-status.offline { color: #b54708; }
.offline-status.pending { color: #8a6100; }
.who-block .lede, .desk-actions .lede { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage { flex: 1; min-height: 0; position: relative; display: flex; }
.view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; background: white; z-index: 1; }
.phonebar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: white; border-bottom: 1px solid var(--border); flex: none; text-align: right;
}
.phonebar h2 { flex: 1; min-width: 0; font-size: 16px; }
.phonebar .lede { margin: 0; }
#map, #route-map, #place-map { flex: 1; min-height: 0; background: #E7EEF6; position: relative; z-index: 1; }
.map-misconfig {
  display: grid; place-content: center; min-height: 160px; padding: 16px; text-align: center;
  color: var(--muted); font-size: 13px; line-height: 1.6;
}
.leaflet-control-attribution { font-size: 10px; }
.stack { flex: 1; min-height: 0; overflow: auto; scrollbar-width: none; display: grid; gap: 10px; align-content: start; padding: 12px; }
.stack::-webkit-scrollbar, .filter-sheet::-webkit-scrollbar, .detail::-webkit-scrollbar, dialog::-webkit-scrollbar { display: none; }
.tabs {
  flex: none; display: flex; gap: 2px; background: white; border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  flex: 1; background: transparent; border: 0; color: var(--muted); border-radius: 12px;
  min-height: 52px; display: grid; gap: 2px; justify-items: center; font-size: 11px; padding: 4px;
}
.tabs button i { font-style: normal; font-size: 16px; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }

.filter-sheet {
  display: none; position: absolute; inset: 0; z-index: 30; background: white; overflow: auto;
  padding: 16px; gap: 12px;
}
.filter-sheet.open {
  display: grid; align-content: start; position: fixed; inset: 0; z-index: 4000;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.field { display: grid; gap: 8px; }
.chips, .stars { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .stars button {
  min-height: 36px; min-width: 42px; border-radius: 999px; border: 1px solid var(--border);
  background: white; padding: 0 12px;
}
.chip.on { background: var(--accent); color: white; border-color: var(--accent); }
.stars button { color: #D1D5DB; background: white; }
.stars button.on { background: white; color: #F5C518; border-color: var(--border); }
.badge.star { color: #F5C518; background: #FFF8DC; }
.area-search { position: relative; }
.area-list {
  display: grid; max-height: 240px; overflow: auto; background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
}
.area-list button, .area-list .meta {
  text-align: right; background: #fff; border: 0; border-bottom: 1px solid var(--border);
  min-height: 40px; padding: 8px 12px;
}
.area-list button:last-child, .area-list .meta:last-child { border-bottom: 0; }
.area-list button:hover, .area-list button.on { background: var(--accent-soft); color: var(--heading); box-shadow: none; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); text-align: right; }
.summary { color: var(--muted); font-size: 12px; display: grid; gap: 4px; }

.detail {
  position: absolute; z-index: 30; left: 10px; right: 10px; bottom: 10px;
  background: white; border: 1px solid var(--border); border-radius: 16px;
  padding: 12px; max-height: 70%; overflow: auto; box-shadow: 0 10px 30px rgba(15, 39, 68, .12);
}
.detail-rows { display: grid; gap: 6px; }
.detail-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: start; }
.detail-row span { color: var(--muted); font-size: 12px; }
.detail-row b { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.detail-row a { color: var(--accent); text-decoration: none; }
.call-list { display: grid; gap: 8px; }
.call {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 0 14px; border-radius: 12px; background: var(--accent);
  color: white; text-decoration: none; font-weight: 700;
}
.call span { font-size: 13px; background: rgba(255,255,255,.18); border-radius: 999px; padding: 4px 10px; }
.call:hover { box-shadow: 0 0 0 3px rgba(81, 154, 236, 0.35); }
.leaflet-tooltip.pin-tip {
  background: white; color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 20px rgba(15, 39, 68, .16); padding: 8px 10px; text-align: right; direction: rtl;
}
.leaflet-tooltip.pin-tip strong, .leaflet-tooltip.pin-tip span { display: block; }
.leaflet-tooltip.pin-tip strong { color: var(--ink); }
.leaflet-tooltip-top.pin-tip::before { border-top-color: white; }
.card, .stop {
  background: white; border: 1px solid var(--border); border-radius: 16px; padding: 12px; display: grid; gap: 6px; text-align: right;
}
.stop p, .card p, .meta { margin: 0; }
.meta { color: var(--muted); font-size: 12px; }
.badges, .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .primary, .actions .ghost { flex: 1 1 140px; }
.ext-row { display: flex; gap: 8px; width: 100%; justify-content: flex-start; }
.ext {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--border); background: white; padding: 0; text-decoration: none;
}
.ext svg, .ext img { width: 28px; height: 28px; display: block; object-fit: contain; }
.badge {
  min-height: 26px; display: inline-flex; align-items: center; padding: 0 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.badge.buy { background: #E5F8EE; color: var(--success); }
.badge.done { background: #F1F2F4; color: var(--muted); }
a.phone { color: var(--accent); font-weight: 700; text-decoration: none; }
.pin {
  width: 22px; height: 22px; border-radius: 999px 999px 999px 4px; transform: rotate(-45deg);
  border: 2px solid white; box-shadow: 0 2px 6px rgba(32, 35, 36, .28);
}
.pin.selected { box-shadow: 0 0 0 4px rgba(81, 154, 236, 0.35), 0 2px 6px rgba(32, 35, 36, .28); }
.cluster-wrap, .route-pin-wrap { background: transparent; border: 0; }
.cluster-pin span, .route-pin b {
  font-family: "Segoe UI", Vazirmatn, sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
}
.van-wrap { background: transparent; border: 0; }
.van-rig, .van-spin { width: 58px; height: 91px; }
.van-spin { transform-origin: 29px 46px; }
.van-spin img { display: block; width: 58px; height: 91px; }
.route-pin { position: relative; width: 36px; height: 46px; filter: drop-shadow(0 2px 4px rgba(15, 39, 68, .35)); }
.route-pin svg { display: block; width: 36px; height: 46px; }
.route-pin b {
  position: absolute; top: 8px; left: 0; width: 36px; text-align: center;
  color: #9A3412; font-size: 12px; font-weight: 800; line-height: 18px;
}
.num {
  width: 28px; height: 28px; border-radius: 999px; background: #E8590C; color: white;
  display: grid; place-items: center; font-weight: 800;
  font-family: "Segoe UI", Vazirmatn, sans-serif;
}
.buyer, .event, .route-stop {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  background: white; border: 1px solid var(--border); border-radius: 14px; padding: 10px;
}
.event div, .buyer div { min-width: 0; }
.event strong, .event .meta, .buyer strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-pin {
  width: 36px; height: 36px; border-radius: 999px; background: var(--accent); color: white;
  display: grid; place-items: center; font-weight: 700; border: 2px solid white;
  box-shadow: 0 0 0 4px rgba(81, 154, 236, 0.28);
}
.stats { flex: 1; overflow: auto; scrollbar-width: none; padding: 16px; display: grid; gap: 12px; align-content: start; }
.metrics, #desk-stats { display: grid; gap: 12px; min-width: 0; }
.metric { display: grid; gap: 6px; min-width: 0; }
.metric-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.metric-top strong { font-size: 20px; color: var(--ink); }
.metric-top span { color: var(--muted); font-size: 12px; }
.meter { height: 8px; border-radius: 99px; background: #E8F3FD; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bars { display: grid; gap: 6px; height: auto; min-width: 0; }
.bar-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 32px; align-items: center; gap: 6px; font-size: 11px; min-width: 0; }
.bar-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-row i { display: block; height: 8px; background: var(--accent); border-radius: 99px; }
.bar-row b { color: var(--ink); font-weight: 700; text-align: left; }
.insight { display: none; }
.toast {
  position: fixed; z-index: 6000; left: 50%; right: auto; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%); width: max-content; max-width: min(280px, calc(100% - 32px));
  background: #202324; color: white; border-radius: 999px; padding: 8px 14px;
  font-size: 13px; line-height: 1.45; text-align: center;
  box-shadow: 0 8px 20px rgba(15, 39, 68, .28);
}
.add-place {
  position: absolute; z-index: 2; top: 12px; left: 12px;
  background: white; color: var(--ink); border: 1px solid var(--border); border-radius: 999px;
  min-height: 36px; padding: 0 12px; font-weight: 700; box-shadow: 0 2px 8px rgba(15, 39, 68, .16);
}
#place-map { height: 180px; border-radius: 12px; border: 1px solid var(--border); }
dialog {
  width: min(460px, calc(100% - 20px)); max-height: calc(100dvh - 24px); border: 0; border-radius: 18px;
  padding: 0; background: white;
}
dialog::backdrop { background: rgba(15, 39, 68, .35); }
.visit-form { display: grid; gap: 12px; padding: 14px; text-align: right; max-height: calc(100dvh - 32px); overflow: auto; scrollbar-width: none; }
.visit-form::-webkit-scrollbar, dialog::-webkit-scrollbar { display: none; }
.status-list { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.choice {
  display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px;
  width: 100%; min-height: 46px; margin: 0; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 14px; text-align: right; background: white;
}
.choice span { flex: 1; text-align: right; line-height: 1.4; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
fieldset { border: 1px solid var(--border); border-radius: 14px; margin: 0; padding: 12px; display: grid; gap: 10px; }
legend { padding: 0 6px; font-weight: 700; color: var(--ink); }
.sheet-head h2 { flex: 1; text-align: right; font-size: 16px; }
.drawer { position: fixed; inset: 0; z-index: 5000; }
.drawer-bg { position: absolute; inset: 0; border: 0; padding: 0; background: rgba(15, 39, 68, .45); }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; right: 0; width: min(300px, 86vw);
  background: var(--surface); color: var(--text); padding: 18px 14px; display: flex; flex-direction: column; gap: 8px;
  overflow: auto; box-shadow: -8px 0 24px rgba(32, 35, 36, .12); border-left: 1px solid var(--border);
}
.drawer-panel button {
  text-align: right; background: transparent; color: var(--text); border: 0; border-radius: 10px; min-height: 46px; padding: 0 12px;
}
.drawer-panel button.on, .drawer-panel button:hover { background: var(--accent-soft); color: var(--heading); box-shadow: none; }

@media (min-width: 980px) {
  .login { grid-template-columns: minmax(320px, 460px) 1fr; grid-template-rows: 1fr; }
  .hero { height: 100%; min-height: 0; }
  #view-route .phonebar { flex-wrap: nowrap; }
  .side { display: flex; flex-direction: column; width: 220px; }
  .topbar, .drawer { display: none !important; }
  .deskbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--border);
  }
  .brand-lockup { display: none; }
  .slogan, .desk-actions { display: flex; align-items: center; gap: 10px; }
  .slogan { flex-direction: column; align-items: center; flex: 1; text-align: center; }
  .slogan strong { color: var(--heading); font-size: 16px; }
  .slogan small { color: var(--muted); }
  .stage { display: grid; grid-template-columns: 240px minmax(0, 1fr) minmax(220px, 280px); gap: 16px; padding: 16px; }
  .filter-sheet, .filter-sheet.open {
    display: grid; position: static; z-index: auto; inset: auto;
    border: 1px solid var(--border); border-radius: 16px; background: #fff;
    padding: 16px; gap: 14px; box-shadow: var(--shadow); align-content: start;
  }
  .filter-sheet #close-filters { display: none; }
  .view { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
  .insight {
    display: flex; flex-direction: column; gap: 0; min-width: 0; min-height: 0;
    height: auto; background: transparent; border: 0; padding: 0; overflow: auto; align-content: start;
  }
  .insight h2, .insight h3 {
    font-size: 14px; margin: 12px 0 0; background: #fff; border: 1px solid var(--border); border-bottom: 0;
    border-radius: 16px 16px 0 0; padding: 14px 14px 8px;
  }
  .insight h2:first-child { margin-top: 0; }
  #desk-stats, .insight .bars, .insight .events {
    flex: none; min-height: 0; background: #fff; border: 1px solid var(--border); border-top: 0;
    border-radius: 0 0 16px 16px; padding: 0 14px 14px; box-shadow: var(--shadow);
  }
  .insight::-webkit-scrollbar { display: none; }
  .slogan { min-width: 0; }
  .tabs { display: none; }
  .toast { bottom: 24px; }
}
@media (min-width: 980px) and (max-width: 1240px) {
  .slogan { display: none; }
}
@media (max-width: 520px) {
  .hero { height: 28dvh; min-height: 150px; }
  #view-route .phonebar { flex-wrap: wrap; }
  #view-route .phonebar h2 { flex-basis: 100%; }
  .tabs button { font-size: 10px; min-height: 48px; }
  .login h1 { font-size: 24px; }
}
