/* Comparatore luce e gas — mobile first, poi due colonne da 960px. */

/*
 * Tema. Il tema scuro vale in due casi: «automatico» (nessun data-theme su <html>,
 * decide il dispositivo con @media (prefers-color-scheme: dark)) e scelta esplicita
 * (<html data-theme="dark">). Ogni blocco scuro ha quindi due scritture con le stesse
 * dichiarazioni: sotto @media con :root:where(:not([data-theme="light"])) davanti al
 * selettore, e fuori con :root[data-theme="dark"]. Qui le differenze di colore sono
 * tutte variabili, così i blocchi sono uno solo e restano corti.
 */

:root {
  --bg: #f6f7fb;
  --bg-2: #eceef5;
  --card: #ffffff;
  --text: #151821;
  --muted: #646b7d;
  --line: #e3e6ef;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 8px 24px rgba(20, 24, 40, .06);
  --radius: 18px;
  --good: #12a150;
  --warn: #c77700;
  --warn-text: #8f5200;       /* testo e link d'avviso: almeno 4,5:1 su bianco e sul riquadro tinto */
  --good-text: #0b7a3a;
  --muted-strong: #555c6e;    /* testo sotto i 12 px: --muted non arriva a 4,5:1 sugli sfondi tinti */
  --bad: #d14343;
  --accent: #f2a900;
  --accent-2: #ff7a1a;
  --accent-soft: rgba(242, 169, 0, .14);
  --accent-ink: #5a3d00;
  --c-energia: #f2a900;
  --c-fisso: #7c5cff;
  --c-disp: #2bb3a3;
  --c-rete: #4c8dff;
  --c-accise: #e2557a;
  --c-iva: #9aa3b5;
  --c-rai: #3c4458;
  --bad-text: #d14343;
  --good-ink: #12a150;
  --teal-text: #0b6b5f;
  --dual-text: #5a3fd6;
  --tm-mix: 90%;
  --sheen: rgba(255, 255, 255, .22);
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

[data-kind="luce"] {
  --accent: #f2a900;
  --accent-2: #ff7a1a;
  --accent-soft: rgba(242, 169, 0, .14);
  --accent-ink: #5a3d00;
  --c-energia: #f2a900;
  --c-rete: #4c8dff;
}
[data-kind="mercato"] {
  --accent: #12a37f;
  --accent-2: #4fd1a5;
  --accent-soft: rgba(18, 163, 127, .13);
  --accent-ink: #064d3b;
}
[data-kind="dual"] {
  --accent: #7c5cff;
  --accent-2: #f2a900;
  --accent-soft: rgba(124, 92, 255, .14);
  --accent-ink: #34208f;
}
[data-kind="gas"] {
  --accent: #2f7bff;
  --accent-2: #19c2d8;
  --accent-soft: rgba(47, 123, 255, .13);
  --accent-ink: #0b2c66;
  --c-energia: #2f7bff;
  --c-rete: #ff9f43;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --bg: #0f1115;
    --bg-2: #161922;
    --card: #181b24;
    --text: #eef0f6;
    --muted: #9aa1b2;
    --muted-strong: #adb3c2;
    --warn-text: #ffb44d;
    --good-text: #4cd38a;
    --line: #262a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
    --accent-ink: #ffd36b;
    --c-rai: #6b7590;
    --bad-text: #ff8a8a;
    --good-ink: #4cd38a;
    --teal-text: #5fd6c7;
    --dual-text: #b9a8ff;
    --tm-mix: 88%;
    --sheen: rgba(255, 255, 255, .08);
  }
  :root:where(:not([data-theme="light"])) [data-kind="luce"] { --accent-ink: #ffd36b; }
  :root:where(:not([data-theme="light"])) [data-kind="gas"] { --accent-ink: #9cc2ff; }
  :root:where(:not([data-theme="light"])) [data-kind="mercato"] { --accent-ink: #7be3c3; }
  :root:where(:not([data-theme="light"])) [data-kind="dual"] { --accent-ink: #c4b5ff; }
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-2: #161922;
  --card: #181b24;
  --text: #eef0f6;
  --muted: #9aa1b2;
  --muted-strong: #adb3c2;
  --warn-text: #ffb44d;
  --good-text: #4cd38a;
  --line: #262a36;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  --accent-ink: #ffd36b;
  --c-rai: #6b7590;
  --bad-text: #ff8a8a;
  --good-ink: #4cd38a;
  --teal-text: #5fd6c7;
  --dual-text: #b9a8ff;
  --tm-mix: 88%;
  --sheen: rgba(255, 255, 255, .08);
}
:root[data-theme="dark"] [data-kind="luce"] { --accent-ink: #ffd36b; }
:root[data-theme="dark"] [data-kind="gas"] { --accent-ink: #9cc2ff; }
:root[data-theme="dark"] [data-kind="mercato"] { --accent-ink: #7be3c3; }
:root[data-theme="dark"] [data-kind="dual"] { --accent-ink: #c4b5ff; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  transition: background .4s;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- header + tab ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px var(--accent-soft);
  position: relative;
}
.logo::after {
  content: "⚡"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 20px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}
body[data-kind="gas"] .logo::after { content: "🔥"; }
h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 12.5px; }

.tabs {
  position: relative; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg-2); border-radius: 14px; padding: 4px;
}
.tabs button {
  position: relative; z-index: 1; border: 0; background: none;
  padding: 9px 0; border-radius: 10px; font-weight: 650; color: var(--muted);
  transition: color .25s;
}
.tabs button[aria-selected="true"] { color: var(--text); }
.tab-ink {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 4);
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- layout ---------- */
.layout { padding: 14px 14px 40px; max-width: 1240px; margin: 0 auto; }
.controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 14px; min-width: 0; }
body[data-kind="luce"] .only-gas, body[data-kind="gas"] .only-luce { display: none; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.eyebrow {
  display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.hint { margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }

/* hero: il numero grande */
.hero { padding-top: 16px; }
.big-value { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.big-value .num {
  width: 5.2ch; border: 0; background: none; padding: 0;
  font-size: 40px; font-weight: 800; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.big-value .num::-webkit-outer-spin-button, .big-value .num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.big-value .unit { color: var(--muted); font-weight: 600; }

/* slider */
.slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: none; margin: 4px 0;
  --pct: 50%;
}
.slider::-webkit-slider-runnable-track {
  height: 8px; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)) 0 / var(--pct) 100% no-repeat, var(--bg-2);
}
.slider::-moz-range-track { height: 8px; border-radius: 99px; background: var(--bg-2); }
.slider::-moz-range-progress { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 4px var(--accent-soft);
  transition: transform .15s;
}
.slider::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 4px var(--accent-soft);
}
.slider:active::-webkit-slider-thumb { transform: scale(1.12); }
.slider.small { height: 28px; }
.slider.small::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -7px; }

/* chips e segmented */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 99px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .2s;
}
.chip small { font-weight: 500; color: var(--muted-strong); margin-left: 4px; }
.chip[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent-ink); border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.seg { display: flex; background: var(--bg-2); border-radius: 12px; padding: 3px; margin: 8px 0 4px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 9px; padding: 7px 6px;
  font-size: 13px; font-weight: 650; color: var(--muted); line-height: 1.2;
}
.seg button small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted-strong); }
.seg button[aria-checked="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.custom-index { display: none; }
.custom-index.on { display: block; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 42px; height: 25px; border-radius: 99px; background: var(--bg-2); position: relative; flex: none;
  border: 1px solid var(--line); transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s;
}
.switch input:checked + .track { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* details/summary */
details.card > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; margin-left: 8px; }
details[open].card > summary::after { transform: rotate(180deg); }
details.card > summary .eyebrow { flex: 1; }
.summary-val { font-size: 13px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.mini-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.fasce-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 8px 0 2px; background: var(--bg-2); }
.fasce-bar span { transition: flex-basis .2s; }
.fasce-bar .f1 { background: var(--accent); }
.fasce-bar .f2 { background: color-mix(in srgb, var(--accent) 55%, var(--card)); }
.fasce-bar .f3 { background: color-mix(in srgb, var(--accent) 25%, var(--card)); }

/* campi */
.field-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.field-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field-row label.grow { flex: 1 1 140px; }
.field-row input, .field-row select, .search {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 10px; padding: 9px 10px;
  font-size: 15px; color: var(--text); width: 100%;
}
.field-row input[type="number"] { width: 110px; }
.search { margin-top: 10px; }
.filters .switch { margin-top: 4px; }

/* ---------- risultati ---------- */
.summary { padding: 12px 16px; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat.best b { color: var(--good); }
.histo { display: flex; align-items: flex-end; gap: 2px; height: 34px; margin-top: 10px; }
.histo i { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; min-height: 2px; transition: height .25s; }
.histo i.hot { background: var(--accent); }

.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.offer {
  position: relative; display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 10px; align-items: center;
  padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); cursor: pointer; will-change: transform;
  transition: border-color .2s, box-shadow .2s;
}
.offer:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.offer:active { transform: scale(.995); }
.offer .rank {
  grid-row: span 2; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; background: var(--bg-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.offer:nth-child(1) .rank { background: linear-gradient(135deg, #ffd34d, #f2a900); color: #4a3200; }
.offer:nth-child(2) .rank { background: linear-gradient(135deg, #e7ebf3, #b9c2d3); color: #2c3446; }
.offer:nth-child(3) .rank { background: linear-gradient(135deg, #f4c9a1, #d08a4f); color: #4a2a0c; }
.offer .name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer .meta { grid-column: 2; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.offer .price { grid-row: span 2; text-align: right; font-variant-numeric: tabular-nums; }
.offer .price b { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.offer .price span { font-size: 12px; color: var(--muted); }
.offer .price em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }
.offer .bar { grid-column: 2 / 4; height: 4px; border-radius: 99px; background: var(--bg-2); overflow: hidden; margin-top: 4px; }
.offer .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.offer.enter { animation: enter .35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.badge {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 99px;
  font-size: 11px; font-weight: 700; background: var(--bg-2); color: var(--muted); white-space: nowrap;
}
.badge.F { background: var(--accent-soft); color: var(--accent-ink); }
.badge.V { background: rgba(43, 179, 163, .14); color: var(--teal-text); }
.badge.warn { background: rgba(199, 119, 0, .13); color: var(--warn-text); }
.badge.bad { background: rgba(209, 67, 67, .12); color: var(--bad-text); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.more {
  display: block; width: 100%; margin: 12px 0; padding: 12px; border-radius: 14px;
  border: 1px dashed var(--line); background: none; color: var(--muted); font-weight: 650;
}
.foot { color: var(--muted); font-size: 12px; margin-top: 18px; line-height: 1.55; }
.foot a { color: inherit; }
.warnbox { border: 1px solid rgba(199,119,0,.35); background: rgba(199,119,0,.08); color: var(--warn-text); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }

/* ---------- bottom sheet / drawer ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(8, 10, 16, .45); z-index: 40;
  opacity: 0; transition: opacity .25s;
}
.sheet-backdrop.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 92vh;
  background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.on { transform: none; }
.grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 8px auto 0; flex: none; }
.close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--bg-2); color: var(--muted); font-size: 15px;
}
.sheet-body { overflow-y: auto; padding: 10px 18px 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.d-head { padding-right: 40px; }
.d-head h2 { font-size: 20px; margin: 6px 0 2px; letter-spacing: -.01em; line-height: 1.25; }
.d-head .vendor { color: var(--muted); font-size: 13.5px; }
.d-head .badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.d-total { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.d-total b { font-size: 34px; font-weight: 850; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.d-total span { color: var(--muted); font-weight: 600; }
.d-rank { color: var(--muted); font-size: 13px; }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin: 14px 0 8px; background: var(--bg-2); }
.stack i { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.legend .k { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.legend .k::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.legend .v { text-align: right; font-weight: 650; }
.legend .tot { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; font-weight: 800; color: var(--text); }
.d-sec { margin-top: 22px; }
.d-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 650; padding-left: 10px; }
.tbl small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--muted); background: var(--bg-2); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.note.warn { color: var(--warn-text); background: rgba(199,119,0,.09); }
.desc { font-size: 13.5px; color: var(--muted); white-space: pre-line; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  flex: 1 1 140px; text-align: center; text-decoration: none; padding: 11px 14px; border-radius: 12px;
  font-weight: 700; font-size: 14px; border: 1px solid var(--line); color: var(--text); background: var(--bg-2);
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; text-shadow: 0 1px 1px rgba(0,0,0,.2); }
.loading { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ---------- desktop ---------- */
@media (min-width: 960px) {
  .top { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; }
  .brand { margin: 0; }
  .tabs { width: 520px; }
  .layout { display: grid; grid-template-columns: 370px 1fr; gap: 22px; padding: 22px 28px 60px; align-items: start; }
  .controls {
    position: sticky; top: 86px; max-height: calc(100vh - 100px); overflow-y: auto;
    padding-right: 4px; margin: 0; scrollbar-width: thin;
  }
  .offer { grid-template-columns: 40px 1fr auto; padding: 14px 18px; }
  .offer .price b { font-size: 20px; }
  .sheet {
    left: auto; top: 0; bottom: 0; width: min(540px, 92vw); max-height: none;
    border-radius: 22px 0 0 22px; transform: translateX(100%);
  }
  .grab { display: none; }
  .sheet-body { padding: 22px 26px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- mobile first: slider agganciato, impostazioni richiudibili ---------- */
.sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > div { min-width: 0; }
.mini {
  display: flex; align-items: center; gap: 12px;
  max-height: 0; opacity: 0; overflow: hidden; pointer-events: none;
  transition: max-height .25s, opacity .2s, margin .25s;
}
.top.show-mini .mini { max-height: 48px; opacity: 1; pointer-events: auto; margin-top: 8px; }
.mini-val { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 92px; font-size: 15px; }
.mini .slider { flex: 1; margin: 0; }

.where { padding: 10px 16px; }
.where-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.where-row select {
  flex: 0 1 200px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 10px;
  padding: 8px 10px; font-size: 15px; font-weight: 600; color: var(--text); min-width: 0;
}

.settings > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.settings > summary::-webkit-details-marker { display: none; }
.settings > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
.settings[open] > summary::after { transform: rotate(180deg); }
.settings-sum { padding: 12px 16px; }
.settings-sum .eyebrow { flex: none; }
.settings-txt { flex: 1; min-width: 0; text-align: right; font-size: 12.5px; color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-body { display: grid; gap: 12px; margin-top: 12px; }

.nudge { margin: 10px 0 0; font-size: 13px; color: var(--warn-text); }
.nudge button { border: 0; background: none; color: inherit; text-decoration: underline; padding: 0; font-weight: 700; }

.big-value .num { width: auto; min-width: 3ch; }

@media (max-width: 599px) {
  .badge.fasce { display: none; }
  h1 { font-size: 16px; }
  .logo { width: 34px; height: 34px; }
  .big-value .num { font-size: 38px; }
}
@media (min-width: 960px) {
  .mini { display: none; }
  .settings > summary { display: none; }
  .settings-body { margin-top: 0; }
}
.legend { column-gap: 0; }
.legend .v { padding-left: 12px; }

/* ---------- tab Mercato ---------- */
:root { --c-pun: #f2a900; --c-psv: #2f7bff; --c-alt: #7c5cff; }
.market { display: none; padding: 14px 14px 40px; max-width: 1240px; margin: 0 auto; }
body[data-kind="mercato"] .layout { display: none; }
body[data-kind="mercato"] .market { display: block; }
body[data-kind="mercato"] .logo::after { content: "📈"; }
.market .card { margin-bottom: 12px; }
.chart-card h2 { font-size: 16px; margin: 0 0 2px; letter-spacing: -.01em; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.small-seg { margin: 0; flex: 0 0 auto; }
.small-seg button { padding: 6px 10px; font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 10px 0 6px; }
.kpi { background: var(--bg-2); border-radius: 12px; padding: 8px 10px; }
.kpi span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 17px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.up b { color: var(--bad-text); }
.kpi.down b { color: var(--good-ink); }
.chart { position: relative; width: 100%; margin-top: 6px; touch-action: pan-y; }
.svgchart { display: block; width: 100%; height: auto; overflow: visible; }
.svgchart .grid { stroke: var(--line); stroke-width: 1; }
.svgchart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.svgchart .ref { stroke: var(--muted); stroke-dasharray: 3 4; stroke-width: 1; opacity: .8; }
.svgchart .ref-label { fill: var(--muted); font-size: 10.5px; font-weight: 600; }
.svgchart .guide { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.tip {
  position: absolute; top: 0; pointer-events: none; background: var(--text); color: var(--bg);
  border-radius: 10px; padding: 6px 9px; font-size: 12.5px; line-height: 1.35; white-space: nowrap;
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums; z-index: 2;
}
.tip small { opacity: .75; }
.grid2 { display: grid; gap: 12px; }
.grid2 .card { margin-bottom: 0; }
.grid2 { margin-bottom: 12px; }
.section-title { font-size: 19px; margin: 26px 2px 2px; letter-spacing: -.01em; }
.section-hint { margin: 0 2px 10px; }
.facts-tabs { max-width: 320px; margin-bottom: 12px; }
.facts { display: grid; gap: 12px; }
.fact { margin: 0 !important; display: flex; flex-direction: column; gap: 4px; }
.fact-head { display: flex; align-items: center; gap: 8px; }
.fact-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fact-icon { font-size: 20px; }
.fact-big { font-size: 24px; font-weight: 850; letter-spacing: -.02em; }
.fact p { margin: 2px 0 4px; font-size: 14px; color: var(--muted); }
.fact-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.fact-list button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; text-align: left;
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 12px; padding: 8px 10px;
}
.fact-list button:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.fl-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-meta { grid-column: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-val { grid-row: 1 / 3; grid-column: 2; align-self: center; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.fl-val small { display: block; font-weight: 600; color: var(--muted); font-size: 11.5px; }
@media (min-width: 760px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .facts { grid-template-columns: repeat(3, 1fr); }
  .market { padding: 22px 28px 60px; }
}

.pv-note { margin-top: 10px; }
.pv-note b { color: var(--text); }

/* ---------- tab Insieme (luce + gas) ---------- */
@media (max-width: 599px) {
  .tabs button { font-size: 13.5px; padding: 9px 0; letter-spacing: -.01em; }
}
body[data-kind="dual"] .logo::after { content: "⚡"; }
.dual-view { display: none; }
body[data-kind="dual"] .dual-view { display: block; }
body[data-kind="dual"] #summary, body[data-kind="dual"] #ranking, body[data-kind="dual"] #more { display: none; }
body[data-kind="dual"] .not-dual { display: none; }
.badge.dual { background: rgba(124, 92, 255, .14); color: var(--dual-text); }
.dual-best { padding: 16px; margin-bottom: 12px; }
.dual-best h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.dual-best .big { font-size: 34px; font-weight: 850; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 2px 0 2px; }
.dual-best .big small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.dual-best p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.pair { display: grid; gap: 6px; margin-top: 10px; }
.pair button {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0 10px; align-items: center; text-align: left; width: 100%;
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 12px; padding: 8px 10px;
}
.pair button:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pair .k { font-size: 18px; grid-row: span 2; }
.pair .n { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair .s { grid-column: 2; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair .e { grid-row: 1 / 3; grid-column: 3; font-weight: 800; font-variant-numeric: tabular-nums; }
.vendor-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.vendor-list .vendor { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; }
.vendor-head { display: grid; grid-template-columns: 34px 1fr auto; gap: 2px 10px; align-items: center; }
.vendor-head .rank { grid-row: span 2; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--bg-2); color: var(--muted); }
.vendor-head .vn { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vendor-head .vm { grid-column: 2; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.vendor-head .vt { grid-row: span 2; text-align: right; font-variant-numeric: tabular-nums; }
.vendor-head .vt b { display: block; font-size: 18px; font-weight: 800; }
.vendor-head .vt span { font-size: 12px; color: var(--muted); }
.dual-note { font-size: 12.5px; color: var(--muted); margin: 10px 2px; }

/* ---------- macchina del tempo ---------- */
/* Modalità ben distinta: barra a gradiente sotto l'header, orologio che pulsa
   con le lancette che girano all'indietro, sfondo tinto, filo colorato sotto
   l'header. Tutto spento da prefers-reduced-motion (regola globale sopra). */
:root { --tm-a: #7c5cff; --tm-b: #e2557a; --tm-c: #f2a900; }

.tm-bar { display: none; }
body.tm-on .tm-bar {
  position: relative; overflow: hidden;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin-top: 10px; padding: 10px 14px; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--tm-a) 40%, var(--line));
  background: linear-gradient(115deg,
    color-mix(in srgb, var(--tm-a) 18%, var(--card)),
    color-mix(in srgb, var(--tm-b) 12%, var(--card)) 55%,
    color-mix(in srgb, var(--tm-c) 16%, var(--card)));
  animation: tm-in .45s cubic-bezier(.2, .8, .2, 1) both;
}
/* riflesso che scorre lento sulla barra */
body.tm-on .tm-bar::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, var(--sheen) 50%, transparent 70%);
  transform: translateX(-100%); animation: tm-sheen 5.5s ease-in-out infinite;
}
.tm-orb { position: relative; width: 46px; height: 46px; flex: none; display: grid; place-items: center; color: #fff; }
.tm-orb::before, .tm-orb::after { content: ""; position: absolute; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--tm-a), var(--tm-b), var(--tm-c), var(--tm-a)); }
.tm-orb::before { inset: -6px; filter: blur(10px); animation: tm-pulse 2.4s ease-in-out infinite; }
.tm-orb::after { inset: 0; animation: tm-spin 7s linear infinite; }
.tm-orb svg { position: relative; z-index: 1; width: 28px; height: 28px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.tm-hands path { transform-box: view-box; transform-origin: 12px 12px; }
.tm-hands .h-min { animation: tm-rewind 2.4s linear infinite; }
.tm-hands .h-hour { animation: tm-rewind 28.8s linear infinite; }

.tm-head { display: flex; flex-direction: column; min-width: 0; }
.tm-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--tm-a), var(--tm-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tm-head b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-nav { display: flex; align-items: center; gap: 4px; }
.tm-nav button, .tm-exit {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; font-weight: 700;
}
.tm-nav button { width: 32px; height: 34px; font-size: 18px; line-height: 1; }
.tm-nav button:disabled { opacity: .35; cursor: default; }
.tm-nav select { height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 650; padding: 0 8px; }
.tm-mode { flex: 1 1 260px; max-width: 420px; }
.tm-mode [aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.tm-exit { padding: 8px 12px; margin-left: auto; }
.tm-exit::before { content: "↩ "; }
.tm-note { flex-basis: 100%; margin: 0; font-size: 12.5px; color: var(--muted); position: relative; z-index: 1; }
.tm-note b { color: var(--text); }
.tm-note a, .tm-legend a { color: var(--text); font-weight: 700; }
.tm-warn { color: var(--warn-text); font-weight: 700; }
.tm-bar > * { position: relative; z-index: 1; }

body.tm-on { background: color-mix(in srgb, var(--bg) var(--tm-mix), var(--tm-a)); }
body.tm-on .top { border-bottom: 0; box-shadow: 0 2px 0 0 color-mix(in srgb, var(--tm-b) 60%, transparent); }
body.tm-on .top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, var(--tm-a), var(--tm-b), var(--tm-c), var(--tm-a));
  background-size: 200% 100%; animation: tm-flow 6s linear infinite;
}
body.tm-on .no-tm { display: none !important; }
body.tm-on .tabs { grid-template-columns: repeat(3, 1fr); }
body.tm-on .tab-ink { width: calc((100% - 8px) / 3); }
.tm-only { display: none; }
body.tm-on .tm-only { display: inline; }

.offer .price .tm-alt { display: block; font-size: 11.5px; color: var(--muted); font-weight: 650; }
.offer .price .tm-alt.up { color: var(--bad); }
.offer .price .tm-alt.down { color: var(--good-text); }
@media (max-width: 599px) { .tm-alt-w { display: none; } }
.tm-verdict { margin: 10px 0 0; font-size: 13px; line-height: 1.5; padding: 9px 11px; border-radius: 12px;
  background: color-mix(in srgb, var(--tm-a) 9%, transparent); border-left: 3px solid var(--tm-a); }
.tm-verdict[hidden] { display: none; }

@keyframes tm-rewind { to { transform: rotate(-360deg); } }
@keyframes tm-spin { to { transform: rotate(360deg); } }
@keyframes tm-pulse { 0%, 100% { opacity: .35; transform: scale(.9); } 50% { opacity: .9; transform: scale(1.12); } }
@keyframes tm-sheen { 0%, 55% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes tm-flow { to { background-position: 200% 0; } }
@keyframes tm-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* spiegazione dei due modi: nella barra su desktop; su telefono una riga corta
   sotto l'interruttore e la versione lunga nel riepilogo */
.tm-note-m, .tm-legend { display: none; }
@media (max-width: 959px) {
  body.tm-on .tm-bar { gap: 8px 10px; padding: 8px 10px; }
  body.tm-on .tm-bar .tm-note { display: none; }
  body.tm-on .tm-note-m { display: block; margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
  .tm-note-m b { color: var(--text); }
  .tm-orb { width: 38px; height: 38px; }
  .tm-orb svg { width: 24px; height: 24px; }
  .tm-head { flex: 1; }
  .tm-exit { order: 1; padding: 7px 10px; font-size: 13px; }
  .tm-nav { order: 2; flex: 1 1 100%; min-width: 0; }
  .tm-nav select { flex: 1; min-width: 0; width: 0; }
  .tm-mode { order: 3; flex: 1 1 100%; max-width: none; }
  .tm-mode button small { display: none; }   /* il valore dell'indice sta nella nota del riepilogo */
  body.tm-on .tm-legend { display: block; order: 4; flex-basis: 100%; margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted-strong); }
  .tm-legend b { color: var(--text); }
  /* nell'intestazione fissa la barra prende il posto del titolo del sito */
  body.tm-on .top .brand { display: none; }
  /* scorrendo, come lo slider compatto: resta una riga con mese, frecce e uscita */
  body.tm-on .top.show-mini .tm-orb, body.tm-on .top.show-mini .tm-head,
  body.tm-on .top.show-mini .tm-mode, body.tm-on .top.show-mini .tm-legend { display: none; }
  body.tm-on .top.show-mini .tm-nav { order: 0; flex: 1 1 0; }
}
@media (min-width: 960px) {
  body.tm-on .top { flex-wrap: wrap; }
  body.tm-on .tm-bar { flex-basis: 100%; }
  body.tm-on .controls { top: 196px; max-height: calc(100vh - 210px); }
}
.tm-odd { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tm-odd button { border: 0; background: none; padding: 0; color: var(--text); font-weight: 700; text-decoration: underline; }

/* ---------- segnale fisso/variabile ---------- */
.fv-signal { margin: 10px 0 0; font-size: 13px; line-height: 1.5; padding: 9px 11px; border-radius: 12px;
  background: var(--bg-2); border-left: 3px solid var(--muted); }
.fv-signal[hidden] { display: none; }
.fv-signal b { display: block; margin-bottom: 2px; }
.fv-signal a { color: inherit; font-weight: 700; }
.fv-signal.up.F, .fv-signal.down.F { border-left-color: var(--good); }
.fv-signal.up.V, .fv-signal.down.V { border-left-color: var(--warn); }

/* ---------- simulatore bolletta (simulatore.html) + link dalla scheda ---------- */
.sim-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13.5px; font-weight: 700;
  color: var(--accent-ink); background: var(--accent-soft); border-radius: 99px; padding: 6px 12px; text-decoration: none; }
.sim-link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabs.two { grid-template-columns: repeat(2, 1fr); }
.tabs.two .tab-ink { width: calc((100% - 8px) / 2); }
.sim-page .logo::after { content: "🧮"; }
.sim-box > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.sim-box > summary::-webkit-details-marker { display: none; }
.sim-box > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
.sim-box[open] > summary::after { transform: rotate(180deg); }
.sim-box > summary .summary-val { margin-left: auto; color: var(--accent-ink); }
.sim-box > summary .summary-val:empty { display: none; }
.sim-box > summary .badge { font-size: 10.5px; }
.sim-box-body { margin-top: 8px; }
.sim-box.seller { border-left: 4px solid var(--accent); }
.sim-box.reg { background: color-mix(in srgb, var(--card) 70%, var(--bg-2)); }
.sim-gap { margin-top: 12px; }
.lever { padding: 8px 0; border-top: 1px solid var(--line); }
.lever:first-of-type { border-top: 0; }
.lev-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 28px; gap: 8px; align-items: center; }
.lev-row label { font-size: 13.5px; font-weight: 650; }
.lev-row label small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.lev-in { display: inline-flex; align-items: baseline; gap: 5px; }
.lev-in .unit { font-size: 12px; color: var(--muted); font-weight: 600; min-width: 46px; }
.lev-num { width: 92px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700;
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 9px; padding: 6px 8px; font-size: 15px; }
.lev-num.bad { border-color: var(--bad); }
.lev-reset { visibility: hidden; border: 0; background: var(--accent-soft); color: var(--accent-ink); border-radius: 99px;
  width: 28px; height: 28px; font-size: 15px; line-height: 1; padding: 0; }
.lever.edited .lev-reset { visibility: visible; }
.lever.edited .lev-row label::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 99px;
  background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.lever .slider { margin-top: 4px; }
.sim-fasce { margin-top: 10px; }
.sim-summary .sim-offer h2 { font-size: 19px; margin: 4px 0 2px; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
.sim-summary .sim-vend { color: var(--muted); font-size: 13.5px; }
.sim-delta { margin: 0; color: var(--muted); font-size: 13.5px; }
.sim-delta b.up, .chg.up, .sim-bar .up { color: var(--bad); }
.sim-delta b.down, .chg.down, .sim-bar .down { color: var(--good-text); }
.sim-stack { position: relative; overflow: visible; }
.sim-stack i:first-child { border-radius: 99px 0 0 99px; }
.sim-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; opacity: .55; }
.sim-actions { margin-top: 10px; }
.sim-receipt-card, .sim-chart-card { margin-top: 12px; }
.sim-tbl .grp th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 14px 0 4px; border-bottom: 1px solid var(--line); }
.sim-tbl .grp:first-child th { padding-top: 4px; }
.sim-tbl td small { overflow-wrap: anywhere; }
.sim-tbl td.dl { width: 1%; padding-left: 8px; }
.sim-tbl .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 8px; }
.sim-tbl .tot td { font-weight: 800; border-bottom: 0; padding-top: 10px; font-size: 15px; }
.chg { font-size: 12px; font-weight: 700; white-space: nowrap; }
.sim-chart svg { width: 100%; height: auto; display: block; margin-top: 8px; }
.sim-chart .gl { stroke: var(--line); }
.sim-chart .tx, .sim-chart .ty { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.sim-chart svg.narrow .tx, .sim-chart svg.narrow .ty { font-size: 12.5px; }
.sim-chart .tx { text-anchor: middle; }
.sim-chart .ty { text-anchor: end; }
.sim-chart .cur { fill: none; stroke: var(--accent); stroke-width: 3; }
.sim-chart .base { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-dasharray: 5 4; }
.sim-chart .now { stroke: var(--accent); stroke-dasharray: 2 3; opacity: .6; }
.sim-chart .pt { fill: var(--card); stroke: var(--accent); stroke-width: 3; }
#simChartCap .leg { white-space: nowrap; margin-left: 6px; font-size: 12px; }
#simChartCap .leg i { display: inline-block; width: 16px; height: 0; vertical-align: middle; margin: 0 3px 0 6px; }
#simChartCap .lc { border-top: 3px solid var(--accent); }
#simChartCap .lb { border-top: 2px dashed var(--muted); }
.sim-bar { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: 30;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; background: var(--card); box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums; font-weight: 700; transform: translateY(160%); transition: transform .25s; }
.sim-bar b { font-size: 18px; }
.sim-bar-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.sim-bar-on .sim-bar { transform: none; }
@media (min-width: 960px) {
  .sim-page .layout.sim { grid-template-columns: 420px 1fr; }
  .sim-results { position: sticky; top: 86px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }
  .sim-bar { display: none; }
}
/* telefono: prima il riepilogo (offerta e totale), poi le leve, poi ricevuta e grafico */
@media (max-width: 959px) {
  .sim-page .layout { padding-bottom: 90px; }
  .sim-page .layout.sim { display: flex; flex-direction: column; }
  .sim-page .sim-results { display: contents; }
  .sim-page .sim-summary { order: 0; margin-bottom: 12px; }
  .sim-page .controls { order: 1; }
  .sim-page .sim-receipt-card { order: 2; }
  .sim-page .sim-chart-card { order: 3; }
  .sim-page .sim-results > .foot { order: 4; }
}

/* lettura bolletta (bill-upload.js): tutto nel browser */
.bill { padding: 10px 14px; }
.bill-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.bill-pick {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 99px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 650; color: var(--text);
}
.bill-pick:hover { border-color: var(--accent); }
.bill-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bill-pick[disabled] { opacity: .6; cursor: progress; }
.bill-priv { font-size: 12px; color: var(--muted); }
.bill-status { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.bill-status.err { color: var(--bad); }
.bill-panel { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.bill-panel h3 { margin: 0 0 6px; font-size: 14px; }
.bill-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bill-row label { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; cursor: pointer; }
.bill-row input { grid-row: 1 / span 2; margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.bill-row b { font-size: 14px; }
.bill-src { grid-column: 2; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.bill-row.missing { color: var(--muted); font-size: 13px; padding-left: 28px; }
.bill-warn { margin: 8px 0 0; font-size: 12.5px; color: var(--warn-text); }
.bill-ocr-note { margin: 0 0 8px; font-size: 12.5px; color: var(--ink-2, var(--muted)); background: var(--bg-2); border-left: 3px solid var(--warn); padding: 6px 10px; border-radius: 6px; }
.bill-progress { width: 100%; height: 8px; accent-color: var(--accent); }
.bill-actions { display: flex; gap: 8px; margin-top: 12px; }
.bill-actions button { border: 1px solid var(--line); background: var(--bg-2); border-radius: 99px; padding: 7px 16px; font-size: 13.5px; font-weight: 650; }
.bill-actions .primary { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); border-color: transparent; }
.bill-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bill-actions button[disabled] { opacity: .5; cursor: not-allowed; }
body[data-kind="mercato"] .bill { display: none; }
