.table-wrap { overflow-x: auto; }
.table-wrap-sticky { overflow: auto; max-height: calc(100vh - 210px); }
/* Con border-collapse (default Bootstrap) gli sfondi delle celle sticky
   lasciano trasparire le righe sottostanti durante lo scroll. */
.table-wrap-sticky table { border-collapse: separate; border-spacing: 0; }
.table-wrap-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--bs-card-bg, #fff);
  box-shadow: inset 0 -1px 0 var(--bs-border-color, #dee2e6);
}
.table-wrap-sticky thead tr + tr th { top: var(--sticky-riga2-top, 2.1rem); }
.campo-suggerimenti { font-size: .8rem; color: #6c757d; }
/* Collegamenti rapidi della pagina Nuovo contratto: una riga compatta per combinazione */
.collegamenti-rapidi .list-group-item { padding-top: .4rem; padding-bottom: .4rem; font-size: .9rem; }
.sezione-card .card-header { font-weight: 600; }
.form-label { margin-bottom: .2rem; font-size: .85rem; }
input.form-control-sm, select.form-select-sm { font-size: .85rem; }
/* Suggerimenti typeahead (typeahead.js: Tipo Via e distributore gas): sopra la barra sticky dei pulsanti */
.typeahead-menu { max-height: 16rem; overflow-y: auto; z-index: 1025; font-size: .85rem; }
.typeahead-menu .dropdown-item { padding: .2rem .75rem; cursor: pointer; }
.typeahead-menu .dropdown-item small { margin-left: .4rem; color: #6c757d; }
.typeahead-menu .dropdown-item.active small { color: rgba(255, 255, 255, .85); }
.typeahead-menu .typeahead-nota { font-size: .8rem; color: #6c757d; padding: .2rem .75rem; }
/* Vista DEBUG del contratto: valori grezzi del database a larghezza fissa,
   JSON come salvato e righe nascoste con "Solo chiavi con valore" */
.debug-valore { font-family: var(--bs-font-monospace); font-size: .85rem; white-space: pre-wrap; word-break: break-all; }
.debug-json { font-size: .8rem; white-space: pre-wrap; word-break: break-all; }
/* Note della pratica (/contratti/{id}/note): a capo come scritti */
.nota-testo { white-space: pre-wrap; overflow-wrap: anywhere; }
.debug-solo-valorizzati .debug-assente, .debug-solo-valorizzati .debug-vuoto { display: none; }
/* Vista Report (report.html, app/report.py): dashboard dei contratti caricati.
   Luce e gas hanno sempre lo stesso colore (blu e arancio: coppia distinguibile
   anche dai daltonici, contrasto >= 3:1 sul bianco delle card); i numeri e le
   etichette restano nel colore del testo, il quadratino accanto al nome fa da
   legenda. */
/* il tooltip sta in fondo al body, fuori da .report: gli servono gli stessi colori */
.report, .report-tooltip { --report-luce: #2a78d6; --report-gas: #eb6834; --report-griglia: #e9ecef; --report-asse: #ced4da; }
.report-seg-luce { background-color: var(--report-luce); fill: var(--report-luce); }
.report-seg-gas { background-color: var(--report-gas); fill: var(--report-gas); }
.report-chiave { display: inline-block; width: .65rem; height: .65rem; border-radius: 2px; margin-right: .35rem; }
/* Riquadri con i numeri principali: uno solo in grande, cifre proporzionali */
.report-tile-label { font-size: .85rem; color: var(--bs-secondary-color); }
.report-tile-value { font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.report-tile-value.report-hero { font-size: 3rem; line-height: 1.1; }
.report-tile-sub { font-size: .8rem; color: var(--bs-secondary-color); }
/* Tabelle dei conteggi: numeri incolonnati, barra luce + gas sull'asse comune
   della tabella (2px di stacco tra i segmenti, estremita' arrotondata) */
.report-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-tabella th:first-child, .report-tabella td:first-child { padding-left: 1rem; white-space: nowrap; }
.report-tabella th:last-child, .report-tabella td:last-child { padding-right: 1rem; }
.report-col-barra { width: 30%; min-width: 7rem; }
.report-barra { display: flex; height: 10px; }
.report-seg { height: 100%; min-width: 2px; box-sizing: border-box; }
.report-seg + .report-seg { min-width: 4px; padding-left: 2px; background-clip: content-box; }
.report-seg:last-child { border-radius: 0 4px 4px 0; }
.report-barra:hover .report-seg { filter: brightness(1.12); }
/* Andamento: colonne sottili luce + gas, griglia e assi in secondo piano; su
   schermi stretti il grafico scorre in orizzontale invece di rimpicciolire */
.report-grafico { display: block; width: 100%; min-width: 34rem; height: auto; overflow: visible; }
.report-grafico text { font-size: 11px; fill: var(--bs-secondary-color); }
.report-grafico .report-tacca { font-variant-numeric: tabular-nums; }
.report-grafico .report-valore { fill: var(--bs-body-color); font-weight: 600; }
.report-grafico .report-griglia { stroke: var(--report-griglia); stroke-width: 1; }
.report-grafico .report-base { stroke: var(--report-asse); stroke-width: 1; }
.report-grafico .report-stacco { fill: var(--bs-card-bg, #fff); }
.report-colonna { outline: none; }
.report-colonna .report-area { fill: transparent; }
.report-colonna:hover .report-area, .report-colonna:focus .report-area { fill: rgba(0, 0, 0, .05); }
.report-colonna:hover path, .report-colonna:focus path { filter: brightness(1.12); }
.report-colonna:focus-visible .report-area { stroke: var(--bs-primary); stroke-width: 1; }
.report-dati { max-height: 16rem; overflow-y: auto; }
/* Tooltip dei grafici (report.js): prima il valore, poi il nome della serie */
.report-tooltip { position: fixed; z-index: 1080; pointer-events: none; min-width: 7rem; padding: .4rem .6rem; font-size: .8rem; line-height: 1.4; color: var(--bs-body-color); background: #fff; border: 1px solid rgba(0, 0, 0, .12); border-radius: .375rem; box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .15); }
.report-tooltip-titolo { font-weight: 600; margin-bottom: .15rem; }
.report-tooltip-riga { display: flex; align-items: center; gap: .4rem; }
.report-tooltip-riga strong { min-width: 1.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.report-tooltip-riga span:last-child { color: var(--bs-secondary-color); }
.report-tooltip-chiave { width: .75rem; height: 2px; border-radius: 1px; }
/* Test API (api_test.js): richiesta in anteprima e corpo della risposta */
.api-test-anteprima { padding: .4rem .6rem; background: var(--bs-tertiary-bg, #f8f9fa); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .375rem; }
.api-test-json { max-height: 70vh; overflow: auto; padding: .6rem .75rem; background: var(--bs-tertiary-bg, #f8f9fa); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .375rem; white-space: pre; }
/* Documentazione API (documentazione_api.html): la guida openapi.md resa in HTML */
.documentazione-api { max-width: 60rem; }
.documentazione-api h1 { font-size: 1.6rem; }
.documentazione-api h2 { font-size: 1.35rem; margin-top: 2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--bs-border-color, #dee2e6); }
.documentazione-api h3 { font-size: 1.1rem; margin-top: 1.5rem; }
.documentazione-api h4 { font-size: 1rem; margin-top: 1.25rem; }
.documentazione-api pre { background-color: #f6f8fa; border: 1px solid #e9ecef; border-radius: .375rem; padding: .75rem; font-size: .85rem; }
.documentazione-api table { font-size: .875rem; }
.documentazione-api blockquote { border-left: .25rem solid #dee2e6; padding-left: .75rem; color: #6c757d; }
.documentazione-api .mermaid { margin: 1rem 0; text-align: center; overflow-x: auto; }
