:root {
  --bg: #0d0f13;
  --panel: #151922;
  --surface: #1d2330;
  --surface-2: #11151c;
  --ink: #f4f7fb;
  --muted: #9aa8b8;
  --line: #313a49;
  --accent: #2a9bb0;
  --accent-2: #3fb874;
  --warning: #d58b28;
  --danger: #d94b42;
  --limited: #c8a735;
  --unknown: #7f8b9a;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* Leaflet critical layout fallback. Keeps tiles positioned even if CDN CSS is late or blocked. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.top-info {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 850;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 980px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 9px;
  background: rgba(17, 21, 28, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.top-info-main {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.top-info-main strong,
.top-info-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-info-main strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.top-info-main span {
  color: var(--muted);
  font-size: 13px;
}

.menu-button {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 11px;
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1100;
  width: min(430px, calc(100vw - 28px));
  transform: translateX(-108%);
  transition: transform 180ms ease;
  will-change: transform;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6, 8, 12, 0.56);
  backdrop-filter: blur(2px);
}

.drawer-backdrop[hidden] {
  display: none;
}

.panel-header,
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 10px;
  font-size: 14px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.icon-button:hover,
.chip:hover,
.segment:hover,
.source-link:hover {
  border-color: var(--accent);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.status-strip > div,
.source-note,
.station-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.status-strip > div {
  padding: 12px;
}

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

.control-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.search-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
}

.search-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(23, 107, 135, 0.16);
}

.segmented,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment,
.chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.segment.active,
.chip.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.source-note {
  padding: 14px;
}

.source-note p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-note .data-health {
  margin-top: 10px;
  color: #bfd1dc;
}

.count {
  min-width: 30px;
  border-radius: 999px;
  padding: 4px 9px;
  text-align: center;
  color: #fff;
  background: var(--accent);
}

.list-limit-note {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.station-list {
  display: grid;
  gap: 10px;
}

.station-card {
  padding: 12px;
}

.station-card h3 {
  margin: 10px 0 4px;
  font-size: 15px;
  line-height: 1.2;
}

.status-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.status-panel.status-available {
  border-color: rgba(63, 184, 116, 0.48);
  background: rgba(63, 184, 116, 0.12);
}

.status-panel.status-queue {
  border-color: rgba(213, 139, 40, 0.52);
  background: rgba(213, 139, 40, 0.13);
}

.status-panel.status-limited {
  border-color: rgba(200, 167, 53, 0.5);
  background: rgba(200, 167, 53, 0.13);
}

.status-panel.status-empty {
  border-color: rgba(217, 75, 66, 0.5);
  background: rgba(217, 75, 66, 0.12);
}

.status-panel-main {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
}

.status-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.status-label,
.status-missing {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status-fuels {
  margin-top: 10px;
}

.status-prices {
  margin-top: 10px;
}

.status-label {
  display: block;
  margin-bottom: 5px;
}

.fuel-empty {
  color: var(--muted);
  font-size: 12px;
}

.status-missing {
  margin-top: 5px;
}

.status-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.status-metrics span {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  padding: 7px;
  background: rgba(0, 0, 0, 0.14);
}

.status-metrics b,
.status-metrics small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-metrics b {
  color: var(--ink);
  font-size: 13px;
}

.status-metrics small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.station-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.station-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.source-link {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  cursor: pointer;
}

.map-wrap {
  position: absolute;
  inset: 0;
  min-width: 0;
  background: #0a0c10;
}

#map {
  width: 100vw;
  height: 100vh;
}

.leaflet-top.leaflet-left {
  top: 74px;
  left: 14px;
}

.map-legend {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: min(520px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(17, 21, 28, 0.94);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 50%;
}

.dot-available {
  background: var(--accent-2);
}

.dot-queue {
  background: var(--warning);
}

.dot-limited {
  background: var(--limited);
}

.dot-empty {
  background: var(--danger);
}

.dot-unknown {
  background: var(--unknown);
}

.fuel-badge {
  display: inline-block;
  margin: 6px 5px 0 0;
  border-radius: 6px;
  padding: 3px 6px;
  color: #d7f1f7;
  background: rgba(42, 155, 176, 0.2);
  font-size: 12px;
}

.fuel-badge-live {
  color: #dcffe9;
  background: rgba(63, 184, 116, 0.24);
}

.fuel-badge-muted {
  color: #bcc8d4;
  background: rgba(127, 139, 154, 0.16);
}

.fuel-price-badge {
  color: #d9f6ff;
  background: rgba(42, 155, 176, 0.22);
}

.popup-title {
  margin: 0 0 4px;
  font-weight: 800;
}

.popup-text {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.leaflet-popup-content {
  min-width: 290px;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
  background: #161b24;
}

.leaflet-control-zoom a,
.leaflet-control-attribution {
  color: var(--ink);
  background: rgba(17, 21, 28, 0.9);
}

.leaflet-control-zoom a {
  border-color: var(--line);
}

.leaflet-control-attribution a {
  color: #8ed7e5;
}

.marker-pin {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.44);
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 680px) {
  .top-info {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 8px;
    padding: 8px;
  }

  .top-info-main strong {
    font-size: 14px;
  }

  .top-info-main span {
    font-size: 12px;
  }

  .drawer {
    width: min(420px, calc(100vw - 18px));
  }

  .leaflet-top.leaflet-left {
    top: 72px;
    left: 8px;
  }
}

@media (max-width: 520px) {
  .status-strip {
    grid-template-columns: 1fr;
  }
}
