/* ==========================================================================
   URSOVA - REPORT DELL'AREA ADMIN (guadagni, andamento setter) E GRAFICI
   Stesso vetro del resto dell'admin. I grafici sono HTML: il testo resta nitido
   e sul telefono niente scorre di lato e nessuna etichetta si accavalla.
   ========================================================================== */

/* ─── Testata, filtri, periodo ─── */

.rp-testa { align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.rp-testa > div { min-width: 0; flex: 1 1 320px; }
.rp-sottotitolo { margin: 0.35rem 0 0; max-width: 62ch; }

.rp-filtri { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.rp-filtri .rp-periodi { margin-bottom: 0; }
.rp-scelta { width: auto; min-width: 220px; max-width: 100%; }
.rp-periodi { flex-wrap: wrap; }
.rp-periodi a.tab { text-decoration: none; display: inline-flex; align-items: center; }

.rp-periodo {
    margin: 0.85rem 0 1.25rem;
    font-size: 0.8rem;
    color: var(--v-grigio, #62625D);
}

.rp-avviso {
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--v-raggio-piccolo, 12px);
    background: rgba(255, 212, 0, 0.22);
    border: 1px solid rgba(201, 154, 0, 0.35);
    font-size: 0.86rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.rp-avviso a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ─── Numeri in alto ─── */

.rp-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.25rem; }
.rp-kpi-sei { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.kpi { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.kpi .stat-value { font-size: 1.85rem; line-height: 1.15; overflow-wrap: anywhere; }
.kpi-principale { background: var(--v-nero, #0A0A0A) !important; border-color: var(--v-nero, #0A0A0A) !important; }
.kpi-principale .stat-label,
.kpi-principale .kpi-nota { color: rgba(255, 255, 255, 0.62); }
.kpi-principale .stat-value { color: var(--v-giallo, #FFD400); }

.kpi-var { font-size: 0.76rem; font-weight: 600; margin-top: 0.15rem; }
.kpi-var span { font-size: 0.62rem; margin-right: 0.15rem; }
.kpi-var-su { color: var(--testo-ok, #146B3A); }
.kpi-var-giu { color: var(--testo-ko, #B42318); }
.kpi-var-pari { color: var(--v-grigio, #62625D); }
.kpi-principale .kpi-var-su { color: #7BE0A5; }
.kpi-principale .kpi-var-giu { color: #FF9C92; }
.kpi-principale .kpi-var-pari { color: rgba(255, 255, 255, 0.62); }
.kpi-nota { font-size: 0.76rem; color: var(--v-grigio, #62625D); line-height: 1.4; }

/* ─── Schede dei grafici ─── */

.rp-scheda {
    min-width: 0;
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.35rem 1.35rem;
    border-radius: var(--v-raggio, 20px);
    border: 1px solid var(--v-bordo, rgba(255, 255, 255, 0.92));
    background: var(--v-vetro, rgba(255, 255, 255, 0.62));
    box-shadow: var(--v-ombra, 0 12px 34px rgba(10, 10, 10, 0.07));
    backdrop-filter: var(--v-sfoca, blur(22px));
    -webkit-backdrop-filter: var(--v-sfoca, blur(22px));
}

.rp-sezione { min-width: 0; margin-bottom: 1.5rem; }

.rp-scheda-testa {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin-bottom: 1rem;
}
.rp-scheda-testa h2 { margin: 0; font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.rp-scheda-nota { font-size: 0.76rem; color: var(--v-grigio, #62625D); }
.rp-scheda-testa-seconda { margin-top: 1.6rem; }

.rp-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.rp-duo > * { margin-bottom: 1.25rem; }
.rp-duo-largo { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }

.rp-lettura { margin: 1rem 0 0; font-size: 0.84rem; line-height: 1.5; color: #2B2B28; }
.rp-lettura-attenzione { padding: 0.6rem 0.8rem; border-radius: 10px; background: rgba(255, 212, 0, 0.22); }
.rp-spiega { margin: 0.75rem 0 0; font-size: 0.78rem; line-height: 1.55; color: var(--v-grigio, #62625D); }

/* ─── Tabelle ─── */

.rp-tabella th.rp-num, .rp-tabella td.rp-num { text-align: right; white-space: nowrap; }
.rp-tabella tfoot td { font-weight: 600; border-top: 1px solid var(--v-linea, rgba(10, 10, 10, 0.07)); background: rgba(255, 212, 0, 0.16); }
.rp-tabella-vuota { text-align: center; padding: 2rem !important; color: var(--v-grigio, #62625D) !important; }
.rp-negativo { color: var(--testo-ko, #B42318) !important; }
.rp-dapagare { font-weight: 600; }
.rp-fermo { color: var(--testo-ko, #B42318) !important; }
.rp-sotto { display: block; font-size: 0.72rem; color: var(--v-grigio, #62625D); font-weight: 400; white-space: nowrap; }
.rp-tabella td[data-primo] .badge { margin-left: 0.35rem; }

.rp-ordina {
    all: unset;
    cursor: pointer;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    white-space: nowrap;
}
.rp-ordina:hover { color: var(--v-nero, #0A0A0A); }
.rp-ordina:focus-visible { outline: 2px solid var(--v-giallo, #FFD400); outline-offset: 2px; border-radius: 4px; }

.rp-quota { display: flex; align-items: center; gap: 0.6rem; min-width: 120px; }
.rp-quota-binario { flex: 1; height: 6px; border-radius: 99px; background: rgba(10, 10, 10, 0.07); overflow: hidden; min-width: 50px; }
.rp-quota-binario > div { height: 100%; border-radius: 99px; background: var(--v-nero, #0A0A0A); }
.rp-quota span { font-size: 0.78rem; color: #4A4A46; white-space: nowrap; }

.rp-esito { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.74rem; font-weight: 500; white-space: nowrap; }
.rp-esito-ok { background: var(--v-nero, #0A0A0A); color: var(--v-giallo, #FFD400); }
.rp-esito-ko { background: rgba(180, 35, 24, 0.1); color: var(--testo-ko, #B42318); }
.rp-esito-attesa { background: rgba(255, 212, 0, 0.35); color: #4A3B00; }
.rp-esito-futuro { background: rgba(10, 10, 10, 0.06); color: #4A4A46; }

.rp-altre { margin-top: 0.75rem; }

.rp-metodo { padding: 1.1rem 1.35rem; border-radius: var(--v-raggio, 20px); background: rgba(255, 255, 255, 0.35); border: 1px dashed rgba(10, 10, 10, 0.12); }
.rp-metodo h2 { margin: 0 0 0.6rem; font-size: 0.92rem; font-weight: 600; }
.rp-metodo ul { margin: 0; padding-left: 1.1rem; }
.rp-metodo li { font-size: 0.8rem; line-height: 1.55; color: #4A4A46; margin-bottom: 0.3rem; }

/* ─── Il setter scelto ─── */

.rp-persona {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--v-raggio, 20px);
    border: 1px solid var(--v-bordo, rgba(255, 255, 255, 0.92));
    background: var(--v-vetro, rgba(255, 255, 255, 0.62));
    box-shadow: var(--v-ombra, 0 12px 34px rgba(10, 10, 10, 0.07));
}
.rp-persona-iniziali {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--v-nero, #0A0A0A);
    color: var(--v-giallo, #FFD400);
    font-weight: 600;
}
.rp-persona-testo { flex: 1 1 220px; min-width: 0; }
.rp-persona-testo h2 { margin: 0; font-size: 1.15rem; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.rp-persona-testo p { margin: 0.2rem 0 0; font-size: 0.82rem; color: var(--v-grigio, #62625D); }
.rp-persona-link { text-decoration: none; }

.rp-conto { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.rp-conto > div {
    padding: 0.85rem 1rem;
    border-radius: var(--v-raggio-piccolo, 12px);
    background: var(--v-vetro, rgba(255, 255, 255, 0.62));
    border: 1px solid var(--v-bordo, rgba(255, 255, 255, 0.92));
    min-width: 0;
}
.rp-conto span { display: block; font-size: 0.74rem; color: var(--v-grigio, #62625D); }
.rp-conto strong { display: block; font-size: 1.05rem; overflow-wrap: anywhere; }
.rp-conto-totale { background: var(--v-nero, #0A0A0A) !important; border-color: var(--v-nero, #0A0A0A) !important; }
.rp-conto-totale span { color: rgba(255, 255, 255, 0.62); }
.rp-conto-totale strong { color: var(--v-giallo, #FFD400); }

/* ==========================================================================
   GRAFICI
   ========================================================================== */

/* Il grafico sa quanto è largo (container query): le etichette si diradano su quello. */
.gr { position: relative; min-width: 0; container: grafico / inline-size; }
.gr-vuoto { margin: 0.75rem 0 0; font-size: 0.82rem; color: var(--v-grigio, #62625D); text-align: center; list-style: none; }

.gr-legenda { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin: 0 0 0.9rem; padding: 0; list-style: none; font-size: 0.78rem; color: #4A4A46; }
.gr-legenda li { display: inline-flex; align-items: center; gap: 0.4rem; }
.gr-legenda i, .gr-tip i, .gr-anello-legenda i, .gr-divisa-legenda i {
    display: inline-block;
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

/* ─── Colonne ─── */

.gr-corpo { display: flex; gap: 0.5rem; height: var(--gr-altezza, 220px); }

.gr-asse { position: relative; flex: 0 0 auto; width: 52px; }
.gr-asse span {
    position: absolute;
    right: 0;
    transform: translateY(50%);
    font-family: var(--font-mono, monospace);
    font-size: 0.66rem;
    color: #8A8A84;
    white-space: nowrap;
}

.gr-piano { position: relative; flex: 1; min-width: 0; }
.gr-griglia { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid rgba(10, 10, 10, 0.06); }
.gr-griglia:first-child { border-top-color: rgba(10, 10, 10, 0.18); }

.gr-colonne { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--gr-n), minmax(0, 1fr)); }

.gr-col {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
    padding: 0 18%;
    outline: none;
    cursor: default;
}
.gr-col::before {
    content: "";
    position: absolute;
    inset: 0 2px;
    border-radius: 8px;
    background: rgba(10, 10, 10, 0.04);
    opacity: 0;
    transition: opacity 0.15s;
}
.gr-col:hover::before, .gr-col:focus-visible::before { opacity: 1; }
.gr-col-on::before { opacity: 1; background: rgba(255, 212, 0, 0.18); }

.gr-pila {
    position: relative;
    width: 100%;
    max-width: 44px;
    display: flex;
    flex-direction: column-reverse;
    border-radius: 6px 6px 2px 2px;
    overflow: hidden;
    transition: height 0.5s var(--ease-out, ease);
}
.gr-pila > div { min-height: 1px; }

.gr-gruppo { position: relative; display: flex; align-items: flex-end; gap: 3px; width: 100%; max-width: 52px; height: 100%; }
.gr-barra { flex: 1; min-width: 0; border-radius: 5px 5px 2px 2px; transition: height 0.5s var(--ease-out, ease); }

.gr-tip {
    position: absolute;
    bottom: calc(100% - 6px);
    left: 50%;
    z-index: 5;
    transform: translate(-50%, 4px);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    width: max-content;
    max-width: 240px;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: var(--v-nero, #0A0A0A);
    color: #FFFFFF;
    font-size: 0.74rem;
    line-height: 1.35;
    box-shadow: 0 12px 30px rgba(10, 10, 10, 0.25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}
.gr-tip strong { font-weight: 600; margin-bottom: 0.15rem; }
/* Il dettaglio è nero: il quadratino del nero ha bisogno di un bordo per vedersi. */
.gr-tip i { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55); }
.gr-tip span { display: flex; align-items: center; gap: 0.4rem; color: rgba(255, 255, 255, 0.78); }
.gr-tip b { margin-left: auto; padding-left: 0.75rem; color: #FFFFFF; font-weight: 600; white-space: nowrap; }
.gr-tip-totale { margin-top: 0.15rem; padding-top: 0.25rem; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.gr-tip-sx { left: 0; transform: translate(0, 4px); }
.gr-tip-dx { left: auto; right: 0; transform: translate(0, 4px); }
.gr-col:hover .gr-tip, .gr-col:focus .gr-tip, .gr-col:focus-within .gr-tip { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.gr-col:hover .gr-tip-sx, .gr-col:focus .gr-tip-sx, .gr-col:focus-within .gr-tip-sx,
.gr-col:hover .gr-tip-dx, .gr-col:focus .gr-tip-dx, .gr-col:focus-within .gr-tip-dx { transform: translate(0, 0); }

/* Le etichette sotto: una ogni tanto, perché non si tocchino mai. */
.gr-etichette {
    display: grid;
    grid-template-columns: repeat(var(--gr-n), minmax(0, 1fr));
    margin: 0.45rem 0 0 calc(52px + 0.5rem);
    height: 1.1rem;
}
.gr-etichette span {
    position: relative;
    display: flex;
    justify-content: center;
    font-size: 0.68rem;
    color: #7A7A74;
    white-space: nowrap;
    visibility: hidden;
}
.gr-etichette span.gr-et-l { visibility: visible; }

@container grafico (max-width: 640px) {
    .gr-etichette span.gr-et-l { visibility: hidden; }
    .gr-etichette span.gr-et-m { visibility: visible; }
}
@container grafico (max-width: 380px) {
    .gr-etichette span.gr-et-m { visibility: hidden; }
    .gr-etichette span.gr-et-s { visibility: visible; }
}

/* ─── Anello ─── */

.gr-anello { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.gr-anello-disco { position: relative; flex: 0 0 auto; width: 168px; height: 168px; }
.gr-anello-disco svg { width: 100%; height: 100%; display: block; }
.gr-anello-disco circle { transition: stroke-dasharray 0.5s var(--ease-out, ease); }
.gr-anello-centro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.gr-anello-centro strong { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.gr-anello-centro span { font-size: 0.7rem; color: var(--v-grigio, #62625D); }

.gr-anello-legenda { flex: 1 1 220px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.gr-anello-legenda li {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto 3.2rem;
    align-items: center;
    gap: 0.6rem;
    padding: 0.42rem 0;
    border-bottom: 1px solid rgba(10, 10, 10, 0.05);
    font-size: 0.82rem;
}
.gr-anello-legenda li:last-child { border-bottom: 0; }
.gr-anello-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-anello-nome a { color: inherit; text-decoration: none; }
.gr-anello-nome a:hover { text-decoration: underline; text-underline-offset: 3px; }
.gr-anello-val { font-weight: 600; white-space: nowrap; }
.gr-anello-quota { text-align: right; color: var(--v-grigio, #62625D); font-size: 0.76rem; white-space: nowrap; }

/* ─── Barra divisa ─── */

.gr-divisa-barra { display: flex; gap: 3px; height: 14px; border-radius: 99px; overflow: hidden; background: rgba(10, 10, 10, 0.06); }
.gr-divisa-barra > div { min-width: 3px; }
.gr-divisa-legenda { margin: 0.8rem 0 0; padding: 0; list-style: none; }
.gr-divisa-legenda li {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto 2.8rem;
    align-items: center;
    gap: 0.6rem;
    padding: 0.32rem 0;
    font-size: 0.82rem;
}
.gr-divisa-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-divisa-val { font-weight: 600; white-space: nowrap; }
.gr-divisa-quota { text-align: right; color: var(--v-grigio, #62625D); font-size: 0.76rem; }

/* ─── Imbuto ─── */

.gr-imbuto { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.gr-imbuto-testa { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; font-size: 0.84rem; margin-bottom: 0.3rem; }
.gr-imbuto-nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; }
.gr-imbuto-num { font-weight: 600; white-space: nowrap; }
.gr-imbuto-binario { height: 10px; border-radius: 99px; background: rgba(10, 10, 10, 0.06); overflow: hidden; }
.gr-imbuto-barra { height: 100%; border-radius: 99px; background: var(--v-nero, #0A0A0A); transition: width 0.5s var(--ease-out, ease); }
.gr-imbuto li:last-child .gr-imbuto-barra { background: var(--v-giallo, #FFD400); }
.gr-imbuto-passa { margin-top: 0.25rem; font-size: 0.72rem; color: var(--v-grigio, #62625D); }
.gr-imbuto-peggiore .gr-imbuto-passa b { color: var(--testo-ko, #B42318); font-weight: 600; }

/* ─── Classifica ─── */

.gr-barre { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.8rem; }
.gr-barre-testa { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; font-size: 0.84rem; margin-bottom: 0.3rem; }
.gr-barre-nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-barre-nome a { color: inherit; text-decoration: none; font-weight: 500; }
.gr-barre-nome a:hover { text-decoration: underline; text-underline-offset: 3px; }
.gr-barre-val { font-weight: 600; white-space: nowrap; }
.gr-barre-binario { height: 10px; border-radius: 99px; background: rgba(10, 10, 10, 0.06); overflow: hidden; }
.gr-barre-binario > div { height: 100%; border-radius: 99px; transition: width 0.5s var(--ease-out, ease); }
.gr-barre-sotto { margin-top: 0.25rem; font-size: 0.72rem; color: var(--v-grigio, #62625D); }

/* ==========================================================================
   SCHERMI STRETTI
   ========================================================================== */

@media (max-width: 1100px) {
    .rp-duo, .rp-duo-largo { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 768px) {
    .rp-scheda { padding: 1rem 1rem 1.1rem; border-radius: 18px; }
    .rp-filtri { flex-direction: column; align-items: stretch; }
    .rp-scelta { width: 100%; min-width: 0; }
    .rp-periodi { width: 100%; }
    .rp-periodi a.tab { flex: 1 1 auto; justify-content: center; padding: 0.5rem 0.6rem; }
    .rp-testa .btn-secondary { width: 100%; }

    .rp-kpi, .rp-kpi-sei { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi .stat-value { font-size: 1.35rem; }

    .gr-asse { width: 40px; }
    .gr-asse span { font-size: 0.6rem; }
    .gr-etichette { margin-left: calc(40px + 0.5rem); }
    .gr-col { padding: 0 12%; }
    .gr-tip { max-width: 210px; }

    .gr-anello { justify-content: center; }
    .gr-anello-disco { width: 150px; height: 150px; }

    .rp-conto { grid-template-columns: minmax(0, 1fr); }

    /* Sul telefono la tabella diventa a schede: i numeri tornano a sinistra, sotto l'etichetta. */
    .rp-tabella td.rp-num { text-align: left; }
    .rp-tabella tfoot { display: none; }
    .rp-quota { min-width: 0; }
    .rp-sotto { display: inline; margin-left: 0.4rem; }
}

@media (max-width: 380px) {
    .rp-kpi, .rp-kpi-sei { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .gr-pila, .gr-barra, .gr-anello-disco circle, .gr-imbuto-barra, .gr-barre-binario > div { transition: none; }
}
