:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f0f1f4;
  --border: #dfe1e6;
  --text: #1c1f23;
  --text-muted: #6b7280;
  --accent: #1f8a70;
  --accent-soft: #e5f4ef;
  --danger: #b04a3a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #1e2126;
    --surface-muted: #24282e;
    --border: #32373f;
    --text: #e8eaed;
    --text-muted: #9aa2ad;
    --accent: #35b894;
    --accent-soft: #1b332c;
    --danger: #d9705c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* Синхронизируем нативные контролы (select, скроллбары) с нашей темой. */
:root { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* --- Шапка --- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.topbar__meta {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
}

.topbar__controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.field { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.field__label { color: var(--text-muted); }

select, .button {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.button:hover, select:hover { border-color: var(--accent); }

.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* --- Фильтр по топливу --- */

.fuels {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}


.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  /* Кнопки не наследуют color — задаём явно, иначе в тёмной теме браузер
     подставит системный тёмный текст на тёмном фоне. */
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, background .12s;
}

.chip:hover { border-color: var(--accent); }

.chip--active {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

.chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  align-self: center;
}

.chip__count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip--active .chip__count { color: var(--accent); }
.chip__count--zero { color: var(--danger); }

/* --- Раскладка --- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 0;
}

.map-pane { min-height: 0; }
#map { width: 100%; height: 100%; background: var(--surface-muted); }

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.list-pane__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
}

.list-pane__hint { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.stations {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.station {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.station:hover { background: var(--surface-muted); }
.station--active { background: var(--accent-soft); }

.station__name { font-weight: 600; font-size: 14px; }
.station__address { color: var(--text-muted); font-size: 12.5px; margin-top: 1px; }

.station__fuels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.station__updated {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.station__hint {
  margin-top: 7px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text);
}

/* --- Бейдж топлива --- */

.fuel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
}

.fuel--available {
  border-color: transparent;
  font-weight: 650;
}

.fuel--out {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: .8;
}

/* Лукойл: ассортимент без наличия — нейтральный серый со знаком вопроса. */
.fuel--unknown {
  background: transparent;
  color: var(--text-muted);
  border-style: dashed;
  border-color: var(--border);
  font-weight: 600;
}

.fuel__price { font-variant-numeric: tabular-nums; opacity: .92; }
.fuel__truck { font-size: 11px; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.empty--note {
  padding: 11px 16px;
  text-align: left;
  color: var(--text);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}

/* --- Попап карты --- */

/* Атрибуцию оставляем (лицензия), но делаем незаметной. */
.maplibregl-ctrl-attrib {
  font-size: 9px;
  opacity: .6;
}
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(255, 255, 255, .7); }

/* Попап всегда на светлом фоне — фиксируем тёмный текст, иначе в тёмной теме
   он наследует светлый цвет и тонет на белом. */
.maplibregl-popup { z-index: 100; }
.maplibregl-popup-content {
  margin: 0;
  padding: 12px 14px;
  min-width: 210px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .18);
  color: #1c1f23;
}
.popup__name { font-weight: 650; font-size: 14px; color: #1c1f23; }
.popup__address { color: #5b6472; font-size: 12.5px; margin: 2px 0 8px; }
.popup__fuels { display: flex; flex-wrap: wrap; gap: 5px; }
.popup__mode { margin-top: 8px; font-size: 12px; color: #5b6472; }
.popup__updated { margin-top: 4px; font-size: 11.5px; color: #5b6472; }
.popup__route { display: inline-block; margin-top: 8px; font-size: 12.5px; }
/* В попапе (всегда светлом) бейджи «нет»/ассортимент — тёмным, не цветом темы. */
.maplibregl-popup .fuel--out,
.maplibregl-popup .fuel--unknown { color: #5b6472; border-color: #d7dbe0; }
.maplibregl-popup .popup__dead { color: #c0392b; }

.marker {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  cursor: pointer;
  box-sizing: border-box;
}

/* Делёный блип: ровный круг, секторы conic-gradient не должны вращаться. */
.marker--pie {
  border-radius: 50%;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Знак вопроса на блипе Лукойла — наличие недостоверно. */
.marker__q {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

/* Нерабочая АЗС — маленькая тусклая точка без обводки. */
.marker--dead {
  border-width: 1px;
  border-color: rgba(255, 255, 255, .7);
  box-shadow: none;
  opacity: .85;
}

.popup__dead, .station__dead {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
}

/* Плашка про localStorage. */
.cookie {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(16, 24, 40, .18);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
}

.cookie .button { flex: 0 0 auto; }

/* display:flex выше перебивает атрибут [hidden] — возвращаем ему силу. */
.cookie[hidden] { display: none; }

@media (max-width: 900px) {
  body { overflow: auto; height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .map-pane { height: 55vh; }
  .list-pane { border-left: none; border-top: 1px solid var(--border); }
  .stations { overflow-y: visible; }
}
