:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-raised: #ffffff;
  --panel-hover: #f7faf8;
  --line: #dfe6e2;
  --line-strong: #c8d4ce;
  --text: #17201c;
  --muted: #718078;
  --muted-strong: #4e5d55;
  --green: #078b4d;
  --green-soft: #258e5a;
  --red: #d43740;
  --orange: #b7660d;
  --blue: #2564c8;
  --grey: #7a8580;
  --focus: #3377df;
  --shadow: 0 14px 40px rgb(39 60 49 / 14%);
}

* { box-sizing: border-box; }

html,
body { margin: 0; min-height: 100%; }

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
select:focus-visible,
a:focus-visible,
.station-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(16px);
}

.brand-block {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 35px;
  height: auto;
  flex: 0 0 auto;
}

.brand {
  display: block;
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
}

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

.topbar-actions { display: flex; align-items: center; gap: 7px; }

.bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: background .16s ease, color .16s ease;
}

.bookmark-btn:hover { background: var(--panel-hover); color: var(--text); }
.bookmark-icon { font-size: 18px; line-height: 1; }

.bookmark-toast {
  position: fixed;
  z-index: 3000;
  right: 18px;
  bottom: 18px;
  max-width: min(370px, calc(100vw - 28px));
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgb(255 255 255 / 96%);
  color: var(--muted-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity .18s ease, transform .18s ease;
}

.bookmark-toast.is-visible { opacity: 1; transform: translateY(0); }

.ghost-btn,
.refresh-btn,
.fuel-tabs button,
.view-tabs button,
select {
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border-radius: 11px;
  background: var(--panel-raised);
}

.ghost-btn:hover { border-color: var(--line-strong); background: var(--panel-hover); }
.ghost-btn:active { transform: translateY(1px); }
.button-icon { color: var(--blue); font-size: 19px; line-height: 1; }

.controls {
  z-index: 900;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-height: 74px;
  padding: 11px 24px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.control-group,
.sort-control { display: grid; gap: 6px; }
.control-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.fuel-tabs,
.view-tabs { display: flex; gap: 5px; }

.fuel-tabs button,
.view-tabs button {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.fuel-tabs button:hover,
.view-tabs button:hover { border-color: var(--line-strong); background: var(--panel-raised); }

.fuel-tabs button.active,
.view-tabs button.active {
  border-color: #75bc96;
  background: #dcf5e7;
  color: #086b3e;
  box-shadow: inset 0 0 0 1px rgb(57 217 138 / 8%);
}

.view-tabs button[data-view="inactive"].active {
  border-color: #b9c3be;
  background: #edf1ef;
  color: #47534d;
}

.control-divider { width: 1px; height: 34px; margin-bottom: 1px; background: var(--line); }
.sort-control { margin-left: auto; }

select {
  min-height: 34px;
  padding: 6px 34px 6px 11px;
  border-radius: 9px;
  background-color: var(--panel);
  color: var(--muted-strong);
  font-size: 13px;
}

select:hover { border-color: var(--line-strong); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(470px, .82fr);
  min-height: 0;
}

.map-wrap { position: relative; min-height: 360px; overflow: hidden; }
.map-wrap #map { width: 100%; height: 100%; background: #e7ede9; }

.map-status {
  position: absolute;
  z-index: 500;
  bottom: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 8px 24px rgb(41 62 51 / 16%);
  color: var(--muted-strong);
  font-size: 12px;
  backdrop-filter: blur(10px);
}

.map-status.is-error { border-color: #efb8bc; background: #fff5f5; color: #b5252e; }

.status-spinner {
  display: none;
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 2px solid rgb(23 32 28 / 16%);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.map-status.is-loading .status-spinner { display: block; }

.map-legend {
  position: absolute;
  z-index: 500;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 7px 20px rgb(41 62 51 / 14%);
  color: var(--muted-strong);
  font-size: 10px;
  backdrop-filter: blur(8px);
}

.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grey); }
.legend-dot.available { background: var(--green); }
.legend-dot.uncertain { background: var(--orange); }
.legend-dot.unavailable { background: var(--red); }
.legend-dot.inactive { border: 1px solid #7e8a84; background: #aeb8b3; }

.list-panel {
  min-width: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  scrollbar-color: #c2cdc7 transparent;
  scrollbar-width: thin;
}

.list-head {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(12px);
}

.result-title { line-height: 1.1; }
.result-title strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.result-title span { color: var(--muted-strong); font-size: 15px; }
.result-summary { margin-top: 5px; color: var(--muted); font-size: 13px; }

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-color: transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
}

.refresh-btn:hover { border-color: var(--line); background: var(--panel-raised); }
.refresh-btn:disabled { cursor: wait; opacity: .62; }
.refresh-btn.is-loading .refresh-icon { animation: spin .8s linear infinite; }

.provider-health {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-raised);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.health-pill::before { width: 6px; height: 6px; border-radius: 50%; background: var(--grey); content: ""; }
.health-pill.ok { border-color: #b8ddc9; background: #f1faf5; color: #23714b; }
.health-pill.ok::before { background: var(--green); }
.health-pill.err { border-color: #f0c3c6; background: #fff5f5; color: #b42e36; }
.health-pill.err::before { background: var(--red); }

.station-list { padding: 12px; }

.station-card {
  position: relative;
  margin-bottom: 9px;
  padding: 19px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-raised);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}

.station-card::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: transparent;
  content: "";
}

.station-card:hover { border-color: var(--line-strong); background: var(--panel-hover); transform: translateY(-1px); }
.station-card.is-selected { border-color: #7cba99; background: #f2fbf6; box-shadow: 0 9px 24px rgb(37 74 54 / 12%); }
.station-card.is-selected::before { background: var(--green); }
.station-card.is-inactive { opacity: .82; }
.station-card.is-inactive.is-selected { border-color: #aeb9b3; background: #f3f5f4; }
.station-card.is-inactive.is-selected::before { background: #7d8982; }

.station-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.station-identity { min-width: 0; }
.station-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.station-name { margin: 0; overflow: hidden; color: var(--text); font-size: 20px; font-weight: 750; letter-spacing: -.02em; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.station-address { margin-top: 6px; overflow: hidden; color: var(--muted); font-size: 14px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.distance { flex: 0 0 auto; color: var(--muted-strong); font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.station-activity {
  padding: 3px 6px;
  border: 1px solid #c6cfca;
  border-radius: 999px;
  background: #edf1ef;
  color: #59655f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.fuel-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 0 13px; }
.fuel-status-wrap { display: flex; align-items: center; gap: 9px; }
.fuel-status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px currentColor; opacity: .9; }
.fuel-status-dot.status-available { color: rgb(57 217 138 / 14%); background: var(--green); }
.fuel-status-dot.status-probably_available { color: rgb(156 231 189 / 14%); background: var(--green-soft); }
.fuel-status-dot.status-unavailable { color: rgb(255 98 105 / 14%); background: var(--red); }
.fuel-status-dot.status-probably_unavailable,
.fuel-status-dot.status-conflict { color: rgb(245 169 78 / 14%); background: var(--orange); }
.fuel-status-dot.status-unknown,
.fuel-status-dot.status-stale { color: rgb(119 130 146 / 15%); background: var(--grey); }
.fuel-label { margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.consensus { font-size: 19px; font-weight: 800; letter-spacing: -.015em; }
.price-wrap { text-align: right; }
.price { font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.price-caption { min-height: 17px; margin-top: 3px; color: var(--muted); font-size: 12px; }

.freshness-highlight {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8f7;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.35;
}

.freshness-icon { flex: 0 0 auto; font-size: 20px; line-height: 1; }
.freshness-age { margin-left: 3px; font-size: 16px; font-weight: 800; white-space: nowrap; }
.freshness-highlight.is-fresh { border-color: #b9dfca; background: #eef9f3; color: #176d45; }
.freshness-highlight.is-fresh .freshness-icon,
.freshness-highlight.is-fresh .freshness-age { color: var(--green); }
.freshness-highlight.is-aging { border-color: #ead9bc; background: #fff9ef; color: #8b570f; }
.freshness-highlight.is-aging .freshness-icon,
.freshness-highlight.is-aging .freshness-age { color: var(--orange); }
.freshness-highlight.is-stale { border-color: #e8c9cb; background: #fff5f5; color: #9d343b; }
.freshness-highlight.is-stale .freshness-icon,
.freshness-highlight.is-stale .freshness-age { color: var(--red); }
.freshness-highlight.is-unknown { color: var(--muted); }

.available-fuels {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.available-fuels[hidden] { display: none; }
.available-fuels-label { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .055em; }
.fuel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fuel-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #83cda5;
  border-radius: 8px;
  background: #e9f8f0;
  color: #087746;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.fuel-chip::before { width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--green); content: ""; }
.fuel-chip.is-probable { border-color: #b9dfca; background: #f2faf5; color: #397258; }
.fuel-chip.is-probable::before { background: var(--green-soft); }
.fuel-chip.is-current { box-shadow: 0 0 0 2px rgb(14 167 103 / 10%); }

.sources { display: grid; gap: 3px; padding: 9px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.source-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 38px; font-size: 14px; }
.source-name { display: inline-flex; align-items: center; gap: 8px; color: var(--muted-strong); font-size: 13.5px; font-weight: 700; }
.provider-logo { width: 22px; height: 22px; flex: 0 0 auto; border-radius: 6px; object-fit: cover; }
.health-pill .provider-logo { width: 18px; height: 18px; margin-left: -1px; }
.source-time { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; }
.source-age { flex: 0 0 auto; padding: 4px 7px; border: 1px solid #bee2ce; border-radius: 7px; background: #edf8f2; color: #087746; font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.source-age.is-unknown { border-color: var(--line); background: #f4f6f5; color: var(--muted); }
.source-age.is-negative { border-color: #e8c9cb; background: #fff5f5; color: var(--red); }
.source-meta { overflow: hidden; text-overflow: ellipsis; }
.source-status { font-size: 12px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.source-status.is-inactive { color: #68746e; }

.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding-top: 9px; }
.confidence-line { color: var(--muted); font-size: 13px; }
.confidence-line strong { color: var(--muted-strong); font-weight: 700; }
.route-link { padding: 5px 0 5px 8px; color: var(--blue); font-size: 13.5px; font-weight: 700; text-decoration: none; }

.map-credits { padding: 6px 18px 18px; color: var(--muted); font-size: 11px; text-align: center; }
.map-credits a { color: inherit; text-underline-offset: 2px; }
.route-link:hover { color: #174c9d; }

.status-available { color: var(--green); }
.status-probably_available { color: var(--green-soft); }
.status-unavailable { color: var(--red); }
.status-probably_unavailable,
.status-conflict { color: var(--orange); }
.status-unknown,
.status-stale { color: var(--grey); }

.empty { display: grid; min-height: 250px; place-content: center; padding: 34px 18px; text-align: center; }
.empty-icon { display: block; margin-bottom: 10px; color: var(--grey); font-size: 30px; }
.empty strong { display: block; font-size: 14px; }
.empty span { display: block; max-width: 260px; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.skeleton-card {
  height: 178px;
  margin-bottom: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(100deg, var(--panel-raised) 30%, #edf2ef 50%, var(--panel-raised) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.leaflet-container { font-family: inherit; }
.leaflet-bar { overflow: hidden; border: 1px solid var(--line) !important; border-radius: 10px !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a { border-bottom-color: var(--line) !important; background: var(--panel-raised); color: var(--text); }
.leaflet-bar a:hover { background: var(--panel-hover); }
.leaflet-control-attribution { border-radius: 7px 0 0; background: rgb(255 255 255 / 86%) !important; color: var(--muted); font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--blue); }
.leaflet-popup-content-wrapper,
.leaflet-popup-tip { background: var(--panel-raised); color: var(--text); box-shadow: var(--shadow); }
.leaflet-popup-content-wrapper { border: 1px solid var(--line-strong); border-radius: 12px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 11px; line-height: 1.45; }
.popup-name { margin-bottom: 2px; font-size: 13px; }
.popup-address { max-width: 230px; margin-bottom: 7px; color: var(--muted); }
.popup-status { font-weight: 800; }
.popup-price { margin-left: 7px; color: var(--text); font-weight: 700; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.custom-marker {
  position: relative;
  width: 19px;
  height: 19px;
  border: 3px solid #f5f7fa;
  border-radius: 50%;
  background: var(--grey);
  box-shadow: 0 3px 12px rgb(0 0 0 / 55%);
  transition: transform .15s ease;
}

.custom-marker:hover,
.custom-marker.is-selected { z-index: 2; transform: scale(1.28); }
.marker-available { background: var(--green); }
.marker-probably_available { background: var(--green-soft); }
.marker-unavailable { background: var(--red); }
.marker-probably_unavailable,
.marker-conflict { background: var(--orange); }
.marker-unknown,
.marker-stale { background: var(--grey); }
.marker-inactive { border-color: #ffffff; background: #7d8982; }
.marker-inactive::after { position: absolute; top: 6px; left: 1px; width: 11px; height: 2px; border-radius: 2px; background: #ffffff; content: ""; transform: rotate(-45deg); }

.user-marker { width: 16px; height: 16px; border: 3px solid white; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 7px rgb(115 170 255 / 18%), 0 3px 12px rgb(0 0 0 / 35%); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

@media (max-width: 1080px) {
  .controls { gap: 11px; padding-right: 14px; padding-left: 14px; }
  .control-divider { display: none; }
  .fuel-tabs button,
  .view-tabs button { padding-right: 9px; padding-left: 9px; }
  .layout { grid-template-columns: minmax(0, 1.25fr) minmax(430px, .9fr); }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app-shell { display: block; height: auto; min-height: 100dvh; }
  .topbar { position: sticky; top: 0; min-height: 64px; padding: 8px 13px; }
  .brand-logo { width: 29px; }
  .brand { max-width: 190px; font-size: 15px; line-height: 1.2; }
  .subtitle { display: none; }
  .ghost-btn { padding: 8px 10px; font-size: 12px; }
  .topbar-actions { gap: 2px; }
  .bookmark-btn { padding: 7px; }
  .controls { align-items: end; gap: 10px 12px; padding: 10px 12px 12px; overflow: hidden; }
  .fuel-control { width: 100%; }
  .fuel-tabs { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .fuel-tabs::-webkit-scrollbar { display: none; }
  .view-tabs { overflow-x: auto; max-width: calc(100vw - 165px); scrollbar-width: none; }
  .view-tabs::-webkit-scrollbar { display: none; }
  .sort-control { min-width: 140px; }
  select { width: 100%; }
  .layout { display: flex; flex-direction: column; }
  .map-wrap { height: 46dvh; min-height: 320px; }
  .list-panel { overflow: visible; border-top: 1px solid var(--line); border-left: 0; }
  .list-head { position: relative; }
  .station-list { padding: 10px; }
  .station-card { border-radius: 12px; }
  .map-legend { top: auto; right: 10px; bottom: 12px; flex-direction: column; gap: 5px; }
  .map-status { bottom: 12px; left: 10px; max-width: calc(100% - 122px); }
}

@media (max-width: 520px) {
  .bookmark-label { display: none; }
  .controls { display: grid; grid-template-columns: minmax(0, 1fr) 128px; }
  .fuel-control { grid-column: 1 / -1; }
  .view-control { min-width: 0; }
  .view-tabs { max-width: none; }
  .view-tabs button { padding-right: 7px; padding-left: 7px; font-size: 11px; }
  .station-address { max-width: calc(100vw - 110px); }
  .source-row { grid-template-columns: 104px minmax(0, 1fr) auto; gap: 8px; }
  .source-meta { display: none; }
  .freshness-highlight { align-items: flex-start; }
  .freshness-age { display: block; margin: 2px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
