:root {
  color-scheme: light;
  --bg: #efeae2;
  --surface: #fffcf8;
  --ink: #1c1915;
  --muted: #6e675e;
  --line: #e3d9cc;
  --accent: #e25b1a;
  --accent-ink: #fff;
  --good: #0c7a45;
  --good-bg: #e5f6ec;
  --bad: #b43324;
  --bad-bg: #fde8e4;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --map-bg: #d9d3c7;
  --shadow: 0 12px 40px rgba(40, 24, 8, 0.12);
  --font: "Outfit", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101417;
  --surface: #1b222a;
  --ink: #f4efe6;
  --muted: #c4bbb0;
  --line: #313a44;
  --accent: #ff8a3d;
  --accent-ink: #1c120c;
  --good: #8dffb4;
  --good-bg: #123528;
  --bad: #ffb4a8;
  --bad-bg: #3a1d1a;
  --warn: #ffd27a;
  --warn-bg: #3a2e14;
  --map-bg: #0c1014;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
[hidden] { display: none !important; }
code { font-family: "Segoe UI", monospace; font-size: 0.92em; }

.shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.map-stage { position: relative; flex: 1 1 auto; min-height: 220px; }
#map { position: absolute; inset: 0; background: var(--map-bg); }
.leaflet-container { font-family: var(--font); background: var(--map-bg); }
.leaflet-control-attribution { font-size: 10px; max-width: 46vw; }
:root[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.95);
}

.map-header {
  position: absolute;
  z-index: 500;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-text { min-width: 0; }
h1 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
#context-line {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn, .text-btn, .pill, .map-tools button {
  border: 0;
  background: var(--bg);
  border-radius: 999px;
}
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
:root[data-theme="light"] .icon-sun, :root[data-theme="dark"] .icon-moon { display: none; }
.text-btn, .pill { min-height: 40px; padding: 0 12px; font-weight: 600; }
.pill { background: var(--good-bg); color: var(--good); }

.status-banner {
  position: absolute;
  z-index: 500;
  left: 12px;
  right: 12px;
  top: calc(86px + env(safe-area-inset-top));
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.4;
}
.map-tools {
  position: absolute;
  z-index: 500;
  right: 12px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-tools button {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

#panel {
  position: relative;
  z-index: 600;
  height: min(620px, 58dvh);
  margin-top: -14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
  padding-bottom: env(safe-area-inset-bottom);
}
.grabber {
  width: 42px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 99px;
  background: var(--line);
  flex: 0 0 auto;
}
.view { flex: 1; min-height: 0; overflow: auto; padding: 8px 16px 18px; }
.filters {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding-bottom: 8px;
}
.search input, .field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  padding: 0 14px;
  font-size: 16px;
}
.search { margin-bottom: 12px; }
.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.search-results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
}
.slider { display: grid; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.slider input { width: 100%; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
.chips button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 600;
}
.chips button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.segmented {
  display: grid;
  grid-template-columns: 1.35fr 0.75fr 0.9fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: var(--bg);
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 10px;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.assumptions, .hint, .legal, .field small, .subtitle, .eyebrow {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.assumptions { margin: 0 0 8px; }
.legal { margin: 8px 0 0; }

.station-list { display: grid; gap: 10px; }
.station-list.is-loading { opacity: 0.55; }
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
}
.card[data-tone="good"] { box-shadow: inset 4px 0 0 var(--good); }
.card[data-tone="bad"] { box-shadow: inset 4px 0 0 var(--bad); }
.card[data-tone="even"] { box-shadow: inset 4px 0 0 var(--warn); }
.card[data-tone="out"] { box-shadow: inset 4px 0 0 var(--muted); }
.card.is-selected { outline: 2px solid var(--accent); }
.card-main {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 14px 48px 14px 14px;
}
.price-line { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.price { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.distance { color: var(--muted); font-size: 14px; }
.title { font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 22px;
}
.badge {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad, .badge.out { background: var(--bad-bg); color: var(--bad); }
.badge.even, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.stock { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.stock[data-stock="disponible"] .dot { background: var(--good); }
.stock[data-stock="faible"] .dot { background: var(--warn); }
.stock[data-stock="rupture"] .dot { background: var(--bad); }
.flags { color: var(--muted); font-size: 13px; }

.back {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  padding: 4px 0 10px;
}
h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.03em; }
h3 { margin: 18px 0 8px; font-size: 16px; }
.math {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  list-style: none;
  border-radius: 16px;
  background: var(--bg);
}
.math li { font-size: 14px; line-height: 1.45; }
.nav-row, .report-grid, .action-col { display: grid; gap: 8px; }
.nav-row, .report-grid { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.btn, .report-grid button, .action-col button, .empty button, #clear-savings, #test-server, .fav-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  font-weight: 600;
  text-align: center;
}
.btn.primary, #save-fill { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.fuel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fuel-list li {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg);
}
.fuel-list li[data-current="true"] { outline: 2px solid var(--accent); }
.fuel-list small { grid-column: 1 / -1; color: var(--muted); }
.static-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-static {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--bg);
  font-size: 13px;
}
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.stat {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stat.good, .saving-amt.good { color: var(--good); }
.stat.bad, .saving-amt.bad { color: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 56px; margin: 8px 0; }
.bars .bar { width: 10px; border-radius: 99px 99px 4px 4px; }
.bars .up { background: var(--good); }
.bars .down { background: var(--bad); }
.savings { list-style: none; margin: 0; padding: 0; }
.saving {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.saving small { display: block; color: var(--muted); }
.saving button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
}
.fav-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 8px; }
.fav-row button { width: 100%; }
.fav-row small { display: block; color: var(--muted); font-weight: 400; }
.formula { margin: 16px 0; }
.formula summary { cursor: pointer; font-weight: 700; }
.empty { padding: 18px 4px; color: var(--muted); }
.skeleton {
  height: 112px;
  border-radius: 18px;
  background: linear-gradient(90deg, var(--bg), color-mix(in srgb, var(--ink) 8%, var(--bg)), var(--bg));
  background-size: 200% 100%;
  animation: shine 1.2s linear infinite;
}
@keyframes shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }
#toast {
  position: fixed;
  z-index: 2000;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 440px);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
}
.noscript { padding: 16px; }
.myfuel-pin { background: transparent !important; border: 0 !important; }
.pin {
  width: 72px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: #1c1915;
  font: 700 12px/1 "Outfit", "Segoe UI", sans-serif;
  box-shadow: 0 6px 16px rgba(28, 22, 14, 0.28);
}
.pin.good { color: #0c7a45; box-shadow: inset 0 0 0 2px #0c7a45, 0 6px 16px rgba(28, 22, 14, 0.28); }
.pin.bad { color: #b43324; box-shadow: inset 0 0 0 2px #b43324, 0 6px 16px rgba(28, 22, 14, 0.28); }
.pin.even { color: #8a5a00; box-shadow: inset 0 0 0 2px #8a5a00, 0 6px 16px rgba(28, 22, 14, 0.28); }
.pin.out { color: #6d675e; box-shadow: inset 0 0 0 2px #8a8175, 0 6px 16px rgba(28, 22, 14, 0.28); }
.pin.is-selected { outline: 2px solid #1c1915; outline-offset: 2px; }

@media (min-width: 980px) {
  .shell { flex-direction: row; }
  .map-stage { height: 100dvh; min-height: 0; }
  #panel {
    width: 420px;
    height: 100dvh;
    flex: 0 0 420px;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid var(--line);
    box-shadow: none;
  }
  .grabber { display: none; }
}
@media (hover: hover) {
  .card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
  .search-results button:hover, .chips button:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- Mode « Dispo chez Total » ---------- */
.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px;
  border-radius: 16px; background: color-mix(in srgb, var(--ink) 7%, transparent);
}
.mode-switch button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 600;
}
.mode-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 10px rgba(40, 24, 8, 0.12); }
.total-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: conic-gradient(#ed1c24 0 33%, #f39200 0 66%, #0072bc 0);
}
#all-filters[hidden] { display: none; }

.brand-tag {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content; margin: 2px 0 0;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.01em;
  background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink);
}
.brand-tag[data-family="total"] { background: color-mix(in srgb, #ed1c24 12%, transparent); color: #c5161d; }
:root[data-theme="dark"] .brand-tag[data-family="total"] { color: #ff8a8f; }
.brand-tag[data-family="total"]::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: conic-gradient(#ed1c24 0 33%, #f39200 0 66%, #0072bc 0);
}

.total-summary {
  margin: 0 0 14px; padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line);
}
.total-summary .eyebrow { margin: 0 0 10px; }
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sum-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.sum-tile strong { font-size: 30px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-tile strong em { font-style: normal; font-size: 18px; color: var(--muted); font-weight: 600; }
.sum-tile span { font-weight: 700; }
.sum-tile small { color: var(--muted); font-size: 12px; }
.sum-tile[data-tone="good"] { background: var(--good-bg); }
.sum-tile[data-tone="good"] strong { color: var(--good); }
.sum-tile[data-tone="even"] { background: var(--warn-bg); }
.sum-tile[data-tone="even"] strong { color: var(--warn); }
.sum-tile[data-tone="bad"] { background: var(--bad-bg); }
.sum-tile[data-tone="bad"] strong { color: var(--bad); }
.total-summary .hint { margin: 10px 0 0; }

.avail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; width: 100%; }
.avail {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 9px; align-items: center;
  padding: 9px 10px; border-radius: 14px; text-align: left;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.avail-icon {
  grid-row: span 2; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  font-weight: 800; font-size: 16px; background: var(--muted); color: var(--surface);
}
.avail-text { display: flex; flex-direction: column; line-height: 1.15; }
.avail-text strong { font-size: 15px; }
.avail-text span { font-size: 13px; color: var(--muted); }
.avail small { grid-column: 2; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avail[data-status="oui"] { background: var(--good-bg); }
.avail[data-status="oui"] .avail-icon { background: var(--good); }
.avail[data-status="oui"] .avail-text span { color: var(--good); font-weight: 600; }
.avail[data-status="faible"] { background: var(--warn-bg); }
.avail[data-status="faible"] .avail-icon { background: var(--warn); }
.avail[data-status="faible"] .avail-text span { color: var(--warn); font-weight: 600; }
.avail[data-status="rupture"] { background: var(--bad-bg); }
.avail[data-status="rupture"] .avail-icon { background: var(--bad); }
.avail[data-status="rupture"] .avail-text span { color: var(--bad); font-weight: 600; }
:root[data-theme="dark"] .avail-icon { color: #101417; }

.total-card .price-line { align-items: center; }
.total-card .updated { color: var(--muted); font-size: 12px; }
.total-more { padding: 0 16px 16px; }
.total-more .fuel-list { margin-top: 0; }
.total-more .nav-row { margin-top: 10px; }
.total-card .card-main { padding-right: 14px; }
