:root {
  /* Светлая тема (по умолчанию) */
  --bg: #e8ebf0;
  --map-bg: #e4e8ee;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --elev: rgba(255, 255, 255, 0.98);
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.17);
  --divider: rgba(0, 0, 0, 0.075);
  --fill: rgba(0, 0, 0, 0.04);      /* лёгкая заливка на карточках */
  --fill-2: rgba(0, 0, 0, 0.07);
  --fill-3: rgba(0, 0, 0, 0.11);
  --text: #1f2733;
  --muted: #66707f;
  --accent: #3b6cff;
  --accent-weak: rgba(59, 108, 255, 0.12);
  --accent-text: var(--accent-text);
  --ev: #7c3aed; /* электрозарядки — фиолетовый, не путать с топливными цветами */
  --yes: #16a34a;
  --low: #ca8a04;
  --queue: #ea580c;
  --no: #dc2626;
  --unknown: #9aa4b2;
  --shadow: 0 8px 30px rgba(23, 33, 54, 0.16);
  --shadow-sm: 0 2px 12px rgba(23, 33, 54, 0.12);
  --radius: 16px;
  --blur: saturate(120%) blur(14px);
}

/* Тёмная тема — включается data-theme="dark" на <html> */
:root[data-theme="dark"] {
  --bg: #0b0e15;
  --map-bg: #0b0e15;
  --panel: rgba(20, 25, 36, 0.82);
  --panel-solid: #151a26;
  --elev: rgba(30, 37, 52, 0.9);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --divider: rgba(255, 255, 255, 0.07);
  --fill: rgba(255, 255, 255, 0.05);
  --fill-2: rgba(255, 255, 255, 0.09);
  --fill-3: rgba(255, 255, 255, 0.14);
  --text: #e8ecf5;
  --muted: #93a0b8;
  --accent: #5b8cff;
  --accent-weak: rgba(91, 140, 255, 0.16);
  --accent-text: #cfe0ff;
  --yes: #22c55e;
  --low: #eab308;
  --queue: #f97316;
  --no: #ef4444;
  --unknown: #64748b;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

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

button, input { font-family: inherit; }

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--map-bg);
}

/* ---- Стеклянная карточка ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

/* ---- Левый столбец управления ---- */
.controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 300px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Поиск ---- */
.search-card { padding: 11px 12px; z-index: 20; }

.brand { display: flex; align-items: center; gap: 10px; margin: 2px 2px 12px; }
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  flex: none;
  background: linear-gradient(140deg, #6aa0ff, #3457d1);
  box-shadow: 0 0 14px rgba(91, 140, 255, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

.search { position: relative; display: flex; align-items: center; }
.search-ico {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  fill: var(--muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--fill);
  border-radius: 11px;
  padding: 11px 34px 11px 38px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
#search-input::placeholder { color: #6f7c94; }
#search-input:focus {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.08);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.search-clear {
  position: absolute;
  right: 8px;
  width: 22px;
  height: 22px;
  border: none;
  background: var(--fill-2);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { background: var(--fill-3); }
.search-clear.hidden { display: none; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.search-results.hidden { display: none; }
.search-result {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  line-height: 1.35;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--accent-weak); }
.search-result .sr-type { color: var(--muted); font-size: 12px; }
.search-empty { padding: 12px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---- Фильтры ---- */
.filters-card { padding: 15px; z-index: 10; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}
.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* ---- Сворачиваемые карточки (фильтры/сводка) ---- */
.card-head, .sum-head { cursor: pointer; user-select: none; }
.head-title { display: inline-flex; align-items: center; }
.chev {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);        /* вниз = развёрнуто */
  transition: transform 0.18s ease;
  flex: none;
  position: relative;
  top: -1px;
}
.collapsed .chev { transform: rotate(-45deg); }  /* вправо = свёрнуто */
.filters-card.collapsed .filter-group,
.filters-card.collapsed .card-foot { display: none; }
.summary-card.collapsed .sum-list,
.summary-card.collapsed .sum-foot { display: none; }
.summary-card.collapsed .sum-head { margin-bottom: 0; }

.filter-group { margin-top: 13px; }
.filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 9px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--fill);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active {
  background: var(--accent-weak);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.dot-yes { background: var(--yes); }
.dot-low { background: var(--low); }
.dot-queue { background: var(--queue); }
.dot-no { background: var(--no); }
.dot-unknown { background: var(--unknown); }

.card-foot {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--muted);
}
.attrib { margin-top: 6px; font-size: 11px; color: #7b8aa5; }
.attrib a { color: var(--accent); text-decoration: none; }
.attrib a:hover { text-decoration: underline; }

/* ---- Сводка по видимой области ---- */
.summary-card { padding: 15px; }
.summary-card.hidden { display: none; }
.sum-head { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.sum-head .muted { font-weight: 500; font-size: 13px; }
.sum-list { display: flex; flex-direction: column; gap: 2px; }
.sum-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}
.sum-l { display: flex; align-items: center; gap: 9px; }
.sum-l .dot { width: 10px; height: 10px; }
.sum-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-foot {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---- Маркеры и кластеры ---- */
.fuel-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 3px rgba(23, 33, 54, 0.4);
}
.fuel-marker.yes { background: var(--yes); }
.fuel-marker.low { background: var(--low); }
.fuel-marker.queue { background: var(--queue); }
.fuel-marker.no { background: var(--no); }
.fuel-marker.unknown { background: var(--unknown); }
/* approx — оценка по региону (не по этой АЗС): меньше, бледнее, без свечения, чтобы
   реальные per-station отметки визуально «выступали» над оценками. */
.fuel-marker.approx {
  width: 11px;
  height: 11px;
  border-width: 1.5px;
  border-color: rgba(255, 255, 255, 0.4);
  opacity: 0.45;
  box-shadow: none;
}

.me-pin {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3), 0 2px 8px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.me-pin svg { width: 20px; height: 20px; fill: #fff; }

.marker-cluster { background: rgba(91, 140, 255, 0.2); }
.marker-cluster div {
  background: rgba(91, 140, 255, 0.9);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
}

/* ---- Карточка АЗС ---- */
.panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 372px;
  max-width: calc(100vw - 32px);
  z-index: 1100;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  padding: 22px;
  overflow-y: auto;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.panel.hidden { opacity: 0; transform: translateX(12px); pointer-events: none; }
.panel-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 30px;
  height: 30px;
  border: none;
  background: var(--fill-2);
  color: var(--text);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-close:hover { background: var(--fill-3); }

.panel h2 { margin: 2px 44px 2px 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.brand-row { color: var(--muted); margin: 5px 0 16px; font-size: 13px; }

.avail-head { display: flex; align-items: center; gap: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.badge.yes { background: var(--yes); }
.badge.low { background: var(--low); }
.badge.queue { background: var(--queue); }
.badge.no { background: var(--no); }
.badge.unknown { background: var(--unknown); }
/* Оценка по региону в карточке: бейдж полупрозрачный + пунктирная рамка = «не точно». */
.badge.approx { opacity: 0.7; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35); }
.src-note.approx { color: var(--muted); font-style: italic; }

.muted { color: var(--muted); }
.price-list { display: flex; flex-direction: column; gap: 2px; }
.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}
.price-row:last-child { border-bottom: none; }
.price-row .pv { font-weight: 600; font-variant-numeric: tabular-nums; }
.src-note { margin-top: 7px; font-size: 12px; color: var(--muted); }
.src-note a { color: var(--accent); text-decoration: none; }
.src-note a:hover { text-decoration: underline; }

.report-q { margin-top: 16px; font-size: 12px; color: var(--muted); }
.report-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.rep-btn {
  flex: 1 1 auto;
  border: 1px solid var(--border);
  background: var(--fill);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.rep-btn:hover { transform: translateY(-1px); }
.rep-yes:hover { border-color: var(--yes); color: var(--yes); background: rgba(34, 197, 94, 0.14); }
.rep-low:hover { border-color: var(--low); color: var(--low); background: rgba(234, 179, 8, 0.14); }
.rep-queue:hover { border-color: var(--queue); color: var(--queue); background: rgba(249, 115, 22, 0.14); }
.rep-no:hover { border-color: var(--no); color: var(--no); background: rgba(239, 68, 68, 0.14); }

.fuel-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ftag {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.section-title {
  margin: 20px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.meta { margin-top: 18px; font-size: 13px; color: var(--muted); line-height: 1.7; }

/* ---- Контролы Leaflet ---- */
.leaflet-control-zoom,
.locate-btn {
  border: 1px solid var(--border) !important;
  border-radius: 11px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.leaflet-control-zoom a,
.locate-btn {
  width: 38px;
  height: 38px;
  line-height: 38px;
  font-size: 19px;
  color: var(--text);
  background: var(--panel-solid);
  border: none;
  text-align: center;
}
.leaflet-control-zoom a:first-child { border-bottom: 1px solid var(--border); }
.leaflet-control-zoom a:hover,
.locate-btn:hover { background: var(--fill-2); color: var(--accent); }
.locate-btn { display: block; cursor: pointer; padding: 0; margin-top: 8px; font-size: 20px; }
.leaflet-bar { border: none; }
.leaflet-control-attribution {
  background: rgba(11, 14, 21, 0.75) !important;
  color: #7b8aa5 !important;
  border-radius: 8px 0 0 0;
  font-size: 11px;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

/* ---- Мобильная адаптация ---- */
@media (max-width: 820px) {
  .controls {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: auto;
    width: min(calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)), 420px);
    max-width: none;
    /* стек (поиск+фильтры+сводка) не должен уходить за низ экрана и стать недоступным */
    max-height: calc(100% - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .controls::-webkit-scrollbar { width: 0; height: 0; }
  /* карточка АЗС — нижний лист, с отступом под «домашнюю полоску» iPhone */
  .panel {
    top: auto;
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 62%;
    padding: 18px;
  }
  .panel.hidden { transform: translateY(14px); }
  /* чуть компактнее, чтобы на маленьком экране оставалось видно карту */
  .search-card { padding: 12px; }
  .filters-card, .summary-card { padding: 13px; }
  .filter-group { margin-top: 11px; }
  /* кнопки отметки — крупнее под палец + отклик на тап (на тач нет :hover) */
  .rep-btn { padding: 11px 10px; }
  .rep-btn:active { transform: scale(0.97); }
  .chip:active { border-color: var(--accent); }
}

/* Контролы зума/геолокации в левом-нижнем — над «домашней полоской» на мобильных */
@media (max-width: 820px) {
  .leaflet-bottom.leaflet-left { margin-bottom: env(safe-area-inset-bottom); }
}

/* ---- Кнопка «?» и подсказка легенды ---- */
.theme-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--fill);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.theme-btn:hover { color: var(--text); border-color: var(--accent); }
/* В Telegram контролы уходят под шапку мини-аппа */
.in-telegram .controls { top: calc(12px + var(--tg-top, 0px)); }
.help-btn {
  margin-left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--fill);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.help-btn:hover { color: var(--text); border-color: var(--accent); }
.filter-note { margin-top: 9px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ---- FAB «Где заправиться» ---- */
.nearby-btn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(140deg, #6aa0ff, #3457d1);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(52, 87, 209, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.nearby-btn:hover { box-shadow: 0 10px 30px rgba(52, 87, 209, 0.62); }
.nearby-btn:active { transform: translateX(-50%) scale(0.97); }
.nearby-btn:disabled { opacity: 0.7; cursor: default; }
.nearby-btn .nb-ico { font-size: 16px; }

/* ---- Список ближайших АЗС ---- */
.nb-list { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 6px; }
.nb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.nb-item:hover { border-color: var(--accent); background: var(--accent-weak); }
.fuel-marker.nb-dot { position: static; flex: none; width: 13px; height: 13px; box-shadow: none; }
.nb-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nb-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-dist { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; flex: none; }
.nb-dist small { font-weight: 400; color: var(--muted); font-size: 11px; }

/* ---- Маршрут в навигатор ---- */
.route-row { display: flex; gap: 8px; margin-top: 12px; }
.route-btn {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.route-btn:hover { background: rgba(91, 140, 255, 0.24); }
.route-btn.alt { flex: 0 0 auto; border-color: var(--border-strong); background: var(--fill); color: var(--text); }

/* ---- Онбординг / легенда ---- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 9, 15, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.intro.hidden { display: none; }
.intro-card {
  max-width: 400px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.intro-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.intro-card h3 { margin: 0 0 6px; font-size: 19px; }
.intro-lead { margin: 0 0 6px; color: var(--text); font-size: 14px; }
.lg-sec {
  margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 700;
}
.intro .legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.intro .legend li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.intro .legend b { color: var(--text); font-weight: 650; }
.intro .legend.plain li { display: list-item; margin-left: 18px; }
.lg-ev { width: 13px; height: 13px; border-radius: 4px; flex: none; background: var(--ev); border: 2px solid #fff; align-self: center; }
.lg-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid rgba(255, 255, 255, 0.9); align-self: center; }
.lg-dot.yes { background: var(--yes); }
.lg-dot.low { background: var(--low); }
.lg-dot.queue { background: var(--queue); }
.lg-dot.no { background: var(--no); }
.lg-dot.unknown { background: var(--unknown); }
.lg-dot.faded { background: var(--yes); opacity: 0.4; border-color: rgba(255, 255, 255, 0.4); }
.intro-card .muted { font-size: 13px; margin: 0 0 18px; line-height: 1.5; }
.intro-ok {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(140deg, #6aa0ff, #3457d1);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.intro-ok:active { transform: scale(0.99); }

/* FAB прячем, когда открыта панель (иначе на мобиле лист/карточка её перекрывает частично) */
@media (max-width: 820px) {
  .nearby-btn { bottom: calc(14px + env(safe-area-inset-bottom)); padding: 12px 18px; }
}

/* ---- Тумблер режима: Бензин / Электро / Оба ---- */
.mode-toggle {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.mode-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--accent); color: #fff; }
.mode-btn[data-mode="ev"].active { background: var(--ev); }
.mode-btn[data-mode="both"].active { background: linear-gradient(90deg, var(--accent), var(--ev)); }

/* ---- Кнопки-триггеры (Фильтры / Сводка) ---- */
.ctrl-actions { display: flex; gap: 8px; }
.ctrl-btn {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.ctrl-btn:hover { border-color: var(--accent); }
.ctrl-btn:active { transform: scale(0.98); }

/* ---- Выдвижные шторки (фильтры слева, сводка справа) ---- */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(86vw, 320px);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
}
.drawer-left { left: 0; border-right: 1px solid var(--border); transform: translateX(-102%); }
.drawer-right { right: 0; border-left: 1px solid var(--border); transform: translateX(102%); }
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  padding-top: calc(14px + env(safe-area-inset-top) + var(--tg-top, 0px));
}
.drawer-title { font-weight: 700; font-size: 16px; }
.drawer-head-actions { display: inline-flex; align-items: center; gap: 14px; }
.drawer-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.drawer-close:hover { color: var(--text); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.drawer-hint { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(0, 0, 0, 0.35);
}
.drawer-backdrop.hidden { display: none; }

/* ---- Маркер зарядки ЭВ: квадрат + молния, фиолетовый ---- */
.ev-marker {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--ev);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(23, 33, 54, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ev-marker svg { width: 12px; height: 12px; fill: #fff; }
.ev-marker.ev-off { background: #9aa4b2; opacity: 0.9; }   /* не работает — серый */
.ev-marker.ev-unk { opacity: 0.5; }                        /* статус неизвестен — бледный */
.ev-status {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.ev-status.ok { background: var(--yes); }
.ev-status.off { background: var(--no); }
.ev-status.unk { background: var(--unknown); }
.ev-cluster {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(124, 58, 237, 0.9);
  border: 2px solid #fff;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5);
}
.ev-tag {
  display: inline-block;
  background: var(--ev);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---- Опрос после заправки ---- */
.ask-report {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 1300;
  width: min(calc(100vw - 24px), 420px);
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  animation: ask-in 0.22s ease;
}
@keyframes ask-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .ask-report { animation: none; } }
.ask-close {
  position: absolute; top: 8px; right: 10px;
  border: none; background: none; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.ask-title { font-weight: 700; font-size: 15px; margin-right: 22px; }
.ask-sub { font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; }
