:root {
  --bg: #f5f7f8;
  --card: #ffffff;
  --text: #16202a;
  --muted: #5d6b78;
  --line: #e2e7eb;
  --accent: #0f766e;
  --accent-soft: #e0f2f0;
  --cheap: #15803d;
  --radius: 12px;
  --bar-h: 56px;
  --bar-bg: #0f766e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --card: #182027;
    --text: #e6edf2;
    --muted: #93a3b1;
    --line: #26323c;
    --accent: #2dd4bf;
    --accent-soft: #123532;
    --cheap: #4ade80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 1000;
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
  background: var(--bar-bg); color: #fff;
}
.title { margin: 0; font-size: 1.15rem; font-weight: 650; white-space: nowrap; }
.bar-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  border: 0; border-radius: 999px;
  padding: 8px 14px; min-height: 40px;
  background: var(--bar-bg); color: #fff; font-weight: 600;
}
.btn-ghost { background: rgba(255, 255, 255, .18); }

.lang { display: flex; border-radius: 999px; background: rgba(255, 255, 255, .18); padding: 3px; }
.lang button {
  border: 0; background: none; color: #fff;
  min-width: 40px; min-height: 34px; border-radius: 999px; font-weight: 600; font-size: .85rem;
}
.lang button[aria-pressed="true"] { background: #fff; color: var(--bar-bg); }

/* layout: list only on phones, list + map side by side on wide screens */
.layout { flex: 1; display: flex; min-height: 0; }
.list-pane { flex: 1; padding: 12px 16px 24px; max-width: 640px; width: 100%; margin: 0 auto; }
.map-pane { display: none; }
#map { width: 100%; height: 100%; }

.map-pane.open {
  display: block;
  position: fixed; inset: var(--bar-h) 0 0 0; z-index: 900;
}
.map-close {
  position: absolute; z-index: 1000; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

@media (min-width: 900px) {
  body { height: 100vh; height: 100dvh; }
  .list-pane { flex: 0 0 440px; max-width: none; margin: 0; overflow-y: auto; border-right: 1px solid var(--line); }
  .map-pane, .map-pane.open { display: block; position: relative; inset: auto; flex: 1; }
  .map-toggle, .map-close { display: none; }
  .foot { border-top: 1px solid var(--line); padding-block: 8px; }
}

/* fuel filter */
.filters { display: flex; align-items: center; gap: 10px; padding: 4px 0 8px; }
.filters label { color: var(--muted); font-size: .9rem; font-weight: 600; }
.filters select {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 40px 8px 14px;
  border: 1px solid var(--line); border-radius: 10px; background-color: var(--card); color: var(--text);
  font: inherit; font-weight: 600; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.filters select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.status { color: var(--muted); margin: 8px 0 12px; font-size: .95rem; }
.status:empty { display: none; }
.status.error {
  color: var(--text); background: var(--card); border: 1px solid #dc2626; border-left-width: 4px;
  border-radius: var(--radius); padding: 12px 14px;
}
.status .btn { margin-top: 8px; }

/* station cards */
.stations { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
}
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.logo {
  flex: none; position: relative; width: 44px; height: 44px; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line);
}
.logo b { color: var(--bar-bg); font-size: 1.1rem; }
.logo img { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); object-fit: contain; background: #fff; }
.card-title { min-width: 0; flex: 1; }
.card-title h2 { margin: 0; font-size: 1.02rem; line-height: 1.3; }
.addr { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.dist { flex: none; font-weight: 700; color: var(--accent); white-space: nowrap; }

.prices { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.prices li { display: contents; }
.prices .fuel { color: var(--muted); font-size: .92rem; }
.prices .fuel small { opacity: .75; }
.prices .price { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.prices .hl .fuel, .prices .hl .price { color: var(--text); font-weight: 700; }
.prices .cheapest { color: var(--cheap); }

.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.card-actions a, .card-actions button {
  flex: 1; text-align: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px; background: none;
  padding: 8px 10px; min-height: 40px; font-size: .9rem; color: var(--accent); font-weight: 600;
}
.meta { margin: 8px 0 0; font-size: .85rem; color: var(--muted); }

/* map popup */
.leaflet-popup-content { margin: 12px 14px; min-width: 210px; font: 14px/1.4 system-ui, sans-serif; }
.leaflet-popup-content h3 { margin: 0; font-size: 1rem; align-self: center; }
.leaflet-popup-content .card-head { align-items: center; margin-bottom: 4px; }
.leaflet-popup-content .logo { width: 36px; height: 36px; }
.leaflet-popup-content .prices { margin-top: 8px; }
.leaflet-popup-content .card-actions { margin-top: 10px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 2px #2563eb55; }

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  color: var(--muted); font-size: .8rem;
}
