/* ==========================================================================
   Sezione Report — stili di pagina e foglio di stampa
   Riferimento: docs/report/Spec_Sezione_Report_2026-10-15.md (par. 2.2, 7.1, 7.2, 8)

   Tutto sta sotto .report-page: nessuna regola esce dalla sezione e nessuna
   classe del tema viene ridefinita.

   COLORI — la specifica grafica elencava colori scritti a mano (#5153C7...) e
   una seconda colonna di token per il tema scuro. Qui il tema scuro non esiste
   (par. 2.2) e non si introduce una palette parallela: i due soli colori sono
   quelli del tema, letti dai token di wwwroot/assets/css/style.css, che sono
   terne RGB e si consumano come rgb(var(--token)).

     nome nella specifica    qui                      sorgente
     --act (crescita)        --rp-accent  (+ -ink)    --primary / --primary-dark
     --at / --ats (calo,     --rp-attention (+ -ink)  --danger / --danger-dark
       attenzione)
     --mu / --fa             --rp-muted / --rp-faded  grigi neutri
     --sf2                   --rp-surface-2           --light-gray del tema

   Le varianti "-ink" servono per il testo: rgb(var(--primary)) e
   rgb(var(--danger)) su fondo bianco stanno sotto 4,5:1 e non sono leggibili
   a 13 px, mentre --primary-dark e --danger-dark superano 11:1. Fondi e bordi
   usano invece il token pieno con alfa.
   ========================================================================== */

.report-page {
    --rp-accent: var(--primary);
    --rp-accent-ink: var(--primary-dark);
    --rp-attention: var(--danger);
    --rp-attention-ink: var(--danger-dark);

    --rp-ink: var(--font-color);
    --rp-ink-soft: var(--font-secondary-color);
    --rp-muted: #6b7384;
    --rp-faded: var(--font-light-color);

    --rp-surface: #ffffff;
    --rp-surface-2: var(--light-gray);
    --rp-line: #e5e8ef;
    --rp-line-strong: #d4d9e4;

    --rp-radius: 12px;
    --rp-radius-sm: 9px;

    color: var(--rp-ink);
}

/* L'attributo hidden deve vincere sui display dichiarati qui: la regola del
   browser ([hidden] { display: none }) arriva dal foglio dell'agente utente e
   qualunque display di una classe la supera, quindi i pannelli dei filtri e le
   righe figlie resterebbero visibili. */
.report-page [hidden] {
    display: none !important;
}

/* I numeri non devono ballare fra una riga e l'altra: cifre a larghezza fissa
   su riquadri e tabella, come chiede la specifica. */
.report-page .rp-num,
.report-page .rp-card-value,
.report-page .rp-table td,
.report-page .rp-table th {
    font-variant-numeric: tabular-nums;
}

/* Focus da tastiera sempre visibile, anello 3 px. */
.report-page a:focus-visible,
.report-page button:focus-visible,
.report-page select:focus-visible,
.report-page input:focus-visible,
.report-page [tabindex]:focus-visible,
.report-page .rp-seg-input:focus-visible + .rp-seg {
    outline: 3px solid rgba(var(--rp-accent), 0.55);
    outline-offset: 2px;
    border-radius: var(--rp-radius-sm);
}

/* ==========================================================================
   Barra delle tab della sezione
   ========================================================================== */

.report-page .rp-tabnav {
    border-bottom: 1px solid var(--rp-line);
}

/* ==========================================================================
   Intestazione (par. 7.2): icona in quadrato 44 px, titolo 22/700,
   una riga di spiegazione, pulsanti di export a destra.
   ========================================================================== */

.report-page .rp-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.report-page .rp-head-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: var(--rp-radius);
    background: rgba(var(--rp-accent), 0.12);
    color: rgb(var(--rp-accent-ink));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.report-page .rp-head-text {
    flex: 1 1 320px;
    min-width: 0;
}

.report-page .rp-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--rp-ink);
}

.report-page .rp-lede {
    margin: 4px 0 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--rp-muted);
    max-width: 78ch;
}

.report-page .rp-head-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Pulsanti della sezione: forma propria, colori del tema. */
.report-page .rp-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--rp-line-strong);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-surface);
    color: var(--rp-ink-soft);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.report-page .rp-btn:hover {
    background: var(--rp-surface-2);
    color: var(--rp-ink);
    text-decoration: none;
}

.report-page .rp-btn i {
    font-size: 17px;
}

.report-page .rp-btn-primary {
    border-color: rgb(var(--rp-accent-ink));
    background: rgb(var(--rp-accent-ink));
    color: #ffffff;
    font-weight: 600;
}

.report-page .rp-btn-primary:hover {
    background: rgba(var(--rp-accent-ink), 0.88);
    border-color: rgba(var(--rp-accent-ink), 0.88);
    color: #ffffff;
}

.report-page .rp-btn-sm {
    height: 32px;
    padding: 0 11px;
    font-size: 13px;
}

/* ==========================================================================
   Barra filtri (par. 5)
   ========================================================================== */

.report-page .rp-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 20px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: var(--rp-surface);
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius);
}

.report-page .rp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* Campo della tendina multipla (Partials/_FiltroMultiplo). Si chiamava
   rp-field-collab quando ogni report scriveva il suo; il nome nuovo vale
   anche per le compagnie. */
.report-page .rp-field-multiplo {
    flex: 1 1 280px;
    max-width: 460px;
}

.report-page .rp-field-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--rp-muted);
}

/* Gruppo di pulsanti del periodo: radio veri, etichette come pulsanti.
   Senza JavaScript il form resta usabile grazie al pulsante Applica. */
.report-page .rp-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.report-page .rp-seg-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.report-page .rp-seg {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 13px;
    border: 1px solid var(--rp-line-strong);
    border-radius: 20px;
    background: var(--rp-surface);
    color: var(--rp-ink-soft);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    white-space: nowrap;
}

.report-page .rp-seg:hover {
    background: var(--rp-surface-2);
}

.report-page .rp-seg-input:checked + .rp-seg {
    border-color: rgb(var(--rp-accent-ink));
    background: rgba(var(--rp-accent), 0.14);
    color: rgb(var(--rp-accent-ink));
    font-weight: 600;
}

/* Pannelli che si aprono sotto il gruppo periodo (Mese, Date personalizzate) */
.report-page .rp-subfilter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: var(--rp-surface-2);
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius-sm);
}

.report-page .rp-input,
.report-page .rp-select {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--rp-line-strong);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-surface);
    color: var(--rp-ink);
    font: inherit;
    font-size: 13.5px;
    max-width: 100%;
}

.report-page .rp-select-multi {
    min-height: 38px;
    height: auto;
}

.report-page .rp-hint {
    font-size: 12.5px;
    color: var(--rp-muted);
}

/* ==========================================================================
   Tendina a scelta multipla (Partials/_FiltroMultiplo + report-filtri.js)

   TomSelect copia sul suo contenitore le classi del select originale, quindi
   il contenitore e' anche .rp-select: qui gli si tolgono bordo e fondo, che
   porta il controllo interno.

   Il campo resta su una riga, alto come gli altri della barra: le etichette
   si restringono coi puntini, e oltre due voci scelte report-filtri.js mette
   un riepilogo ("3 collaboratori", attributo data-riepilogo letto da ::before)
   al posto delle etichette. A destra: svuota (solo con voci scelte) e freccia.
   ========================================================================== */

.report-page .ts-wrapper.rp-select-multi {
    padding: 0;
    border: none;
    background: none;
}

.report-page .ts-wrapper.rp-filtro-multiplo {
    min-height: 38px;
    /* Spazio a destra per svuota + freccia, letto dal padding-right del tema TomSelect. */
    --ts-pr-caret: 30px;
    --ts-pr-clear-button: 26px;
}

.report-page .ts-wrapper.rp-filtro-multiplo:not(.has-items) {
    --ts-pr-clear-button: 0px;
}

/* .multi in piu' nel selettore: il tema TomSelect da' il suo padding con
   .ts-wrapper.multi.has-items .ts-control, che altrimenti pareggerebbe. */
.report-page .ts-wrapper.rp-filtro-multiplo.multi .ts-control {
    flex-wrap: nowrap;
    gap: 4px;
    min-height: 38px;
    padding: 4px 10px;
    border: 1px solid var(--rp-line-strong);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-surface);
    color: var(--rp-ink);
    font-size: 13.5px;
    line-height: 1.4;
    cursor: pointer;
    box-shadow: none;
    transition: border-color .15s ease-in-out;
}

.report-page .ts-wrapper.rp-filtro-multiplo:not(.focus):hover .ts-control {
    border-color: rgba(var(--rp-accent-ink), 0.40);
}

/* Fuoco: lo stesso anello di 3 px degli altri campi della sezione. */
.report-page .ts-wrapper.rp-filtro-multiplo.focus .ts-control {
    border-color: rgb(var(--rp-accent-ink));
    outline: 3px solid rgba(var(--rp-accent), 0.55);
    outline-offset: 2px;
    box-shadow: none;
}

/* Casella di ricerca e segnaposto ("Tutti i collaboratori"): il segnaposto e'
   uno stato vero (nessun filtro = tutti), quindi non sbiadito come un suggerimento. */
.report-page .ts-wrapper.rp-filtro-multiplo .ts-control > input {
    min-width: 4rem;
    color: var(--rp-ink);
    font-size: 13.5px;
    cursor: text;
}

/* Con etichette presenti la ricerca si accontenta di meno spazio: quanto basta
   per vedere cosa si scrive, senza schiacciare i nomi accanto. */
.report-page .ts-wrapper.rp-filtro-multiplo.has-items .ts-control > input {
    min-width: 3rem;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-control > input::placeholder {
    color: var(--rp-ink-soft);
    opacity: 1;
}

/* Freccia: dice che e' una tendina e non una casella di testo. */
.report-page .ts-wrapper.rp-filtro-multiplo::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    z-index: 2;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--rp-muted);
    border-bottom: 1.5px solid var(--rp-muted);
    transform: translateY(-70%) rotate(45deg);
    transition: transform .15s ease-in-out;
    pointer-events: none;
}

.report-page .ts-wrapper.rp-filtro-multiplo.dropdown-active::after {
    transform: translateY(-25%) rotate(-135deg);
}

/* Etichette delle voci scelte, con la x. */
.report-page .ts-wrapper.rp-filtro-multiplo .ts-control > .item {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 4.5em;
    max-width: 100%;
    height: 26px;
    margin: 0;
    padding: 0 2px 0 9px;
    border: 1px solid rgba(var(--rp-accent-ink), 0.22);
    border-radius: 6px;
    background: rgba(var(--rp-accent), 0.10);
    color: rgb(var(--rp-accent-ink));
    font-size: 12.5px;
    font-weight: 600;
    cursor: default;
}

/* Con due etichette nessuna prende piu' di meta' campo: altrimenti una
   ragione sociale lunga si mangia lo spazio e il nome corto accanto resta
   "M...". Un'etichetta sola usa tutta la larghezza. Le voci scelte sono gli
   unici <div> del controllo (la ricerca e' un <input>, svuota un <button>). */
.report-page .ts-wrapper.rp-filtro-multiplo .ts-control > .item:not(:only-of-type) {
    max-width: 50%;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-control > .item.active {
    border-color: rgb(var(--rp-accent-ink));
    background: rgb(var(--rp-accent-ink));
    color: #ffffff;
}

.report-page .ts-wrapper.rp-filtro-multiplo .rp-fm-etichetta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-control .item .remove {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    /* Il tema azzera il padding destro dell'etichetta con !important: lo spazio
       dal bordo lo da' il margine della x. */
    margin: 0 2px 0 3px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    color: inherit;
    font-size: 13px;
    opacity: 0.75;
    text-decoration: none;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-control .item .remove:hover {
    background: rgba(var(--rp-accent-ink), 0.12);
    opacity: 1;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-control .item.active .remove:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Riepilogo oltre la soglia: le etichette si nascondono, resta un'etichetta sola.
   La classe rp-fm-riassunto la mette report-filtri.js oltre due voci; sul
   telefono basta rp-fm-piu-voci (due voci), vedi la regola sotto i 576 px. */
.report-page .ts-wrapper.rp-filtro-multiplo.rp-fm-riassunto .ts-control > .item {
    display: none !important;
}

.report-page .ts-wrapper.rp-filtro-multiplo.rp-fm-riassunto .ts-control::before {
    content: attr(data-riepilogo);
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border: 1px solid rgba(var(--rp-accent-ink), 0.22);
    border-radius: 6px;
    background: rgba(var(--rp-accent), 0.10);
    color: rgb(var(--rp-accent-ink));
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

/* Svuota: c'e' solo quando qualcosa e' scelto. Il tema lo mostrava solo al
   passaggio del mouse; qui resta visibile, perche' e' l'unico modo rapido per
   tornare a "tutti" quando il campo mostra il riepilogo. */
.report-page .ts-wrapper.rp-filtro-multiplo .clear-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    right: 30px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--rp-muted);
    font-size: 14px;
    line-height: 1;
    opacity: 1;
    transition: none;
}

.report-page .ts-wrapper.rp-filtro-multiplo .clear-button:hover {
    background: var(--rp-surface-2) !important;
    color: var(--rp-ink);
}

.report-page .ts-wrapper.rp-filtro-multiplo:not(.has-items) .clear-button {
    visibility: hidden;
}

/* Menu a tendina */
.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown {
    margin-top: 4px;
    border: 1px solid var(--rp-line-strong);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-surface);
    color: var(--rp-ink);
    box-shadow: 0 10px 24px rgba(21, 38, 75, 0.10), 0 2px 6px rgba(21, 38, 75, 0.06);
    font-size: 13.5px;
    overflow: hidden;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .ts-dropdown-content {
    max-height: 296px;
    padding: 4px;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .option {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--rp-ink);
    white-space: nowrap;
    cursor: pointer;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .option.active {
    background: var(--rp-surface-2);
    color: var(--rp-ink);
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .option.selected .rp-fm-nome {
    font-weight: 600;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .tomselect-checkbox {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: rgb(var(--rp-accent-ink));
    cursor: pointer;
}

.report-page .ts-wrapper.rp-filtro-multiplo .rp-fm-nome {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-page .ts-wrapper.rp-filtro-multiplo .rp-fm-nota {
    flex: 0 0 auto;
    padding: 0 6px;
    border: 1px solid var(--rp-line-strong);
    border-radius: 10px;
    color: var(--rp-muted);
    font-size: 11px;
    line-height: 16px;
}

/* Conteggio: badge piccolo a destra, cifre a larghezza fissa. */
.report-page .ts-wrapper.rp-filtro-multiplo .rp-fm-conteggio {
    flex: 0 0 auto;
    margin-left: auto;
    min-width: 26px;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--rp-surface-2);
    color: var(--rp-muted);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.report-page .ts-wrapper.rp-filtro-multiplo .option.active .rp-fm-conteggio {
    background: var(--rp-surface);
}

.report-page .ts-wrapper.rp-filtro-multiplo .option.selected .rp-fm-conteggio {
    background: rgba(var(--rp-accent), 0.12);
    color: rgb(var(--rp-accent-ink));
}

/* Testo per i soli lettori di schermo (l'unita' del conteggio). */
.report-page .rp-fm-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .highlight {
    border-radius: 2px;
    background: rgba(var(--rp-accent), 0.22);
    color: inherit;
}

.report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .no-results {
    padding: 8px 10px;
    color: var(--rp-muted);
    font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
    .report-page .ts-wrapper.rp-filtro-multiplo .ts-control,
    .report-page .ts-wrapper.rp-filtro-multiplo::after {
        transition: none;
    }
}

/* ==========================================================================
   Etichette dei filtri applicati (par. 5)
   La prima, il periodo, non si rimuove; una per collaboratore, con la x.
   ========================================================================== */

.report-page .rp-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.report-page .rp-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--rp-line-strong);
    border-radius: 20px;
    background: var(--rp-surface);
    font-size: 12.5px;
    color: var(--rp-ink-soft);
    white-space: nowrap;
}

.report-page .rp-tag i {
    font-size: 15px;
    color: var(--rp-muted);
}

.report-page .rp-tag-fixed {
    border-color: rgba(var(--rp-accent-ink), 0.35);
    background: rgba(var(--rp-accent), 0.10);
    color: rgb(var(--rp-accent-ink));
    font-weight: 600;
}

.report-page .rp-tag-fixed i {
    color: rgb(var(--rp-accent-ink));
}

.report-page .rp-tag-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0 -4px 0 1px;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--rp-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
}

.report-page .rp-tag-x:hover {
    background: var(--rp-surface-2);
    color: var(--rp-ink);
}

.report-page .rp-tags-clear {
    font-size: 12.5px;
    font-weight: 600;
    color: rgb(var(--rp-accent-ink));
    text-decoration: none;
    padding: 4px 6px;
    border-radius: var(--rp-radius-sm);
}

.report-page .rp-tags-clear:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Avvisi del report (AvvisoReport)
   ========================================================================== */

.report-page .rp-notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 13px;
    margin-bottom: 10px;
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-surface-2);
    font-size: 13px;
    color: var(--rp-ink-soft);
}

.report-page .rp-notice i {
    flex: 0 0 auto;
    font-size: 17px;
    color: var(--rp-muted);
    margin-top: 1px;
}

.report-page .rp-notice-warn {
    border-color: rgba(var(--rp-attention-ink), 0.30);
    background: rgba(var(--rp-attention), 0.08);
    color: rgb(var(--rp-attention-ink));
}

.report-page .rp-notice-warn i {
    color: rgb(var(--rp-attention-ink));
}

/* ==========================================================================
   Riquadri sintetici (par. 7.2): il numero importante prima del dettaglio.
   ========================================================================== */

.report-page .rp-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.report-page .rp-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 14px 16px;
    background: var(--rp-surface);
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius);
    min-width: 0;
}

.report-page .rp-card-strong {
    border-color: rgba(var(--rp-accent-ink), 0.28);
}

.report-page .rp-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--rp-muted);
}

.report-page .rp-card-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--rp-ink);
    overflow-wrap: anywhere;
}

.report-page .rp-card-var {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--rp-muted);
    margin-top: 2px;
}

.report-page .rp-card-var i {
    font-size: 15px;
}

.report-page .rp-var-up {
    color: rgb(var(--rp-accent-ink));
}

.report-page .rp-var-down {
    color: rgb(var(--rp-attention-ink));
}

.report-page .rp-var-flat,
.report-page .rp-var-none {
    color: var(--rp-muted);
}

.report-page .rp-card-var-ref,
.report-page .rp-card-note {
    font-size: 12px;
    font-weight: 400;
    color: var(--rp-faded);
}

/* ==========================================================================
   Tabella (par. 7.2)
   Intestazione fissa e prima colonna ferma: il contenitore fa da scrollport
   su entrambi gli assi, altrimenti position: sticky non ha riferimento.
   MAI righe trasformate in schede su schermo stretto: si scorre.
   ========================================================================== */

.report-page .rp-table-wrap {
    position: relative;
    max-height: min(72vh, 900px);
    overflow: auto;
    background: var(--rp-surface);
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius);
}

.report-page .rp-table {
    width: 100%;
    min-width: 780px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
    margin: 0;
}

.report-page .rp-table th,
.report-page .rp-table td {
    padding: 9px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--rp-line);
    background: var(--rp-surface);
}

.report-page .rp-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 0;
    background: var(--rp-surface-2);
    border-bottom: 1px solid var(--rp-line-strong);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--rp-muted);
    white-space: nowrap;
}

/* L'angolo in alto a sinistra incrocia le due direzioni di sticky. */
.report-page .rp-table thead th:first-child {
    z-index: 5;
}

.report-page .rp-table th:first-child,
.report-page .rp-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 1px 0 0 var(--rp-line);
}

/* La riga di intestazione del gruppo e la riga figlia dei livelli occupano
   tutta la larghezza: se restassero ferme a sinistra scorrerebbero sopra le
   altre celle. */
.report-page .rp-table .rp-group-head td,
.report-page .rp-table .rp-detail td {
    position: static;
    box-shadow: none;
}

/* ---- intestazioni ordinabili ---- */
.report-page .rp-sort {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.report-page .rp-sort:hover {
    color: var(--rp-ink);
}

.report-page .rp-table th.rp-col-num .rp-sort {
    justify-content: flex-end;
}

.report-page .rp-sort i {
    font-size: 14px;
    opacity: 0.45;
}

.report-page .rp-table th[aria-sort="ascending"],
.report-page .rp-table th[aria-sort="descending"] {
    color: rgb(var(--rp-accent-ink));
}

.report-page .rp-table th[aria-sort="ascending"] .rp-sort i,
.report-page .rp-table th[aria-sort="descending"] .rp-sort i {
    opacity: 1;
}

/* ---- celle ---- */
.report-page .rp-col-num,
.report-page .rp-table td.rp-num,
.report-page .rp-table td.rp-date {
    text-align: right;
}

.report-page .rp-table tbody tr:hover > td {
    background: #fafbfd;
}

.report-page .rp-name {
    font-weight: 600;
    color: var(--rp-ink);
}

.report-page .rp-name-sub {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--rp-faded);
}

.report-page .rp-td-name {
    min-width: 240px;
}

.report-page .rp-td-name-inner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.report-page .rp-role {
    font-size: 12.5px;
    color: var(--rp-muted);
    white-space: nowrap;
}

/* ---- pulsante di espansione ---- */
.report-page .rp-expand {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border: 1px solid var(--rp-line-strong);
    border-radius: 6px;
    background: var(--rp-surface);
    color: var(--rp-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.report-page .rp-expand:hover {
    background: var(--rp-surface-2);
    color: var(--rp-ink);
}

.report-page .rp-expand i {
    transition: transform 0.15s ease;
}

.report-page .rp-expand[aria-expanded="true"] i {
    transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
    .report-page .rp-expand i {
        transition: none;
    }
}

/* ---- riga di intestazione del gruppo ---- */
.report-page .rp-group-head td {
    padding: 13px 14px 7px;
    background: var(--rp-surface);
    border-bottom: 1px solid var(--rp-line-strong);
}

.report-page .rp-group-name {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--rp-ink-soft);
}

.report-page .rp-group-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--rp-faded);
    margin-left: 8px;
}

/* ---- righe di totale: gruppo e rete ---- */
.report-page .rp-row-total > td,
.report-page .rp-row-net > td {
    background: var(--rp-surface-2);
    font-weight: 600;
}

.report-page .rp-row-total:hover > td,
.report-page .rp-row-net:hover > td {
    background: #eef1f6;
}

.report-page .rp-row-net > td {
    border-top: 2px solid var(--rp-line-strong);
    border-bottom: none;
    font-size: 14px;
}

/* ---- riga senza preventivi nel periodo: numeri spenti, nessun allarme ---- */
.report-page .rp-row-empty td.rp-num,
.report-page .rp-row-empty td.rp-date {
    color: var(--rp-faded);
}

/* ---- unica evidenziazione prevista (par. 7.2) ---- */
.report-page .rp-flag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding: 2px 8px;
    border: 1px solid rgba(var(--rp-attention-ink), 0.30);
    border-radius: 20px;
    background: rgba(var(--rp-attention), 0.10);
    color: rgb(var(--rp-attention-ink));
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: help;
}

.report-page .rp-flag i {
    font-size: 13px;
}

/* Utenza disattivata: informazione neutra, con il pallino e non col colore. */
.report-page .rp-chip-off {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding: 2px 8px;
    border: 1px solid var(--rp-line-strong);
    border-radius: 20px;
    background: var(--rp-surface-2);
    color: var(--rp-muted);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.report-page .rp-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ---- riga figlia con i tre livelli ---- */
.report-page .rp-detail > td {
    padding: 0 14px 14px;
    background: #fbfcfe;
}

.report-page .rp-detail-inner {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-surface);
}

.report-page .rp-levels-title {
    margin: 0 0 7px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--rp-muted);
}

.report-page .rp-levels {
    margin: 0;
}

.report-page .rp-level {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 0;
    border-bottom: 1px dotted var(--rp-line);
}

.report-page .rp-level:last-child {
    border-bottom: none;
}

.report-page .rp-level dt {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--rp-muted);
}

.report-page .rp-level dd {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--rp-ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.report-page .rp-level-total dt,
.report-page .rp-level-total dd {
    font-weight: 700;
    color: var(--rp-ink);
}

.report-page .rp-level-note {
    margin: 7px 0 0;
    font-size: 12px;
    color: var(--rp-faded);
}

/* ==========================================================================
   Stati: caricamento, nessun dato, senza permessi (par. 7.2)
   Intestazione e filtri restano visibili: cambia solo l'area dati.
   ========================================================================== */

/* Caricamento: col rendering lato server pagina e dati arrivano insieme,
   quindi l'unica attesa e quella del submit. L'area dati si attenua e pulsa,
   senza cerchi che girano. */
.report-page.rp-busy .rp-data {
    animation: rp-pulse 1.1s ease-in-out infinite alternate;
    pointer-events: none;
}

.report-page.rp-busy .rp-filters {
    pointer-events: none;
}

@keyframes rp-pulse {
    from { opacity: 1; }
    to   { opacity: 0.38; }
}

@media (prefers-reduced-motion: reduce) {
    .report-page.rp-busy .rp-data {
        animation: none;
        opacity: 0.5;
    }
}

.report-page .rp-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 56px 24px;
    background: var(--rp-surface);
    border: 1px solid var(--rp-line);
    border-radius: var(--rp-radius);
}

.report-page .rp-state-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rp-surface-2);
    color: var(--rp-muted);
    font-size: 26px;
    margin-bottom: 4px;
}

.report-page .rp-state-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--rp-ink);
}

.report-page .rp-state-text {
    margin: 0;
    font-size: 13.5px;
    color: var(--rp-muted);
    max-width: 64ch;
}

.report-page .rp-state-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

/* ==========================================================================
   Schermi stretti — leggibile a 1366, usabile a 768.
   Le tabelle scorrono in orizzontale: nessuna riga diventa scheda.
   ========================================================================== */

@media (max-width: 1199.98px) {
    .report-page .rp-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .report-page .rp-head-actions {
        margin-left: 0;
        width: 100%;
    }

    .report-page .rp-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .report-page .rp-card-value {
        font-size: 22px;
    }

    .report-page .rp-field-multiplo {
        flex: 1 1 100%;
        max-width: none;
    }

    .report-page .rp-detail-inner {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Senza altezza massima lo scorrimento verticale torna alla pagina:
       l'intestazione fissa non avrebbe piu riferimento, quindi resta il solo
       scorrimento orizzontale con la prima colonna ferma. */
    .report-page .rp-table-wrap {
        max-height: none;
    }

    .report-page .rp-table thead th {
        position: static;
    }

    .report-page .rp-table th:first-child,
    .report-page .rp-table td:first-child {
        position: sticky;
        left: 0;
    }
}

/* Telefono: la tendina multipla prende tutta la riga (regola qui sopra) e
   diventa da dito — voci alte 42 px, x delle etichette piu' grande, menu che
   non supera meta' schermo. La casella di ricerca va a 16 px: sotto quella
   misura Safari su iPhone ingrandisce la pagina appena la si tocca. */
@media (max-width: 575.98px) {
    .report-page .ts-wrapper.rp-filtro-multiplo .ts-control > input {
        font-size: 16px;
    }

    /* Due etichette in 340 px si tagliano entrambe: gia' da due voci il campo
       mostra il riepilogo ("2 collaboratori"). Stesso aspetto della regola
       principale, che qui si ripete per la classe rp-fm-piu-voci. */
    .report-page .ts-wrapper.rp-filtro-multiplo.rp-fm-piu-voci .ts-control > .item {
        display: none !important;
    }

    .report-page .ts-wrapper.rp-filtro-multiplo.rp-fm-piu-voci .ts-control::before {
        content: attr(data-riepilogo);
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        height: 26px;
        padding: 0 10px;
        border: 1px solid rgba(var(--rp-accent-ink), 0.22);
        border-radius: 6px;
        background: rgba(var(--rp-accent), 0.10);
        color: rgb(var(--rp-accent-ink));
        font-size: 12.5px;
        font-weight: 600;
        white-space: nowrap;
    }

    .report-page .ts-wrapper.rp-filtro-multiplo .ts-control .item .remove {
        width: 24px;
        height: 24px;
    }

    .report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .ts-dropdown-content {
        max-height: min(296px, 50vh);
    }

    .report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .option {
        min-height: 42px;
    }

    .report-page .ts-wrapper.rp-filtro-multiplo .ts-dropdown .tomselect-checkbox {
        width: 18px;
        height: 18px;
    }
}

/* ==========================================================================
   Foglio di stampa (par. 8) — e anche il "Scarica PDF": nessun motore PDF.
   Via sidebar, barra superiore, piede, filtri interattivi e pulsanti; i filtri
   applicati si stampano come testo sotto il titolo, la tabella non scorre e
   l'intestazione si ripete su ogni pagina.
   ========================================================================== */

/* Blocco dei filtri come testo: invisibile a schermo, stampato. */
.report-page .rp-print-meta {
    display: none;
}

@media print {
    @page {
        margin: 12mm;
    }

    html,
    body {
        background: #ffffff !important;
    }

    /* Telaio del gestionale */
    nav.dark-sidebar,
    header.header-main,
    footer,
    .go-top,
    .loader-wrapper,
    .offcanvas,
    .offcanvas-backdrop,
    .app-line-breadcrumbs,
    .alert-dismissible .btn-close {
        display: none !important;
    }

    .app-wrapper,
    .app-content,
    .app-content main,
    .app-content main .container-fluid {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        width: auto !important;
        max-width: none !important;
        overflow: visible !important;
    }

    /* Comandi e filtri interattivi */
    .report-page .rp-head-actions,
    .report-page .rp-tabnav,
    .report-page .rp-filters,
    .report-page .rp-tags,
    .report-page .rp-expand,
    .report-page .rp-state-actions,
    .report-page .rp-sort i {
        display: none !important;
    }

    /* L'intestazione a schermo ha padding 0 sulla cella e il pulsante che lo porta:
       in stampa il pulsante resta (e' il testo della colonna) e tiene il padding
       della cella, altrimenti le intestazioni toccherebbero i bordi. */
    .report-page .rp-sort {
        padding: 4px 6px;
    }

    /* Filtri applicati come testo, con la data di generazione */
    .report-page .rp-print-meta {
        display: block;
        margin: 0 0 12px;
        padding: 8px 0;
        border-top: 1px solid #cccccc;
        border-bottom: 1px solid #cccccc;
        font-size: 10.5pt;
        color: #333333;
    }

    .report-page .rp-print-meta dl {
        margin: 0;
    }

    .report-page .rp-print-row {
        display: flex;
        gap: 8px;
        padding: 1px 0;
    }

    .report-page .rp-print-meta dt {
        font-weight: 700;
        min-width: 34mm;
    }

    .report-page .rp-print-meta dd {
        margin: 0;
    }

    /* Riquadri: quattro in fila, senza ombre */
    .report-page .rp-cards {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 6px;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .report-page .rp-card {
        padding: 6px 8px;
        border: 1px solid #cccccc;
    }

    .report-page .rp-card-value {
        font-size: 14pt;
    }

    /* Tabella: niente scorrimento, intestazione ripetuta a ogni pagina */
    .report-page .rp-table-wrap {
        max-height: none !important;
        overflow: visible !important;
        border: none;
        border-radius: 0;
    }

    .report-page .rp-table {
        min-width: 0 !important;
        width: 100% !important;
        font-size: 9.5pt;
    }

    .report-page .rp-table thead {
        display: table-header-group;
    }

    .report-page .rp-table th,
    .report-page .rp-table td {
        position: static !important;
        box-shadow: none !important;
        padding: 4px 6px;
        border-bottom: 1px solid #dddddd;
        background: transparent !important;
    }

    .report-page .rp-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .report-page .rp-row-total > td,
    .report-page .rp-row-net > td {
        background: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Solo accento e attenzione come colori */
    .report-page .rp-flag,
    .report-page .rp-notice-warn,
    .report-page .rp-var-up,
    .report-page .rp-var-down {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-page .rp-detail[hidden] {
        display: none !important;
    }

    .report-page .rp-state {
        border: 1px solid #cccccc;
        padding: 24px;
    }
}
