:root {
  --green: #1b8a3a;
  --green-dk: #136d2d;
  --green-soft: #e6f4ea;
  --warn: #e0a800;
  --warn-soft: #fdf3d6;
  --red: #d83b3b;
  --red-soft: #fbe4e4;
  --none: #9aa0a6;
  --bg: #f4f5f7;
  --card: #ffffff;
  --surface: #ffffff;
  --field: #ffffff;
  --field-2: #eef0f3;
  --text: #1c2430;
  --muted: #6b7280;
  --border: #e4e7eb;
  --shadow: 0 8px 30px rgba(15, 22, 34, 0.16);
  --radius: 14px;
}

/* Ночная тема — спокойные тёмные поверхности, статусы остаются яркими */
body.theme-dark {
  --green: #2fae54;
  --green-dk: #7fe0a0;
  --green-soft: #16331f;
  --warn: #f0bf3a;
  --warn-soft: #36300f;
  --red: #ef5757;
  --red-soft: #3a1c1c;
  --none: #8a93a3;
  --bg: #0f1622;
  --card: #182233;
  --surface: #182233;
  --field: #202c40;
  --field-2: #243149;
  --text: #e7ecf3;
  --muted: #9aa6b8;
  --border: #2a3850;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

button { font-family: inherit; }

/* ---------- Шапка ---------- */
.topbar {
  flex: 0 0 auto;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) 10px 8px;
  z-index: 1000;
}
.topbar-row { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand-logo { font-size: 24px; }
.brand-text strong { font-size: 16px; display: block; line-height: 1.05; }
.brand-text small { color: var(--muted); font-size: 11px; }

.city-search { flex: 1 1 auto; display: flex; min-width: 0; }
.city-search input {
  flex: 1 1 auto; min-width: 0;
  border: 1.5px solid var(--border); border-right: none;
  border-radius: 10px 0 0 10px;
  padding: 9px 11px; font-size: 14px; outline: none;
  background: var(--field); color: var(--text);
}
.city-search input::placeholder { color: var(--muted); }
.city-search input:focus { border-color: var(--green); }
.city-search button {
  flex: 0 0 auto;
  border: 1.5px solid var(--border); border-left: none;
  background: var(--field); border-radius: 0 10px 10px 0;
  padding: 0 12px; font-size: 16px; cursor: pointer; color: var(--text);
}
.icon-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--field);
  font-size: 17px; cursor: pointer; color: var(--green-dk);
  transition: transform .12s, background .15s;
}
.icon-btn:active { transform: scale(.92); }

.chips-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.chips-row::-webkit-scrollbar { display: none; }
.chips-label { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--field); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.chip.city-chip.active { background: var(--green-dk); border-color: var(--green-dk); }

/* ---------- Карта ---------- */
#map { flex: 1 1 auto; width: 100%; z-index: 1; }

/* Маркеры */
.marker-pin {
  width: 100%; height: 100%; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
  display: grid; place-items: center;
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.m-yes  { background: var(--green); }
.m-warn { background: var(--warn); }
.m-no   { background: var(--red); }
.m-none { background: var(--none); }
.marker-pin.confident { box-shadow: 0 0 0 3px rgba(27,138,58,.35), 0 1px 4px rgba(0,0,0,.4); }
.marker-pin.contested { opacity: .85; }

/* Кластеры */
.cl { border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; border: 3px solid rgba(255,255,255,.85);
  box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.cl-yes { background: rgba(27,138,58,.92); }
.cl-warn { background: rgba(224,168,0,.92); }
.cl-no { background: rgba(216,59,59,.92); }
.cl-none { background: rgba(122,128,134,.92); }

/* ---------- Плавающие элементы ---------- */
.fab-group {
  position: fixed; right: 14px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; z-index: 900;
}
.fab {
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--card); box-shadow: var(--shadow); font-size: 21px;
  cursor: pointer; display: grid; place-items: center;
}

.refuel-bar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  height: 54px; border: none; border-radius: 14px;
  background: var(--green); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 20px rgba(27,138,58,.45);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  z-index: 900;
}
.refuel-bar:active { transform: scale(.99); }
.refuel-ic { font-size: 20px; }

.legend {
  position: fixed; left: 10px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 900;
}
.legend-toggle {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  font-size: 15px; cursor: pointer; display: none;
}
.legend-body {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px;
  font-size: 11.5px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.legend.collapsed .legend-body { display: none; }
.legend.collapsed .legend-toggle { display: grid; place-items: center; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-yes { background: var(--green); }
.dot-warn { background: var(--warn); }
.dot-no { background: var(--red); }
.dot-none { background: var(--none); }

/* ---------- Плашка безопасности ---------- */
.safety {
  position: fixed; left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top) + 8px);
  background: #1c2430; color: #fff; border-radius: 10px;
  padding: 9px 34px 9px 12px; font-size: 13px; z-index: 1700;
  box-shadow: var(--shadow);
}
.safety button {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: #fff; font-size: 14px; cursor: pointer;
}

/* ---------- Нижний лист ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1500; animation: fadeIn .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); color: var(--text);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  z-index: 1600; max-height: 88dvh; overflow-y: auto;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .26s cubic-bezier(.22,1,.36,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; background: #d4d7dc; border-radius: 3px; margin: 6px auto 4px; }
.sheet-close {
  position: absolute; top: 10px; right: 12px; border: none; background: var(--field-2);
  width: 32px; height: 32px; border-radius: 50%; font-size: 14px; cursor: pointer; color: var(--muted);
}
.sheet-body { padding-top: 4px; }

/* ---------- Карточка АЗС ---------- */
.st-name { font-size: 19px; font-weight: 700; margin: 2px 0; padding-right: 28px; }
.st-brand { color: var(--muted); font-size: 13px; }
.st-addr { color: var(--muted); font-size: 13px; margin-top: 4px; }

.status-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 10px; font-weight: 600; margin: 12px 0 4px; font-size: 15px;
}
.sb-yes  { background: var(--green-soft); color: var(--green-dk); }
.sb-warn { background: var(--warn-soft); color: var(--warn); }
.sb-no   { background: var(--red-soft); color: var(--red); }
.sb-none { background: var(--field-2); color: var(--muted); }

.freshline { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.freshline .stale { color: #b06a00; }
.st-meta { font-size: 13px; color: var(--muted); margin: 6px 0; line-height: 1.5; }

/* Бейджи топлива */
.fuel-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.fuel-badge {
  border-radius: 8px; padding: 4px 9px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); background: var(--field-2);
}
.fuel-badge.has { background: var(--green-soft); color: var(--green-dk); border-color: transparent; }
.fuel-badge.no  { background: var(--red-soft); color: var(--red); border-color: transparent; text-decoration: line-through; }

/* Информационная строка «что есть сейчас» (НЕ кнопки) */
.fuel-now { font-size: 13.5px; font-weight: 600; color: var(--green-dk); margin: 8px 0; }
.fuel-now-no { color: var(--red); }

/* Статус ПО КАЖДОМУ топливу (информация, не кнопки) */
.fuel-state { margin: 10px 0 6px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.fs-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.fs-row:last-child { border-bottom: none; }
.fs-name { font-weight: 700; font-size: 14px; }
.fs-val { font-size: 13px; font-weight: 600; text-align: right; }
.fs-yes { color: var(--green-dk); }
.fs-warn { color: var(--warn); }
.fs-no { color: var(--red); }
.fs-stale, .fs-none { color: var(--muted); }

/* Быстрый выбор топлива на карточке + чипы очереди/ожидания */
.fuel-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 8px 0 4px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.fp-chip, .pick-row .chip { flex: 0 0 auto; }
.fp-chip { padding: 9px 15px; font-size: 14px; font-weight: 600; }

/* Быстрые кнопки «в один тап» */
.quick-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0 6px; }
.quick-btn {
  border: none; border-radius: 12px; padding: 14px 6px; font-size: 15px; font-weight: 700;
  cursor: pointer; color: #fff;
}
.q-yes { background: var(--green); }
.q-warn { background: var(--warn); color: #5a4700; }
.q-no { background: var(--red); }
.quick-btn { transition: transform .1s; }
.quick-btn:active { transform: scale(.96); }

/* Подтвердить / оспорить */
.vote-row { display: flex; gap: 8px; margin: 8px 0; }
.vote-btn {
  flex: 1 1 0; border-radius: 11px; padding: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--field); color: var(--text);
  transition: transform .1s;
}
.vote-btn:active { transform: scale(.97); }
.vote-yes { color: var(--green-dk); background: var(--green-soft); border-color: transparent; }
.vote-no { color: var(--red); background: var(--red-soft); border-color: transparent; }
.vote-btn b { font-weight: 800; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; border: none; border-radius: 12px; padding: 13px;
  font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-secondary { background: var(--field-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--green-dk); border: 1px solid var(--green); }
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }

.route-row { display: flex; gap: 8px; }
.section-title { font-weight: 700; font-size: 15px; margin: 16px 0 8px; }
.collapse-link {
  display: inline-block; margin-top: 8px; color: var(--green-dk);
  font-size: 14px; font-weight: 600; cursor: pointer; background: none; border: none;
}

/* ---------- Форма уточнения ---------- */
.form-group { margin: 14px 0; }
.form-group > label.lbl { font-size: 13px; color: var(--muted); display: block; margin-bottom: 7px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 11px;
  text-align: center; cursor: pointer; font-size: 14px; font-weight: 600; user-select: none;
  background: var(--field); color: var(--text); transition: all .12s;
}
.opt input { display: none; }
.opt.sel-fuel { border-color: var(--green); background: var(--green-soft); color: var(--green-dk); }
input[type="number"], textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 11px; font-size: 15px; font-family: inherit; resize: vertical;
  background: var(--field); color: var(--text);
}
input[type="number"]::placeholder, textarea::placeholder { color: var(--muted); }
input[type="number"]:focus, textarea:focus { outline: none; border-color: var(--green); }
textarea { min-height: 56px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* ---------- Список «рядом» ---------- */
.near-sort {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 8px 0 6px; padding-bottom: 2px;
}
.near-sort::-webkit-scrollbar { display: none; }
.sort-chip { flex: 0 0 auto; }
.near-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.near-item:last-child { border-bottom: none; }
.near-dot { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; }
.near-info { flex: 1 1 auto; min-width: 0; }
.near-info .n { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-info .s { font-size: 12px; color: var(--muted); }
.near-fav {
  flex: 0 0 auto; background: none; border: none; font-size: 18px;
  cursor: pointer; color: var(--none); padding: 2px 4px; line-height: 1;
}
.near-fav.on { color: var(--warn); }
.near-dist { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Строка «в избранное» на карточке */
.fav-line {
  display: inline-block; background: none; border: none; cursor: pointer;
  color: var(--green-dk); font-size: 14px; font-weight: 600; padding: 4px 0; margin: 2px 0 4px;
}

/* Тумблер «по талонам» в форме (использует стиль .opt) */
.vouchers-toggle { display: block; }

/* Бейдж-геймификация в «О сервисе» */
.contrib-line { font-size: 14px; font-weight: 700; color: var(--green-dk); margin: 8px 0; }

/* Антимошенническое предупреждение */
.antifraud {
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: 12px; padding: 11px 13px; margin: 12px 0;
}
.antifraud > b { display: block; color: var(--warn); font-size: 15px; margin-bottom: 4px; }
.antifraud p { font-size: 13px; line-height: 1.5; margin: 6px 0 0; color: var(--text); }
.antifraud p b { color: var(--red); }

/* ---------- О сервисе / футер ---------- */
.about h2 { font-size: 19px; margin: 6px 0 10px; }
.about p { font-size: 14px; line-height: 1.55; color: var(--text); margin: 10px 0; }
.about .muted { color: var(--muted); font-size: 13px; }
.about a { color: var(--green-dk); font-weight: 600; }
.about .contacts { font-size: 14px; margin: 10px 0; }
.footer-credit {
  border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px;
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
}
.footer-credit a { color: var(--green-dk); font-weight: 600; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: #1c2430; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 2000; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}

@media (min-width: 720px) {
  .sheet { left: auto; right: 16px; bottom: 16px; width: 400px; border-radius: 18px; max-height: 84dvh; }
  .refuel-bar { left: auto; right: 80px; width: 320px; }
}

/* ---------- MapLibre: маркеры-указатели и точка пользователя ---------- */
.maplibregl-marker { cursor: pointer; }
.user-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(26,115,232,.25);
}

/* ---------- Тёмная тема: контролы MapLibre ---------- */
body.theme-dark .maplibregl-ctrl-group { background: var(--surface); }
body.theme-dark .maplibregl-ctrl-group button { background: var(--surface); }
body.theme-dark .maplibregl-ctrl-group button + button { border-top-color: var(--border); }
body.theme-dark .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) hue-rotate(180deg) brightness(1.1);
}
body.theme-dark .maplibregl-ctrl-attrib {
  background: rgba(24,34,51,.8); color: var(--muted);
}
body.theme-dark .maplibregl-ctrl-attrib a { color: var(--green-dk); }

/* Аккуратное «всплытие» маркеров */
.marker-pin { animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.4); opacity: .2; } to { transform: scale(1); opacity: 1; } }

/* Уважение к настройке «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  .sheet, .overlay, .marker-pin { animation: none !important; }
}
