@font-face { font-family: "Instrument Sans"; font-weight: 400; font-display: swap; src: url("/fonts/instrument-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-display: swap; src: url("/fonts/instrument-sans-500.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-display: swap; src: url("/fonts/instrument-sans-600.woff2") format("woff2"); }

:root {
    --bg: #f4f6f7;
    --surface: #ffffff;
    --ink: #1b2328;
    --ink-2: #48545c;
    --muted: #7a858c;
    --line: #e3e8eb;
    --line-2: #cdd5d9;
    --accent: #1d5c66;
    --accent-hover: #164a52;
    --accent-ink: #ffffff;
    --accent-soft: #e5eff0;
    --ok: #3c7657;
    --ok-soft: #e6f0ea;
    --warn: #a36b17;
    --warn-soft: #f7eedd;
    --bad: #a5443c;
    --bad-soft: #f5e5e3;
    --off: #6f7a82;
    --off-soft: #edf0f2;
    --focus: #1d5c6633;
    --shadow: 0 1px 2px rgba(20, 30, 36, .04), 0 4px 16px rgba(20, 30, 36, .04);
    --radius: 10px;
    --radius-s: 6px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111618; --surface: #171d20; --ink: #e6ecee; --ink-2: #b4bfc4; --muted: #849096;
        --line: #252e32; --line-2: #344045; --accent: #5fa9b4; --accent-hover: #79bcc6; --accent-ink: #0d1517;
        --accent-soft: #1b2c30; --ok: #74b493; --ok-soft: #18271f; --warn: #d6a253; --warn-soft: #2b2316;
        --bad: #dd8178; --bad-soft: #2d1b19; --off: #96a1a7; --off-soft: #20272a; --focus: #5fa9b440;
        --shadow: none; color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 400 15px/1.5 "Instrument Sans", system-ui, sans-serif;
    font-feature-settings: "tnum" 1;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
[x-cloak], [hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.barra { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.barra-in { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 28px; }
.marchio { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.marchio svg { display: block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 7px 12px; border-radius: var(--radius-s); color: var(--ink-2); font-weight: 500; }
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a.attivo { color: var(--accent); background: var(--accent-soft); }
.utente { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.utente a:hover { color: var(--ink); }
.utente form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer; }
.linkbtn:hover { color: var(--ink); }

.pagina { max-width: 1160px; margin: 0 auto; padding: 32px 24px 80px; }
.testa { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.testa .sopra { color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
.testa .sopra a:hover { color: var(--accent); }
.azioni { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid transparent;
    font: 500 14px/1 "Instrument Sans", system-ui, sans-serif; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn svg { flex: none; }
.btn-primario { background: var(--accent); color: var(--accent-ink); }
.btn-primario:hover { background: var(--accent-hover); }
.btn-secondario { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondario:hover { border-color: var(--ink-2); }
.btn-tenue { background: transparent; color: var(--ink-2); }
.btn-tenue:hover { background: var(--off-soft); color: var(--ink); }
.btn-pericolo { background: transparent; color: var(--bad); border-color: var(--line-2); }
.btn-pericolo:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-piccolo { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: progress; }

.riquadro { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.riquadro-testa .nota { white-space: nowrap; }
.riquadro-testa { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px 0; }
.riquadro-corpo { padding: 18px 22px 22px; }
.riquadro + .riquadro { margin-top: 20px; }
.nota { color: var(--muted); font-size: 13.5px; }

.cifre { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.cifra { background: var(--surface); padding: 18px 22px; }
.cifra .val { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; }
.cifra .eti { color: var(--muted); font-size: 13.5px; }
.cifra.avviso .val { color: var(--warn); }

.linea { position: relative; padding: 8px 22px 38px; }
.linea-pista { position: relative; height: 128px; border-bottom: 1px solid var(--line-2); margin-top: 22px; }
.linea-mese { position: absolute; top: calc(100% + 6px); transform: translateX(-1px); font-size: 12px; color: var(--muted); line-height: 1.25; }
.linea-mese small { display: block; font-size: 11px; }
.linea-mese::before { content: ""; position: absolute; left: 0; top: -8px; width: 1px; height: 6px; background: var(--line-2); }
.linea-mese.anno { color: var(--ink-2); font-weight: 500; }
.linea-griglia { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.linea-oggi { position: absolute; top: -6px; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); }
.linea-oggi span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11.5px; color: var(--accent); font-weight: 600; }
.segno { position: absolute; width: 10px; margin-left: -5px; height: 24px; border-radius: 3px; background: var(--ok); color: var(--ok); }
.segno.in_scadenza { background: var(--warn); color: var(--warn); }
.segno.scaduta { background: var(--bad); color: var(--bad); }
.segno:hover, .segno:focus-visible { z-index: 3; outline: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px currentColor; }
.segno .fumetto {
    position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: var(--ink); color: var(--surface); font-size: 12.5px; line-height: 1.35; padding: 7px 10px; border-radius: var(--radius-s);
    white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s;
}
.segno:hover .fumetto, .segno:focus-visible .fumetto { opacity: 1; }
.segno .fumetto b { font-weight: 600; display: block; }

.griglia-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; margin-top: 20px; }
.griglia-2 > div > .riquadro + .riquadro { margin-top: 20px; }

.elenco-righe { list-style: none; margin: 0; padding: 0; }
.elenco-righe li + li { border-top: 1px solid var(--line); }
.elenco-righe a { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.elenco-righe a:hover .tit { color: var(--accent); }
.elenco-righe .tit { font-weight: 500; }
.elenco-righe .sub { color: var(--muted); font-size: 13px; }
.elenco-righe .fine { margin-left: auto; text-align: right; white-space: nowrap; }
.giorni { font-weight: 600; }
.giorni.in_scadenza { color: var(--warn); }
.giorni.scaduta { color: var(--bad); }

.stato { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; padding: 3px 9px 3px 8px; border-radius: 4px; white-space: nowrap; }
.stato::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stato.attiva { color: var(--ok); background: var(--ok-soft); }
.stato.in_scadenza { color: var(--warn); background: var(--warn-soft); }
.stato.scaduta { color: var(--bad); background: var(--bad-soft); }
.stato.disdetta, .stato.sostituita { color: var(--off); background: var(--off-soft); }
.ambito { font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 7px; white-space: nowrap; }

.filtri { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.filtri .select { width: auto; }
.filtri .cerca { flex: 1 1 260px; min-width: 200px; width: auto; }
.tabella { width: 100%; border-collapse: collapse; }
.tabella th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabella td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabella tbody tr:last-child td { border-bottom: 0; }
.tabella th:first-child, .tabella td:first-child { padding-left: 22px; }
.tabella th:last-child, .tabella td:last-child { padding-right: 22px; }
.tabella.cliccabile tbody tr { cursor: pointer; transition: background .1s; }
.tabella.cliccabile tbody tr:hover { background: var(--bg); }
.tabella .num { text-align: right; white-space: nowrap; }
.tabella .tit { font-weight: 500; }
.tabella .sub { color: var(--muted); font-size: 13px; }
.tabella tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
.vuoto { padding: 48px 22px; text-align: center; color: var(--muted); }
.vuoto h3 { color: var(--ink); margin-bottom: 6px; }
.vuoto .btn { margin-top: 16px; }

.sezione { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 24px 22px; }
.sezione + .sezione { border-top: 1px solid var(--line); }
.sezione-intro p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.campi { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px 18px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > label, .etichetta { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.campo .aiuto { font-size: 12.5px; color: var(--muted); }
.errore { font-size: 12.5px; color: var(--bad); }
.input, .select, .area {
    width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s);
    background-color: var(--surface); color: var(--ink); font: 400 14.5px "Instrument Sans", system-ui, sans-serif; font-feature-settings: "tnum" 1;
    transition: border-color .15s, box-shadow .15s;
}
.area { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%237a858c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:hover, .select:hover, .area:hover { border-color: var(--muted); }
.input:focus, .select:focus, .area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input.err, .select.err, .area.err { border-color: var(--bad); }
.prefisso { position: relative; }
.prefisso span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.prefisso .input { padding-left: 28px; }
.scelta { display: flex; border: 1px solid var(--line-2); border-radius: var(--radius-s); overflow: hidden; width: fit-content; }
.scelta label { position: relative; padding: 9px 16px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.scelta label + label { border-left: 1px solid var(--line-2); }
.scelta input { position: absolute; opacity: 0; pointer-events: none; }
.scelta label:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.scelta label:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--accent); }
.spunta { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14.5px; }
.spunta input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); }
.piede-modulo { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }

.zona-file { position: relative; display: block; border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; font-size: 14px; }
.zona-file:hover, .zona-file.sopra { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.zona-file strong { color: var(--ink); font-weight: 500; }
.zona-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-lista { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.file-lista li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); font-size: 14px; }
.file-lista li .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-lista li .peso { color: var(--muted); font-size: 13px; white-space: nowrap; }
.caricamento { font-size: 13px; color: var(--accent); margin-top: 8px; }

.scheda { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.scheda > div > .riquadro + .riquadro { margin-top: 20px; }
.periodo { padding: 22px; }
.periodo-date { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
.periodo-date b { display: block; color: var(--ink); font-size: 15px; font-weight: 600; }
.periodo-date .dx { text-align: right; }
.periodo-pista { position: relative; height: 8px; border-radius: 4px; background: var(--off-soft); }
.periodo-pieno { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); }
.periodo-pieno.in_scadenza { background: var(--warn); }
.periodo-pieno.scaduta { background: var(--bad); }
.periodo-disdetta { position: absolute; top: -5px; width: 2px; height: 18px; margin-left: -1px; background: var(--ink); }
.periodo-legenda { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 13.5px; color: var(--ink-2); flex-wrap: wrap; }
.dati { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 28px; margin: 0; }
.dati div { padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.dati dt { font-size: 13px; color: var(--muted); }
.dati dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.testo-lungo { white-space: pre-line; color: var(--ink-2); }
.testo-lungo + .etichetta { margin-top: 16px; display: block; }
.costo .tot { font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.costo .riga { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.costo .riga span:first-child { color: var(--muted); }
.allegato { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.allegato + .allegato { border-top: 1px solid var(--line); }
.allegato .ico { width: 34px; height: 40px; border: 1px solid var(--line-2); border-radius: 4px; display: grid; place-items: center; font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; flex: none; }
.allegato .info { flex: 1; min-width: 0; }
.allegato .nome { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.allegato a.nome:hover { color: var(--accent); }
.allegato .sub { color: var(--muted); font-size: 12.5px; }
.carica-riga { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.carica-riga .select { width: auto; flex: 1; }

.esito { display: flex; align-items: center; gap: 10px; background: var(--ok-soft); color: var(--ok); border-radius: var(--radius-s); padding: 11px 14px; margin-bottom: 20px; font-weight: 500; font-size: 14px; }

.velo { position: fixed; inset: 0; background: rgba(15, 22, 26, .38); display: grid; place-items: center; padding: 16px; z-index: 50; }
.finestra { background: var(--surface); border-radius: var(--radius); width: min(520px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .18); }
.finestra .riquadro-corpo { display: grid; gap: 16px; }

.accesso { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.accesso .riquadro { width: min(400px, 100%); }
.accesso .marchio { margin-bottom: 22px; font-size: 17px; }
.accesso form { display: grid; gap: 16px; }

@media (max-width: 960px) {
    .scheda, .griglia-2 { grid-template-columns: 1fr; }
    .sezione { grid-template-columns: 1fr; gap: 14px; }
    .cifre { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
    .barra-in { height: auto; padding: 12px 16px; flex-wrap: wrap; gap: 10px 16px; }
    .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .utente { margin-left: auto; }
    .pagina { padding: 22px 16px 60px; }
    h1 { font-size: 22px; }
    .campi { grid-template-columns: 1fr 1fr; }
    .c2, .c3, .c4, .c6 { grid-column: span 2; }
    .campi .meta { grid-column: span 1; }
    .dati { grid-template-columns: 1fr; }
    .tabella thead { display: none; }
    .tabella, .tabella tbody, .tabella tfoot, .tabella tr, .tabella td { display: block; width: 100%; }
    .tabella tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .tabella td { border: 0 !important; padding: 2px 0 !important; }
    .tabella td.num { text-align: left; }
    .tabella td[data-eti]::before { content: attr(data-eti) ": "; color: var(--muted); font-size: 13px; font-weight: 400; }
    .linea { overflow-x: auto; }
    .linea-pista { min-width: 640px; }
    .cifra { padding: 14px 16px; }
    .cifra .val { font-size: 21px; }
    .riquadro-testa { padding: 16px 16px 0; }
    .riquadro-corpo, .periodo { padding: 16px; }
    .filtri { padding: 14px 16px; }
    .sezione { padding: 20px 16px; }
    .piede-modulo { padding: 14px 16px; }
}

.lettura-ai { margin-bottom: 20px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.lettura-testa { display: flex; gap: 12px; align-items: flex-start; }
.lettura-testa svg { color: var(--accent); flex: none; margin-top: 1px; }
.lettura-testa .nota { margin-top: 3px; }
.lettura-azioni { display: flex; gap: 12px; align-items: stretch; margin-top: 16px; }
.lettura-azioni .zona-file { flex: 1; padding: 12px 16px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lettura-azioni .btn { height: auto; min-height: 46px; }
.esito-ai { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--ink); font-size: 14px; display: grid; gap: 6px; }
.esito-ai .avvertenze { color: var(--warn); }
.input.ai, .select.ai, .area.ai { background-color: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
@media (max-width: 720px) { .lettura-azioni { flex-direction: column; } }
.spunta.lettore { padding: 8px 0; }
.spunta.lettore + .spunta.lettore { border-top: 1px solid var(--line); }
.spunta.lettore .sub { display: block; color: var(--muted); font-size: 12.5px; }
.tabella td.intestatario { font-size: 14px; color: var(--ink-2); max-width: 200px; }
