/* Parcella · il documento: foglio A4 in registro istituzionale.
   Carta bianca, un serif con figure tabulari, filetti sottili, un solo colore d'accento per tema.
   Le unità sono in mm e pt perché il foglio è pensato per la stampa (A4, margini 16/18/14 mm). */

.sheet {
  --acc: #1f3a5f;
  --tintbox: rgba(31, 58, 95, .07);
  --ink: #1b1a18;
  --ink-2: #5f5c57;
  --ink-3: #8e8a83;
  --rule: #d6d2cb;
  --rule-soft: #ebe8e3;
  --ph: #b3aea6;

  position: relative;
  width: 210mm; min-height: 297mm; padding: 14mm 18mm 12mm;
  display: flex; flex-direction: column;
  background: #fff; color: var(--ink);
  font-family: var(--font-doc); font-size: 10pt; line-height: 1.42; letter-spacing: 0;
  font-variant-numeric: lining-nums; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  box-shadow: var(--paper-shadow);
  text-align: left; hyphens: manual;
}
.sheet.theme-bordeaux { --acc: #6b1f2a; --tintbox: rgba(107, 31, 42, .07); }
.sheet.theme-grafite { --acc: #2b2d31; --tintbox: rgba(43, 45, 49, .07); }

.sheet .num { font-variant-numeric: tabular-nums lining-nums; text-align: right; white-space: nowrap; }
.sheet .ph { color: var(--ph); font-style: italic; }
.sh-label { margin: 0; font-size: 7.25pt; line-height: 1.3; letter-spacing: .13em; text-transform: uppercase; font-weight: 600; color: var(--acc); }

/* intestazione */
.sh-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10mm; padding-bottom: 4mm; border-bottom: 1.5pt solid var(--acc); }
.sh-brand { min-width: 0; flex: 1; }
.sh-logo { display: block; max-height: 16mm; max-width: 70mm; width: auto; height: auto; object-fit: contain; object-position: left bottom; margin-bottom: 2.5mm; }
.sh-name { font-size: 19pt; font-weight: 500; letter-spacing: -0.012em; line-height: 1.1; color: var(--ink); text-wrap: balance; }
.sh-qual { margin-top: 2mm; font-size: 7.25pt; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-2); line-height: 1.4; text-wrap: balance; }
.sh-issuer { flex: none; text-align: right; font-size: 8pt; line-height: 1.5; color: var(--ink-2); max-width: 72mm; }
.sh-issuer b { color: var(--ink); font-weight: 500; }

/* titolo e dati del documento: una sola riga in serif, "Fattura n. 12/2026" */
.sh-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10mm; margin-top: 7mm; }
.sh-title h1 { margin: 0; font-size: 22pt; font-weight: 400; line-height: 1.1; letter-spacing: -0.012em; color: var(--ink); font-variant-numeric: tabular-nums lining-nums; text-wrap: balance; }
.sh-meta { display: grid; grid-template-columns: auto auto; gap: 1mm 6mm; margin: 0; font-size: 9pt; line-height: 1.35; }
.sh-meta dt { color: var(--ink-3); }
.sh-meta dd { margin: 0; text-align: right; color: var(--ink); white-space: nowrap; }

/* soggetti */
.sh-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin-top: 6mm; padding-top: 4mm; border-top: .5pt solid var(--rule); }
.sh-party { min-width: 0; }
.sh-party h3 { margin: 0 0 2.2mm; }
.sh-party p { margin: 0; font-size: 10pt; line-height: 1.45; overflow-wrap: anywhere; }
.sh-party .sh-party-name { font-size: 12pt; font-weight: 500; line-height: 1.25; margin-bottom: 1mm; }
.sh-party .sh-ids { margin-top: 2mm; font-size: 8.5pt; line-height: 1.5; color: var(--ink-2); }
.sh-party .sh-rif { margin-top: 1.5mm; font-size: 8.5pt; color: var(--ink-2); }

/* tabella prestazioni */
.sh-table { width: 100%; border-collapse: collapse; margin-top: 7mm; font-size: 9.5pt; }
.sh-table th { padding: 0 0 2mm; text-align: left; font-size: 7.25pt; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--ink-3); border-bottom: .75pt solid var(--ink); vertical-align: bottom; }
.sh-table th.num { text-align: right; }
.sh-table td { padding: 2.6mm 0; vertical-align: top; border-bottom: .5pt solid var(--rule-soft); line-height: 1.4; }
.sh-table td.desc { padding-right: 6mm; overflow-wrap: anywhere; }
.sh-table td .unit { color: var(--ink-3); font-size: 8pt; margin-left: .3em; }
.sh-table tbody tr:last-child td { border-bottom: .75pt solid var(--ink); }
.sh-table .c-qty { width: 18mm; }
.sh-table .c-price { width: 28mm; }
.sh-table .c-amt { width: 30mm; }

/* pagamento e totali */
.sh-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 78mm; gap: 12mm; margin-top: 5mm; align-items: start; }
.sh-pay h3 { margin: 0 0 2.2mm; }
.sh-pay p { margin: 0; font-size: 9pt; line-height: 1.55; color: var(--ink-2); overflow-wrap: anywhere; }
.sh-pay .iban { font-variant-numeric: tabular-nums; letter-spacing: .03em; color: var(--ink); font-weight: 500; }
.sh-pay .paid { color: var(--ink); font-weight: 500; }
.sh-sums { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.6mm 6mm; font-size: 9.5pt; line-height: 1.35; align-items: baseline; }
.sh-sums dt { color: var(--ink-2); }
.sh-sums dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.sh-sums .tot { padding-top: 2mm; border-top: .5pt solid var(--rule); color: var(--ink); font-weight: 500; }
.sh-sums .minus { color: var(--ink-2); }
.sh-netto { grid-column: 1 / -1; margin-top: 2.5mm; display: flex; justify-content: space-between; align-items: baseline; gap: 6mm; padding: 3mm 4mm; background: var(--tintbox); }
.sh-netto dt { font-size: 7.5pt; letter-spacing: .13em; text-transform: uppercase; font-weight: 600; color: var(--acc); }
.sh-netto dd { margin: 0; font-size: 15pt; font-weight: 500; letter-spacing: -0.012em; color: var(--ink); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }

/* calce */
.sh-foot { margin-top: auto; padding-top: 6mm; }
.sh-legal { margin: 0; padding: 0 0 0 4mm; font-size: 7.25pt; line-height: 1.4; color: var(--ink-2); columns: 2; column-gap: 8mm; }
.sh-legal li { margin-bottom: 1mm; padding-left: 1mm; break-inside: avoid; }
.sh-usernotes { margin: 2.5mm 0 0; font-size: 8.5pt; line-height: 1.5; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
/* le citazioni di legge sono collegamenti ai testi ufficiali: invisibili sulla carta, attivi nel PDF */
.sheet a { color: inherit; text-decoration: none; }
.sheet a:hover { text-decoration: underline; text-decoration-color: var(--acc); text-underline-offset: 2pt; }
.sh-fonti { margin: 2.5mm 0 0; font-size: 7pt; line-height: 1.45; color: var(--ink-3); }
.sh-colophon { margin-top: 4mm; padding-top: 2.5mm; border-top: .5pt solid var(--rule); font-size: 7pt; line-height: 1.45; letter-spacing: .01em; color: var(--ink-3); display: flex; justify-content: space-between; gap: 8mm; }
.sh-colophon span { flex: 1 1 0; min-width: 0; }
.sh-colophon .right { text-align: right; }

/* un valore appena cambiato si "assesta" con una velatura nel colore d'accento del tema */
@keyframes sh-flash { from { background-color: color-mix(in srgb, var(--acc) 22%, transparent); } to { background-color: transparent; } }
.sheet .changed { animation: sh-flash 900ms var(--ease-out) both; border-radius: 1px; }
@media (prefers-reduced-motion: reduce) { .sheet .changed { animation: none; } }

/* ---------- stampa ---------- */
@media print {
  @page { size: A4; margin: 14mm 0 12mm; }
  html, body { background: #fff !important; margin: 0 !important; min-height: 0 !important; }
  .wash, .topbar, .tabbar, .toast, .menu, .preview-tools, .theme-pill, .zoom-pill, dialog, .pane-editor { display: none !important; }
  .main { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .pane-preview { display: block !important; position: static !important; height: auto !important; overflow: visible !important; padding: 0 !important; }
  .sheet-wrap { zoom: 1 !important; margin: 0 !important; }
  /* 297 - 14 - 12 = 271mm disponibili: 3mm di margine evitano che un arrotondamento spinga la calce in seconda pagina */
  .sheet { box-shadow: none !important; width: 210mm; min-height: 268mm; padding: 0 18mm; margin: 0; }
  .sheet .changed { animation: none !important; background: transparent !important; }
  .sh-table tr, .sh-netto, .sh-pay, .sh-sums, .sh-parties, .sh-head, .sh-title { break-inside: avoid; }
  .sh-foot { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
