/* Report per lo sponsor A4mobility: anteprima a schermo e PDF (Stampa → Salva come PDF).
   Documento A4 verticale su carta intestata A4mobility / Phoenix, grigio grafite e arancio A4mobility.
   Pagina 1: numeri, attività per perimetro (torta), prossime scadenze (linea del tempo).
   Pagine successive: per ogni perimetro le attività svolte nel periodo e i prossimi passi. */

#report-root {
  --r-text: #2F3940;
  --r-graphite: #5B6670;
  --r-graphite-dark: #3E4851;
  --r-muted: #78828A;
  --r-line: #D5DADE;
  --r-grid: #E6E9EC;
  --r-orange: #E37B3D;
  --r-font: Calibri, Carlito, 'Instrument Sans', 'Segoe UI', sans-serif;
}

body.is-report { overflow: hidden; }
#report-root:empty { display: none; }

.r-overlay { position: fixed; inset: 0; z-index: 50; overflow: auto; background: #D9DCE0; }

/* ---------- barra dell'anteprima (non si stampa) ---------- */

.r-toolbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--char, #59595B); color: #fff;
}
.r-toolbar .r-tb-title { font-weight: 650; font-size: 15px; margin-right: 8px; }
.r-toolbar .r-tb-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255, 255, 255, .85); }
.r-toolbar .r-tb-field input {
  height: 30px; padding: 0 8px; border: 0; border-radius: var(--radius, 4px);
  background: #fff; color: #2B2B2D; font-variant-numeric: tabular-nums;
}
.r-toolbar .r-tb-hint { color: rgba(255, 255, 255, .72); font-size: 13px; }
.r-toolbar .spacer { flex: 1; }
.r-toolbar .btn { height: 32px; }
.r-toolbar .btn-quiet { color: #fff; }
.r-toolbar .btn-quiet:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.r-toolbar .btn-gold { background: var(--gold, #E3BC2F); border-color: var(--gold, #E3BC2F); color: #2B2B2D; }
.r-toolbar .btn-gold:hover { background: #D6AE22; border-color: #D6AE22; }

/* ---------- il foglio ---------- */

.r-paper {
  page: report;
  width: 210mm; min-height: 297mm; margin: 24px auto 48px; padding: 16mm 18mm 18mm;
  background: #fff; color: var(--r-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 8px 24px rgba(0, 0, 0, .08);
  font-family: var(--r-font); font-size: 10pt; line-height: 1.35;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.r-paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.r-paper p { margin: 0; }
.r-paper strong { font-weight: 700; color: var(--r-text); }
.r-muted, .r-none { color: var(--r-muted); }

/* carta intestata */
.r-letterhead {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 3.5mm; margin-bottom: 9mm;
  border-bottom: 1.25pt solid var(--r-orange);
}
.r-logo-a4m { height: 10mm; width: auto; }
.r-logo-phx { height: 15mm; width: auto; }

.r-title { margin: 0 0 1.5mm; font-size: 20pt; font-weight: 700; line-height: 1.15; color: var(--r-graphite-dark); }
.r-meta { font-size: 10.5pt; color: var(--r-graphite); }

/* tre numeri, senza riquadri */
.r-figures { display: grid; grid-template-columns: repeat(3, 1fr); margin: 8mm 0 2mm; }
.r-figures > div { padding: 0 5mm; border-left: 0.5pt solid var(--r-line); }
.r-figures > div:first-child { padding-left: 0; border-left: 0; }
.r-fig { display: block; font-size: 22pt; font-weight: 700; line-height: 1.1; color: var(--r-graphite-dark); font-variant-numeric: tabular-nums; }
.r-fig-lbl { display: block; margin-top: 0.8mm; font-size: 9.5pt; color: var(--r-graphite); }

/* titoli di sezione */
.r-paper h2 {
  margin: 0; padding-bottom: 1.2mm;
  font-size: 12.5pt; font-weight: 700; color: var(--r-graphite-dark);
  border-bottom: 0.5pt solid var(--r-graphite);
  break-after: avoid;
}
.r-chart { margin-top: 8mm; break-inside: avoid; }
.r-chart-sub { margin: 1.5mm 0 4mm; font-size: 9pt; color: var(--r-muted); }

/* torta */
.r-pie { display: grid; grid-template-columns: 58mm minmax(0, 1fr); align-items: center; column-gap: 12mm; }
.r-pie svg { width: 58mm; height: 58mm; display: block; }
.r-legend { list-style: none; margin: 0; padding: 0; }
.r-legend li {
  display: grid; grid-template-columns: 4mm minmax(0, 1fr) 10mm 12mm; column-gap: 2.5mm; align-items: center;
  padding: 1.6mm 0; border-bottom: 0.5pt solid var(--r-grid);
}
.r-sw { width: 3.2mm; height: 3.2mm; border-radius: 0.6mm; }
.r-lg-name { color: var(--r-text); }
.r-lg-n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.r-lg-pct { text-align: right; color: var(--r-muted); font-variant-numeric: tabular-nums; }
.r-legend-tot { margin-top: 2mm !important; font-size: 9pt; color: var(--r-muted); }

/* prossime scadenze: un rombo sulla data, colore del perimetro, righe raggruppate per perimetro */
.r-sc { font-size: 9pt; }
.r-sc-row { display: grid; grid-template-columns: 62mm minmax(0, 1fr); column-gap: 4mm; align-items: center; min-height: 6mm; break-inside: avoid; }
.r-sc-axis { min-height: 5.5mm; align-items: end; }
.r-sc-group { min-height: 6.5mm; }
.r-sc-group .r-sc-name { display: flex; align-items: center; gap: 2mm; padding-top: 1.6mm; font-weight: 700; color: var(--r-graphite-dark); }
.r-sc-group .r-sw { width: 2.6mm; height: 2.6mm; }
.r-sc-name { min-width: 0; }
.r-sc-row:not(.r-sc-group) .r-sc-name { padding-left: 3mm; }
.r-sc-title { display: block; color: var(--r-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sc-plot { position: relative; align-self: stretch; margin-right: 12mm; border-left: 0.75pt solid var(--r-graphite); }
.r-sc-axis .r-sc-plot { border-left: 0; }
.r-sc-band { position: absolute; top: 0; bottom: 0; }
.r-sc-band.is-alt { background: #F2F4F5; }
.r-sc-tick { position: absolute; bottom: 1mm; padding-left: 1mm; font-size: 7.5pt; color: var(--r-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-sc-mark {
  position: absolute; top: 50%; width: 2.6mm; height: 2.6mm; margin: -1.3mm 0 0 -1.3mm;
  transform: rotate(45deg); box-shadow: 0 0 0 0.5mm #fff;
}
.r-sc-date { position: absolute; top: 50%; transform: translate(2.6mm, -50%); font-size: 8pt; color: var(--r-text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-sc-ric { color: var(--r-muted); }

/* dettaglio per perimetro: inizia su una pagina nuova */
.r-details { break-before: page; }
.r-perim { margin-bottom: 8mm; }
.r-perim h2 { display: flex; align-items: center; gap: 2.5mm; }
.r-perim h2 .r-sw { width: 3mm; height: 3mm; }
.r-perim-sum { margin: 1.5mm 0 3mm; font-size: 9.5pt; color: var(--r-muted); break-after: avoid; }
.r-perim-head { break-inside: avoid; break-after: avoid; }
.r-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9.5pt; }
.r-table col.c-titolo { width: 29%; }
.r-table col.c-adv { width: 31%; }
.r-table col.c-next { width: auto; }
.r-table col.c-due { width: 13%; }
.r-table thead { display: table-header-group; }
.r-table .r-cols th {
  padding: 1.5mm 2mm; text-align: left; font-size: 9pt; font-weight: 700;
  color: #fff; background: var(--r-graphite);
}
.r-table .r-gh th { padding: 0 0 2.5mm; text-align: left; font-weight: 400; }
.r-table .r-gh .r-perim-sum { margin-bottom: 0; }
.r-table td { padding: 1.8mm 2mm; vertical-align: top; border-bottom: 0.5pt solid var(--r-line); }
.r-table tr { break-inside: avoid; }
.r-sub { display: block; margin-top: 0.4mm; color: var(--r-muted); font-size: 8.5pt; }
/* testi lunghi tagliati a due righe: il report resta sintetico */
.r-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.r-adv-date { color: var(--r-muted); font-variant-numeric: tabular-nums; margin-right: 1mm; }
.r-next .ln { display: block; }
.r-next .ln.is-item { padding-left: 3mm; text-indent: -3mm; }
.r-next .ln.is-item::before { content: "–"; display: inline-block; width: 3mm; text-indent: 0; color: var(--r-muted); }
.r-due { white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-ric { display: block; color: var(--r-muted); font-size: 8.5pt; }

/* ---------- stampa ---------- */

@media print {
  body.is-report { overflow: visible; background: #fff; }
  body.is-report #app, body.is-report #drawer-root, body.is-report #modal-root, body.is-report #toast { display: none !important; }
  body.is-report .r-overlay { position: static; overflow: visible; background: #fff; }
  body.is-report .r-toolbar { display: none; }
  body.is-report .r-paper { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
}

@page report {
  size: A4 portrait;
  margin: 16mm 18mm 18mm;
}
