:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --divider: #f0f1f4;
  --accent: #2563eb;
  --accent-weak: #eff4ff;
  --low: #16a34a;
  --medium: #f59e0b;
  --high: #ef4444;
  --shadow: 0 8px 30px rgba(17, 24, 39, 0.12);
  --shadow-sm: 0 2px 10px rgba(17, 24, 39, 0.10);
  --radius: 14px;
}

* { 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;
}

button, input { font-family: inherit; }

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #e8eaed;
}

/* ---- Общая карточка ---- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 2px 11px;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  flex: none;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  box-shadow: inset 0 0 0 2px 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: 11px;
  width: 18px;
  height: 18px;
  fill: var(--muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  border: 1px solid var(--border);
  background: #f9fafb;
  border-radius: 10px;
  padding: 10px 34px 10px 36px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
#search-input::placeholder { color: #9ca3af; }
#search-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.search-clear {
  position: absolute;
  right: 8px;
  width: 22px;
  height: 22px;
  border: none;
  background: #e5e7eb;
  color: #4b5563;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { background: #d1d5db; }
.search-clear.hidden { display: none; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  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: 14px; 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; }

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

.card-foot {
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--muted);
}

/* ---- Маркеры и кластеры ---- */
.fuel-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.fuel-marker.low { background: var(--low); }
.fuel-marker.medium { background: var(--medium); }
.fuel-marker.high { background: var(--high); }

.marker-cluster { background: rgba(37, 99, 235, 0.18); }
.marker-cluster div {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
}

/* ---- Карточка АЗС ---- */
.panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 360px;
  max-width: calc(100vw - 32px);
  z-index: 1100;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  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: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: #f3f4f6;
  color: #4b5563;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-close:hover { background: #e5e7eb; }

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.badge.low { background: var(--low); }
.badge.medium { background: var(--medium); }
.badge.high { background: var(--high); }

.section-title {
  margin: 20px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.fuel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.fuel-row:last-child { border-bottom: none; }
.fuel-name { font-weight: 600; font-size: 14px; }
.fuel-right { display: flex; align-items: center; gap: 10px; }
.fuel-price { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.avail {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 7px;
}
.avail.yes { background: #e7f6ec; color: var(--low); }
.avail.low { background: #fef3d8; color: #b45309; }
.avail.no { background: #fde8e8; color: var(--high); }

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

/* ---- Контролы Leaflet ---- */
.leaflet-control-zoom {
  border: none !important;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.leaflet-control-zoom a {
  width: 36px;
  height: 36px;
  line-height: 36px;
  font-size: 20px;
  color: #374151;
  background: #fff;
  border: none;
}
.leaflet-control-zoom a:first-child { border-bottom: 1px solid var(--border); }
.leaflet-control-zoom a:hover { background: #f3f4f6; color: var(--text); }
.leaflet-bar { border: none; }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.8) !important;
  border-radius: 6px 0 0 0;
  font-size: 11px;
}

/* ---- Мобильная адаптация ---- */
@media (max-width: 820px) {
  .controls { top: 12px; left: 12px; right: 12px; width: auto; max-width: none; }
  .panel {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 58%;
  }
  .panel.hidden { transform: translateY(14px); }
}
