/* Dashboard Accademia del Cinema (v2).
   Colori dell'Accademia: nero, bianco e il rosso del logo (#FF002B, da
   accademiadelcinema.it: colore primario del tema e fill dei loghi SVG).
   Tutti i colori sono variabili qui sotto: i grafici le leggono da app.js
   (temaGrafici), quindi un cambio di tema ridisegna anche ECharts. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/vendor/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/vendor/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/vendor/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/vendor/fonts/inter-latin-700-normal.woff2") format("woff2"); }

/* ---------- Tema chiaro (default) ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;          /* fondi secondari, skeleton, celle n/d */
  --border: #e6e6e6;
  --border-strong: #cfcfcf;
  --text: #111111;
  --text-2: #555555;             /* testo secondario: 7,5:1 su bianco */
  --text-3: #6b6b6b;             /* etichette: 5,3:1 su bianco */
  /* Rosso del marchio, esatto: solo accenti (scheda attiva, selezione nei
     grafici, dettagli dell'header) */
  --brand: #ff002b;
  /* Rosso per testo e pulsanti: #FF002B su bianco ha 3,97:1, sotto il 4,5:1
     del testo normale; questa variante arriva a 5,4:1 */
  --brand-strong: #d6001f;
  --on-brand: #ffffff;
  /* Errori e avvisi: rosso scuro desaturato, distinto dal marchio */
  --danger: #8a2f2f;
  --danger-bg: #f8eded;
  --ok: #2f7a4f;                 /* solo il pallino "dati aggiornati" */
  --griglia: #eeeeee;
  --tt-bg: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .12);
  --overlay: rgba(0, 0, 0, .32);

  /* Loghi: variante per il tema chiaro (scura) o scuro (bianca); logo AI invertito nel tema scuro */
  --logo-chiaro: inline-block;
  --logo-scuro: none;
  --filtro-logo-ai: none;

  --radius: 14px;
  --radius-s: 8px;
  /* Spaziatura: scala da 4 px */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --dur: 200ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Tema scuro: stesso elenco di variabili ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0e;
    --surface: #181818;          /* il nero del sito dell'Accademia */
    --surface-2: #232323;
    --border: #2b2b2b;
    --border-strong: #3d3d3d;
    --text: #f2f2f2;
    --text-2: #b3b3b3;
    --text-3: #9a9a9a;
    --brand: #ff3352;            /* schiarito: 4,9:1 sulle card */
    --brand-strong: #ff3352;
    --on-brand: #0e0e0e;
    --danger: #e3a0a0;
    --danger-bg: #2a1d1d;
    --ok: #5fbf86;
    --griglia: #262626;
    --tt-bg: #1f1f1f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .6);
    --overlay: rgba(0, 0, 0, .6);
    --logo-chiaro: none;
    --logo-scuro: inline-block;
    --filtro-logo-ai: invert(1);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0e;
  --surface: #181818;
  --surface-2: #232323;
  --border: #2b2b2b;
  --border-strong: #3d3d3d;
  --text: #f2f2f2;
  --text-2: #b3b3b3;
  --text-3: #9a9a9a;
  --brand: #ff3352;
  --brand-strong: #ff3352;
  --on-brand: #0e0e0e;
  --danger: #e3a0a0;
  --danger-bg: #2a1d1d;
  --ok: #5fbf86;
  --griglia: #262626;
  --tt-bg: #1f1f1f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .6);
  --overlay: rgba(0, 0, 0, .6);
  --logo-chiaro: none;
  --logo-scuro: inline-block;
  --filtro-logo-ai: invert(1);
}

/* ---------- Palette dei grafici (solo grafici: l'interfaccia resta bianco, nero e rosso) ----------
   Categorica a colori fissi: Meta, Google, Non tracciata, poi --cat-4 … --cat-6
   per le altre sorgenti; --cat-altro per "Altro" (sorgenti senza colore e
   nodi piccoli). Google e Serie 6 del tema chiaro sono scuriti (solo la
   luminosità HSL) fino a 3:1 sulla card: #E69F00 -> #C68900, #56B4E9 -> #239DE2. Il rosso (--risultato) solo per il risultato:
   Iscritto, curva cumulativa, elemento scelto; in nessuna palette categorica.
   Sequenziale (mappa e heatmap): 5 classi di una tinta, --seq-1 = meno,
   --seq-5 = di più (nel tema scuro lo stesso ordine, luminosità invertita). */
:root {
  --cat-meta: #0072b2; --cat-google: #c68900; --cat-nt: #8c8c8c;
  --cat-4: #009e73; --cat-5: #cc79a7; --cat-6: #239de2; --cat-altro: #bdbdbd;
  --risultato: #d6001f;
  --seq-1: #e3eef7; --seq-2: #b5d0e8; --seq-3: #7fafd6; --seq-4: #3f86bf; --seq-5: #0b5a99;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cat-meta: #4fa3e0; --cat-google: #f0b43c; --cat-nt: #9a9a9a;
    --cat-4: #2bc598; --cat-5: #de97c0; --cat-6: #7cc7f0; --cat-altro: #6e6e6e;
    --risultato: #ff3352;
    --seq-1: #0b5a99; --seq-2: #3f86bf; --seq-3: #7fafd6; --seq-4: #b5d0e8; --seq-5: #e3eef7;
  }
}
:root[data-theme="dark"] {
  --cat-meta: #4fa3e0; --cat-google: #f0b43c; --cat-nt: #9a9a9a;
  --cat-4: #2bc598; --cat-5: #de97c0; --cat-6: #7cc7f0; --cat-altro: #6e6e6e;
  --risultato: #ff3352;
  --seq-1: #0b5a99; --seq-2: #3f86bf; --seq-3: #7fafd6; --seq-4: #b5d0e8; --seq-5: #e3eef7;
}

/* Legende dei grafici in HTML: scala sequenziale, tacca del pareggio, "nessun dato" */
.legenda-grafico { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s5); margin-top: var(--s2);
  font-size: 12px; color: var(--text-2); }
.legenda-scala { display: inline-flex; align-items: center; gap: var(--s2); }
.scala { position: relative; width: 200px; height: 10px; border-radius: 3px; }
.tacca { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); }
.tacca-etichetta { position: absolute; top: 12px; transform: translateX(-50%); white-space: nowrap; font-size: 11px;
  color: var(--text); font-weight: 600; }
.legenda-scala.con-tacca { padding-bottom: 14px; }
.campione-nd { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: -1px;
  margin-right: 6px; background: repeating-linear-gradient(-45deg, var(--border-strong) 0 1.5px, var(--surface-2) 1.5px 5px);
  border: 1px solid var(--border); }
.interruttore { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.interruttore input { accent-color: var(--risultato); width: 16px; height: 16px; margin: 0; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
/* Numeri in colonna: cifre tutte larghe uguali */
body, table, .num { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--text-3); }
.nd { color: var(--text-3); }

.contenitore { max-width: 1320px; margin: 0 auto; padding: 0 var(--s6); }

/* ---------- Header ---------- */
.header { border-bottom: 1px solid var(--border); background: var(--bg); }
.header .contenitore { display: flex; align-items: center; gap: var(--s4); min-height: 64px; }
.marchio { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.marchio-segno { width: 4px; height: 28px; background: var(--brand); border-radius: 2px; flex: none; }
.logo-accademia { height: 36px; width: auto; flex: none; }
.logo-tema-chiaro { display: var(--logo-chiaro); }
.logo-tema-scuro { display: var(--logo-scuro); }
.marchio-separatore { width: 1px; height: 28px; background: var(--border-strong); flex: none; }
.esci { margin: 0; }
/* Footer: "Realizzato da Alternative Intelligence", in piccolo */
.piede { display: flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s6) var(--s4) var(--s8); font-size: 12px; color: var(--text-3); }
.logo-ai { height: 16px; width: auto; filter: var(--filtro-logo-ai); opacity: .85; }

/* ---------- Pagina di accesso ---------- */
.pagina-accesso { min-height: 100vh; display: flex; flex-direction: column; }
.accesso { flex: 1; display: grid; place-items: center; padding: var(--s8) var(--s4); }
.accesso-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: var(--s8) var(--s8) var(--s6); }
.accesso-logo { display: flex; justify-content: center; margin-bottom: var(--s5); }
.accesso-logo .logo-accademia { height: 64px; }
.accesso h1 { text-align: center; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.accesso-sotto { text-align: center; margin: var(--s1) 0 var(--s6); font-size: 13px; color: var(--text-3); }
.accesso form { display: flex; flex-direction: column; gap: var(--s4); }
.campo { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.campo input { height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: var(--surface); font-size: 14px; color: var(--text);
  transition: border-color var(--dur) var(--ease); }
.campo input:hover { border-color: var(--text-3); }
.campo input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.accesso .btn-primario { height: 40px; justify-content: center; font-size: 14px; font-weight: 600; margin-top: var(--s2); }
.accesso .avviso { margin-bottom: 0; }
/* Esito positivo: neutro (niente verde), distinto dal rosso degli errori */
.avviso-ok { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4);
  border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong); }
.avviso-info { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-radius: 12px; font-size: 13px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); text-align: center; }
.campo-aiuto { margin: calc(-1 * var(--s2)) 0 0; font-size: 12px; color: var(--text-3); }
.accesso-azioni { display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
  margin-top: var(--s4); }
.accesso-azioni .esci { margin-left: auto; }
.marchio-testi { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.marchio-nome { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.marchio-titolo { font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.header-azioni { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.stato { display: inline-flex; align-items: center; gap: var(--s2); padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.stato:hover { border-color: var(--border-strong); }
.pallino { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.stato[data-errore="1"] { color: var(--danger); border-color: var(--danger); }
.stato[data-errore="1"] .pallino { background: var(--danger); }

.btn { display: inline-flex; align-items: center; gap: var(--s2); height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.btn:hover { border-color: var(--border-strong); }
a.btn { text-decoration: none; }
.btn-icona { width: 34px; padding: 0; justify-content: center; }
.btn-primario { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.btn-testo { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-testo:hover { color: var(--text); border-color: transparent; background: var(--surface-2); }
.icona { width: 16px; height: 16px; flex: none; }

/* ---------- Barra filtri fissa ---------- */
.filtri { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--border); }
.filtri .contenitore { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  padding-top: var(--s3); padding-bottom: var(--s3); }
.segmenti { display: inline-flex; flex-wrap: wrap; padding: 3px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); }
.segmenti button { border: 0; background: transparent; padding: 5px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.segmenti button:hover { color: var(--text); }
.segmenti button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segm-nota { font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.date-personalizzate { display: inline-flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--text-2); }
.date-personalizzate input { height: 32px; padding: 0 8px; border: 1px solid var(--border);
  border-radius: var(--radius-s); background: var(--surface); }
.menu { position: relative; display: inline-block; }
.menu select { appearance: none; height: 34px; padding: 0 28px 0 10px; max-width: 168px;
  border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface);
  font-size: 13px; font-weight: 500; cursor: pointer; text-overflow: ellipsis;
  transition: border-color var(--dur) var(--ease); }
.menu select:hover { border-color: var(--border-strong); }
.menu select.attivo { border-color: var(--text); }
.menu::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.menu-piccolo select { height: 30px; font-size: 12.5px; max-width: none; }
.filtri-spazio { flex: 1; }
.opzioni { position: relative; }
.menu-opzioni { right: 0; top: calc(100% + 6px); width: 300px; }
.casella { display: flex; gap: var(--s2); align-items: center; padding: 6px 0; font-size: 13px; cursor: pointer; }
.casella input { accent-color: var(--brand-strong); width: 16px; height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; width: 100%; }
.filtri-titolo { font-size: 12.5px; color: var(--text-3); }
.chip-filtro { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  font-size: 12.5px; cursor: pointer; color: var(--text); }
.chip-filtro:hover { border-color: var(--text); }
.chip-filtro.tutti { border-color: transparent; color: var(--text-2); }
.chip-filtro.tutti:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Griglia e sezioni ---------- */
main.contenitore { padding-top: var(--s6); padding-bottom: var(--s10); }
.griglia { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s4); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; } .span-12 { grid-column: span 12; }
.sezione-testa { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin: var(--s8) 0 var(--s3); }
.sezione-testa:first-of-type, .avviso + .sezione-testa { margin-top: 0; }
.sezione-titolo { font-size: 15px; font-weight: 600; }
.sotto { font-size: 12.5px; color: var(--text-3); }
.finestra { font-size: 12.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--s5); position: relative; }

/* ---------- KPI grandi ---------- */
.kpi { display: flex; flex-direction: column; gap: var(--s2); min-height: 172px; }
.kpi-testa { display: flex; align-items: center; gap: var(--s2); }
.kpi-nome { font-size: 13px; font-weight: 500; color: var(--text-2); }
.kpi-valore { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi-riga { display: flex; align-items: center; gap: var(--s2); min-height: 20px; flex-wrap: wrap; }
.kpi-base { font-size: 12.5px; color: var(--text-3); }
.delta { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.delta .freccia { font-size: 10px; margin-right: 2px; }
.delta.giu { color: var(--text-2); }
.delta-prec { font-size: 12.5px; color: var(--text-3); }
.spark-slot { margin-top: auto; }
.spark { height: 36px; width: 100%; display: block; overflow: visible; }
.spark .linea { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--text); opacity: .05; }
.spark .isolato { stroke: var(--text-3); stroke-width: 4; stroke-linecap: round; fill: none; }
.spark .ultimo { stroke: var(--brand); stroke-width: 6; stroke-linecap: round; fill: none; }

/* Badge "min." / "n/d": avvertenza breve, spiegazione nel popover */
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; cursor: pointer; white-space: nowrap; }
.badge:hover { border-color: var(--border-strong); color: var(--text); }

/* ---------- KPI secondari e "Altri indicatori" ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s4); }
.tiles-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 0; }
.tile { padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); display: flex; flex-direction: column; gap: 2px; min-height: 92px; }
.tile-nome { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.tile-valore { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.tile-base { font-size: 12px; color: var(--text-3); }
.altri-apri { margin-top: var(--s2); }
.altri-apri .freccia-giu { transition: transform var(--dur) var(--ease); }
.altri-apri[aria-expanded="true"] .freccia-giu { transform: rotate(180deg); }
.tiles.altri { margin-top: var(--s2); animation: comparsa var(--dur) var(--ease); }

/* ---------- Meta vs Google ---------- */
.mvg { display: grid; grid-template-columns: 1fr 1fr; padding: 0; overflow: hidden; }
.mvg-col { padding: var(--s4) var(--s6) var(--s5); }
.mvg-col + .mvg-col { border-left: 1px solid var(--border); }
.mvg-testa { display: flex; align-items: center; gap: var(--s2); font-weight: 600; font-size: 15px; margin-bottom: var(--s3); }
.mvg-segno { width: 10px; height: 10px; border-radius: 3px; }
.mvg-riga { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: var(--s3);
  row-gap: 6px; padding: 8px 0 10px; border-top: 1px solid var(--border); }
.mvg-riga:first-of-type { border-top: 0; }
.mvg-nome { font-size: 13px; color: var(--text-2); }
.mvg-valore { font-size: 17px; font-weight: 600; text-align: right; display: inline-flex; gap: var(--s2); align-items: center; }
.mvg-barra { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.mvg-barra span { display: block; height: 100%; border-radius: 2px; transition: width 400ms var(--ease); }
.mvg-meta .mvg-barra span, .mvg-meta .mvg-segno { background: var(--cat-meta); }
.mvg-google .mvg-barra span, .mvg-google .mvg-segno { background: var(--cat-google); }

/* ---------- Schede ---------- */
.schede { display: flex; gap: var(--s1); margin: var(--s10) 0 var(--s4); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; }
.schede::-webkit-scrollbar { display: none; }
.schede [role="tab"] { position: relative; border: 0; background: transparent; padding: 10px 14px;
  font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: color var(--dur) var(--ease); }
.schede [role="tab"]:hover { color: var(--text); }
.schede [role="tab"][aria-selected="true"] { color: var(--text); font-weight: 600; }
.schede [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px;
  bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.scheda { animation: dissolvenza var(--dur) var(--ease); }

/* ---------- Card dei grafici ---------- */
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--s5); min-width: 0; }
.chart-card > h3 { display: flex; align-items: center; gap: var(--s2); font-size: 15px; font-weight: 600; }
/* Domande e note lunghe: nel popover ⓘ accanto al titolo */
.chart-card .domanda, .chart-card .nota { display: none; }
.filtrato-su { margin: var(--s2) 0 0; font-size: 12.5px; color: var(--text-2); }
.link-azione { border: 0; background: none; padding: 0; color: var(--brand-strong); font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.controlli { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s3); }
.avvertenze { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.avvertenze:empty { display: none; }
.headline { margin: var(--s3) 0 0; font-size: 15px; font-weight: 600; }
.chart-box { height: 300px; margin-top: var(--s3); border-radius: 10px; transition: opacity var(--dur) var(--ease); }
.chart-box.medio { height: 300px; }
.chart-box.alto { height: 380px; }
.chart-box.mappa { height: 520px; }
.chart-box.pannelli { height: 480px; }
.chart-box.molto-alto { height: 540px; }
.carico .chart-box, .carico .table-wrap, .carico .tiles, .carico .headline { opacity: .5; }
.scelte { gap: 6px; }
.scelta { border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.scelta:hover { color: var(--text); border-color: var(--border-strong); }
.scelta[aria-pressed="true"] { color: var(--text); border-color: var(--text); font-weight: 600; }

.vista-tabella { margin-top: var(--s3); font-size: 13px; }
.vista-tabella summary { cursor: pointer; color: var(--text-2); width: fit-content; }
.vista-tabella summary:hover { color: var(--text); }
.vista-tabella table { margin-top: var(--s2); }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; margin-top: var(--s3); transition: opacity var(--dur) var(--ease); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-3); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
tr:hover td { background: var(--surface-2); }
th.num, td.num { text-align: right; white-space: nowrap; }
#tbl-leads td:nth-child(8) { white-space: nowrap; }
td.nd { color: var(--text-3); }
tr.riga-nt td { color: var(--text-2); }
tr.riga-totale td { font-weight: 600; border-top: 1px solid var(--border-strong); }
tr.riga-principale td { background: var(--surface-2); font-size: 14px; }
tr.riga-principale td:first-child { box-shadow: inset 3px 0 0 var(--text); }
tr.riga-nota td { color: var(--text-3); font-size: 12px; padding-top: 0; }
tr.riga-sezione td { padding-top: var(--s6); font-weight: 600; font-size: 14px; }
tr.riga-sezione .nota-cella { display: block; margin-top: 2px; }
.nota-cella { color: var(--text-3); font-size: 11.5px; font-weight: 400; }
.avviso-riga { margin-top: 2px; font-size: 11.5px; color: var(--danger); }

/* ---------- Simulatore ---------- */
.span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; }
.sim-input { width: 92px; height: 30px; padding: 0 8px; text-align: right; border: 1px solid var(--border);
  border-radius: var(--radius-s); background: var(--surface); font-variant-numeric: tabular-nums;
  transition: border-color var(--dur) var(--ease); }
.sim-input:hover { border-color: var(--border-strong); }
.sim-input.modificato { border-color: var(--text); font-weight: 600; }
.sim-input[aria-invalid="true"] { border-color: var(--danger); color: var(--danger); }
.sim-input::placeholder { color: var(--text-3); }
.sim-tabella td { vertical-align: middle; }
.sim-privato { font-size: 12.5px; color: var(--text-3); }
.sim-suggerimento { font-size: 12.5px; color: var(--text-2); }
.pareggio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pareggio.sopra { color: var(--text); }
.pareggio.sotto { color: var(--text-2); }
.pareggio.incerto { color: var(--text-2); font-weight: 500; }
/* Al posto del ROAS o del CPA obiettivo quando il margine non supera l'utile richiesto */
.irraggiungibile { display: inline-block; max-width: 180px; font-size: 12.5px; color: var(--text-2); text-align: right;
  white-space: normal; line-height: 1.35; }
.sim-obiettivo-campo { font-size: 13px; font-weight: 600; color: var(--text); }
.intervallo { color: var(--text-2); }
.intervallo b { color: var(--text); font-weight: 600; white-space: nowrap; }
tr.evidenza td { background: var(--surface-2); font-size: 14px; }
tr.evidenza td:first-child { box-shadow: inset 3px 0 0 var(--text); }
.etichetta-info { display: inline-flex; align-items: center; gap: 4px; }
.scenario-controlli { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); margin-top: var(--s3); }
.scenario-cursore { flex: 1 1 240px; min-width: 200px; accent-color: var(--brand-strong); }
.scenario-valore { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 190px; }
.scenario-ipotesi { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.scenario-ipotesi .sim-input { width: 64px; }
/* Sempre visibile: la stima vale a costo per iscritto costante */
.scenario-avvertenza { margin: var(--s3) 0 0; font-size: 13px; color: var(--text-2); }
/* Il rosso del marchio solo come evidenza: il punto accanto a "sotto pareggio" */
.punto-brand { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); flex: none; }
#sim-piattaforme td:first-child { color: var(--text-2); }
/* Tabelle larghe del simulatore: intestazioni a capo e celle più strette, per stare nella card */
#sim-ipotesi th { white-space: normal; vertical-align: bottom; }
#sim-ipotesi th, #sim-ipotesi td { padding-left: 6px; padding-right: 6px; }
#sim-ipotesi .sim-input { width: 72px; }
/* Per corso: 6 colonne a vista, il resto nella riga di dettaglio */
tr.riga-apribile { cursor: pointer; }
tr.riga-apribile.aperta td { background: var(--surface-2); border-bottom-color: transparent; }
.sim-apri { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none;
  font-weight: 600; text-align: left; cursor: pointer; }
.sim-apri:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: 3px; border-radius: 4px; }
.sim-freccia { width: 0; height: 0; border-style: solid; border-width: 4px 0 4px 6px; flex: none;
  border-color: transparent transparent transparent var(--text-3); transition: transform var(--dur) var(--ease); }
.sim-apri[aria-expanded="true"] .sim-freccia { transform: rotate(90deg); }
tr.riga-dettaglio > td { background: var(--surface-2); padding: var(--s2) var(--s4) var(--s4); }
tr.riga-dettaglio:hover td { background: var(--surface-2); }
.sim-dettaglio { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s3) var(--s5); margin: 0; }
.sim-dettaglio dt { font-size: 12px; color: var(--text-3); }
.sim-dettaglio dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.sim-dettaglio .irraggiungibile { text-align: left; }
#sim-piattaforme tr:last-child td { border-bottom: 0; padding-top: var(--s3); }

/* ---------- Tooltip dei grafici (HTML di ECharts, sempre da tip()) ---------- */
.tt { min-width: 180px; font-family: var(--font); }
.tt-t { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.tt-r { display: flex; justify-content: space-between; gap: 16px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.tt-r span { color: var(--text-2); }
.tt-r b { font-weight: 600; color: var(--text); text-align: right; }
.tt-r b.nd { color: var(--text-3); font-weight: 500; }
.tt-n { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 11.5px; }

/* ---------- Info ⓘ e popover ---------- */
.info { width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent;
  color: var(--text-3); cursor: pointer; display: inline-grid; place-items: center; padding: 0; flex: none; }
.info:hover, .info[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.info svg { width: 15px; height: 15px; }
.popover { position: absolute; z-index: 50; max-width: 340px; padding: var(--s3) var(--s4);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 13px; line-height: 1.5;
  font-weight: 400; animation: comparsa 150ms var(--ease); }
.popover h4 { margin: 0 0 var(--s1); font-size: 13px; font-weight: 600; }
.popover p { margin: 0 0 var(--s2); color: var(--text-2); }
.popover p:last-child { margin-bottom: 0; }
.popover ul { margin: 0; padding: 0; list-style: none; }
.popover li { display: flex; justify-content: space-between; gap: var(--s4); padding: 5px 0;
  border-top: 1px solid var(--border); font-size: 12.5px; }
.popover li:first-child { border-top: 0; }
.popover li .errore { color: var(--danger); text-align: right; }
.popover li .testo-2 { color: var(--text-2); text-align: right; }

/* ---------- Pannello laterale "Come leggere i numeri" ---------- */
.velo { position: fixed; inset: 0; background: var(--overlay); z-index: 60; animation: dissolvenza 200ms var(--ease); }
.pannello { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 61;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop);
  overflow-y: auto; padding: var(--s6); animation: entrata 220ms var(--ease); }
.pannello h2 { margin: 0 0 var(--s4); font-size: 18px; }
.pannello h3 { margin: var(--s5) 0 var(--s1); font-size: 14px; }
.pannello p { margin: 0 0 var(--s2); color: var(--text-2); font-size: 13.5px; }
.pannello-chiudi { position: absolute; top: var(--s4); right: var(--s4); }

/* ---------- Avvisi (errori, dati non aggiornati) ---------- */
.avviso { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4);
  border-radius: 12px; background: var(--danger-bg); color: var(--danger); font-size: 13px;
  margin-bottom: var(--s4); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- Skeleton, transizioni ---------- */
.caricamento .kpi-valore, .caricamento .tile-valore, .caricamento .mvg-valore {
  color: transparent; border-radius: 6px; background: var(--surface-2);
  background-image: linear-gradient(90deg, transparent, var(--surface), transparent);
  background-size: 200% 100%; animation: luccichio 1.2s linear infinite; }
.caricamento .kpi-valore { width: 60%; min-height: 37px; }
.caricamento .tile-valore { width: 50%; min-height: 26px; }
.caricamento .delta, .caricamento .kpi-base, .caricamento .spark, .caricamento .badge { visibility: hidden; }
.chart-box.vuoto { background: var(--surface-2);
  background-image: linear-gradient(90deg, transparent, var(--surface), transparent);
  background-size: 200% 100%; animation: luccichio 1.2s linear infinite; }
.aggiorna { transition: opacity var(--dur) var(--ease); }
body.in-aggiornamento .aggiorna { opacity: .55; }
@keyframes luccichio { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes comparsa { from { opacity: 0; transform: translateY(-4px); } }
@keyframes dissolvenza { from { opacity: 0; } }
@keyframes entrata { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Schermi stretti: la griglia passa a una colonna ---------- */
@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; }
  .span-5, .span-7 { grid-column: span 12; }
  .tiles-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-box.alto { height: 340px; }
  .chart-box.mappa { height: 460px; }
}
@media (max-width: 760px) {
  .contenitore { padding: 0 var(--s4); }
  .span-3, .span-4, .span-6 { grid-column: span 12; }
  .tiles, .tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mvg { grid-template-columns: 1fr; }
  .mvg-col + .mvg-col { border-left: 0; border-top: 1px solid var(--border); }
  .stato-testo, .btn-legenda-testo, .segm-nota { display: none; }
  .marchio-titolo { font-size: 15px; }
  .chart-box.medio { height: 420px; }
  .chart-box.alto { height: 320px; }
  .chart-box.molto-alto { height: 600px; }
}
