.viz-root {
  color-scheme: light;
  /* superfici e testo: token del sito (assets/sito.css) */
  --surface-0: var(--bg);
  --surface-1: var(--card);
  --grid: var(--line);
  --axis: #c9c8c1;
  --text-primary: var(--ink);
  --text-secondary: var(--muted);
  --text-muted: var(--muted);
  --series-1: #2a78d6;      /* scenario */
  --series-1-band: rgba(42, 120, 214, .18);
  --base: #8e8d86;          /* caso base */
  --base-band: rgba(142, 141, 134, .20);
  --observed: var(--ink);   /* osservato */
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100; --cat-5: #e87ba4;
  --critical: #c62f2f;
  --good: #1f7a3a;
  --accent: var(--rosso);   /* elementi dell'interfaccia: colore del marchio */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-0: var(--bg); --surface-1: var(--card); --grid: var(--line); --axis: #45443f;
    --text-primary: var(--ink); --text-secondary: var(--muted); --text-muted: var(--muted);
    --series-1: #3987e5; --series-1-band: rgba(57, 135, 229, .25);
    --base: #8e8d86; --base-band: rgba(142, 141, 134, .22); --observed: var(--ink);
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500; --cat-5: #d55181;
    --critical: #e66767; --good: #4fb06e; --accent: var(--rosso);
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--surface-0); color: var(--text-primary); }
a { color: var(--accent); }
code { font-size: 12px; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--surface-1); border-bottom: 1px solid var(--grid); }
.sotto { margin: 2px 0 0; color: var(--text-secondary); font-size: 12px; }
.stato-live { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.punto { width: 10px; height: 10px; border-radius: 50%; background: var(--axis); }
.punto.ok { background: var(--good); }
.punto.ko { background: var(--critical); }
.layout { display: grid; grid-template-columns: 330px 1fr; min-height: calc(100vh - 62px); }
.parametri { background: var(--surface-1); border-right: 1px solid var(--grid); padding: 14px 16px;
  overflow-y: auto; max-height: calc(100vh - 62px); position: sticky; top: 0; }
.par-testa { display: flex; justify-content: space-between; align-items: center; }
details { border-top: 1px solid var(--grid); padding: 8px 0; }
summary { cursor: pointer; font-weight: 600; padding: 2px 0 6px; }
.riga, .riga-inline { display: block; margin: 6px 0; color: var(--text-secondary); }
.riga select { width: 100%; margin-top: 3px; }
.riga-inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.check { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0; color: var(--text-secondary); }
.slider { margin: 8px 0 10px; }
.slider .lbl { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 13px; }
.slider .val { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
.slider .val.mod { color: var(--accent); }
.slider input { width: 100%; accent-color: var(--accent); }
.slider .aiuto { font-size: 11px; color: var(--text-muted); }
.nota { font-size: 12px; color: var(--text-muted); margin: 6px 0; }
.costo { border-top: 1px solid var(--grid); padding-top: 10px; margin-top: 6px; font-size: 13px; }
.costo b { font-variant-numeric: tabular-nums; }
main { padding: 14px 20px 40px; min-width: 0; }
.schede { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 14px; flex-wrap: wrap; }
.schede button { background: none; border: none; padding: 8px 12px; cursor: pointer; font: inherit;
  color: var(--text-secondary); border-bottom: 2px solid transparent; }
.schede button.attiva { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.scheda { display: none; }
.scheda.attiva { display: block; }
.intro { color: var(--text-secondary); margin: 0 0 12px; }
.card { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.card-testa { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.griglia2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.griglia2 .card { margin-bottom: 0; }
.griglia2 + .card, .griglia2 + .griglia2 { margin-top: 14px; }
@media (max-width: 1200px) { .griglia2 { grid-template-columns: 1fr; } .layout { grid-template-columns: 290px 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 8px; padding: 10px 12px; }
.tile .k { font-size: 12px; color: var(--text-secondary); }
.tile .v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .d { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tile .d .meglio { color: var(--good); } .tile .d .peggio { color: var(--critical); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis line, .chart .axis path { stroke: var(--axis); }
.chart .ref line { stroke: var(--critical); stroke-width: 1; }
.chart .ref text { fill: var(--critical); font-weight: 600; }
.chart .ora line { stroke: var(--text-muted); stroke-width: 1; }
.chart .cross line { stroke: var(--text-muted); stroke-width: 1; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legenda i.band { height: 10px; border-radius: 2px; }
.legenda i.box { width: 10px; height: 10px; border-radius: 2px; }
.tooltip { position: fixed; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--axis); border-radius: 6px; padding: 6px 9px; font-size: 12px; display: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.12); z-index: 10; font-variant-numeric: tabular-nums; max-width: 320px; }
.tooltip .t { font-weight: 600; margin-bottom: 2px; }
.tooltip .r { display: flex; gap: 8px; justify-content: space-between; }
.tooltip .r i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; }
td.meglio { color: var(--good); font-weight: 600; } td.peggio { color: var(--critical); }
.form-riga { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.form-riga input[type=number] { width: 64px; }
.progresso { font-size: 12px; color: var(--text-secondary); }
.progresso .barra { height: 4px; background: var(--grid); border-radius: 2px; margin: 6px 0; overflow: hidden; }
.progresso .barra div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.errore { color: var(--critical); }
.caricamento { opacity: .55; transition: opacity .2s; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--axis); color: var(--text-secondary); }

.link-doc { font-size: 13px; margin-left: auto; margin-right: 18px; }
.sel-codice { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 8px; }
.sel-codice button { font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--axis); background: none; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 5px; }
.sel-codice button.attivo { border-color: var(--accent); color: var(--text-primary); font-weight: 600; }
.sel-codice button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sel-codice button .mod { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.griglia2.interna { gap: 18px; }
td.sub { color: var(--text-muted); }

body.statico .solo-locale, body:not(.statico) .solo-statico { display: none !important; }
.azioni { float: right; display: flex; gap: 6px; margin-top: 2px; }
.torna { margin: 0 0 4px; font-size: 12px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .parametri { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--grid); }
  .azioni { float: none; margin-bottom: 8px; }
  .top { flex-wrap: wrap; }
}

/* ---------- allineamento allo stile del sito ---------- */
body { font: 14.5px/1.5 var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
.top { display: block; padding: 22px 24px 0; background: var(--bg); border-bottom: none; }
.top .sotto { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; max-width: 90ch; }
.top .sito-nav { margin: 12px 0 10px; }
.stato-live { font-family: var(--mono); font-size: 12px; white-space: normal; max-width: 520px; text-align: right; }
.layout { border-top: 1px solid var(--line); min-height: auto; }
.parametri { max-height: calc(100vh - 20px); top: 10px; }
main { padding: 16px 24px 30px; }
h1, h2 { font-family: var(--disp); text-transform: uppercase; letter-spacing: .01em; }
h2 { font-size: 20px; font-weight: 800; }
h3, .card-testa h3 { font-family: var(--disp); font-weight: 700; font-size: 18px; letter-spacing: .02em; text-transform: uppercase; line-height: 1.1; margin: 0 0 10px; }
summary { font-family: var(--disp); font-weight: 700; font-size: 16px; letter-spacing: .02em; text-transform: uppercase; }
.card, .tile { border-radius: var(--raggio); box-shadow: var(--shadow); border-color: var(--line); }
.card { padding: 18px 20px; }
.tile .k { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
.tile .v { font-family: var(--mono); font-weight: 600; font-size: 26px; }
.schede button { font-weight: 500; }
.schede button.attiva { border-bottom-color: var(--rosso); }
table { font-size: 13.5px; }
td { font-family: var(--mono); font-size: 13px; }
td:first-child { font-family: var(--sans); }
thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.slider input { accent-color: var(--rosso); }
.sel-codice button { border-radius: 999px; }
.piede { max-width: 1400px; padding: 0 24px 40px; }
a { color: inherit; }
main a, .parametri a { color: var(--rosso); }

/* schede Istruzioni e Metodo: testo lungo con lo stile delle pagine del sito */
.schede .scheda-doc { color: var(--text-secondary); }
.doc-contenuto.card { padding: 6px 30px 26px; max-width: 980px; }
.doc-contenuto td, .doc-contenuto th { font-family: var(--sans); font-size: 14px; text-align: left; }
.doc-contenuto h1:first-child { margin-top: 18px; }

/* sotto-menu del simulatore: Simulazioni · Istruzioni · Metodo */
.sotto-nav { display: flex; gap: 18px; margin: -2px 0 12px 4px; font-size: 13.5px; }
.sotto-nav a { color: var(--muted); text-decoration: none; padding: 3px 0; border-bottom: 2px solid transparent; }
.sotto-nav a:hover { color: var(--ink); }
.sotto-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--rosso); }
body.lettura .schede, body.lettura .azioni { display: none; }
