:root {
  --background: transparent;
  --surface: #ffffff;
  --surface-subtle: #eef1f4;
  --text: #141414;
  --muted: #5c6570;
  --border: #e3e5e8;
  --accent: #005ac7;
  --accent-soft: #e7f1fb;
  --danger: #b42318;
  --success: #0b7a32;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: transparent;
  color: var(--text);
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

h1, h2, p { margin: 0; }

.page-shell {
  width: min(100% - 24px, 680px);
  margin: 0 auto;
  padding: 12px 0 18px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  transform: translateY(-150%);
  background: var(--surface);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}

.skip:focus { transform: none; }

:focus-visible {
  outline: 3px solid rgba(0, 90, 199, 0.28);
  outline-offset: 2px;
}

.embed-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 2px 2px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.65rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.lede {
  max-width: 470px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.asof {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.publisher-payoff {
  flex: 0 0 auto;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

.publisher-payoff strong,
.publisher-payoff a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.banner {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  background: #fffbeb;
  color: #92400e;
  font-size: 0.92rem;
}

#status, #error { margin-top: 14px; color: var(--muted); }

#error {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
}

#error p { margin-bottom: 14px; }

#retry {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

#retry:hover { background: #004a9e; }

#app {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-subtle);
}

.segment button {
  appearance: none;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #3d4450;
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
}

.segment button[aria-checked="true"] {
  background: var(--accent);
  color: #fff;
}

.segment.compact {
  display: inline-flex;
  flex-wrap: wrap;
  width: auto;
  margin: 0;
  padding: 4px;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.segment.compact button {
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.segment.compact button[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(24, 24, 27, 0.08);
}

.amount-row { display: grid; gap: 8px; }

.amount-row label,
.region-row label {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 650;
}

.amount-field {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: var(--surface);
}

.amount-field:focus-within {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 90, 199, 0.16);
}

.amount-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.amount-field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.presets { display: flex; gap: 8px; }

.presets button {
  min-width: 44px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}

.presets button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.hint, .note {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.result { margin-top: 22px; }

.lead {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.liters {
  display: block;
  margin: 4px 0 8px;
  font-size: clamp(3rem, 12vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.result.is-error .liters {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.35;
}

.caption {
  display: block;
  max-width: 38rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.figures p { display: flex; flex-direction: column; gap: 4px; }

.label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.figure {
  font-size: clamp(1.45rem, 4vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.change { font-size: 0.9rem; }

.up { color: var(--danger); }
.down { color: var(--success); }

.region-row {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: var(--surface);
}

select:focus-visible { border-color: var(--accent); }

.city-box { position: relative; }

#city {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: var(--surface);
}

#city:focus-visible { border-color: var(--accent); }

.city-list {
  position: absolute;
  z-index: 3;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 16rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.city-list button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.city-list button[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.city-figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.city-figures p { display: flex; flex-direction: column; gap: 4px; }
.city-figures .hint { margin: 0; }

.pump-figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.pump-figures p { display: flex; flex-direction: column; gap: 4px; }
.pump-figures .hint { margin: 0; }

.station {
  font-size: 0.95rem;
  line-height: 1.35;
}

#pumps-note { margin-top: 8px; }

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.region-table-wrap { margin-top: 14px; overflow-x: auto; }

.region-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.region-table th,
.region-table td {
  padding: 8px 8px;
  border-top: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}

.region-table thead th {
  border-top: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.region-table th:first-child { text-align: left; font-weight: 650; }

.region-table .col-min { color: var(--success); font-weight: 650; }
.region-table .col-avg { font-weight: 700; }
.region-table .col-max { color: var(--danger); font-weight: 650; }
.region-table .is-missing { color: var(--muted); font-weight: 400; }
.region-table tr.is-selected { background: var(--accent-soft); }

.region-name {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 44px;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.region-name small { color: var(--accent); font-size: 0.75rem; font-weight: 650; }

.compare {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.compare li {
  display: grid;
  grid-template-columns: minmax(8.5rem, 12rem) minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.when { font-weight: 650; }
.when small { display: block; color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.row-liters { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.fill, .fill-today {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #b9d4f5;
}

.fill-today { background: var(--accent); }

.meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  margin-top: 12px;
}

.chart-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 3.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

#chart { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent); }

#chart-desc, #history-note { margin-top: 12px; }

.tax-bar {
  display: flex;
  width: 100%;
  height: 10px;
  margin-top: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-subtle);
}

.seg-excise { background: var(--accent); }
.seg-vat { background: #8eb8ea; }
.seg-net { background: #18181b; }

#tax-text { margin-top: 8px; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.legend li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
}

details { padding: 0 2px; }
summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
details p { margin-top: 8px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

footer {
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

footer p + p { margin-top: 6px; }

a { color: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 16px, 680px); padding-top: 8px; }
  .embed-header { display: grid; gap: 10px; }
  .publisher-payoff { margin: 0; text-align: left; white-space: normal; }
  .panel { padding: 18px 16px; }
  .figures, .pump-figures { grid-template-columns: 1fr; }
  .compare li { grid-template-columns: 1fr auto; }
  .region-table { font-size: 0.86rem; }
  .region-table th, .region-table td { padding: 8px 4px; }
  .track { grid-column: 1 / -1; grid-row: 2; }
  .region-pick .meta, .compare .meta { grid-row: 3; }
}

.widget-head { align-items: flex-start; }

.widget-head h1 {
  font-size: clamp(1.35rem, 4vw, 1.7rem);
}

.widget-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

html[data-widget] .widget-repeat { display: none !important; }

html[data-widget="litri"] [data-part]:not([data-part~="litri"]):not([data-part~="shared"]),
html[data-widget="prezzo"] [data-part]:not([data-part~="prezzo"]):not([data-part~="shared"]),
html[data-widget="regioni"] [data-part]:not([data-part~="regioni"]):not([data-part~="shared"]),
html[data-widget="comune"] [data-part]:not([data-part~="comune"]):not([data-part~="shared"]),
html[data-widget="impianti"] [data-part]:not([data-part~="impianti"]):not([data-part~="shared"]),
html[data-widget="andamento"] [data-part]:not([data-part~="andamento"]):not([data-part~="shared"]),
html[data-widget="imposte"] [data-part]:not([data-part~="imposte"]):not([data-part~="shared"]) {
  display: none !important;
}

/* Nel pezzo dell'articolo la colonna è stretta: il blocco sta sul testo, senza riquadro. */
html[data-widget] .page-shell {
  width: 100%;
  padding: 12px 0 8px;
  border-top: 3px solid var(--accent);
}

html[data-widget] .embed-header { padding: 0; }

html[data-widget] .lede {
  max-width: none;
  margin-top: 6px;
  color: #3a4150;
}

html[data-widget] #app {
  gap: 0;
  margin-top: 16px;
}

html[data-widget] .panel {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

html[data-widget] .caption { color: #3a4150; }

html[data-widget] details {
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

html[data-widget] summary { font-size: 0.92rem; }

html[data-widget] footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
