:root {
  --bg: #101418;
  --panel: #1a2027;
  --panel-2: #232b34;
  --text: #e8edf2;
  --muted: #8b98a5;
  --accent: #3ddc84;
  --accent-dim: #2aa763;
  --warn: #f5b54a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

#topbar {
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
}

#grade-tabs { display: flex; gap: 6px; }
#grade-tabs button {
  flex: 1;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
}
#grade-tabs button.active { background: var(--accent); color: #06250f; }

#controls { display: flex; align-items: center; gap: 8px; }
#radius-label { flex: 1; display: flex; align-items: center; gap: 8px; }
#radius { flex: 1; accent-color: var(--accent); min-height: 28px; }
#radius-value { min-width: 44px; text-align: right; color: var(--muted); font-size: 14px; }
#sort {
  background: var(--panel-2);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 14px;
}
#refresh {
  background: var(--panel-2);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  width: 42px;
  height: 40px;
  font-size: 18px;
}
/* spin just the arrow glyph, not the whole button box */
.refresh-icon { display: inline-block; line-height: 1; }
#refresh.spin .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* one-line car chip: always shows the active car + tank state */
#car-chip {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#car-chip.empty { color: var(--muted); font-weight: 400; }
/* --- car sheet building blocks --- */
.cp-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 7px;
}

#fuel-seg { display: flex; gap: 6px; }
#fuel-seg button {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
}
#fuel-seg button.active { background: var(--accent); color: #06250f; }

#curated-list { display: flex; flex-direction: column; gap: 6px; }
.curated-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel-2);
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}
.curated-row .cr-spec { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.curated-row.active { outline: 2px solid var(--accent); }

#car-clear {
  width: 100%;
  margin-top: 14px;
  background: var(--panel-2);
  color: var(--warn);
  border: 0;
  border-radius: 10px;
  padding: 11px 0;
  font-size: 14px;
  font-weight: 600;
}
#car-clear.hidden { display: none; }

/* --- car picker modal --- */
#carpicker-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgb(0 0 0 / 60%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#carpicker-modal.hidden { display: none; }
#carpicker-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
}
#carpicker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 10px;
}
#carpicker-close {
  background: var(--panel-2);
  color: var(--text);
  border: 0;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 15px;
}
.cp-field {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.cp-field select,
.cp-field input {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--panel-2);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 11px 8px;
  font-size: 15px;
}
.cp-field select:disabled { opacity: 0.45; }
#epa-info { font-size: 13px; color: var(--accent); min-height: 18px; margin: 4px 0 10px; }
#epa-use {
  width: 100%;
  background: var(--accent);
  color: #06250f;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 12px 0;
  font-size: 15px;
}
#epa-use:disabled { opacity: 0.4; }
#carpicker-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.4; }

/* --- Pareto modal --- */
#pareto-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgb(0 0 0 / 60%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
/* id selector beats .hidden, so spell out the hidden state explicitly */
#pareto-modal.hidden { display: none; }
#pareto-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
}
#pareto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
#pareto-title { font-weight: 600; font-size: 16px; }
#pareto-close {
  background: var(--panel-2);
  color: var(--text);
  border: 0;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 15px;
}
#pareto-chart { width: 100%; }
.pareto-svg { width: 100%; height: auto; display: block; }
.pareto-svg .ax { stroke: var(--muted); stroke-width: 1; }
.pareto-svg .grid { stroke: #2c3540; stroke-width: 1; }
.pareto-svg .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.pareto-svg .ylab, .pareto-svg .xlab {
  fill: var(--muted);
  font-size: 9px;
  font-family: system-ui, sans-serif;
}
.pareto-svg .ylab { text-anchor: end; }
.pareto-svg .xlab { text-anchor: middle; }
.pareto-svg .axtitle {
  fill: var(--muted);
  font-size: 9px;
  text-anchor: middle;
  font-family: system-ui, sans-serif;
}
.pareto-svg .pt { fill: var(--muted); }
.pareto-svg .pt.front { fill: var(--accent); }
.pareto-svg .frontline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.p-loading { padding: 30px 0; text-align: center; color: var(--muted); }
.p-sub { font-size: 12px; color: var(--muted); margin: 8px 0 6px; }
.p-row {
  font-size: 13px;
  padding: 8px 0;
  border-top: 1px solid #2c3540;
  display: flex;
  align-items: center;
  gap: 10px;
}
.p-info { flex: 1; min-width: 0; }
.p-save {
  display: inline-block;
  min-width: 52px;
  font-weight: 700;
  color: var(--accent);
}
.p-nav {
  flex: 0 0 auto;
  text-decoration: none;
  background: var(--accent-dim);
  color: #04200d;
  font-weight: 600;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 9px;
}
#pareto-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.4; }

.hidden { display: none; }

.savings {
  margin: 8px 10px 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border-left: 4px solid var(--muted);
}
.savings.win { border-left-color: var(--accent); background: #14241a; }
.savings.flat { border-left-color: var(--warn); }
.savings { cursor: pointer; }
.s-head { font-size: 12px; color: var(--muted); }
.s-amount { font-size: 20px; font-weight: 700; color: var(--accent); margin: 2px 0; }
.s-body { font-size: 13px; line-height: 1.35; }
.s-link {
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

/* divider between priced and unpriced stations in the cheapest-first list */
.list-divider {
  list-style: none;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  padding: 8px 0 4px;
}

#ratelimit {
  background: var(--warn);
  color: #20140a;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  padding: 7px 10px;
  line-height: 1.3;
}

#map { flex: 1; min-height: 35vh; background: #0b0e11; }

#list-panel {
  background: var(--panel);
  max-height: 45vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}

#drag-handle {
  width: 42px;
  height: 4px;
  border-radius: 2px;
  background: var(--muted);
  margin: 8px auto 4px;
  opacity: 0.5;
}

#status {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
}

#station-list { list-style: none; margin: 0; padding: 0 10px 12px; }

.station {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.station.highlight { outline: 2px solid var(--accent); }

.station .name { font-weight: 600; font-size: 15px; }
.station .addr { color: var(--muted); font-size: 12px; grid-column: 1; }
.station .meta { color: var(--muted); font-size: 12px; grid-column: 1; }
.station .meta .stale { color: var(--warn); }

.station .price {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}
.station .price.missing { color: var(--muted); font-size: 14px; font-weight: 400; }

.station .actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.station .actions a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 0;
  font-size: 14px;
}
.station .actions a.nav { background: var(--accent-dim); color: #04200d; font-weight: 600; }

/* Let the divIcon shrink-wrap its content instead of Leaflet's 12x12 box,
   and center the bubble over the station point. */
.price-pin-icon {
  width: auto !important;
  height: auto !important;
}
.price-pin {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
  padding: 2px 6px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgb(0 0 0 / 55%);
}
.price-pin.cheapest { background: var(--accent); color: #06250f; border-color: #06250f; }
.price-pin.nodata {
  background: var(--panel);
  border-color: var(--muted);
  color: var(--muted);
}
