/* Portale TradeMe — stile unico. Desktop a tutta larghezza, telefono a colonna; tema chiaro e scuro.
   Niente risorse esterne: font di sistema. Campi ≥ 16 px sul telefono (Safari non ingrandisce). */
:root {
  --sfondo: #f4f6f8; --carta: #ffffff; --testo: #17212b; --tenue: #5b6875; --bordo: #d9e0e6;
  --primario: #0f5c6e; --primario-testo: #ffffff; --accento: #c98a1b; --link: #0b6b80;
  --verde: #1d7a4a; --verde-sf: #e3f4ea; --rosso: #b3261e; --rosso-sf: #fbe7e5; --giallo-sf: #fdf3dc;
  --grigio-sf: #eef1f4; --ombra: 0 1px 2px rgba(16, 32, 48, .06), 0 2px 8px rgba(16, 32, 48, .05);
  --innova-grafite: #17212b; --innova-ambra: #c98a1b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sfondo: #0f1419; --carta: #171e25; --testo: #e6ebef; --tenue: #9aa8b4; --bordo: #2a3540;
    --primario: #3aa6bd; --primario-testo: #06232a; --accento: #e0a640; --link: #6cc6da;
    --verde: #59c58a; --verde-sf: #143224; --rosso: #f08b83; --rosso-sf: #3a1c1a; --giallo-sf: #3a2f14;
    --grigio-sf: #1e2731; --ombra: none; --innova-grafite: #e6ebef;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
body {
  margin: 0; background: var(--sfondo); color: var(--testo);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--link); }
h1 { font-size: 1.45rem; margin: .2rem 0 .8rem; line-height: 1.25; }
h2 { font-size: 1.12rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
code { font-size: .88em; background: var(--grigio-sf); padding: 0 .25em; border-radius: 3px; overflow-wrap: anywhere; }
.d-none { display: none !important; }
.tenue { color: var(--tenue); }
.piccolo { font-size: .86rem; }
.w-100 { width: 100%; }
.mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; }
.centro { text-align: center; }

/* ── testata e menu a tendina ── */
.testata {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
  background: var(--primario); color: var(--primario-testo);
}
.marchio { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-weight: 700;
  font-size: 1.08rem; letter-spacing: .01em; }
.marchio img { width: 28px; height: 28px; border-radius: 6px; }
.testata .dove { font-size: .9rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.testata .spazio { flex: 1; }
.lineette {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-width: 44px; height: 44px;
  padding: 0 .7rem; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; background: transparent;
  color: inherit; font: inherit; cursor: pointer;
}
.lineette svg { width: 22px; height: 22px; }
.lineette .testo-menu { font-size: .92rem; }
.tendina {
  position: fixed; left: 0; right: 0; top: var(--alto-testata, 60px); z-index: 19;
  background: var(--carta); border-bottom: 1px solid var(--bordo); box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: calc(100svh - var(--alto-testata, 60px)); overflow-y: auto; padding: .8rem 1rem 1.2rem;
}
.tendina-gruppi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .4rem 1.4rem; }
.tendina h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--tenue); margin: .6rem 0 .2rem; }
.tendina a { display: block; padding: .55rem .5rem; border-radius: 8px; text-decoration: none; color: var(--testo); min-height: 44px; }
.tendina a:hover, .tendina a.attiva { background: var(--grigio-sf); }
.tendina a.attiva { font-weight: 600; }
.tendina form { margin: 0; }
.tendina .esci { display: block; width: 100%; text-align: left; padding: .55rem .5rem; border: 0; background: none;
  color: var(--rosso); font: inherit; cursor: pointer; min-height: 44px; border-radius: 8px; }
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 18; }

/* ── pagina ── */
.pagina { padding: 1rem 1.25rem 2.5rem; width: 100%; }
@media (min-width: 1100px) { .pagina { padding: 1.4rem 2.2rem 3rem; } }
.piede { padding: 1rem 1.25rem 2rem; color: var(--tenue); font-size: .8rem; border-top: 1px solid var(--bordo); }
.avvisi { margin-bottom: 1rem; display: grid; gap: .5rem; }
.avviso { padding: .65rem .85rem; border-radius: 10px; border: 1px solid var(--bordo); background: var(--carta); }
.avviso.danger, .avviso.ko { background: var(--rosso-sf); border-color: var(--rosso); }
.avviso.success, .avviso.ok { background: var(--verde-sf); border-color: var(--verde); }
.avviso.warning { background: var(--giallo-sf); border-color: var(--accento); }
.riga-essenziale { padding: .75rem 1rem; border-left: 4px solid var(--primario); background: var(--carta); border-radius: 8px;
  box-shadow: var(--ombra); margin-bottom: 1rem; }

/* ── riquadri e griglie ── */
.griglia { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.griglia-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.carta { background: var(--carta); border: 1px solid var(--bordo); border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--ombra); min-width: 0; }
.carta h2 { margin-top: 0; font-size: 1rem; }
.carta .cifra { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.carta .sotto { color: var(--tenue); font-size: .86rem; }
.pastiglie { display: flex; flex-wrap: wrap; gap: .35rem; }
.pastiglia { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .82rem; font-weight: 600;
  background: var(--grigio-sf); white-space: nowrap; }
.favorevole { background: var(--verde-sf); color: var(--verde); }
.sfavorevole { background: var(--rosso-sf); color: var(--rosso); }
.neutro { background: var(--grigio-sf); color: var(--tenue); }
.mancante { background: var(--giallo-sf); color: var(--testo); }
.positivo { color: var(--verde); } .negativo { color: var(--rosso); }
.barra-stati { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--grigio-sf); margin: .5rem 0 .3rem; }
.barra-stati span { display: block; height: 100%; }
.barra-stati .b-fav { background: var(--verde); } .barra-stati .b-neu { background: #9aa8b4; } .barra-stati .b-sfa { background: var(--rosso); }
.dato-mancante { color: var(--tenue); font-style: italic; }

/* ── tabelle: scorrono nel loro riquadro, mai la pagina ── */
.tabella-scorre { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border: 1px solid var(--bordo);
  border-radius: 10px; background: var(--carta); margin: .5rem 0 1rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--bordo); text-align: left; vertical-align: top; }
th { background: var(--grigio-sf); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in srgb, var(--grigio-sf) 60%, transparent); }
.filtri { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: .5rem 0 .8rem; }
.filtri label { display: grid; gap: .2rem; font-size: .84rem; color: var(--tenue); }
.filtri .conta { margin-left: auto; color: var(--tenue); font-size: .86rem; }

/* Paniere sul telefono: una carta per titolo invece della tabella larga */
@media (max-width: 760px) {
  .tabella-carte thead { display: none; }
  .tabella-carte, .tabella-carte tbody, .tabella-carte tr, .tabella-carte td { display: block; width: 100%; }
  .tabella-carte tr { border-bottom: 1px solid var(--bordo); padding: .6rem .7rem; }
  .tabella-carte td { border: 0; padding: .12rem 0; }
  .tabella-carte td[data-etichetta]::before { content: attr(data-etichetta) " · "; color: var(--tenue); font-size: .8rem; }
  .tabella-carte td.num { text-align: left; }
  .tabella-carte td.nome-titolo { font-size: 1.02rem; }
}

/* ── moduli e pulsanti ── */
input, select, textarea, button { font: inherit; }
.form-control, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--bordo); border-radius: 10px; background: var(--carta);
  color: var(--testo); min-height: 44px;
}
@media (max-width: 760px) { .form-control, select, input { font-size: 16px; } }
label.campo { display: block; font-size: .9rem; margin-bottom: .25rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid var(--primario); background: var(--primario); color: var(--primario-testo);
  text-decoration: none; cursor: pointer; font-weight: 600;
}
.btn.secondario { background: transparent; color: var(--primario); }
.btn.pericolo { background: transparent; color: var(--rosso); border-color: var(--rosso); }
.btn.piccolo-btn { min-height: 36px; padding: .3rem .7rem; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-link { background: none; border: 0; color: var(--link); text-decoration: underline; cursor: pointer; padding: 0; }
.spunta { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.spunta input { width: 20px; height: 20px; }
.accesso { max-width: 420px; margin: 2rem auto; }
.accesso .carta { padding: 1.4rem; }
.accesso .logo { display: flex; align-items: center; gap: .6rem; margin-bottom: .2rem; }
.accesso .logo img { width: 40px; height: 40px; border-radius: 9px; }
.separatore { display: flex; align-items: center; gap: .6rem; color: var(--tenue); font-size: .82rem; margin: 1rem 0; }
.separatore::before, .separatore::after { content: ""; flex: 1; border-top: 1px solid var(--bordo); }
#telefono-qr { background: #fff; padding: 6px; border-radius: 8px; max-width: 240px; width: 100%; height: auto; }

/* ── documenti ── */
.documento { max-width: 980px; }
.documento h1 { font-size: 1.35rem; }
.documento blockquote { margin: .8rem 0; padding: .4rem .9rem; border-left: 4px solid var(--accento); background: var(--carta); border-radius: 6px; }
.documento img { max-width: 100%; }
.documento pre { overflow-x: auto; background: var(--grigio-sf); padding: .7rem; border-radius: 8px; }
.documento td, .documento th { font-size: .86rem; }
.link-spento { text-decoration: underline dotted; }
.barra-azioni { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 1rem; }
.estratti { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.estratti .carta { max-height: 420px; overflow: auto; }
.estratti .carta .documento { font-size: .9rem; }
details.scheda-intera > summary { cursor: pointer; font-weight: 600; padding: .6rem 0; min-height: 44px; }

/* ── finestra dell'anteprima PDF ── */
.modale { position: fixed; inset: 0; z-index: 40; display: flex; align-items: stretch; justify-content: center;
  background: rgba(10, 16, 22, .6); padding: 2vh 2vw; }
.modale-scatola { background: var(--carta); border-radius: 12px; width: min(1000px, 100%); display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modale-testa { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-bottom: 1px solid var(--bordo); flex-wrap: wrap; }
.modale-testa h2 { margin: 0; font-size: 1rem; flex: 1; min-width: 10rem; }
.modale-corpo { flex: 1; overflow-y: auto; background: #7b8794; padding: .8rem; -webkit-overflow-scrolling: touch; }
.modale-corpo img { display: block; width: 100%; max-width: 820px; margin: 0 auto .8rem; background: #fff; border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.modale-stato { color: #fff; text-align: center; padding: 2rem 1rem; }
@media (max-width: 760px) { .modale { padding: 0; } .modale-scatola { border-radius: 0; } }
iframe.stampa { position: fixed; width: 1px; height: 1px; left: -10px; top: -10px; border: 0; }
iframe.report { width: 100%; height: 78svh; border: 1px solid var(--bordo); border-radius: 10px; background: #fff; }

/* ── grafici SVG ── */
.grafico { width: 100%; height: 260px; display: block; }
.grafico-barre { height: auto; max-width: 560px; }
.grafico-z { width: 220px; max-width: 100%; height: 34px; display: block; }
.g-griglia { stroke: var(--bordo); stroke-width: 1; }
.g-asse { fill: var(--tenue); font-size: 11px; }
.g-valore { fill: var(--testo); font-size: 12px; }
.g-linea { fill: none; stroke: var(--primario); stroke-width: 2; vector-effect: non-scaling-stroke; }
.g-area { fill: color-mix(in srgb, var(--primario) 14%, transparent); stroke: none; }
.g-punto { fill: var(--primario); }
.g-punto.g-fuori { fill: var(--rosso); }
.g-barra { fill: var(--primario); }
.g-soglia { fill: color-mix(in srgb, var(--verde) 18%, transparent); }
.g-zero { stroke: var(--tenue); stroke-width: 1; stroke-dasharray: 2 2; }
/* larghezze senza attributi style (la CSP li vieta): .larghezza-N = N % */
.larghezza-0{width:0%}.larghezza-1{width:1%}.larghezza-2{width:2%}.larghezza-3{width:3%}.larghezza-4{width:4%}.larghezza-5{width:5%}.larghezza-6{width:6%}.larghezza-7{width:7%}.larghezza-8{width:8%}.larghezza-9{width:9%}.larghezza-10{width:10%}.larghezza-11{width:11%}.larghezza-12{width:12%}.larghezza-13{width:13%}.larghezza-14{width:14%}.larghezza-15{width:15%}.larghezza-16{width:16%}.larghezza-17{width:17%}.larghezza-18{width:18%}.larghezza-19{width:19%}.larghezza-20{width:20%}.larghezza-21{width:21%}.larghezza-22{width:22%}.larghezza-23{width:23%}.larghezza-24{width:24%}.larghezza-25{width:25%}.larghezza-26{width:26%}.larghezza-27{width:27%}.larghezza-28{width:28%}.larghezza-29{width:29%}.larghezza-30{width:30%}.larghezza-31{width:31%}.larghezza-32{width:32%}.larghezza-33{width:33%}.larghezza-34{width:34%}.larghezza-35{width:35%}.larghezza-36{width:36%}.larghezza-37{width:37%}.larghezza-38{width:38%}.larghezza-39{width:39%}.larghezza-40{width:40%}.larghezza-41{width:41%}.larghezza-42{width:42%}.larghezza-43{width:43%}.larghezza-44{width:44%}.larghezza-45{width:45%}.larghezza-46{width:46%}.larghezza-47{width:47%}.larghezza-48{width:48%}.larghezza-49{width:49%}.larghezza-50{width:50%}.larghezza-51{width:51%}.larghezza-52{width:52%}.larghezza-53{width:53%}.larghezza-54{width:54%}.larghezza-55{width:55%}.larghezza-56{width:56%}.larghezza-57{width:57%}.larghezza-58{width:58%}.larghezza-59{width:59%}.larghezza-60{width:60%}.larghezza-61{width:61%}.larghezza-62{width:62%}.larghezza-63{width:63%}.larghezza-64{width:64%}.larghezza-65{width:65%}.larghezza-66{width:66%}.larghezza-67{width:67%}.larghezza-68{width:68%}.larghezza-69{width:69%}.larghezza-70{width:70%}.larghezza-71{width:71%}.larghezza-72{width:72%}.larghezza-73{width:73%}.larghezza-74{width:74%}.larghezza-75{width:75%}.larghezza-76{width:76%}.larghezza-77{width:77%}.larghezza-78{width:78%}.larghezza-79{width:79%}.larghezza-80{width:80%}.larghezza-81{width:81%}.larghezza-82{width:82%}.larghezza-83{width:83%}.larghezza-84{width:84%}.larghezza-85{width:85%}.larghezza-86{width:86%}.larghezza-87{width:87%}.larghezza-88{width:88%}.larghezza-89{width:89%}.larghezza-90{width:90%}.larghezza-91{width:91%}.larghezza-92{width:92%}.larghezza-93{width:93%}.larghezza-94{width:94%}.larghezza-95{width:95%}.larghezza-96{width:96%}.larghezza-97{width:97%}.larghezza-98{width:98%}.larghezza-99{width:99%}.larghezza-100{width:100%}
