:root {
  --bg: #f0f1f5;
  --surface: #ffffff;
  --surface2: #f4f5f9;
  --border: #e2e4ed;
  --accent: #c8102e;
  --accent2: #0066cc;
  --text: #111827;
  --text2: #6b7280;
  --red: #c8102e;
  --green: #059669;
  --orange: #d97706;
  --panel-w: 320px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Source Sans 3', sans-serif; background: var(--bg); color: var(--text); height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.app-body { flex: 1; display: flex; overflow: hidden; }

.panel-info-strip {
  padding: 7px 16px; font-size: 12px; color: var(--text2);
  background: var(--surface2); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.panel-info-strip-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.panel-info-strip .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.panel {
  width: var(--panel-w); min-width: var(--panel-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: 500;
}

.panel-section { padding: 16px; border-bottom: 1px solid var(--border); }
.panel-label { font-family: 'Barlow Condensed', sans-serif; font-size: 13px; font-weight: 700; color: var(--text2); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 10px; }

.fuel-tabs { display: flex; flex-direction: column; gap: 4px; }
.fuel-tabs-always { margin-bottom: 4px; }
.fuel-row { display: flex; gap: 4px; }
.fuel-tab {
  flex: 1;
  padding: 7px 6px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer;
  font-family: 'Source Sans 3', sans-serif; font-size: 13px; font-weight: 500;
  transition: all 0.15s; text-align: center; white-space: nowrap;
}
.fuel-tab:hover { border-color: #3effd0; color: #111; background: rgba(62,255,208,0.12); }
.fuel-tab.active { background: #3effd0; border-color: #3effd0; color: #000; font-weight: 600; }

.panel-collapse-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0; margin: 0 0 10px 0;
  border: none; background: transparent; cursor: pointer;
  font: inherit; text-align: left;
}
.panel-collapse-toggle .panel-label { margin-bottom: 0; flex: 1; }
.panel-collapse-chevron {
  flex-shrink: 0; margin-left: 10px; font-size: 11px;
  color: var(--text2); transition: transform 0.2s ease; line-height: 1;
}
.panel-collapse-toggle[aria-expanded="true"] .panel-collapse-chevron { transform: rotate(180deg); }
.panel-collapse-body[hidden] { display: none !important; }
.panel-collapse-toggle:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 4px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat-box { background: var(--surface2); border-radius: 8px; padding: 10px 8px; text-align: center; border: 1px solid var(--border); }
.stat-val { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 700; color: var(--accent); }
.stat-lbl { font-size: 12px; color: var(--text2); margin-top: 2px; }
.stat-box.min .stat-val { color: var(--green); }
.stat-box.max .stat-val { color: var(--red); }

.legend-bar { height: 10px; border-radius: 5px; background: linear-gradient(to right, #15803d, #4ade80, #fb923c, #fca5a5, #b91c1c); margin-bottom: 6px; }
.legend-labels { display: flex; justify-content: space-between; font-family: 'Barlow Condensed', sans-serif; font-size: 12px; color: var(--text2); }

.filter-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.filter-label { font-size: 14px; color: var(--text2); }
.filter-input {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 5px 10px; font-size: 14px; font-family: 'Source Sans 3', sans-serif;
  width: 160px;
}
.filter-input:focus { outline: none; border-color: var(--accent); }
.toggle-24h { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-switch { width: 36px; height: 20px; border-radius: 10px; background: var(--border); position: relative; transition: background 0.2s; }
.toggle-switch.on { background: var(--accent2); }
.toggle-switch::after { content: ''; width: 14px; height: 14px; background: white; border-radius: 50%; position: absolute; top: 3px; left: 3px; transition: left 0.2s; }
.toggle-switch.on::after { left: 19px; }

.station-list-header { padding: 12px 16px 8px; font-family: 'Barlow Condensed', sans-serif; font-size: 13px; color: var(--text2); letter-spacing: 0.1em; text-transform: uppercase; }
.station-list { flex: 1; overflow-y: auto; }
.station-list::-webkit-scrollbar { width: 4px; }
.station-list::-webkit-scrollbar-track { background: transparent; }
.station-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.station-item {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s; display: flex; align-items: center; gap: 10px;
}
.station-item:hover { background: var(--surface2); }
.station-item.selected { background: var(--surface2); border-left: 3px solid var(--accent); }
.station-rank { font-family: 'Barlow Condensed', sans-serif; font-size: 12px; color: var(--text2); width: 20px; flex-shrink: 0; }
.station-info { flex: 1; min-width: 0; }
.station-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-loc { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-price { font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; flex-shrink: 0; }

.leaflet-tooltip {
  background: var(--text) !important; color: var(--surface) !important;
  border: none !important; border-radius: 6px !important;
  font-family: 'Source Sans 3', sans-serif; font-size: 13px !important;
  padding: 5px 9px !important; box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
  white-space: nowrap;
}
.leaflet-tooltip::before { display: none !important; }

.map-wrap { flex: 1; position: relative; min-width: 0; min-height: 0; }
.map-wrap #map { position: absolute; inset: 0; width: 100%; height: 100%; }
.leaflet-container { background: #e5e3df; }

.map-zoom-block {
  position: absolute; inset: 0; z-index: 650;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.map-zoom-block[hidden] { display: none !important; }
.map-zoom-overlay { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.52); pointer-events: none; }
.map-zoom-dialog {
  position: relative; z-index: 1;
  max-width: min(440px, calc(100% - 28px)); margin: 14px;
  padding: 20px 22px; background: var(--surface);
  border-radius: 12px; border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22); pointer-events: auto;
}
.map-zoom-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 12px;
}
.map-zoom-text { font-size: 14px; line-height: 1.5; color: var(--text2); margin-bottom: 10px; }
.map-zoom-text:last-child { margin-bottom: 0; }
.map-zoom-text strong { color: var(--text); }

.leaflet-popup-content-wrapper {
  background: var(--surface) !important; color: var(--text) !important;
  border: 1px solid var(--border) !important; border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content { margin: 14px 16px !important; min-width: 200px; }
.popup-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.popup-addr { font-size: 13px; color: var(--text2); margin-bottom: 10px; line-height: 1.4; }
.popup-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.popup-price-item { background: var(--surface2); border-radius: 6px; padding: 6px 8px; }
.popup-price-btn {
  border: 1px solid var(--border); cursor: pointer; text-align: left; font: inherit; color: inherit;
  width: 100%; transition: border-color 0.12s, box-shadow 0.12s;
}
.popup-price-btn:hover { border-color: #3effd0; background: rgba(62,255,208,0.08); }
.popup-price-btn.selected { border: 2px solid #3effd0; padding: 5px 7px; box-shadow: 0 0 0 1px rgba(62,255,208,0.25); }
.popup-price-lbl { font-size: 12px; color: var(--text2); margin-bottom: 2px; }
.popup-price-val { font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; }
.popup-chart-block { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.popup-chart-block[hidden] { display: none !important; }
.popup-chart-hint { font-size: 11px; color: var(--text2); margin-bottom: 6px; line-height: 1.35; }
.popup-chart-title { font-size: 12px; font-weight: 700; color: var(--text2); letter-spacing: 0.04em; margin-bottom: 6px; }
.popup-chart-wrap { min-height: 72px; }
.popup-chart-msg { font-size: 12px; color: var(--text2); text-align: center; padding: 16px 8px; line-height: 1.4; }
.popup-chart-msg.popup-chart-err { color: var(--accent); }
.popup-chart-svg { width: 100%; height: auto; display: block; max-width: 260px; overflow: visible; }
.popup-chart-svg circle { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18)); }
.popup-chart-svg .popup-chart-dot-peak { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.28)); }
.popup-chart-axis { fill: var(--text2); font-size: 9px; font-family: 'Source Sans 3', sans-serif; }
.popup-schedule { margin-top: 10px; font-size: 12px; color: var(--text2); border-top: 1px solid var(--border); padding-top: 8px; }
.popup-24h { display: inline-block; background: var(--green); color: #000; font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 4px; margin-bottom: 4px; }
.popup-gmaps { display: block; margin-top: 10px; padding: 7px 10px; background: #3effd0; color: #000; border-radius: 6px; font-size: 13px; font-weight: 600; text-align: center; text-decoration: none; }

.loading-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 16px;
}
.loading-spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; color: var(--text2); }

@media (max-width: 700px) {
  body { height: auto; min-height: 100dvh; overflow-y: auto; overflow-x: hidden; }
  .app-body { flex-direction: column; height: auto; overflow: visible; }
  .map-wrap { order: 1; height: 55vh; flex: none; }
  .panel {
    order: 2; width: 100%; min-width: unset; position: static;
    height: auto; max-height: none; overflow: visible;
    border-right: none; border-top: 1px solid var(--border);
  }
  .station-list { flex: none; overflow: visible; height: auto; }
  .panel-section { padding: 10px 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
}
