:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e2e5ea;
  --primary: #1f6feb;
  --primary-text: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #20242c;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2b303a;
    --primary: #3b82f6;
    --ok: #4ade80;
    --ok-bg: #12331f;
    --bad: #f87171;
    --bad-bg: #3b1414;
    --warn: #fbbf24;
    --warn-bg: #3a2c0b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 18px; }
h2 { font-size: 16px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.bad { color: var(--bad); }
[hidden] { display: none !important; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost.bad { color: var(--bad); }
.btn.big { min-height: 52px; font-size: 16px; padding: 12px 18px; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.icon {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; font-size: 15px;
}
.icon:hover { background: var(--surface-2); color: var(--text); }

select, input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; min-height: 40px; padding: 6px 10px;
}

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar .back { font-size: 20px; text-decoration: none; color: var(--text); padding: 4px 6px; }
.bar .spacer { flex: 1; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.badge.firebase { background: var(--ok-bg); color: var(--ok); }

/* home */
.home {
  max-width: 420px; margin: 0 auto; min-height: 100vh; padding: 40px 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 12px; text-align: center;
}
.home h1 { font-size: 28px; }
.home .logo {
  width: 72px; height: 72px; margin: 0 auto 4px; border-radius: 20px;
  display: grid; place-items: center; background: var(--primary); color: #fff;
}
.home .btn { width: 100%; }
.login { display: grid; gap: 12px; text-align: left; margin-top: 8px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { min-height: 48px; font-size: 16px; }
.linkish { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }
.note { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 10px 12px; margin-top: 16px; }

/* dispatcher */
.dispatch { padding: 16px; display: grid; gap: 16px; max-width: 1500px; margin: 0 auto; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.card.courier { cursor: pointer; border-left: 4px solid var(--c); }
.card.courier.active { outline: 2px solid var(--c); }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-top b { flex: 1; min-width: 0; line-height: 1.25; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-top .del { width: 26px; height: 26px; font-size: 12px; }
.state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.state.go { background: #dbeafe; color: #1d4ed8; }
.state.ok { background: var(--ok-bg); color: var(--ok); }
@media (prefers-color-scheme: dark) { .state.go { background: #172554; color: #93c5fd; } }
.big-num { font-size: 30px; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 16px; color: var(--muted); font-weight: 500; }
.progress { display: flex; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress span { background: var(--ok); transition: width .3s; }
.progress span.fail { background: var(--bad); }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 13px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; flex: none; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; grid-column: 1 / -1; }
.empty p { margin: 6px 0 0; }

.day-total {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.day-total > div { display: grid; gap: 2px; padding: 12px 16px; border-left: 1px solid var(--border); }
.day-total > div:first-child { border-left: 0; }
.day-total span { font-size: 12px; }
.day-total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.day-total small { font-size: 12px; }
@media (max-width: 700px) {
  .day-total { grid-template-columns: 1fr 1fr; }
  .day-total > div:nth-child(odd) { border-left: 0; }
  .day-total > div:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (min-width: 701px) and (max-width: 1000px) {
  .day-total { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .day-total > div:nth-child(4) { border-left: 0; }
  .day-total > div:nth-child(n+4) { border-top: 1px solid var(--border); }
}
/* loading check */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.tabs:empty { display: none; }
.tab { border: 0; background: transparent; border-radius: 9px; min-height: 44px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab-count { font-weight: 600; font-size: 13px; color: var(--muted); margin-left: 4px; }
.load-part { display: grid; gap: 10px; }
.load-summary { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.load-summary p { margin: 0; }
.load-card {
  display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 12px;
  border-radius: var(--radius); border: 1px solid var(--border); border-left: 6px solid #eab308;
  background: #fefce8;
}
.load-card.loaded { background: var(--ok-bg); border-left-color: var(--ok); }
.load-card.missing { background: var(--bad-bg); border-left-color: var(--bad); }
.load-card.loaded .load-body { opacity: .75; }
@media (prefers-color-scheme: dark) { .load-card { background: #2a2408; } }
.load-check {
  width: 44px; height: 44px; border-radius: 10px; border: 2px solid #ca8a04; background: var(--surface);
  font-size: 24px; font-weight: 800; color: #fff; cursor: pointer; display: grid; place-items: center;
}
.load-card.loaded .load-check { background: var(--ok); border-color: var(--ok); }
.load-card.missing .load-check { background: var(--bad); border-color: var(--bad); }
.load-items { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.load-items li.bad { font-weight: 700; text-decoration: underline wavy; }
.load-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.missing-items { display: grid; gap: 2px; margin-bottom: 10px; }
.missing-items .check { margin: 4px 0; font-weight: 400; }
/* feedback */
.fb-btn { font-size: 20px; width: 40px; height: 40px; flex: none; }
.fb-text { display: grid; gap: 6px; margin: 12px 0; }
.fb-text textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; resize: vertical; min-height: 110px;
}
.fb-photo { margin-top: 4px; }
.fb-page { max-width: 900px; }
.fb-body { margin: 6px 0; font-size: 16px; white-space: pre-line; }
.fb-resolve { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.fb-resolve input { flex: 1; min-width: 200px; }
.fb-count:not(:empty), .badge-count { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 13px; margin-left: 4px; }
/* cash handover */
.cash-page { max-width: 1200px; }
.cash-list { display: grid; gap: 16px; }
.cash-card { border-left: 4px solid var(--c); }
.cash-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cash-head b { font-size: 16px; }
.cash-card tfoot td { border-top: 2px solid var(--border); border-bottom: 0; }
.cash-totals { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 14px; }
.cash-accept { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.cash-accept p { width: 100%; margin: 0; }
.accept-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; width: 100%; }
.accept-row > span { font-size: 15px; margin-right: auto; align-self: center; }
.accept-row label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.accept-row input[name=amount] { width: 130px; }
.accept-row input[name=note] { width: 220px; }
.accepted { color: var(--ok); font-size: 15px; }
/* payments */
.pay-summary { font-size: 14px; padding-top: 4px; }
.pay-summary.wide { grid-column: 1 / -1; }
.warn-text { color: var(--warn); }
.pay-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.pay-row .btn.primary { width: 100%; }
.tag.pay-ok { background: var(--ok-bg); color: var(--ok); }
.tag.pay-bad { background: var(--bad-bg); color: var(--bad); }
.pay-edit { text-decoration: none; }
.pay-grid { display: grid; gap: 8px; margin: 10px 0; }
.pay-more { margin: 6px 0 4px; font-size: 14px; }
.pay-more summary { cursor: pointer; color: var(--primary); padding: 4px 0; }
.pay-more label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.pay-more input[name] { min-height: 44px; font-size: 16px; }
.pay-methods { margin-top: 8px; }
.pay-methods .chip { gap: 6px; }
.pay-methods .chip input { min-height: 0; width: 16px; height: 16px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .dot { margin-right: 6px; }

.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.map-panel { position: sticky; top: 76px; }
.map { height: 560px; background: var(--surface-2); }
.map.placing { cursor: crosshair; }
.hint { padding: 10px 14px; background: var(--warn-bg); color: var(--warn); font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bulk-bar { position: sticky; top: 60px; z-index: 5; padding: 8px 14px; background: #dbeafe; color: #1e3a8a; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; border-bottom: 1px solid #93c5fd; }
@media (prefers-color-scheme: dark) { .bulk-bar { background: #172554; color: #bfdbfe; border-color: #1e40af; } }
th.pick, td.pick { width: 28px; padding-right: 0; }
td.pick input, th.pick input { width: 17px; height: 17px; min-height: 0; margin: 2px 0 0; cursor: pointer; }
tr.picked td { background: color-mix(in srgb, #3b82f6 12%, transparent); }
.section-title { margin: 20px 0 0; font-size: 18px; }
.transfer-to .chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num { color: var(--muted); font-variant-numeric: tabular-nums; }
tr.st-delivered td { background: color-mix(in srgb, var(--ok-bg) 45%, transparent); }
tr.st-failed td { background: color-mix(in srgb, var(--bad-bg) 45%, transparent); }
.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.status.delivered { background: var(--ok-bg); color: var(--ok); }
.status.failed { background: var(--bad-bg); color: var(--bad); }
/* returns — violet */
.status.returned, .tag.ret { background: #ede9fe; color: #6d28d9; }
.ret-text { color: #7c3aed; }
.ret-btn { color: #7c3aed; }
tr.st-returned td { background: color-mix(in srgb, #ede9fe 45%, transparent); }
.pin.returned { background: #7c3aed; }
.stop.returned { opacity: .7; box-shadow: none; }
.stop.returned .stop-num { background: #7c3aed; }
.ret-type, .ret-reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.ret-type .chip, .ret-reasons .chip { gap: 6px; font-weight: 500; }
.ret-type .chip input, .ret-reasons .chip input { min-height: 0; width: 16px; height: 16px; margin: 0; }
@media (prefers-color-scheme: dark) {
  .status.returned, .tag.ret { background: #2e1065; color: #c4b5fd; }
  .ret-text, .ret-btn { color: #a78bfa; }
}
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

/* map pins */
.pin {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c); color: #fff; font: 700 12px/1 system-ui, sans-serif;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.pin.delivered { opacity: .55; }
.truck {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c); border: 3px solid #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent), 0 2px 6px rgba(0, 0, 0, .35);
}
.truck.stale { filter: grayscale(1); opacity: .6; }
.ok-text { color: var(--ok); }
.gps-bar { background: var(--warn-bg); color: var(--warn); padding: 8px 16px; font-size: 14px; }
.gps-bar.ok { background: var(--ok-bg); color: var(--ok); font-size: 13px; padding: 6px 16px; }
.gps-bar.bad { background: var(--bad-bg); color: var(--bad); }
.photo-dialog img { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; background: var(--surface-2); margin-bottom: 12px; }
.c-form { display: grid; gap: 10px; }
.c-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.c-form input { min-height: 44px; font-size: 16px; }
.couriers-page .hint { border-radius: var(--radius); flex-wrap: wrap; }
.report-presets { margin: 10px 0 4px; }
.pin.depot { width: 30px; height: 30px; border-radius: 8px; background: #111827; font-size: 13px; }
.start-switch { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.shift-row:empty, #v-news:empty { display: none; }
.news { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; border-radius: var(--radius); padding: 12px 14px; font-size: 14px; }
.news-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tag.new { background: #dbeafe; color: #1d4ed8; }
@media (prefers-color-scheme: dark) {
  .news { background: #172554; color: #bfdbfe; border-color: #1e40af; }
  .tag.new { background: #172554; color: #93c5fd; }
}
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; font-weight: 600; }
.check input { width: 18px; height: 18px; min-height: 0; }
.depart-btn { width: 100%; border-color: var(--primary); color: var(--primary); }
.shift-edit { text-decoration: none; font-size: 13px; }
.pin.failed { background: #dc2626; }

/* driver */
.driver { padding: 12px 16px 40px; max-width: 640px; margin: 0 auto; display: grid; gap: 12px; }
.summary {
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 6px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.summary .big-num { margin: 0; }
.summary .progress.wide { grid-column: 1 / -1; }
.summary .empty { border: 0; padding: 8px; }
.row-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.routeinfo { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; font-size: 14px; }
.routeinfo:empty { display: none; }
.driver-map { height: 50vh; min-height: 300px; border-radius: var(--radius); border: 1px solid var(--border); }
.choose { display: grid; gap: 10px; }
.choose-btn { justify-content: flex-start; }

.stops { display: grid; gap: 10px; }
.stop {
  display: grid; grid-template-columns: 36px 1fr; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.stop.delivered, .stop.failed { opacity: .7; box-shadow: none; }
.stop-num {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #fff; font-weight: 700;
}
.stop.delivered .stop-num { background: var(--ok); }
.stop.failed .stop-num { background: var(--bad); }
.stop-body { min-width: 0; }
.stop-client { font-weight: 700; font-size: 16px; }
.stop-addr { margin: 2px 0 4px; }
.stop-meta .amount { color: var(--text); }
.note-box {
  margin: 6px 0; padding: 8px 10px; border-radius: 8px;
  background: var(--warn-bg); color: var(--text); border-left: 4px solid var(--warn);
  font-size: 15px; white-space: pre-line;
}
.note-box b { color: var(--warn); }
.sellers { margin: 4px 0 12px; font-size: 14px; }
.sellers summary { cursor: pointer; color: var(--primary); }
.sellers ul { margin: 6px 0 0; padding-left: 4px; list-style: none; max-height: 200px; overflow: hidden auto; overflow-wrap: anywhere; }
.not-counted { color: var(--muted); font-weight: 400; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.leg { margin: 2px 0 4px; font-size: 13px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.note-inline { margin-top: 4px; padding: 3px 6px; border-radius: 6px; background: var(--warn-bg); font-size: 13px; white-space: pre-line; }
.stop details { margin-top: 6px; font-size: 14px; }
.stop summary { cursor: pointer; color: var(--primary); }
.stop details ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.stop-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.stop-done { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.section-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 0; text-transform: uppercase; letter-spacing: .04em; }

/* dialog */
.dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--border); border-radius: 16px; padding: 18px;
  background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog h2 { margin-bottom: 12px; }
.sheet { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; }
.sheet-title { font-weight: 700; margin-bottom: 8px; }
.sheet-fields { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.sheet-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.preview { margin: 10px 0 0; padding-left: 18px; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 2000; display: flex; gap: 12px; align-items: center;
  max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 12px;
  background: #1f2937; color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); font-size: 14px;
}
.toast button { background: transparent; border: 0; color: #93c5fd; font: inherit; font-weight: 700; cursor: pointer; }

@media (max-width: 600px) {
  .bar { gap: 6px; padding-left: 10px; padding-right: 10px; flex-wrap: nowrap; }
  .bar .btn { flex: none; }
  .bar h1 { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
  .bar .spacer { flex: 1 1 0; }
  .bar select { min-height: 34px; padding: 4px 6px; font-size: 13px; max-width: 120px; }
  .map { height: 380px; }
  .sheet-fields { grid-template-columns: 1fr; }
}

/* ---------- analytics ---------- */
:root { --an-s1: #2a78d6; --an-s2: #eb6834; --an-s3: #4a3aa7; --an-s0: #c3c2b7; --an-grid: #e9eaee; --an-base: #c3c6cd; }
@media (prefers-color-scheme: dark) { :root { --an-s1: #3987e5; --an-s2: #d95926; --an-s3: #9085e9; --an-s0: #4a4f5a; --an-grid: #262a32; --an-base: #3a404c; } }
.an-page { display: grid; gap: 14px; }
.an-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.an-filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.an-filters input[type=date] { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.an-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.an-kpis > div { display: grid; gap: 4px; align-content: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.an-kpis span { font-size: 13px; }
.an-kpis b { font-size: 26px; font-weight: 650; }
.an-kpis small { font-size: 12px; }
.an-kpis .an-hero b { font-size: 48px; line-height: 1; }
.an-card { margin-bottom: 14px; }
.an-card .panel-head h2 { margin: 0; font-size: 16px; }
.an-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); padding: 0 16px; }
.an-legend span { display: inline-flex; align-items: center; gap: 6px; }
.an-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.an-s1 { background: var(--an-s1); fill: var(--an-s1); }
.an-s2 { background: var(--an-s2); fill: var(--an-s2); }
.an-s3 { background: var(--an-s3); fill: var(--an-s3); }
.an-s0 { background: var(--an-s0); fill: var(--an-s0); }
.an-chart { padding: 6px 12px 0; }
.an-chart svg { display: block; overflow: visible; }
.an-grid { stroke: var(--an-grid); stroke-width: 1; }
.an-base { stroke: var(--an-base); stroke-width: 1; }
.an-tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.an-hit { fill: transparent; cursor: default; }
.an-hit.on { fill: var(--text); fill-opacity: .05; }
.an-tip { position: fixed; z-index: 50; pointer-events: none; min-width: 190px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.an-tip b { display: block; margin-bottom: 4px; }
.an-tip div { display: flex; align-items: center; gap: 6px; }
.an-tip div span { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.an-tip .an-tip-sum { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; color: var(--muted); }
.an-table { padding: 8px 16px 12px; }
.an-table summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.an-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.an-two .an-card { margin-bottom: 0; }
.an-two { margin-bottom: 14px; }
.an-bars { display: grid; gap: 8px; padding: 4px 16px 16px; }
.an-bar-row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.an-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-bar-track { display: block; height: 14px; }
.an-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.an-bar-val { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.an-note { padding: 0 16px 12px; margin: 0; }
/* ---------- fleet ---------- */
.f-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
.c-form select { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); min-height: 44px; }
.plate { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; padding: 1px 6px; border: 1.5px solid var(--text); border-radius: 5px; margin-left: 4px; vertical-align: 1px; }
.f-grid > label { min-width: 0; }
.f-grid input, .f-grid select { width: 100%; min-width: 0; box-sizing: border-box; }
.f-grid select { min-height: 0; height: 100%; max-height: 48px; font-size: 16px; }
.f-grid { align-items: end; }

/* ---------- notify client ---------- */
.notify-apps { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.notify-apps .btn { flex: 1 1 110px; }
.notify-field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.notify-field input { font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 8em; }
.notify-field textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); resize: vertical; width: 100%; box-sizing: border-box; font-size: 16px; }
.notify-field input[name=note] { width: 100%; }
.load-addr { font-size: 14px; margin: 2px 0 4px; }
.load-addr .tag { margin-left: 4px; }

/* ---------- points & classes ---------- */
.pt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.pt-head h2 { margin: 0; font-size: 16px; }
.pt-head input[type=search] { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); min-width: 220px; flex: 1 1 220px; }
.pt-select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); max-width: 220px; }
.pt-select.empty-type { border-color: var(--warn); background: var(--warn-bg); }
.pt-heavy { margin: 0; font-weight: 400; white-space: nowrap; }
.pt-types summary { padding: 12px 14px; cursor: pointer; }
.pt-types form { padding: 0 14px 14px; }.rates-dialog { width: min(640px, calc(100vw - 32px)); }
.rates-dialog .f-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.rates-dialog .notify-field input, .rates-dialog .notify-field select { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.warn-news { background: var(--warn-bg); border-color: var(--warn); color: var(--text); margin-top: 8px; }
.warn-news ul { margin: 6px 0; padding-left: 20px; }
.ret-line { display: grid; gap: 2px; margin: 4px 0; }
.ret-line .check { margin: 4px 0; }
.ret-qty { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 28px; font-size: 14px; color: var(--muted); }
.ret-qty input { width: 90px; font: inherit; font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.manager-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.mg-row .f-grid input.empty-type { border-color: var(--warn); background: var(--warn-bg); }

/* ---------- errands ---------- */
.stop.task { border-left: 4px solid #7c3aed; }
.task-box { background: #f3e8ff; border-color: #7c3aed; color: #3b0764; }
.task-tag { background: #f3e8ff; color: #6b21a8; }
@media (prefers-color-scheme: dark) { .task-box { background: #2e1065; color: #e9d5ff; } .task-tag { background: #2e1065; color: #e9d5ff; } }

/* ---------- courier alerts ---------- */
.alert-dialog h2 { font-size: 24px; }
.alert-dialog .alert-lines { margin: 8px 0 16px; padding-left: 20px; font-size: 17px; line-height: 1.45; }
.alert-dialog .alert-lines li { margin: 6px 0; }
.alert-dialog .dialog-actions .btn { width: 100%; }
.notify-mgr { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-weight: 600; }

/* ---------- chat ---------- */
.badge-count { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 18px; }
.chat-page { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 61px); height: calc(100dvh - 61px); max-width: 1200px; margin: 0 auto; }
.chat-rooms { border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.chat-room-btn { display: grid; gap: 2px; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.chat-room-btn:hover { background: var(--surface-2); }
.chat-room-btn.on { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.chat-room-name { font-weight: 600; }
.chat-room-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-room { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-day { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }
.chat-msg { align-self: flex-start; max-width: min(78%, 560px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 8px 12px 6px; }
.chat-msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--primary) 14%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: 14px 14px 4px 14px; }
.chat-from { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.chat-text { white-space: normal; overflow-wrap: anywhere; }
.chat-time { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.chat-ref { font-size: 13px; background: var(--warn-bg); border-radius: 8px; padding: 6px 8px; margin: 4px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-ref.link { cursor: pointer; text-decoration: underline dotted; }
.chat-img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; margin-top: 4px; }
.chat-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.chat-form { border-top: 1px solid var(--border); background: var(--surface); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); max-height: 140px; }
@media (max-width: 860px) {
  .chat-page { grid-template-columns: 1fr; }
  .chat-page.in-room .chat-rooms { display: none; }
  .chat-page:not(.in-room) .chat-room { display: none; }
}.archive-box { align-items: flex-start; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-weight: 400; font-size: 14px; }
.archive-box input { margin-top: 2px; flex: none; }

/* ---------- returns journal ---------- */
.rj-items { margin: 4px 0; padding-left: 18px; font-size: 13px; }
tr.rj-wait td, tr.rj-changed td { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
tr.rj-diff td { background: color-mix(in srgb, var(--bad-bg) 55%, transparent); }
.rj-1c { margin: 0; font-weight: 400; font-size: 13px; }

/* delivery cost («💰 Вартість доставки») */
.cs-in { width: 76px; min-height: 32px; padding: 4px 6px; font-size: 14px; text-align: right; }
.cs-in::placeholder { color: var(--muted); opacity: .8; }
.cs-dialog { width: min(760px, 96vw); }
.cs-big { font-size: 16px; }
#cs-calc-out { line-height: 1.7; margin-top: 4px; }
/* home: menu on the left, today's routes on the right (dispatcher / operator) */
.home-split { display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: 100vh; }
.home-split > .home { margin: 0; max-width: none; min-height: 0; padding: 28px 20px; justify-content: flex-start; border-right: 1px solid var(--border); }
.home-map-panel { position: sticky; top: 0; height: 100vh; box-sizing: border-box; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.home-map-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.home-map-head h2 { margin: 0; font-size: 18px; }
.home-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.home-legend:empty { display: none; }
.home-legend .chip { display: inline-flex; align-items: center; gap: 6px; }
.home-map-box { position: relative; flex: 1; min-height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.home-map-box .map { position: absolute; inset: 0; height: auto; }
.home-map-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 500; background: var(--surface); color: var(--text);
  padding: 14px 18px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; max-width: 80%; }
@media (max-width: 899px) {
  .home-split { grid-template-columns: 1fr; }
  .home-split > .home { border-right: 0; max-width: 420px; margin: 0 auto; width: 100%; box-sizing: border-box; }
  .home-map-panel { position: static; height: auto; padding: 0 16px 24px; }
  .home-map-box { flex: none; height: 380px; }
}
/* return to the depot (dispatcher card toggle, courier note) */
.return-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 13px; }
.return-toggle input { width: 16px; height: 16px; min-height: 0; margin: 0; }
.return-note { margin-top: 6px; }
/* crews of the day (dispatcher) */
.crew-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

/* voice input («🎤») */
.voice-wrap { display: flex; gap: 6px; align-items: stretch; flex: 1; min-width: 0; }
.voice-wrap > input, .voice-wrap > textarea { flex: 1; min-width: 0; }
.mic-btn { flex: none; min-width: 44px; padding: 0 10px; font-size: 18px; }
.mic-btn.rec { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: .55; } }
/* AI conclusions */
.ai-summary { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); line-height: 1.5; }

/* stops that may belong to another driver */
.mis-bar { margin-bottom: 12px; }
.mis-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.mis-actions { display: inline-flex; gap: 6px; margin-left: 6px; flex-wrap: wrap; }

/* dispatcher's assistant */
.ask-dialog { width: min(640px, 96vw); }
.ask-examples { margin: 8px 0; }
.ask-examples .chip { font-size: 12px; }
.ask-answer { margin-top: 10px; }
.ask-result { line-height: 1.6; }
.ask-list { margin: 6px 0; padding-left: 18px; }
.ask-big { font-size: 18px; margin: 4px 0 8px; }

/* offline / pending changes bar */
.net-bar { position: sticky; top: 0; z-index: 1000; padding: 6px 12px; font-size: 13px; text-align: center; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--border); }
.net-bar.off { background: var(--bad-bg); color: var(--bad); }
/* opening hours in the points directory */
.pt-hours input { width: 92px; min-height: 32px; padding: 2px 4px; }

/* courier list: closed stops in place / below */
.done-place { text-align: center; margin: 14px 0 4px; }

/* vehicle documents */
.vdocs-dialog { width: min(760px, 96vw); }
.vdocs-list { display: grid; gap: 12px; margin: 8px 0; }
.vdoc { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.vdoc-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.vdoc-pages { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.vdoc-page { position: relative; }
.vdoc-thumb { width: 88px; height: 64px; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; font-size: 13px; }
.vdoc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vdoc-del { position: absolute; top: -8px; right: -8px; min-width: 24px; min-height: 24px; padding: 0; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 12px; }
.vdoc-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vdoc-edit label.small { display: inline-flex; gap: 4px; align-items: center; }
.vdoc-edit input:not([type=file]) { min-height: 32px; padding: 2px 6px; max-width: 150px; }