/* PumpYourTank — estilos. Tema via [data-theme] (definido por theme.js) */
:root {
  --bg: #f4f5f3;
  --card: #ffffff;
  --card-2: #f8f9f7;
  --text: #1b2220;
  --muted: #5d6965;
  --line: #e1e5e2;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f0;
  --cheap: #15803d;
  --mid: #b45309;
  --dear: #b91c1c;
  --s-fuel: #0d9488;
  --s-brent: #c2410c;
  --me: #2563eb;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 6px 20px rgba(16, 24, 22, .08);
  --glass: rgba(255, 255, 255, .82);
  --glass-line: rgba(16, 24, 22, .08);
  --pill-bg: var(--accent); --pill-ink: #ffffff; --pill-line: var(--accent);
  --primary-bg: var(--accent); --primary-ink: #ffffff; --primary-glow: 0 8px 24px rgba(15, 118, 110, .30);
  --card-sheen: none;
  --radius: 14px;
  --top-h: 60px;
  --bottom-h: 0px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #09090b;
  --card: #121215;
  --card-2: #18181c;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --line: rgba(255, 255, 255, .08);
  --accent: #34d399;
  --accent-ink: #052e1c;
  --accent-soft: rgba(52, 211, 153, .12);
  --cheap: #4ade80;
  --mid: #fbbf24;
  --dear: #f87171;
  --s-fuel: #0ea394;
  --s-brent: #e0661f;
  --me: #60a5fa;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 32px -12px rgba(0, 0, 0, .7);
  --glass: rgba(18, 18, 21, .72);
  --glass-line: rgba(255, 255, 255, .09);
  --pill-bg: rgba(52, 211, 153, .14); --pill-ink: #6ee7b7; --pill-line: rgba(52, 211, 153, .45);
  --primary-bg: linear-gradient(135deg, #4ade80 0%, #10b981 100%); --primary-ink: #052e1c;
  --primary-glow: 0 0 0 1px rgba(52, 211, 153, .35), 0 10px 30px -10px rgba(16, 185, 129, .5);
  --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 38%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
a { color: var(--accent); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; }
select, input[type=search] {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; width: 100%;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- barra de cima */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 1100; height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0; display: flex; align-items: center; gap: 16px;
  background: var(--glass); border-bottom: 1px solid var(--glass-line);
  -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-bg); color: var(--primary-ink); box-shadow: var(--primary-glow); display: grid; place-items: center; }
.logo svg { width: 20px; height: 20px; }
.brandname { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.brandname b { color: var(--accent); }
.mainnav { display: flex; gap: 4px; margin-left: 8px; }
.mainnav button {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .92rem;
}
.mainnav button:hover { background: var(--card-2); color: var(--text); }
.mainnav button.active { background: var(--pill-bg); color: var(--pill-ink); box-shadow: inset 0 0 0 1px var(--pill-line); }
.topctl { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.updated { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; cursor: pointer; border-radius: 7px; padding: 5px 11px; font-weight: 700; font-size: .88rem; color: var(--muted); }
.seg button.active { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
:root[data-theme="dark"] .seg { background: rgba(255, 255, 255, .04); }
:root[data-theme="dark"] .seg button.active { background: rgba(255, 255, 255, .09); color: #f4f4f5; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .iconbtn { background: rgba(255, 255, 255, .04); }
:root[data-theme="dark"] select, :root[data-theme="dark"] input[type=search] { background-color: rgba(255, 255, 255, .04); }
:root[data-theme="dark"] .modal { background: #121215; border: 1px solid rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .modal::backdrop { background: rgba(0, 0, 0, .65); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
/* mapa escuro mais profundo, para os pontos sobressaírem */
:root[data-theme="dark"] .base-darkgray .leaflet-tile-pane { filter: brightness(.62) contrast(1.15) saturate(.9); }
:root[data-theme="dark"] .leaflet-control-zoom a, :root[data-theme="dark"] .leaflet-control-layers { background: rgba(18, 18, 21, .8) !important; }
.seg.small button { font-size: .78rem; padding: 4px 9px; font-weight: 600; }
.iconbtn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.iconbtn:hover { border-color: var(--accent); color: var(--accent); }
.themebtn .ic-sun { display: none; }
:root[data-theme="dark"] .themebtn .ic-sun { display: block; }
:root[data-theme="dark"] .themebtn .ic-moon { display: none; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); font-size: .9rem; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--primary-bg); border-color: transparent; color: var(--primary-ink); font-weight: 600; box-shadow: var(--primary-glow); }
.btn:disabled { opacity: .6; cursor: progress; }

.bottomnav { display: none; }

/* ---------------- vista mapa */
.mapview { position: fixed; inset: calc(var(--top-h) + env(safe-area-inset-top, 0px)) 0 var(--bottom-h) 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { font: inherit; }
.leaflet-bar a, .leaflet-control-layers { background: var(--card) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-layers { border-radius: 12px !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-control-attribution { background: var(--card) !important; color: var(--muted) !important; opacity: .9; }
.leaflet-mask-pane { pointer-events: none; }
.leaflet-tooltip.pricetip { font-weight: 700; padding: 2px 6px; font-size: 12px; }
.leaflet-tooltip.stip { font-size: 12px; line-height: 1.3; }

.leftcol {
  position: absolute; top: 14px; left: 14px; bottom: 26px; z-index: 1000; width: min(440px, calc(100% - 80px));
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.leftcol > * { pointer-events: auto; }
.floattop { position: relative; flex: none; }
.stationcard {
  position: relative; flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 18px; box-shadow: var(--shadow); padding: 16px 16px 14px;
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
}
.stationcard .close { position: absolute; top: 10px; right: 10px; }
.stationcard h2 { margin: 0 40px 2px 0; font-size: 1.12rem; line-height: 1.25; }
.stationcard .sub { color: var(--muted); font-size: .82rem; }
.stationcard h3 { font-size: .88rem; margin: 14px 0 6px; }
.stationcard .chartbox { height: 170px; }
.stationcard .pricetable { font-size: .84rem; }
.stationcard .actions { margin-top: 10px; }
.stationcard .btn { padding: 7px 12px; font-size: .84rem; }
.sc-price { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.sc-price .big { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sc-price .lbl { color: var(--muted); font-size: .82rem; }
.searchbox {
  display: flex; align-items: center; gap: 6px; background: var(--glass); border-radius: 999px;
  box-shadow: var(--shadow); padding: 4px 4px 4px 14px; border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
}
.searchbox .sicon { color: var(--muted); }
.searchbox input { border: 0; background: none; padding: 8px 4px; font-size: .95rem; }
.searchbox input:focus-visible { outline: none; }
.locbtn { width: 38px; height: 38px; border-radius: 999px; border: 0; cursor: pointer; background: var(--primary-bg); color: var(--primary-ink); box-shadow: var(--primary-glow); display: grid; place-items: center; }
.locbtn.busy { opacity: .6; cursor: progress; }
.placeres {
  position: absolute; top: 54px; left: 0; right: 0; z-index: 5;
  list-style: none; margin: 0; padding: 6px; background: var(--glass); border-radius: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px); max-height: 50vh; overflow-y: auto;
}
.placeres li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.placeres li:hover, .placeres li.sel { background: var(--accent-soft); }
.placeres .ptype { font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); min-width: 66px; }
.placeres .pname { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.placeres .pctx { font-size: .75rem; color: var(--muted); }
.placeres .none { color: var(--muted); cursor: default; font-size: .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--text);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-radius: 999px; cursor: pointer;
  padding: 6px 12px; font-size: .84rem; font-weight: 600; box-shadow: var(--shadow); display: inline-flex; gap: 6px; align-items: center;
}
.chip.active { background: var(--pill-bg); border-color: var(--pill-line); color: var(--pill-ink); }
:root:not([data-theme="dark"]) .chip.active { background: var(--accent); color: #fff; }
.chip select { border: 0; background: none; padding: 0; font-weight: 600; font-size: .84rem; width: 5.2em; color: inherit; cursor: pointer; }
.chip select option { color: var(--text); background: var(--card); }

.rightcol {
  position: absolute; top: 14px; right: 64px; bottom: 26px; z-index: 1000; width: min(400px, calc(100% - 560px));
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.rightcol > * { pointer-events: auto; }
.areacard {
  margin-top: auto; flex: none; align-self: flex-end; width: 250px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px;
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
}
.aclabel { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.achead { display: flex; align-items: flex-start; gap: 6px; }
.achead .aclabel { flex: 1; min-width: 0; }
.acmin {
  flex: none; width: 24px; height: 24px; margin: -5px -7px 0 0; border: 0; border-radius: 8px; cursor: pointer;
  background: none; color: var(--muted); display: grid; place-items: center;
}
.acmin:hover { color: var(--accent); background: var(--accent-soft); }
.acmin svg.i { width: 16px; height: 16px; }
.acicon {
  margin-top: auto; flex: none; align-self: flex-end; width: 44px; height: 44px; border-radius: 14px; cursor: pointer;
  display: grid; place-items: center; color: var(--accent);
  background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
}
.acicon:hover { border-color: var(--accent); }
.acicon svg.i { width: 22px; height: 22px; }
.acicon[hidden] { display: none; }
.acscale { display: flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.acscale .bar { flex: 1; display: flex; gap: 2px; height: 10px; }
.acscale .bar i { flex: 1; border-radius: 3px; }
.acrows { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 10px 0 0; font-size: .82rem; }
.acrows dt { color: var(--muted); }
.acrows dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.besttoggle {
  flex: none; display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer; text-align: left;
  border: 1px solid var(--glass-line); border-radius: 14px; padding: 11px 14px; font-weight: 700; font-size: .95rem;
  background: var(--glass); color: var(--text); box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
}
.besttoggle > .i:first-child { color: var(--accent); }
.besttoggle .bt-sum { margin-left: auto; font-weight: 600; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.besttoggle .chev { transition: transform .2s; color: var(--muted); }
.besttoggle[aria-expanded="true"] { border-color: var(--pill-line); }
.besttoggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.besttoggle:hover { border-color: var(--pill-line); }
.leftcol .panel .panelhead { display: none; }
.leftcol .panel .locline { padding-top: 14px; }

.panel {
  position: relative; flex: 1 1 auto; min-height: 0; width: 100%;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
}
.panelhead { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 4px 18px; }
.panelhead h2 { margin: 0; font-size: 1.1rem; }
.locline { padding: 0 18px 8px; font-size: .82rem; color: var(--muted); }
.locline b { color: var(--text); }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--glass-line); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; cursor: pointer; white-space: nowrap; color: var(--muted);
  border-bottom: 2px solid transparent; padding: 8px 8px; font-size: .84rem;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.scopeopts { padding: 10px 14px 0; display: flex; flex-direction: column; gap: 8px; }
.range { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.range input { flex: 1; accent-color: var(--accent); }
.areasel, .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.areasel select:nth-child(3) { grid-column: 1 / -1; }
.summary { padding: 10px 16px 6px; font-size: .82rem; color: var(--muted); }
.summary b { color: var(--text); }
.results { list-style: none; margin: 0; padding: 4px 12px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  transition: border-color .15s, background-color .15s, transform .15s;
}
.card:hover { border-color: var(--pill-line); background: var(--accent-soft); }
:root[data-theme="dark"] .card { background: rgba(255, 255, 255, .03); }
.rank { font-weight: 700; color: var(--muted); text-align: center; font-size: .85rem; }
.card .name { font-weight: 600; line-height: 1.25; font-size: .92rem; }
.card .sub { color: var(--muted); font-size: .78rem; }
.price { font-weight: 800; font-size: 1.08rem; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.price small { display: block; font-weight: 500; font-size: .7rem; color: var(--muted); }
.p-cheap { color: var(--cheap); } .p-mid { color: var(--mid); } .p-dear { color: var(--dear); }
.stale { color: var(--mid); }
.empty, .error { padding: 16px; text-align: center; color: var(--muted); border-radius: 12px; border: 1px dashed var(--line); list-style: none; }
.error { color: var(--dear); }

/* ---------------- estatísticas */
.statspage { position: fixed; inset: calc(var(--top-h) + env(safe-area-inset-top, 0px)) 0 var(--bottom-h) 0; overflow-y: auto; }
.statsinner { max-width: 1280px; margin: 0 auto; padding: 22px 20px 32px; display: flex; flex-direction: column; gap: 16px; }
.statshead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.statshead h1 { margin: 0; font-size: 1.7rem; letter-spacing: -.01em; }
.statshead p { margin: 4px 0 0; font-size: .9rem; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--muted); }
.pills button.active { background: var(--pill-bg); border-color: var(--pill-line); color: var(--pill-ink); }
:root:not([data-theme="dark"]) .pills button.active { background: var(--accent); color: #fff; }
.pills .pill-more { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 3px 8px; }
.pills .pill-more select { border: 0; background: none; padding: 3px 0; font-weight: 600; font-size: .86rem; width: 5.2em; color: var(--muted); cursor: pointer; }
.pills .pill-more.active { background: var(--pill-bg); border-color: var(--pill-line); }
.pills .pill-more.active select { color: var(--pill-ink); }
:root:not([data-theme="dark"]) .pills .pill-more.active { background: var(--accent); }
:root:not([data-theme="dark"]) .pills .pill-more.active select { color: #fff; }
.insight {
  display: flex; align-items: center; gap: 14px; border-radius: var(--radius); padding: 14px 16px;
  background: linear-gradient(90deg, var(--accent), #0e7490); color: #fff;
}
:root[data-theme="dark"] .insight {
  background: linear-gradient(120deg, rgba(52, 211, 153, .16), rgba(16, 185, 129, .06) 60%, rgba(52, 211, 153, .03));
  border: 1px solid rgba(52, 211, 153, .28); color: var(--text);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .02) inset, 0 20px 40px -24px rgba(16, 185, 129, .45);
}
:root[data-theme="dark"] .insight .bulb { color: #6ee7b7; }
:root[data-theme="dark"] .insight .ilabel { color: #6ee7b7; opacity: 1; }
:root[data-theme="dark"] .inav .iconbtn { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .08); }
.insight .bulb { width: 26px; height: 26px; }
.itext { flex: 1; min-width: 0; font-size: .98rem; }
#insighttext { display: grid; }
#insighttext .ins { grid-area: 1 / 1; visibility: hidden; }
#insighttext .ins.on { visibility: visible; }
.ilabel { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; opacity: .85; }
.inav { display: flex; align-items: center; gap: 8px; }
.inav .iconbtn { width: 30px; height: 30px; background: rgba(255, 255, 255, .18); border-color: transparent; color: inherit; }
.dots { display: flex; gap: 5px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; }
.dots i.on { opacity: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--card) var(--card-sheen); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .lbl { font-size: .7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .note { font-size: .78rem; color: var(--muted); }
.delta-up { color: var(--dear); } .delta-down { color: var(--cheap); } .delta-flat { color: var(--muted); }
.sech { font-size: .78rem; margin: 10px 0 -6px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 14px; }
.sbox { background: var(--card) var(--card-sheen); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.sbox h3 { margin: 0 0 2px; font-size: 1rem; }
.sbox .hint { font-size: .8rem; color: var(--muted); margin: 0 0 10px; }
.sbox.placeholder { align-self: start; border-style: dashed; box-shadow: none; }
.boxhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.boxctl { display: flex; gap: 8px; flex-wrap: wrap; }
.brentgrid { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; margin-top: 6px; }
@media (max-width: 900px) { .brentgrid { grid-template-columns: 1fr; } }
.chartbox { position: relative; height: 240px; }
.chartbox.tall { height: 340px; }
.brentside { display: flex; flex-direction: column; gap: 10px; }
.bs-item { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.bs-item .lbl { font-size: .72rem; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.bs-item .lbl i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bs-item .val { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.bs-item .sub { font-size: .75rem; color: var(--muted); }
.chgtable { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; }
.chgtable th, .chgtable td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.chgtable th:first-child, .chgtable td:first-child { text-align: left; }
.chgtable th { color: var(--muted); font-weight: 600; font-size: .72rem; }
.legendtoggles { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.legendtoggles button {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: .8rem; color: var(--muted);
}
.legendtoggles button i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; opacity: .3; }
.legendtoggles button.on { color: var(--text); border-color: var(--muted); font-weight: 600; }
.legendtoggles button.on i { opacity: 1; }
.weekday { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.wkrow { display: grid; grid-template-columns: 120px 1fr 90px; gap: 10px; align-items: center; font-size: .86rem; }
.wkrow.best .wkname { color: var(--cheap); font-weight: 700; }
.wkrow.worst .wkname { color: var(--dear); font-weight: 700; }
.wktrack { position: relative; height: 16px; }
.wktrack::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: .5; }
.wkbar { position: absolute; top: 3px; height: 10px; border-radius: 4px; background: var(--muted); opacity: .55; }
.wkrow.best .wkbar { background: var(--cheap); opacity: 1; }
.wkrow.worst .wkbar { background: var(--dear); opacity: 1; }
.wkval { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.wknote { font-size: .82rem; color: var(--muted); margin-top: 8px; }
/* nome do posto clicável (abre o caminho no Google Maps), com o pin antes do nome */
.gmlink { display: inline-flex; align-items: flex-start; gap: 6px; color: inherit; text-decoration: none; }
.gmlink:hover span { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
/* margens negativas: o pin é maior mas não mexe na altura da linha nem na formatação do nome */
.gmico { width: 24px; height: 24px; flex: none; margin: -3px 0 -6px -2px; }
.sc-metric { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); font-size: .84rem; }
.locbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: var(--card) var(--card-sheen); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.locbar .range { flex: 1; min-width: 220px; }
/* as listas ocupam a altura toda do cartão; a altura da linha vem do mapa/ranking (flex-basis 0) */
.dpbox { display: flex; flex-direction: column; }
.dplist { list-style: none; margin: 0; padding: 0; flex: 1 1 0; min-height: 260px; overflow-y: auto; overscroll-behavior: contain; }
.dplist[hidden] { display: none; }
/* grupo de secção dentro das estatísticas: mesmo espaçamento que o resto da página */
.statsgroup { display: flex; flex-direction: column; gap: 16px; }
.statsgroup[hidden] { display: none; }
/* título do cartão + ✕ para limpar a seleção desse cartão (só aparece quando há algo escolhido) */
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; margin-bottom: 2px; }
.cardhead h3 { margin: 0; min-width: 0; }
/* o ✕ usa o mesmo estilo do ✕ das fichas (.iconbtn); margens negativas para não aumentar a linha do título */
.clearx.iconbtn { flex: none; width: 32px; height: 32px; margin: -7px 0; padding: 0; }
.clearx[hidden] { display: none; }
/* "Todas as freguesias" fica fixa no topo da lista ao fazer scroll */
.dplist li[data-freg=""] { position: sticky; top: 0; z-index: 1; background: var(--card); }
.dplist li[data-freg=""].sel { background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--card); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
/* ficha ao lado do "Raio": fica com a altura da linha e faz scroll por dentro */
.tstation { display: flex; flex-direction: column; min-height: 420px; overflow: hidden; }
.dpstation .tsscroll { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* ✕ dentro da área com scroll: fixo no topo, à direita, antes da barra de scroll; o título contorna-o */
.dpstation .close { position: sticky; top: 0; float: right; margin: 0 4px 4px 8px; z-index: 2; }
.dpstation .close[hidden] { display: none; }
.toplist li.on { background: var(--accent-soft); border-radius: 8px; box-shadow: inset 3px 0 0 var(--accent); }
.dpstation #dpsbody > h3:first-child, .dpstation #tsbody > h3:first-child { margin: 0 0 2px; font-size: 1rem; }   /* título do cartão vazio, igual aos outros */
.dpstation h2 { margin: 0 0 2px; font-size: 1.12rem; line-height: 1.25; }
.dpstation .sub { color: var(--muted); font-size: .82rem; }
.dpstation h3 { font-size: .88rem; margin: 14px 0 6px; }
.dpstation .chartbox { height: 170px; }
.dpstation .pricetable { font-size: .84rem; }
.dpstation .btn { padding: 7px 12px; font-size: .84rem; }
.dplist li { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: .84rem; line-height: 1.25; }
.dplist li:hover { background: var(--accent-soft); }
.dplist li.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.dplist li.sel .dpname { font-weight: 700; color: var(--accent); }
.dplist .dpmain { flex: 1; min-width: 0; }
.dplist .dpname { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dplist .dpsub { display: block; font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dplist .dpval { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .8rem; }
.dplist .dpval.n { color: var(--muted); font-weight: 600; }
/* mapa do distrito ao lado do "Raio": ocupa a altura da linha (definida pelo cartão do Raio) */
.dmapbox { display: flex; flex-direction: column; }
.dmap { flex: 1 1 0; min-height: 260px; border-radius: 10px; background: var(--card-2); }
/* "Explorar por distrito": todos os cartões com a altura do maior entre o mapa e o ranking completo
   (--exrow, medido em JS a partir do conteúdo, para o ranking nunca ter scroll) */
.exgrid { grid-auto-rows: var(--exrow, auto); }
.exgrid > .sbox { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.exgrid > .sbox[hidden] { display: none; }
.exgrid > #chorobox > *, .exgrid > #rankbox > * { flex-shrink: 0; }   /* medidos pelo conteúdo: não encolher */
.exgrid > #brandsbox { grid-column: -2 / -1; }   /* marcas sempre na última coluna, à direita */
.exgrid #sbrands { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.exgrid .dplist { min-height: 0; }
/* alvos de toque maiores no telemóvel (mín. ~32 px): a caixa "Outros combustíveis" ocupa o chip todo
   e os links do rodapé ganham altura, sem mudar o aspeto */
@media (max-width: 760px) {
  .chip select { padding-block: 6px; margin-block: -6px; }
  .footer a { display: inline-block; padding-block: 6px; }
}
/* mobile (uma coluna): cada cartão fica com a altura do conteúdo quando este é menor;
   se for maior, fica com a altura atual (--exrow) e faz scroll por dentro */
@media (max-width: 760px) {
  .exgrid { grid-auto-rows: auto; }
  .exgrid > .sbox { max-height: var(--exrow, none); }
  .exgrid .dplist, .exgrid #sbrands, .exgrid .dpstation .tsscroll { flex: 0 1 auto; }
}
/* a linha destacada (.me) usa margem negativa de 6px: dar-lhe folga dentro da área com scroll, sem scroll horizontal */
.exgrid #sbrands { overflow-x: hidden; padding-inline: 6px; margin-inline: -6px; }
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 7px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.toplist li:first-child { border-top: 0; }
.toplist li:hover .tname { color: var(--accent); }
.toplist .rk { font-weight: 700; color: var(--muted); font-size: .85rem; text-align: center; }
.toplist .tname { font-weight: 600; font-size: .88rem; line-height: 1.2; }
.toplist .tsub { font-size: .75rem; color: var(--muted); }
.toplist .tp { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.two h4 { margin: 0 0 4px; font-size: .8rem; color: var(--muted); }
.two .toplist li { cursor: default; grid-template-columns: 1fr auto; }
.choromap { height: 420px; background: var(--card-2); border-radius: 10px; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: .72rem; color: var(--muted); }
.legend .sw { display: inline-flex; align-items: center; gap: 4px; }
.legend .legico { width: 16px; height: 16px; }
.legend .legtitle { flex-basis: 100%; font-weight: 700; color: var(--text); }
.legend .legstats { flex-basis: 100%; }
.legend .sw i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.leaflet-tooltip.chorotip { font-size: 12px; line-height: 1.35; }
.strip { list-style: none; margin: 0; padding: 0; }
.strip li { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 58px; gap: 8px; align-items: center; padding: 3px 0; font-size: .82rem; }
.strip li[data-code], .strip li[data-brand] { cursor: pointer; border-radius: 8px; }
.strip li[data-code]:hover, .strip li[data-brand]:hover { background: var(--accent-soft); }
.strip li.me { background: var(--accent-soft); border-radius: 8px; margin-inline: -6px; padding-inline: 6px; box-shadow: inset 3px 0 0 var(--accent); }
.strip li.me .sname, .strip li.me .sval { font-weight: 800; color: var(--accent); }
.strip li.me .dot { width: 14px; height: 14px; margin-left: -7px; top: 1px; }
.strip .sname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .track { position: relative; height: 16px; }
.strip .track::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 2px; border-radius: 2px; background: var(--line); }
.strip .dot { position: absolute; top: 3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--card); }
.strip .sval { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.strip-axis { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 58px; gap: 8px; font-size: .7rem; color: var(--muted); }
.strip-axis span:nth-child(2) { display: flex; justify-content: space-between; }
.footer { font-size: .75rem; color: var(--muted); padding: 10px 2px 0; border-top: 1px solid var(--line); }

/* ---------------- modal do posto */
.modal {
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  border: 0; border-radius: 18px; padding: 22px; background: var(--card); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.modal::backdrop { background: rgba(0, 0, 0, .5); }
.modal .close { position: absolute; top: 12px; right: 12px; }
.modal h2 { margin: 0 44px 2px 0; font-size: 1.25rem; }
.modal .sub { color: var(--muted); font-size: .88rem; }
.modal h3 { font-size: .95rem; margin: 18px 0 8px; }
.tablewrap { overflow-x: auto; }
.pricetable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.pricetable td, .pricetable th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.pricetable th { font-size: .75rem; color: var(--muted); font-weight: 600; }
.pricetable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip { background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; font-size: .8rem; }
.hours { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: .88rem; }
.hours dt { color: var(--muted); }
.hours dd { margin: 0; }
.charthead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 18px 0 8px; }
.charthead h3 { margin: 0; flex: 1; }
.charthead select { width: auto; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------------- telemóvel */
@media (max-width: 760px) {
  :root { --top-h: 56px; --bottom-h: calc(62px + env(safe-area-inset-bottom, 0px)); }
  .mainnav, .updated { display: none; }
  .brandname { font-size: 1.05rem; }
  .topbar { gap: 10px; padding-inline: 12px; }
  .bottomnav {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 1100; height: var(--bottom-h);
    padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--glass); border-top: 1px solid var(--glass-line);
    -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
  }
  .bottomnav button {
    flex: 1; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; font-size: .74rem; font-weight: 600; color: var(--muted);
  }
  .bottomnav button svg { width: 22px; height: 22px; }
  .bottomnav button.active { color: var(--accent); }
  .leftcol { top: 10px; left: 10px; bottom: 84px; width: calc(100% - 64px); }
  .rightcol { top: auto; right: auto; left: 10px; bottom: 84px; width: 190px; }
  .wkrow { grid-template-columns: 96px 1fr 76px; }
  .stationcard {
    position: fixed; left: 0; right: 0; bottom: var(--bottom-h); z-index: 1060; max-height: 62%;
    border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
  }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
  .chip { flex: none; }
  .areacard { width: 190px; padding: 10px 12px; }
  .areacard .acrows { display: none; }
  .leftcol .panel .panelhead { display: flex; }
  .leftcol .panel .locline { padding-top: 0; }
  .besttoggle { padding: 9px 12px; font-size: .88rem; }
  .acicon { align-self: flex-start; }
  .mapview.panel-open .areacard, .mapview.card-open .areacard,
  .mapview.panel-open .acicon, .mapview.card-open .acicon { display: none; }
  .mapview.card-open .panel { display: none; }
  /* folhas inferiores: opacas e com pega, como nas apps nativas */
  .panel, .stationcard { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .panel { padding-top: 8px; }
  .stationcard { padding-top: 22px; }
  .panel::before, .stationcard::before {
    content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px;
    border-radius: 2px; background: var(--muted); opacity: .4;
  }
  /* estatísticas compactas */
  .statshead p { font-size: .84rem; }
  .pills, .legendtoggles { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; padding-inline: 14px; }
  .pills::-webkit-scrollbar, .legendtoggles::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
  .pills > *, .legendtoggles > * { flex: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .val { font-size: 1.22rem; }
  .kpi .note { font-size: .72rem; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .insight { padding: 12px; gap: 10px; align-items: flex-start; }
  .insight .bulb { width: 20px; height: 20px; margin-top: 2px; }
  .itext { font-size: .88rem; }
  .inav { flex-direction: column; gap: 6px; }
  .inav .iconbtn { width: 28px; height: 28px; }
  .sbox { padding: 14px; }
  .sbox .hint { font-size: .76rem; }
  .panel { position: fixed; top: auto; left: 0; right: 0; bottom: var(--bottom-h); z-index: 1055; width: 100%; height: 70%; border-radius: 18px 18px 0 0; }
  .statsinner { padding: 16px 14px 28px; }
  .statshead h1 { font-size: 1.4rem; }
  .inav .dots { display: none; }
  .chartbox.tall { height: 280px; }
}
:root[data-theme="dark"] .searchbox input,
:root[data-theme="dark"] .chip select,
:root[data-theme="dark"] .pills .pill-more select { background: none; }
