@page { size: A4; }

:root {
    --rosso: #d8102a;
    --testo: #1c2024;
    --grigio: #5b636b;
    --linea: #d7dbdf;
    --sfondo-box: #f5f6f8;
}

* { box-sizing: border-box; }

body {
    font-family: "Segoe UI", "Liberation Sans", Arial, sans-serif;
    font-size: 10.5pt;
    line-height: 1.5;
    color: var(--testo);
    margin: 0;
}

/* ---------------------------------------------------------- copertina */
.copertina {
    height: 245mm;
    display: flex;
    flex-direction: column;
    justify-content: center;
    page-break-after: always;
    text-align: center;
}
.copertina .marchio {
    font-size: 34pt;
    font-weight: 800;
    color: var(--rosso);
    letter-spacing: -1px;
}
.copertina h1 {
    font-size: 26pt;
    margin: 6mm 0 2mm;
    border: 0;
    padding: 0;
    color: var(--testo);
    page-break-before: auto;
}
.copertina .sottotitolo { font-size: 13pt; color: var(--grigio); }
.copertina .meta {
    margin-top: 20mm;
    font-size: 9.5pt;
    color: var(--grigio);
}
.copertina hr {
    width: 40mm; border: 0; border-top: 3px solid var(--rosso); margin: 8mm auto;
}

/* ---------------------------------------------------------- struttura */
body { counter-reset: cap; }

h1 {
    font-size: 17pt;
    color: var(--rosso);
    border-bottom: 2px solid var(--rosso);
    padding-bottom: 2mm;
    margin: 0 0 5mm;
    page-break-before: always;
    page-break-after: avoid;
}
h1.numerato { counter-increment: cap; counter-reset: fig-nil; }
h1.numerato::before { content: counter(cap) ". "; }
h1.senza-salto { page-break-before: auto; }

h2 {
    font-size: 12.5pt;
    margin: 7mm 0 2mm;
    color: #22272b;
    page-break-after: avoid;
}
h3 {
    font-size: 10.8pt;
    margin: 5mm 0 1mm;
    color: #33383d;
    page-break-after: avoid;
}
p { margin: 0 0 3mm; text-align: justify; }
ul, ol { margin: 0 0 3mm; padding-left: 6mm; }
li { margin-bottom: 1.2mm; }

code, .campo {
    font-family: "Liberation Mono", Consolas, monospace;
    font-size: 9pt;
    background: var(--sfondo-box);
    padding: 0 1mm;
    border-radius: 2px;
}

/* ---------------------------------------------------------- indice */
.indice ol { list-style: none; padding-left: 0; counter-reset: idx; }
.indice > ol > li {
    counter-increment: idx;
    border-bottom: 1px dotted var(--linea);
    padding: 1.4mm 0;
    font-weight: 600;
}
.indice > ol > li::before { content: counter(idx) ". "; color: var(--rosso); }
.indice ol ol { padding-left: 7mm; margin-top: 1mm; }
.indice ol ol li {
    font-weight: 400; font-size: 9.5pt; color: var(--grigio);
    border: 0; padding: 0.4mm 0;
}

/* ---------------------------------------------------------- figure */
figure {
    counter-increment: fig;
    margin: 4mm 0 5mm;
    page-break-inside: avoid;
    text-align: center;
}
figure img {
    max-width: 100%;
    border: 1px solid var(--linea);
    border-radius: 3px;
}
figcaption {
    font-size: 8.5pt;
    color: var(--grigio);
    margin-top: 1.5mm;
    text-align: center;
}
figcaption::before { content: "Fig. " counter(fig) " — "; font-weight: 600; color: var(--testo); }
body { counter-reset: cap fig; }

/* ---------------------------------------------------------- tabelle */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
    margin: 3mm 0 5mm;
    page-break-inside: avoid;
}
thead th {
    background: var(--rosso);
    color: #fff;
    text-align: left;
    padding: 1.6mm 2mm;
    font-weight: 600;
}
td { padding: 1.4mm 2mm; border-bottom: 1px solid var(--linea); vertical-align: top; }
tbody tr:nth-child(even) td { background: #fafbfc; }
td.cod { font-family: "Liberation Mono", Consolas, monospace; white-space: nowrap; }

/* ---------------------------------------------------------- richiami */
.nota, .attenzione {
    border-left: 3px solid var(--rosso);
    background: var(--sfondo-box);
    padding: 2.5mm 3mm;
    margin: 3mm 0 4mm;
    font-size: 9.5pt;
    page-break-inside: avoid;
}
.nota { border-left-color: #2a72c9; }
.nota strong, .attenzione strong { display: block; margin-bottom: 1mm; }
.attenzione strong { color: var(--rosso); }

.passi { counter-reset: passo; list-style: none; padding-left: 0; }
.passi li {
    counter-increment: passo;
    position: relative;
    padding-left: 8mm;
    margin-bottom: 2mm;
}
.passi li::before {
    content: counter(passo);
    position: absolute; left: 0; top: 0.2mm;
    width: 5.2mm; height: 5.2mm; line-height: 5.2mm;
    background: var(--rosso); color: #fff;
    border-radius: 50%; text-align: center;
    font-size: 8pt; font-weight: 700;
}

.stato { font-family: "Liberation Mono", Consolas, monospace; font-weight: 700; }

svg { max-width: 100%; height: auto; }
.diagramma { page-break-inside: avoid; margin: 4mm 0 6mm; text-align: center; }
