:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --car: #e11d48;
  --top: #1f2937;
  --radius: 14px;
  --tabbar-h: 68px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: var(--top); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; }
.stats { flex: 1; font-size: 13px; opacity: .75; }
.user-btn {
  background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 20px;
  padding: 6px 12px; font-size: 14px; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

main { padding: 14px 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
main.full { padding: 0; max-width: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600; gap: 2px;
}
.tabbar a span { font-size: 24px; line-height: 1; }
.tabbar a.active { color: var(--accent); }
.tabbar a.primary { color: #fff; background: var(--accent); margin: 8px 4px; border-radius: 14px; }
.tabbar a.primary.active { background: var(--accent-2); }

h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 15px; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%236b7280' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
input, textarea, select {
  width: 100%; font: inherit; padding: 13px 14px;
  border: 2px solid var(--line); border-radius: 12px; background-color: #fff; color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
.plate-input {
  font-size: 28px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase;
  text-align: center; font-family: "Roboto Mono", ui-monospace, Consolas, monospace;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; margin-top: 12px;
  font: inherit; font-weight: 700; font-size: 17px;
  border: 0; border-radius: 12px; background: var(--accent); color: #fff; cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.ok { background: var(--ok); }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.big { padding: 20px; font-size: 19px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.search-box { position: relative; }
.search-box input { padding-left: 46px; }
.search-box::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 20px; }

.seg { display: flex; background: #e5e7eb; border-radius: 10px; padding: 3px; margin: 10px 0; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); padding: 10px; text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.row img, .row .noimg { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; background: #e5e7eb; flex: none; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.row .info { flex: 1; min-width: 0; }
.row .go { font-size: 22px; color: var(--muted); }

.plate {
  display: inline-block; font-family: "Roboto Mono", ui-monospace, Consolas, monospace;
  font-weight: 800; letter-spacing: 1px; font-size: 19px;
  border: 2px solid #111; border-radius: 6px; padding: 1px 8px; background: #fff; color: #111;
}
.plate.lg { font-size: 26px; padding: 2px 12px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: #e5e7eb; color: var(--muted); vertical-align: middle; }
.badge.released { background: #fef3c7; color: #92400e; }
.badge.zone { background: #dbeafe; color: #1e40af; }
/* Авто без гос. номера — опознаётся по последним 5 символам VIN */
.plate.vin { border-style: dashed; border-color: #7c3aed; color: #4c1d95; }
.plate .vin-tag { font-size: .55em; font-weight: 700; letter-spacing: 0; vertical-align: middle; margin-right: 4px; color: #7c3aed; }
.badge.vin { background: #ede9fe; color: #5b21b6; font-family: "Roboto Mono", ui-monospace, Consolas, monospace; }
.or-sep { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; margin: 10px 0 -4px; }
.vin-input { letter-spacing: 6px; }

.gps {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  background: #fef3c7; color: #78350f; font-weight: 600;
}
.gps.good { background: #dcfce7; color: #14532d; }
.gps.bad { background: #fee2e2; color: #7f1d1d; }
.gps .dot { width: 14px; height: 14px; border-radius: 50%; background: currentColor; flex: none; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.photos .ph { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; background: #e5e7eb; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; }

.warn-box { background: #fef3c7; color: #78350f; border-radius: 12px; padding: 12px 14px; margin-top: 10px; font-size: 15px; }
.warn-box a { font-weight: 700; }

/* --- Экран навигации к авто --- */
.nav-wrap { position: relative; height: 60vh; height: 60dvh; min-height: 320px; }
.nav-wrap.fullh { height: calc(100vh - 52px - var(--tabbar-h) - env(safe-area-inset-bottom)); height: calc(100dvh - 52px - var(--tabbar-h) - env(safe-area-inset-bottom)); }
.hide-labels .leaflet-tooltip.mini-lbl { display: none; }
.nav-wrap .map { position: absolute; inset: 0; }
.map { width: 100%; height: 100%; background: #ddd; }
.nav-panel {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 500;
  background: rgba(255,255,255,.96); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  display: flex; align-items: center; gap: 12px;
}
.arrow-box { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.arrow-box svg { width: 40px; height: 40px; transition: transform .25s linear; }
.nav-panel .dist { font-size: 30px; font-weight: 800; line-height: 1.1; }
.nav-panel .sub { font-size: 13px; color: var(--muted); }
.nav-panel .grow { flex: 1; min-width: 0; }
.nav-panel.near { background: #dcfce7; }
.map-btns { position: absolute; right: 10px; bottom: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.map-btns button {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff; font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.sheet-btn {
  position: absolute; left: 10px; bottom: 16px; z-index: 500;
  background: #fff; border: 0; border-radius: 26px; padding: 0 18px; height: 52px; font: inherit; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* Маркеры */
.car-pin { position: relative; }
.car-pin .pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: var(--car);
  transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  position: absolute; left: 0; top: 0;
}
.car-pin .lbl {
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: #fff; border: 2px solid #111; border-radius: 5px; padding: 0 5px;
  font: 800 13px ui-monospace, Consolas, monospace; color: #111;
}
.me-dot { width: 20px; height: 20px; border-radius: 50%; background: #16a34a; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(22,163,74,.45), 0 2px 6px rgba(0,0,0,.4); }
.corner {
  width: 30px; height: 30px; border-radius: 50%; background: #facc15; color: #111; border: 3px solid #111;
  display: flex; align-items: center; justify-content: center; font: 800 14px system-ui, sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.walk-bar { position: absolute; left: 10px; right: 10px; bottom: 16px; z-index: 500; display: flex; gap: 8px; align-items: stretch; }
.walk-bar .btn { margin-top: 0; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.walk-bar .btn.big { padding: 14px; }
.walk-bar .btn.secondary { background: #fff; }
.walk-bar .btn.danger { background: #fff; }
.badge.good { background: #dcfce7; color: #14532d; }
.admin-link { text-decoration: none; font-size: 20px; padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,.12); }
.mini-lbl { background: #fff; border: 1px solid #333; border-radius: 4px; padding: 0 4px; font: 700 11px ui-monospace, Consolas, monospace; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 6000;
  opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 4000; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; }

.hist { font-size: 14px; border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.hint { font-size: 14px; color: var(--muted); margin-top: 6px; }
.center { text-align: center; }
/* --- Камера --- */
.cam { position: fixed; inset: 0; z-index: 5000; background: #000; color: #fff; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: camflash .25s ease-out; }
@keyframes camflash { 0% { opacity: .85; } 100% { opacity: 0; } }
.cam-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(12px + env(safe-area-inset-top)) 14px 12px; background: linear-gradient(rgba(0,0,0,.65), transparent); text-align: center; }
.cam-label { font-size: 17px; line-height: 1.35; text-shadow: 0 1px 3px #000; }
.cam-recog { display: inline-block; margin-top: 8px; padding: 6px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; background: rgba(255,255,255,.9); color: #111; }
.cam-recog.ok { background: rgba(220,252,231,.95); color: #14532d; }
.cam-recog.bad { background: rgba(254,243,199,.95); color: #78350f; }
.cam-torch { position: absolute; right: 14px; top: calc(110px + env(safe-area-inset-top)); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); font-size: 22px; }
.cam-torch.on { background: #facc15; }
.cam-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; background: linear-gradient(transparent, rgba(0,0,0,.7));
}
.cam-thumbs { position: relative; width: 96px; height: 64px; display: flex; align-items: center; }
.cam-thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 2px solid #fff; margin-right: -18px; }
.cam-count { position: absolute; right: 0; top: -6px; background: #2563eb; color: #fff; border-radius: 12px; padding: 1px 8px; font-weight: 800; font-size: 14px; }
.cam-shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.35); flex: none; }
.cam-shutter:active { background: #fff; transform: scale(.94); }
.cam-done { width: 96px; height: 52px; border: 0; border-radius: 26px; background: #16a34a; color: #fff; font: 700 16px system-ui, sans-serif; }
.link-btn { display: block; margin: 10px auto 0; background: none; border: 0; color: var(--accent); font: inherit; font-size: 15px; text-decoration: underline; }
.first-hint { background: #dbeafe; color: #1e3a8a; border-radius: 12px; padding: 11px 14px; font-size: 15px; }
.photos .ph .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(37,99,235,.92); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.recog { margin-top: 10px; padding: 11px 14px; border-radius: 12px; font-size: 15px; font-weight: 600; background: #e5e7eb; color: #374151; }
.recog.ok { background: #dcfce7; color: #14532d; }
.recog.bad { background: #fef3c7; color: #78350f; }
.plate-input.auto { border-color: var(--ok); background: #f0fdf4; }
.plate-input.need { border-color: var(--danger); background: #fef2f2; }
.warn-box.bad { background: #fee2e2; color: #7f1d1d; font-weight: 600; }
.big-ok { font-size: 64px; line-height: 1; margin: 6px 0 4px; }
.added .photos { margin-top: 14px; }
/* --- Торги --- */
.badge.lot.active { background: #ffedd5; color: #9a3412; }
.badge.lot.won { background: #fee2e2; color: #991b1b; }
.lot-card { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: var(--radius); padding: 12px 14px; margin-top: 10px; border-left: 5px solid #9ca3af; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.lot-card.active { border-left-color: #f97316; background: #fff7ed; }
.lot-card.won { border-left-color: #dc2626; background: #fef2f2; }
.lot-row { border-left: 5px solid #9ca3af; }
.lot-row.active { border-left-color: #f97316; }
.lot-row.won { border-left-color: #dc2626; }
.lot-name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lot-car .pick { width: 26px; height: 26px; flex: none; accent-color: var(--ok); }
.lot-car .pick-done { width: 26px; text-align: center; color: var(--ok); font-weight: 800; flex: none; }
.lot-car.done { opacity: .6; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #9ca3af; }
.map-legend { position: absolute; left: 10px; bottom: 22px; z-index: 500; background: rgba(255,255,255,.92); border-radius: 10px; padding: 5px 10px; margin: 0; color: #374151; }
.chip { flex: none; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 20px; }
.chip.on { border-color: #f97316; background: #ffedd5; }
