:root {
  --ink: #17201c;
  --muted: #69736d;
  --paper: #f4f1e8;
  --card: #fffdf7;
  --line: #ded9cb;
  --green: #1d5c45;
  --lime: #cce56d;
  --orange: #e66b3c;
  --shadow: 0 16px 40px rgba(37, 45, 39, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: radial-gradient(#716d62 0.5px, transparent 0.5px);
  background-size: 7px 7px;
}
header, main, footer { position: relative; }
header {
  max-width: 1380px;
  margin: 0 auto;
  padding: 48px 36px 28px;
  display: flex;
  justify-content: space-between;
  align-items: end;
}
h1, h2, p { margin: 0; }
h1 { font-family: Georgia, serif; font-size: clamp(2.4rem, 5vw, 5rem); line-height: .95; font-weight: 500; }
h2 { font-family: Georgia, serif; font-size: 1.75rem; font-weight: 500; }
.eyebrow { margin-bottom: 9px; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .19em; }
.subtitle { margin-top: 14px; color: var(--muted); }
button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: wait; }
.primary { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(29, 92, 69, .2); }
.primary:hover { background: #124b36; }
.secondary { color: var(--green); background: #e2ebd1; }
main { max-width: 1380px; margin: 0 auto; padding: 0 36px 48px; }
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.summary div { padding: 18px 22px; border-right: 1px solid var(--line); }
.summary div:last-child { border: 0; }
.summary span { display: block; font: 500 1.5rem Georgia, serif; }
.summary small { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.notice { padding: 12px 18px; margin-bottom: 18px; border: 1px solid #dec572; border-radius: 12px; background: #fff5c8; }
.hidden { display: none; }
.dashboard-grid { display: grid; grid-template-columns: minmax(360px, .8fr) 1.2fr; gap: 20px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.panel-title { display: flex; justify-content: space-between; align-items: center; padding: 24px; }
.list-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px 16px; flex-wrap: wrap; }
.fuel-tabs { display: flex; gap: 6px; }
.fuel-tabs button, .range-buttons button, .sort-buttons button { padding: 7px 13px; color: var(--muted); background: transparent; }
.fuel-tabs button.active, .range-buttons button.active, .sort-buttons button.active { color: var(--ink); background: var(--lime); }
.sort-buttons { display: flex; align-items: center; gap: 4px; }
.sort-buttons span { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.sort-buttons button { padding: 6px 10px; font-size: .78rem; }
.station-list { max-height: 490px; overflow: auto; }
.station {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 17px 24px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.station:hover, .station.selected { background: #f0f3e5; }
.station h3 { margin: 0 0 5px; font-size: .98rem; }
.station .address, .station .timestamp { color: var(--muted); font-size: .78rem; }
.station .distance { margin-top: 3px; color: var(--green); font-size: .74rem; font-weight: 700; }
.price { grid-row: span 2; align-self: center; font: 500 1.45rem Georgia, serif; }
.price small { font: 500 .75rem sans-serif; color: var(--muted); }
.remove-favorite { position: absolute; top: 4px; right: 5px; z-index: 2; padding: 2px 8px; color: var(--muted); background: transparent; font-size: 1.15rem; line-height: 1; opacity: 0; transition: opacity .15s, color .15s, background .15s; }
.station:hover .remove-favorite, .remove-favorite:focus-visible { opacity: 1; }
.remove-favorite:hover { color: #a83f31; background: #f5ded6; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #56a16f; }
.status-dot.closed { background: var(--orange); }
.empty { padding: 30px 24px; color: var(--muted); text-align: center; }
#map { height: 590px; background: #dfe6d6; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
/* Markers are zero-sized: the dot sits on the station, the label floats at a computed offset. */
.station-marker-wrap { width: 0; height: 0; background: transparent; border: 0; overflow: visible; }
.anchor-dot { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border: 3px solid var(--card); border-radius: 50%; background: var(--muted); box-shadow: 0 3px 10px #17201c55; }
.anchor-dot.cheap { background: #258755; }
.anchor-dot.average { background: #d18b2c; }
.anchor-dot.expensive { background: #c94f3d; }
.anchor-dot.closed { background: var(--orange); }
.leader { position: absolute; left: 0; top: -1.5px; width: var(--len, 0); height: 3px; border-radius: 3px; background: var(--ink); box-shadow: 0 0 0 1.5px #fffdf7cc; transform-origin: 0 50%; transform: rotate(var(--rot, -1.5708rad)); }
.price-marker { position: absolute; left: var(--dx, 0px); top: var(--dy, -29px); display: flex; align-items: baseline; justify-content: center; gap: 4px; width: 78px; padding: 8px 7px; border: 3px solid var(--card); border-radius: 10px; color: white; background: var(--green); box-shadow: 0 5px 16px #17201c55; font-size: .78rem; font-weight: 800; white-space: nowrap; transform: translate(-50%, -50%); transition: left .18s, top .18s; }
.price-marker small { font-size: .52rem; opacity: .75; }
.price-marker.cheap { background: #258755; }
.price-marker.average { background: #d18b2c; }
.price-marker.expensive { background: #c94f3d; }
.price-marker.unknown { background: #69736d; }
.price-marker.closed { background: var(--orange); }
.price-marker.selected { border-color: var(--lime); transform: translate(-50%, -50%) scale(1.12); }
/* Duration-weighted weekday/hour price pattern */
.heatmap-panel { margin-top: 20px; }
.heatmap-best { max-width: 330px; color: var(--green); font-size: .86rem; font-weight: 750; text-align: right; }
.heatmap-scroll { overflow-x: auto; padding: 0 24px 18px; }
.heatmap-grid { display: grid; grid-template-columns: 42px repeat(24, minmax(22px, 1fr)); gap: 3px; min-width: 710px; align-items: center; }
.heatmap-grid strong { color: var(--muted); font-size: .7rem; }
.hour-label { color: var(--muted); font-size: .6rem; text-align: center; }
.heat-cell { display: block; height: 28px; border-radius: 4px; transition: transform .12s; }
.heat-cell:hover { transform: scale(1.28); outline: 2px solid var(--card); z-index: 2; }
.empty-cell { background: #ece8dd; }
.heatmap-legend { display: flex; align-items: center; justify-content: end; gap: 8px; padding: 0 24px 20px; color: var(--muted); font-size: .68rem; }
.heatmap-legend i { width: 120px; height: 7px; border-radius: 9px; background: linear-gradient(90deg, hsl(120 58% 55%), hsl(60 58% 55%), hsl(0 58% 55%)); }
.history-panel { margin-top: 20px; }
.chart-wrap { position: relative; height: 300px; padding: 0 22px 20px; }
/* pan-y, not none: dragging sideways scrubs the chart while a vertical swipe
   still scrolls the page — otherwise the chart traps the scroll on a phone. */
#historyChart { touch-action: pan-y; }
.history-panel .empty { padding-top: 90px; }
dialog { width: min(620px, calc(100% - 30px)); max-height: 80vh; padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 24px 80px #18241e55; }
dialog::backdrop { background: #17201c88; backdrop-filter: blur(3px); }
.dialog-title { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; padding: 24px; border-bottom: 1px solid var(--line); background: var(--card); }
.icon-button { padding: 2px 12px; font-size: 1.6rem; background: transparent; }
.discover-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 17px 24px; border-bottom: 1px solid var(--line); }
.discover-row p { color: var(--muted); font-size: .82rem; }
.header-actions { display: flex; flex-direction: column; align-items: end; gap: 9px; }
.auth-status { color: var(--muted); font-size: .74rem; }
.auth-status strong { color: var(--ink); }
.link-button { padding: 0; color: var(--green); background: transparent; font-size: .74rem; font-weight: 700; text-decoration: underline; }
.login-dialog { width: min(400px, calc(100% - 30px)); }
.login-body { display: flex; flex-direction: column; padding: 22px 24px 24px; }
.login-hint { margin-bottom: 18px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.login-body label { margin-bottom: 6px; font-size: .74rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.login-body input { margin-bottom: 15px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font: inherit; font-size: .92rem; color: var(--ink); }
.login-body input:focus-visible { border-color: var(--green); outline: 2px solid #cce56d88; }
.login-error { margin-bottom: 14px; padding: 9px 12px; border-radius: 9px; color: #8d3324; background: #f7e0d9; font-size: .82rem; }
.login-actions { display: flex; justify-content: end; gap: 9px; margin-top: 4px; }
#toast { position: fixed; right: 24px; bottom: 24px; z-index: 9999; max-width: 360px; padding: 13px 18px; border-radius: 10px; color: white; background: var(--ink); opacity: 0; transform: translateY(12px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
footer { padding: 20px; color: var(--muted); font-size: .72rem; text-align: center; }
code { padding: 2px 5px; border-radius: 4px; background: #ede7d9; }

@media (hover: none) { .remove-favorite { opacity: 1; } }
@media (max-width: 800px) {
  header { padding: 30px 18px 20px; align-items: center; }
  main { padding: 0 18px 32px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .map-panel { order: -1; }
  #map { height: 360px; }
  .station-list { max-height: none; }
}
@media (max-width: 520px) {
  header { align-items: start; gap: 20px; }
  header .primary { padding: 10px 12px; }
  .summary div { padding: 13px 9px; }
  .panel-title { padding: 19px; }
}
