:root {
  --bg-0: #060912;
  --bg-1: #0b1220;
  --bg-2: #111a2e;
  --surface: rgba(22, 32, 56, 0.65);
  --surface-solid: #16223b;
  --surface-hi: rgba(30, 44, 75, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e7edf7;
  --text-dim: #b6c0d3;
  --muted: #8a98b3;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --accent-3: #0f766e;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px rgba(45, 212, 191, 0.2), 0 12px 30px rgba(45, 212, 191, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

button { touch-action: manipulation; }

/* Inputs >=16px so iOS Safari does not zoom in on focus */
input, select { font-size: 16px; }

@media (hover: none) {
  .station:hover { transform: none; background: var(--surface); }
  .station:hover::before { opacity: 0; }
  .icon-btn:hover { transform: none; background: var(--surface); color: var(--text-dim); }
  .primary-btn:hover { filter: none; }
}

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(45, 212, 191, 0.18), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(99, 102, 241, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

body { overflow-x: hidden; }

button { font-family: inherit; }

/* ==================== Layout shell ==================== */

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 12px) 16px max(env(safe-area-inset-bottom), 16px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 12px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-3) 100%);
  font-size: 22px;
  box-shadow: 0 8px 22px rgba(45, 212, 191, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
  font-weight: 700;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

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

.icon-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.15s var(--ease), background 0.2s, color 0.2s;
}

.icon-btn:hover { background: var(--surface-hi); color: var(--text); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }

/* ==================== Filters ==================== */

.filters {
  position: sticky;
  top: 8px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 12px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.filter-row--compact {
  grid-template-columns: 1fr auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  min-width: 0;
}

.field span { display: flex; justify-content: space-between; gap: 8px; }
.field em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}

.field--grow { min-width: 0; }

.select-wrap {
  position: relative;
}

.select-wrap select {
  width: 100%;
  appearance: none;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 38px 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.select-wrap .chev {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.select-wrap select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

/* Range input */
input[type="range"] {
  appearance: none;
  width: 100%;
  background: transparent;
  height: 28px;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, var(--accent) var(--val, 14%), rgba(255, 255, 255, 0.12) var(--val, 14%));
  border-radius: 999px;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  background: var(--accent);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  margin-top: -6px;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.25), 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 0;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.25), 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-solid);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  gap: 2px;
  flex-wrap: wrap;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  letter-spacing: 0.2px;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.is-active {
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-3) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(45, 212, 191, 0.35);
}

.primary-btn {
  appearance: none;
  border: 0;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-3) 100%);
  color: white;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 22px rgba(45, 212, 191, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.15s var(--ease), filter 0.2s;
}

.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.65; cursor: progress; }

/* ==================== Chip toggles (open now / favs only) ==================== */

.filter-row--toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  user-select: none;
}

.chip-toggle:hover { color: var(--text); border-color: var(--border-strong); }

.chip-toggle input { display: none; }

.chip-toggle:has(input:checked) {
  background: linear-gradient(140deg, rgba(45, 212, 191, 0.18), rgba(45, 212, 191, 0.08));
  border-color: var(--accent);
  color: var(--accent);
}

/* ==================== Star (favorite) button ==================== */

.star-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.15s var(--ease);
}

.star-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); }
.star-btn:active { transform: scale(0.92); }

.star-btn.is-active {
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

.star-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ==================== Open-now badge ==================== */

.open-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

.open-badge--open { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.open-badge--closing { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.open-badge--closed { background: rgba(248, 113, 113, 0.16); color: var(--bad); }

/* ==================== Net savings (detour) ==================== */

.station-savings--detour {
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.16), transparent);
  border-color: rgba(45, 212, 191, 0.28);
  color: var(--accent);
}

.station-savings--detour.is-loss {
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.14), transparent);
  border-color: rgba(248, 113, 113, 0.28);
  color: #fca5a5;
}

.station-savings--detour.is-reference {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent);
  border-color: var(--border-strong);
  color: var(--muted);
}

/* ==================== Out-of-radius favorite ==================== */

.station--outside {
  border-style: dashed;
  opacity: 0.92;
}

.station--outside .meta-chip.outside {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warn);
}

.station--favorite .station-avatar::after {
  content: "⭐";
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 11px;
  background: var(--bg-1);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}

/* ==================== Settings modal ==================== */

.settings-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.setting-field {
  display: grid;
  gap: 6px;
}

.setting-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.setting-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 12px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.setting-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.setting-input input {
  flex: 1;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 10px 0;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

.setting-input em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
  font-weight: 600;
}

.setting-field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.ghost-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.ghost-btn:hover { background: var(--surface-hi); color: var(--text); }

.ghost-btn--danger { color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
.ghost-btn--danger:hover { background: rgba(127, 29, 29, 0.25); color: #fecaca; }

/* ==================== Status banner ==================== */

.status {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.2);
  flex: none;
  animation: pulse 1.6s ease-in-out infinite;
}

.status.success::before { background: var(--good); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2); animation: none; }
.status.error { color: #fecaca; border-color: rgba(248, 113, 113, 0.3); background: rgba(127, 29, 29, 0.25); }
.status.error::before { background: var(--bad); box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.2); animation: none; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ==================== View tabs ==================== */

.view-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 8px;
  background: var(--surface);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
  backdrop-filter: blur(10px);
}

.view-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s;
}

.view-btn:hover { color: var(--text); }
.view-btn.is-active { background: var(--surface-hi); color: var(--text); }

/* ==================== Layout (results + map) ==================== */

.layout {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  /* defaults to single column; the data-view attr decides what shows */
}

.layout[data-view="list"] .map-pane { display: none; }
.layout[data-view="map"] .results-pane { display: none; }
.layout[data-view="map"] { grid-template-rows: 1fr; }
.layout[data-view="map"] .map-pane { min-height: calc(100dvh - 320px); }

.results-pane { min-width: 0; }

.map-pane {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  height: 420px;
  position: relative;
  background: #0a0f1c;
  box-shadow: var(--shadow-2);
}

.map { width: 100%; height: 100%; }

@media (min-width: 980px) {
  .layout[data-view="split"] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .layout[data-view="split"] .map-pane,
  .layout[data-view="split"] .results-pane { display: block; }
  .layout[data-view="split"] .map-pane { height: calc(100dvh - 280px); position: sticky; top: 200px; }
  .layout[data-view="split"] .results-pane { max-height: calc(100dvh - 280px); overflow-y: auto; padding-right: 4px; }
}

@media (max-width: 979px) {
  .view-btn[data-view="split"] { display: none; }
  .layout[data-view="split"] .map-pane { display: none; }
}

/* ==================== Result cards ==================== */

.results { display: grid; gap: 10px; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty-emoji { font-size: 36px; }

.station {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 6px 12px;
  align-items: start;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.station::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(45, 212, 191, 0.08), transparent 40%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.station:hover { background: var(--surface-hi); transform: translateY(-1px); }
.station:hover::before { opacity: 1; }

.station.is-selected {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.station.is-cheapest {
  border-color: rgba(52, 211, 153, 0.5);
  background: linear-gradient(160deg, rgba(52, 211, 153, 0.08), var(--surface) 60%);
}

.station-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  flex: none;
  position: relative;
}

.station-avatar.t-0 { background: linear-gradient(140deg, #34d399, #059669); }
.station-avatar.t-1 { background: linear-gradient(140deg, #4ade80, #16a34a); }
.station-avatar.t-2 { background: linear-gradient(140deg, #facc15, #ca8a04); }
.station-avatar.t-3 { background: linear-gradient(140deg, #fb923c, #ea580c); }
.station-avatar.t-4 { background: linear-gradient(140deg, #f87171, #dc2626); }

.station-main { min-width: 0; }

.station-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-loc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-price {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
}

.price-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.station.is-cheapest .price-value { color: var(--good); }

.price-delta {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

.price-delta.neg { background: rgba(52, 211, 153, 0.15); color: var(--good); }
.price-delta.pos { background: rgba(248, 113, 113, 0.12); color: var(--bad); }
.price-delta.zero { background: rgba(255, 255, 255, 0.08); color: var(--muted); }

.station-meta {
  grid-column: 2 / 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.meta-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

.meta-actions { display: flex; align-items: center; gap: 8px; }

.linklike {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.linklike:hover { background: rgba(45, 212, 191, 0.1); }

.sparkline {
  display: block;
  width: 80px;
  height: 22px;
}

.sparkline-empty {
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
}

.station-savings {
  grid-column: 1 / 4;
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.14), transparent);
  border: 1px solid rgba(52, 211, 153, 0.25);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--good);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-top: 6px;
}

/* Skeletons */
.skeleton {
  height: 96px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hi) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ==================== Footer ==================== */

.appfoot {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.appfoot .dot { opacity: 0.6; }

/* ==================== Map markers ==================== */

.price-pin {
  --pin-bg: linear-gradient(140deg, var(--accent) 0%, var(--accent-3) 100%);
  background: var(--pin-bg);
  color: white;
  font-weight: 800;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -100%);
  position: relative;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.price-pin::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: inherit;
  border-right: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
}

.price-pin.t-0 { --pin-bg: linear-gradient(140deg, #34d399, #059669); }
.price-pin.t-1 { --pin-bg: linear-gradient(140deg, #4ade80, #16a34a); }
.price-pin.t-2 { --pin-bg: linear-gradient(140deg, #facc15, #ca8a04); color: #1f1305; }
.price-pin.t-3 { --pin-bg: linear-gradient(140deg, #fb923c, #ea580c); }
.price-pin.t-4 { --pin-bg: linear-gradient(140deg, #f87171, #dc2626); }

.price-pin.is-selected {
  transform: translate(-50%, -100%) scale(1.18);
  z-index: 1000 !important;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.4), 0 6px 18px rgba(0, 0, 0, 0.45);
}

.user-pin {
  width: 18px;
  height: 18px;
  background: #3b82f6;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.25);
  animation: userPulse 2s ease-in-out infinite;
}

@keyframes userPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.25); }
  50% { box-shadow: 0 0 0 14px rgba(59, 130, 246, 0.05); }
}

/* Leaflet overrides */
.leaflet-container { background: #0a0f1c; font-family: inherit; }
.leaflet-popup-content-wrapper {
  background: var(--surface-solid);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}
.leaflet-popup-tip { background: var(--surface-solid); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-content strong { font-weight: 700; }
.leaflet-popup-content .pop-price { color: var(--accent); font-weight: 800; font-size: 16px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.leaflet-control-attribution {
  background: rgba(11, 18, 32, 0.7) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-bar a {
  background: var(--surface-solid) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar a:hover { background: var(--surface-hi) !important; }

/* ==================== Modal ==================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s var(--ease);
}

.modal-card {
  position: relative;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 18px;
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-2);
  animation: pop 0.25s var(--ease);
  max-height: 90dvh;
  overflow-y: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-chart {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-value.up { color: var(--bad); }
.stat-value.down { color: var(--good); }

.modal-note {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* ==================== Responsive ==================== */

@media (min-width: 720px) {
  .filter-row { grid-template-columns: 2fr 1fr; }
  .filter-row--compact { grid-template-columns: 1fr auto; }
}

/* ==================== Tablet (<= 720px) ==================== */

@media (max-width: 720px) {
  .filters { top: 4px; border-radius: 18px; }
  .filter-row { gap: 10px; }
}

/* ==================== Phone (<= 540px) ==================== */

@media (max-width: 540px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .topbar { gap: 8px; padding: 0 0 8px; }

  .brand { gap: 10px; min-width: 0; }
  .brand-logo {
    width: 38px; height: 38px;
    font-size: 18px;
    border-radius: 12px;
  }
  .brand-text { min-width: 0; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { font-size: 11px; }

  .topbar-actions { gap: 6px; }
  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .filters {
    padding: 10px;
    gap: 10px;
    border-radius: 16px;
  }
  .filter-row { gap: 8px; }
  .filter-row--compact { gap: 8px; }
  .field { font-size: 11px; gap: 4px; }
  .select-wrap select { padding: 11px 36px 11px 12px; }
  .seg-btn { padding: 9px 12px; font-size: 12px; min-height: 38px; }
  .primary-btn {
    padding: 11px 14px;
    font-size: 13px;
    min-height: 42px;
  }

  .view-tabs {
    width: 100%;
    box-sizing: border-box;
    margin: 10px 0 6px;
  }
  .view-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    font-size: 12px;
    min-height: 40px;
  }

  .status { padding: 10px 12px; font-size: 13px; margin-top: 10px; }

  .station {
    grid-template-columns: 38px 1fr auto;
    gap: 4px 10px;
    padding: 12px;
    border-radius: 14px;
  }
  .station-avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
    border-radius: 10px;
  }
  .station-title { font-size: 14px; }
  .station-loc { font-size: 11px; }
  .price-value { font-size: 18px; }
  .price-delta { font-size: 10px; padding: 1px 6px; }
  .meta-chip { font-size: 10px; padding: 2px 6px; }
  .sparkline { width: 56px; height: 20px; }
  .station-savings {
    font-size: 11px;
    padding: 5px 8px;
    border-radius: 8px;
  }
  .station-meta { gap: 8px; margin-top: 4px; }

  .linklike { padding: 6px 8px; font-size: 12px; min-height: 36px; display: inline-flex; align-items: center; }

  .map-pane {
    height: 360px;
    border-radius: 12px;
  }
  .layout[data-view="map"] .map-pane {
    height: calc(100dvh - 280px);
    min-height: 360px;
  }

  .modal {
    padding: 8px;
    align-items: flex-end;
  }
  .modal-card {
    padding: 14px;
    border-radius: 18px 18px 12px 12px;
    max-height: 88dvh;
  }
  .modal-head h2 { font-size: 16px; }
  .modal-sub { font-size: 12px; }
  .modal-chart { padding: 8px; margin-bottom: 8px; }
  .modal-stats { gap: 6px; }
  .stat { padding: 8px 10px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 13px; }

  .appfoot { font-size: 10px; margin-top: 14px; }

  .price-pin { font-size: 10px; padding: 3px 6px; }
}

/* ==================== Tiny phones (<= 380px) ==================== */

@media (max-width: 380px) {
  .seg-btn { padding: 8px 10px; font-size: 11px; }
  .view-btn { padding: 9px 6px; font-size: 11px; }
  .primary-btn span { display: none; }
  .primary-btn { padding: 11px 14px; }
  .station-meta { flex-direction: column; align-items: flex-start; }
  .meta-actions { width: 100%; justify-content: flex-end; }
  .field span em { font-size: 11px; }
}

/* ==================== Landscape phones — keep map usable ==================== */

@media (max-height: 520px) and (orientation: landscape) {
  .map-pane { height: calc(100dvh - 200px); min-height: 240px; }
  .filters { position: static; }
}
