/* ==========================================================================
   QUOTAZIONI CASE — foglio di stile. Scritto a mano sui token. Nessuna
   libreria, nessuna classe di framework. Mobile-first.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--font-text);
  font-size: var(--t-md);
  line-height: var(--lh-body);
  color: var(--ink);
  background-color: var(--paper);
  /* grana appena percettibile: SVG noise inline, opacita' bassissima */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img, svg { display: block; max-width: 100%; }
svg { height: auto; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* --- focus visibile ovunque -------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: var(--s3) var(--s4);
}
.skip:focus { left: var(--s3); top: var(--s3); color: var(--paper); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--s4); }

/* ==========================================================================
   TESTATA
   ========================================================================== */
.masthead {
  border-bottom: var(--border);
  background: var(--panel);
  position: sticky; top: 0; z-index: 40;
}
.masthead__in {
  display: flex; align-items: center; gap: var(--s4);
  min-height: 60px;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; flex: 0 0 auto; }
.brand svg { height: 30px; width: auto; }
.nav {
  display: flex; align-items: center; gap: var(--s1);
  margin-left: auto; flex-wrap: wrap;
}
.nav a {
  font-family: var(--font-text);
  font-size: var(--t-sm); font-weight: 600;
  color: var(--ink-soft); text-decoration: none;
  padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
  min-height: 40px; display: inline-flex; align-items: center;
}
.nav a:hover { color: var(--ink); background: var(--panel-sunken); }
.nav a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.menu-btn {
  display: none; margin-left: auto;
  font-family: var(--font-text); font-weight: 600; font-size: var(--t-sm);
  background: var(--panel); color: var(--ink);
  border: var(--border); border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3); min-height: 44px; cursor: pointer;
}

@media (max-width: 820px) {
  .menu-btn { display: inline-flex; align-items: center; gap: var(--s2); }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--panel); border-bottom: var(--border);
    box-shadow: var(--elev-pop); padding: var(--s2);
  }
  .nav.open { display: flex; }
  .nav a { min-height: 48px; border-radius: var(--radius-sm); }
}

/* ==========================================================================
   IMPIANTO / GRIGLIA
   ========================================================================== */
main { display: block; padding-bottom: var(--s16); }
.crumb { padding: var(--s3) 0 0; }
.crumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0; font-size: var(--t-xs); color: var(--ink-faint); }
.crumb li:not(:last-child)::after { content: "›"; margin-left: var(--s2); color: var(--n-400); }
.crumb a { color: var(--ink-faint); text-decoration: none; }
.crumb a:hover { color: var(--accent); text-decoration: underline; }
.crumb [aria-current="page"] { color: var(--ink-soft); }

/* colonna principale + rail destro (asimmetrica) */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); gap: var(--s10); align-items: start; margin-top: var(--s5); }
.layout > * { min-width: 0; }
.rail { position: sticky; top: 76px; display: flex; flex-direction: column; gap: var(--s5); }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .rail { position: static; } }

.stack > * + * { margin-top: var(--s5); }
.section-gap { margin-top: var(--s8); }

/* ==========================================================================
   PANNELLI (a filo, hairline, niente ombre)
   ========================================================================== */
.panel { background: var(--panel); border: var(--border); border-radius: var(--radius); }
.panel__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3);
  border-bottom: var(--border);
}
.panel__head h2 { font-size: var(--t-lg); }
.panel__body { padding: var(--s4); }
.panel--pad { padding: var(--s5); }
.muted { color: var(--ink-faint); font-size: var(--t-sm); text-decoration: none; }
.muted:hover { color: var(--accent); }

.prose { font-size: var(--t-md); }
.prose p { max-width: var(--measure); }
.prose h2 { margin-top: var(--s6); margin-bottom: var(--s3); }
.prose h3 { margin-top: var(--s5); margin-bottom: var(--s2); }
.prose p + p { margin-top: var(--s3); }
.prose ul, .prose ol { margin: var(--s3) 0; padding-left: var(--s5); max-width: var(--measure); }
.prose li + li { margin-top: var(--s1); }
.prose a { font-weight: 600; }

/* ==========================================================================
   DOMINANTE: BLOCCO DI VALORE (hero)
   ========================================================================== */
.hero { border-bottom: var(--border); background: var(--panel); }
.hero__in { padding-block: var(--s8); }
.hero__eyebrow {
  font-family: var(--font-num); font-size: var(--t-xs);
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint);
}
.hero h1 { margin-top: var(--s2); max-width: 20ch; }
.hero__sub { margin-top: var(--s3); color: var(--ink-soft); max-width: 54ch; font-size: var(--t-lg); }

/* il numerone: intervallo min-max in mono */
.value-hero { margin-top: var(--s5); display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3) var(--s6); }
.value-big {
  font-family: var(--font-num); font-weight: 500;
  font-size: var(--t-2xl); line-height: var(--lh-num);
  letter-spacing: -0.02em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.value-big .unit { font-size: var(--t-lg); color: var(--ink-faint); }
.value-cap { font-size: var(--t-sm); color: var(--ink-faint); max-width: 34ch; }

/* la barra di valore (dominante + firma) */
.rbar { display: block; width: 100%; }
.rbar__scale { display: flex; justify-content: space-between; font-family: var(--font-num); font-size: var(--t-xs); color: var(--ink-faint); margin-top: var(--s2); }
.rbar svg { width: 100%; height: auto; }

/* striscia di distribuzione: righe zona con barra */
.dist { display: flex; flex-direction: column; }
.dist__row {
  display: grid; grid-template-columns: minmax(120px, 34%) 1fr auto;
  align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  min-height: var(--row-h);
  border-top: var(--border-soft);
  text-decoration: none; color: inherit;
}
.dist__row:first-child { border-top: 0; }
.dist__row:hover { background: var(--panel-sunken); }
.dist__name { font-weight: 600; font-size: var(--t-sm); color: var(--ink); }
.dist__name .fascia { display: block; font-weight: 400; font-size: var(--t-xs); color: var(--ink-faint); }
.dist__track { position: relative; height: 12px; background: var(--panel-sunken); border-radius: 999px; overflow: hidden; }
.dist__fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.dist__val { font-family: var(--font-num); font-size: var(--t-sm); color: var(--ink); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.dist__val small { color: var(--ink-faint); }

/* ==========================================================================
   BADGE FASCIA DI PREZZO
   ========================================================================== */
.band {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--t-xs); font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}
.band::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; opacity: .9; }
.band--1 { color: var(--band-1-ink); background: var(--band-1-bg); }
.band--2 { color: var(--band-2-ink); background: var(--band-2-bg); }
.band--3 { color: var(--band-3-ink); background: var(--band-3-bg); }
.band--4 { color: var(--band-4-ink); background: var(--band-4-bg); }
.band--5 { color: var(--band-5-ink); background: var(--band-5-bg); }
.band--none { color: var(--ink-faint); background: var(--panel-sunken); }

/* ==========================================================================
   RICERCA (azione primaria)
   ========================================================================== */
.finder { margin-top: var(--s6); }
.finder__label { font-family: var(--font-head); font-weight: 600; font-size: var(--t-lg); }
.finder__form { margin-top: var(--s3); display: flex; gap: var(--s2); flex-wrap: wrap; }
.finder__input {
  flex: 1 1 260px; min-width: 0;
  font-family: var(--font-text); font-size: var(--t-md); line-height: 1.3;
  padding: var(--s2) var(--s3); min-height: 46px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
}
.finder__input::placeholder { color: var(--ink-faint); opacity: 1; }
.finder__input:hover { border-color: var(--n-400); }
.finder__input:focus-visible { border-color: var(--accent); outline-offset: 1px; }
/* modulo impilato (richiesta valutazione): i campi non prendono l'altezza
   dalla flex-basis, restano proporzionati e a piena larghezza della colonna */
.finder__form--col { flex-direction: column; align-items: stretch; gap: var(--s3); }
.finder__form--col .finder__input,
.finder__form--col .btn { flex: 0 0 auto; width: 100%; }
.btn {
  font-family: var(--font-text); font-weight: 600; font-size: var(--t-md);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s3) var(--s5); min-height: 46px; cursor: pointer;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--radius);
  text-decoration: none;
}
.btn:hover { background: var(--panel-sunken); color: var(--ink); }
.btn--primary { background: var(--accent); color: #fffdf9; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); color: #fffdf9; }
.btn--sm { min-height: 40px; padding: var(--s2) var(--s3); font-size: var(--t-sm); }

/* suggerimenti/scorciatoie come chip cliccabili */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--t-sm); font-weight: 600;
  padding: var(--s2) var(--s3); min-height: 40px;
  border: 1px solid var(--rule); border-radius: 999px;
  background: var(--panel); color: var(--ink-soft); text-decoration: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.chip .ico { width: 16px; height: 16px; color: var(--ink-faint); }
.chip:hover .ico { color: var(--accent); }

/* ==========================================================================
   GRIGLIA DI SCELTE (card cliccabili, non liste testo+numero)
   ========================================================================== */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: var(--s3); }
.tile {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); min-height: 60px;
  border: var(--border); border-radius: var(--radius);
  background: var(--panel); color: inherit; text-decoration: none;
}
.tile:hover { border-color: var(--accent); background: var(--panel-sunken); }
.tile .ico { flex: 0 0 auto; width: 22px; height: 22px; color: var(--ink-faint); }
.tile:hover .ico { color: var(--accent); }
.tile__txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tile__name { display: block; font-weight: 600; font-size: var(--t-sm); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__meta { display: block; font-size: var(--t-xs); color: var(--ink-faint); font-family: var(--font-num); }
.tile__meta[data-zero="1"] { opacity: .55; }

/* ==========================================================================
   TABELLE
   ========================================================================== */
.table-wrap { width: 100%; overflow-x: auto; }
table.board { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
table.board thead th {
  text-align: left; font-family: var(--font-text); font-weight: 600;
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint); padding: var(--s2) var(--s4);
  border-bottom: var(--border);
}
table.board thead th.r, table.board td.r { text-align: right; }
table.board tbody td { padding: var(--s3) var(--s4); border-top: var(--border-soft); vertical-align: middle; }
table.board tbody tr:hover { background: var(--panel-sunken); }
table.board td .num { white-space: nowrap; }
table.board td a { font-weight: 600; text-decoration: none; }
table.board td a:hover { text-decoration: underline; }
.t-name { display: block; font-weight: 600; color: var(--ink); }
.t-sub { display: block; font-size: var(--t-xs); color: var(--ink-faint); }

.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--ink-faint); }
.empty strong { display: block; color: var(--ink); font-family: var(--font-head); font-size: var(--t-lg); margin-bottom: var(--s1); }

/* ==========================================================================
   NOTE / AVVISI / DEMO
   ========================================================================== */
.notice { padding: var(--s3) var(--s4); border-radius: var(--radius); border: var(--border); background: var(--panel); font-size: var(--t-sm); margin-top: var(--s4); }
.notice--info { border-left: 3px solid var(--accent); }
.notice--stale { border-left: 3px solid var(--band-3); background: var(--band-3-bg); color: var(--band-3-ink); }
.callout { margin-top: var(--s5); padding: var(--s4); border: var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--panel); font-size: var(--t-sm); color: var(--ink-soft); }
.callout strong { color: var(--ink); }

.demobar {
  background: var(--band-3-bg); color: var(--band-3-ink);
  border-bottom: 1px solid var(--band-4);
  font-size: var(--t-sm); font-weight: 600;
}
.demobar .wrap { padding-block: var(--s2); display: flex; gap: var(--s3); align-items: center; }
.demobar .tag { font-family: var(--font-num); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; border: 1px solid currentColor; border-radius: 3px; padding: 1px 6px; }

.source-line { font-size: var(--t-xs); color: var(--ink-faint); margin-top: var(--s3); }
.source-line strong { color: var(--ink-soft); }

/* ==========================================================================
   ANDAMENTO NEL TEMPO (grafico secondario: linea + valori leggibili su ogni
   semestre + variazione complessiva. Resta sotto la barra di valore dominante)
   ========================================================================== */
.tchart { margin-top: var(--s2); max-width: 560px; }
.tchart__cap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s1) var(--s4); margin-bottom: var(--s3); }
.tchart__cap .lbl { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
.tchart__delta { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--t-sm); font-weight: 500; color: var(--ink); display: inline-flex; align-items: center; gap: 5px; }
.tchart__delta .car { flex: 0 0 auto; }
.tchart__delta small { font-family: var(--font-text); font-weight: 400; color: var(--ink-faint); }
.tchart__plot { position: relative; height: 92px; border-bottom: var(--border); }
.tchart__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tchart__dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--panel); }
.tchart__cols { display: flex; margin-top: var(--s2); }
.tchart__col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 2px; text-align: center; }
.tchart__val { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--t-sm); color: var(--ink); white-space: nowrap; }
.tchart__val--nd { color: var(--ink-faint); }
.tchart__sem { font-size: var(--t-xs); color: var(--ink-faint); white-space: nowrap; }
@media (max-width: 460px) {
  .tchart__plot { height: 76px; }
  .tchart__val { font-size: var(--t-xs); }
  .tchart__sem { font-size: 11px; }
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); font-size: var(--t-sm); }
.kv dt { color: var(--ink-faint); }
.kv dd { color: var(--ink); text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   PUBBLICITA' (slot, spenti finche' non c'e' consenso + ID)
   ========================================================================== */
.adslot { margin: var(--s5) 0; min-height: 90px; display: flex; align-items: center; justify-content: center; }
.adslot[data-empty] { display: none; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.foot { border-top: var(--border); background: var(--panel); margin-top: var(--s16); }
.foot .wrap { padding-block: var(--s8); }
.foot__cols { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: var(--s8); }
.foot__brand svg { height: 28px; width: auto; margin-bottom: var(--s3); }
.foot__brand p { font-size: var(--t-sm); color: var(--ink-faint); max-width: 42ch; }
.foot h2 { font-size: var(--t-sm); font-family: var(--font-text); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin-bottom: var(--s3); }
.foot ul { list-style: none; padding: 0; }
.foot li { margin-bottom: var(--s2); }
.foot a { color: var(--ink-soft); text-decoration: none; font-size: var(--t-sm); }
.foot a:hover { color: var(--accent); text-decoration: underline; }
.foot__src { margin-top: var(--s6); padding-top: var(--s5); border-top: var(--border); font-size: var(--t-xs); color: var(--ink-faint); }
.foot__src p { max-width: 90ch; }
.foot__src p + p { margin-top: var(--s2); }
.foot__src a { color: var(--ink-soft); }
@media (max-width: 720px) { .foot__cols { grid-template-columns: 1fr 1fr; } .foot__brand { grid-column: 1 / -1; } }

/* ==========================================================================
   CONSENSO COOKIE
   ========================================================================== */
.cmp { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--panel); border-top: var(--border); box-shadow: var(--elev-pop); }
.cmp__in { padding-block: var(--s3); display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.cmp p { font-size: var(--t-sm); color: var(--ink-soft); flex: 1 1 320px; margin: 0; }
.cmp__acts { display: flex; gap: var(--s2); margin-left: auto; }
.cmp .btn { min-height: 44px; }
@media (max-width: 560px) { .cmp__acts { width: 100%; } .cmp__acts .btn { flex: 1; } }

/* ==========================================================================
   404 / errore
   ========================================================================== */
.err { text-align: center; padding-block: var(--s16); }
.err__code { font-family: var(--font-num); font-size: var(--t-2xl); color: var(--band-3); }
.err h1 { margin-top: var(--s3); }
.err p { margin-top: var(--s3); color: var(--ink-soft); }
.err .btn { margin-top: var(--s5); }

/* ==========================================================================
   TABELLE -> LISTA su mobile
   ========================================================================== */
@media (max-width: 640px) {
  .value-big { font-size: 2rem; }
  table.board.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.board.responsive, table.board.responsive tbody, table.board.responsive tr, table.board.responsive td { display: block; width: 100%; }
  table.board.responsive tr { border: var(--border); border-radius: var(--radius); margin-bottom: var(--s3); padding: var(--s2) var(--s3); background: var(--panel); }
  table.board.responsive tbody td { border: 0; padding: var(--s1) 0; display: flex; justify-content: space-between; gap: var(--s3); text-align: right; }
  table.board.responsive tbody td::before { content: attr(data-label); font-size: var(--t-xs); color: var(--ink-faint); text-align: left; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
  table.board.responsive td .num { white-space: normal; }
  .dist__row { grid-template-columns: 1fr auto; grid-template-areas: "name val" "track track"; row-gap: var(--s2); }
  .dist__name { grid-area: name; } .dist__val { grid-area: val; } .dist__track { grid-area: track; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
