/* ==========================================================================
   SISTEMA CARD COERENTE
   ==========================================================================
   Sorgente unica per risultato.php, index.php (dashboard) e profilo.php.
   Caricare DOPO app.css, così le regole seguenti hanno la precedenza.
   ========================================================================== */

:root {
    --primary: #4361ee;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --light: #f8f9fa;
    --dark: #333;
    --muted: #666;
    --border: #e0e0e0;
    --radius: 16px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --transition: 0.2s ease;
}

/* --- Contenitore pagina --------------------------------------------------- */
.page-container {
    width: 100%;
    max-width: 720px;
    margin: 1.5rem auto 0;
    box-sizing: border-box;
    overflow-x: hidden;
    /* Spazio per il FAB fisso in fondo: senza, l'ultimo elemento della pagina
       (footer, pulsanti finali) resta coperto dal pulsante "Nuova Scansione". */
    padding: 0 1rem 5.5rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 1rem 0;
}

.muted {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0;
}

/* --- Card canonica -------------------------------------------------------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    padding: 0;
    overflow: hidden;
    max-width: 480px;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    background: var(--light);
    border-bottom: 1px solid #e9ecef;
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
}

.card-body {
    padding: 1rem;
}

/* --- Sezione interna (stessa grafica in tutte le pagine) ------------------ */
.section-card {
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.section-card .section-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Griglia statistiche -------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Tre tessere: occupano tutta la riga (una colonna per voce). */
.stat-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 0.9rem 0.75rem;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.stat-card h3 {
    margin: 0 0 0.35rem 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #7f8c8d;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* --- Profilo -------------------------------------------------------------- */
.profile-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.profile-details h3 {
    margin: 0 0 0.15rem 0;
    font-size: 1.1rem;
    color: var(--dark);
}

.profile-details p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* --- Scheda esito (risultato.php) ----------------------------------------- */
.result-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

/* Corpo: pila di sezioni separate da uno spazio uniforme */
.result-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1rem;
}

/* I margini delle sezioni interne sono gestiti dal gap del contenitore */
.result-body .boycott-card,
.result-body .product-info,
.result-body .product-details-card,
.result-body .comparison-section,
.result-body .history-section {
    margin-bottom: 0;
}

/* --- Scheda boicottaggio (risultato.php + boicottaggio.php) ---------------- */
.boycott-card {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    font-weight: 700;
}
.boycott-not-in-list {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #495057;
}
.boycott-warning {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}
.boycott-title {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}
.boycott-brand {
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.boycott-reason {
    margin-bottom: 0.25rem;
}
.boycott-category {
    font-size: 0.85rem;
    opacity: 0.85;
}
.boycott-not-in-list-text {
    font-weight: 500;
}

/* La scheda di boicottaggio è cliccabile: porta alla pagina di dettaglio. */
.boycott-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}
.boycott-link:hover {
    filter: brightness(0.97);
    box-shadow: 0 4px 14px rgba(220, 53, 69, 0.22);
}
.boycott-link:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}
.boycott-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.6rem;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: underline;
}
.boycott-not-in-list .boycott-cta {
    color: #495057;
}

/* --- Pagina di dettaglio del boicottaggio (boicottaggio.php) -------------- */
.boycott-hero {
    background: linear-gradient(135deg, #fdf1f2 0%, #f8d7da 100%);
    border: 2px solid var(--danger);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    color: #721c24;
    text-align: center;
}
.boycott-hero.ok {
    background: linear-gradient(135deg, #eaf7ee 0%, #d4edda 100%);
    border-color: #28a745;
    color: #155724;
}
.boycott-hero h2 {
    margin: 0 0 0.35rem 0;
    font-size: 1.2rem;
    color: inherit;
}
.boycott-hero .boycott-hero-brand {
    font-weight: 700;
    font-size: 1.05rem;
}
.boycott-hero .boycott-hero-sub {
    font-size: 0.9rem;
    opacity: 0.9;
}

.reason-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-left: 4px solid var(--danger);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}
.reason-item:last-child {
    margin-bottom: 0;
}
.reason-category {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #721c24;
    background: #f8d7da;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    margin-bottom: 0.45rem;
}
.reason-text {
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.5;
}
.reason-meta {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
}
.reason-meta a {
    color: var(--primary);
    font-weight: 600;
}

/* --- Dettaglio prodotto (condiviso: risultato.php e boicottaggio.php) ------ */
/* Scheda "Dettagli prodotto": ogni dettaglio disponibile e' una tessera
   con icona, etichetta e valore. I dettagli assenti non vengono mostrati. */
.product-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 0.6rem;
}

.product-field {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    /* La pagina di risultato centra il testo delle card: qui i dettagli
       tornano allineati a sinistra, che e' piu' leggibile. */
    text-align: left;
    padding: 0.65rem 0.8rem;
    border: 1px solid #eceff1;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #fbfcfd 100%);
    min-width: 0;
}

.field-icon {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    background: #f1f3f5;
}

.field-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.field-label {
    font-weight: 700;
    color: #8a94a6;
    font-size: 0.68rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    line-height: 1.2;
}

.field-value {
    color: #212529;
    font-weight: 600;
    font-size: 0.92rem;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

@media (max-width: 420px) {
    .product-details-grid {
        grid-template-columns: 1fr;
    }

    .product-field {
        padding: 0.6rem 0.7rem;
    }
}

/* --- Pulsanti in fondo alla pagina di dettaglio boicottaggio -------------- */
.boycott-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-top: 1.25rem;
}

.boycott-actions .btn {
    width: 100%;
    margin: 0;
    padding: 0.85rem 0.9rem;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-align: center;
}

@media (max-width: 420px) {
    .boycott-actions {
        grid-template-columns: 1fr;
    }
}

/* --- Scheda boicottaggio collassabile (risultato.php) --------------------- */
.boycott-collapsible-card {
    border-radius: 12px;
    padding: 0;
    margin: 0 1.5rem 1rem;
    border: 2px solid;
    overflow: hidden;
}

.boycott-collapsible-card.boycott-danger {
    border-color: #dc3545;
}

.boycott-collapsible-card.boycott-success {
    border-color: #28a745;
}

.boycott-toggle {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: inherit;
    transition: background 0.15s ease;
}

.boycott-toggle:hover {
    background: rgba(0,0,0,0.03);
}

.boycott-toggle:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: -2px;
}

.boycott-collapsible-card.boycott-danger .boycott-toggle {
    color: #721c24;
    background: #f8d7da;
}

.boycott-toggle:hover {
    filter: brightness(0.98);
}

.boycott-collapsible-card.boycott-success .boycott-toggle {
    color: #155724;
    background: #d4edda;
}

.boycott-toggle-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.boycott-toggle-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.05rem;
}

.boycott-toggle-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: var(--muted);
    flex-shrink: 0;
}

.boycott-toggle[aria-expanded="true"] .boycott-toggle-chevron {
    transform: rotate(180deg);
}

.boycott-details-content {
    padding: 0 1.25rem 1rem;
    overflow: hidden;
}

.boycott-details-content[hidden] {
    display: none;
}

.boycott-details-inner {
    padding: 1rem 0 0.5rem;
}

.boycott-detail-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.95rem;
    line-height: 1.5;
}

.boycott-detail-row:last-of-type {
    border-bottom: none;
}

.boycott-detail-row strong {
    color: var(--dark);
    margin-right: 0.5rem;
}

.boycott-detail-sep {
    margin: 0.75rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

.boycott-detail-link {
    display: inline-block;
    padding: 0.5rem 0;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.boycott-detail-link:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .boycott-toggle {
        padding: 0.85rem 1rem;
        font-size: 1rem;
    }
}

/* --- Barra supermercato: Home | "Ti trovi in" | Cambia -------------------- */
.supermercato-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.9rem;
    font-size: 0.9rem;
}

.supermercato-bar .bar-home,
.supermercato-bar .bar-cambia {
    flex-shrink: 0;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--dark);
    font-weight: 600;
    font-size: 0.82rem;
    text-decoration: none;
}

.supermercato-bar .bar-cambia {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.supermercato-bar .bar-center {
    flex: 1;
    min-width: 0;
    text-align: center;
    line-height: 1.25;
}

.supermercato-bar .bar-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: #95a5a6;
}

.supermercato-bar .bar-center strong {
    display: block;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Pagina di conferma del prezzo (conferma-prezzo.php) ------------------ */
.conferma-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem 1.25rem 1.25rem;
    text-align: center;
    margin-top: 1rem;
}

.conferma-testo {
    margin: 0 0 0.35rem 0;
    font-size: 0.95rem;
    color: var(--muted);
}

.conferma-scarto {
    margin: 0.9rem 0 0 0;
    font-size: 0.88rem;
    color: var(--muted);
}

.conferma-prezzo {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--dark);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-bottom: 0.2rem;
}

.conferma-label {
    display: block;
    margin: 1.4rem 0 0.4rem 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: #495057;
}

#conferma-input {
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    padding: 0.6rem 0.8rem;
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

.conferma-btn {
    width: 100%;
    margin-top: 0.9rem;
    padding: 0.95rem 1.2rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 12px;
}

/* Coppia di tasti: Annulla | Conferma */
.conferma-azioni {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.conferma-azioni .btn {
    margin: 0;
    padding: 0.95rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.conferma-prodotto {
    margin: 1rem 0 0 0;
    font-size: 0.82rem;
    color: #95a5a6;
}

.conferma-stato {
    margin: 0.7rem 0 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    min-height: 1.2em;
}

.conferma-stato.errore {
    color: var(--danger);
    font-weight: 600;
}

/* Errore di conferma (prezzo non confermato): il messaggio resta a
   schermo per due secondi, quindi deve essere immediatamente leggibile
   e non confondersi con il normale stato del form. */
.conferma-stato.errore.conferma-errore {
    margin: 0.7rem 0 0 0;
    padding: 0.6rem 0.75rem;
    background: #fdecea;
    border: 1px solid #ef6c62;
    border-radius: 8px;
    color: #a71d2a;
}

/* Stato di attesa (limite di scansioni): il conto alla rovescia e' vivo. */
.conferma-stato.attesa {
    color: #b26a00;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* --- Versione in fondo alla pagina ---------------------------------------- */
.page-footer {
    text-align: center;
    padding: 0.75rem 1rem 5rem;
    font-size: 0.85rem;
    color: #475569;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.page-footer .version {
    font-weight: 600;
    font-size: 0.85rem;
    color: inherit;
    margin-left: 0.35rem;
}

/* --- Badges Utente: Root vs Livello Gamification --- */
.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.1;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.4px;
    vertical-align: middle;
    margin-left: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-transform: uppercase;
}

.badge-root {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #ffffff;
    border: 1px solid #1d4ed8;
}

.badge-level {
    background: linear-gradient(135deg, #065f46, #059669);
    color: #ffffff;
    border: 1px solid #047857;
}

/* --- Link flottante "Nuova Scansione" - centrato e sempre raggiungibile --- */
.new-scan-fab {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.85rem 1.7rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary) 0%, #3a0ca3 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.45);
    transition: var(--transition);
}

.new-scan-fab:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 10px 26px rgba(67, 97, 238, 0.55);
}

.new-scan-fab:active {
    transform: translateX(-50%) translateY(0);
}

/* --- Barra di navigazione normale nell'header (sostituisce i pulsanti float) --- */
.top-actions-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}
.btn-top-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    box-sizing: border-box;
}
.btn-top-menu {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.22);
}
.btn-top-menu:hover {
    background: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}
.btn-top-scan {
    background: #10b981;
    color: #ffffff;
    border: 1px solid #059669;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}
.btn-top-scan:hover {
    background: #059669;
    color: #ffffff;
}
.btn-top-logout {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.35);
}
.btn-top-logout:hover {
    background: rgba(239, 68, 68, 0.38);
    color: #ffffff;
}

@media (max-width: 540px) {
    .top-actions-bar {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.4rem;
        gap: 0.35rem;
    }
    .btn-top-action {
        padding: 0.38rem 0.65rem;
        font-size: 0.82rem;
    }
}

/* Disattivazione pulsanti float e reminder su richiesta: sostituiti da pulsanti normali */
.floating-nav-bar,
.pwa-install-reminder-bar {
    display: none !important;
}

.floating-nav-bar .fab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1.15rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-nav-bar .fab-btn-menu {
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.floating-nav-bar .fab-btn-menu:hover,
.floating-nav-bar .fab-btn-menu.is-active {
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.3);
}

.floating-nav-bar .fab-btn-scan {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
    border: 1px solid rgba(52, 211, 153, 0.35);
}

.floating-nav-bar .fab-btn-scan:hover,
.floating-nav-bar .fab-btn-scan.is-active {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.55);
    transform: translateY(-1px);
}

.floating-nav-bar .fab-btn-logout {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.35);
}

.floating-nav-bar .fab-btn-logout:hover,
.floating-nav-bar .fab-btn-logout:active {
    background: rgba(239, 68, 68, 0.38);
    color: #ffffff;
    border-color: rgba(248, 113, 113, 0.55);
    transform: translateY(-1px);
}

.floating-nav-bar .fab-btn:active {
    transform: translateY(0);
}

/* Quando l'app NON è installata, i pulsanti floating "menu e nuova scansione" non appaiono (tranne nella maschera di scansione) */
html.app-not-installed body:not(.page-scan) .floating-nav-bar,
html:not(.app-is-installed) body:not(.page-scan) .floating-nav-bar {
    display: none !important;
}

/* Nella maschera di scansione (scan.php), i pulsanti restano sempre e comunque float */
body.page-scan .floating-nav-bar {
    display: inline-flex !important;
    position: fixed !important;
    bottom: 1.15rem !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 9999 !important;
}

/* Promemoria collegamento schermata Home (finché l'app non è installata) */
.pwa-install-reminder-bar {
    position: fixed;
    bottom: 0.85rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9990;
    width: calc(100% - 1.5rem);
    max-width: 480px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 0.65rem 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.4), 0 4px 10px -2px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-sizing: border-box;
    font-family: inherit;
    animation: pwaSlideUp 0.35s ease-out;
}

.pwa-install-reminder-bar .reminder-text {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.82rem;
    line-height: 1.3;
    color: #cbd5e1;
}

.pwa-install-reminder-bar .reminder-text strong {
    color: #ffffff;
    display: block;
    font-size: 0.88rem;
}

.pwa-install-reminder-bar .reminder-icon {
    font-size: 1.35rem;
    flex-shrink: 0;
}

.pwa-install-reminder-bar .reminder-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: 1px solid rgba(52, 211, 153, 0.4);
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
    transition: all 0.15s ease;
}

.pwa-install-reminder-bar .reminder-btn:active {
    transform: scale(0.96);
}

/* Quando l'app è installata o siamo nella pagina di scansione, nascondi il promemoria floating */
html.app-is-installed .pwa-install-reminder-bar,
body.page-scan .pwa-install-reminder-bar {
    display: none !important;
}

/* Se l'app è già installata (PWA standalone), non visualizzare la scheda di installazione */
html.app-is-installed .menu-install-card,
html.app-is-installed #pwa-install-card,
#pwa-install-card.is-installed {
    display: none !important;
}

@media all and (display-mode: standalone) {
    .menu-install-card,
    #pwa-install-card,
    .pwa-install-reminder-bar {
        display: none !important;
    }
    .floating-nav-bar {
        display: inline-flex !important;
    }
}

.menu-card-logout {
    border-color: #fecaca !important;
    background: #fff5f5 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-card-logout:hover {
    background: #fef2f2 !important;
    border-color: #f87171 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.12);
}

@media (max-width: 480px) {
    .floating-nav-bar {
        bottom: 0.85rem;
        padding: 0.3rem 0.4rem;
        gap: 0.4rem;
    }
    .floating-nav-bar .fab-btn {
        padding: 0.6rem 0.95rem;
        font-size: 0.88rem;
    }
}

/* --- Hub Menù & Benvenuto (menu.php) --- */
.menu-welcome-header {
    margin-bottom: 0.5rem;
    text-align: left;
}

.menu-welcome-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 0.15rem 0;
}

.menu-welcome-header p.muted {
    font-size: 0.78rem;
    margin: 0;
    line-height: 1.3;
}

/* 1. Barra Supermercato in Alto (Compatta) */
.menu-market-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.45rem;
    box-sizing: border-box;
}

.menu-market-info {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
    color: #334155;
    min-width: 0;
}

.menu-market-info strong {
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-market-cambia {
    font-size: 0.78rem;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.menu-market-cambia:hover {
    background: #dbeafe;
}

/* 2. Pulsante Hero in Evidenza in Alto: Nuova Scansione (Compatto) */
.menu-hero-scan-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #ffffff;
    border-radius: 12px;
    padding: 0.65rem 0.95rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
    box-shadow: 0 4px 14px -2px rgba(16, 185, 129, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    width: 100%;
    box-sizing: border-box;
}

.menu-hero-scan-card:hover, .menu-hero-scan-card:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px -2px rgba(16, 185, 129, 0.5);
    color: #ffffff;
}

.hero-scan-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.hero-scan-details {
    flex: 1;
    min-width: 0;
}

.hero-scan-badge {
    display: inline-block;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    background: rgba(255, 255, 255, 0.25);
    padding: 1px 6px;
    border-radius: 999px;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
}

.hero-scan-title {
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.05rem;
    color: #ffffff;
}

.hero-scan-desc {
    font-size: 0.75rem;
    line-height: 1.25;
    margin: 0;
    color: #d1fae5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-scan-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    flex-shrink: 0;
}

.hero-scan-arrow {
    font-size: 1.05rem;
    font-weight: bold;
    color: #ffffff;
    transition: transform 0.18s ease;
}

.menu-hero-scan-card:hover .hero-scan-arrow {
    transform: translateX(3px);
}

/* 3. Scheda Gamification & Livello Consumatore (Portata in Basso & Compattata 50%) */
.menu-gamification-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    margin-top: 0.4rem;
    margin-bottom: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
    width: 100%;
    box-sizing: border-box;
}

.menu-game-level-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}

.menu-game-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 700;
    font-size: 0.82rem;
    color: #38bdf8;
}

.menu-game-level-icon {
    font-size: 1rem;
}

.menu-game-points-pill {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fef08a;
}

.menu-game-progress-wrap {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    height: 4px;
    width: 100%;
    overflow: hidden;
    margin-bottom: 0.2rem;
}

.menu-game-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #10b981);
    border-radius: 999px;
    transition: width 0.4s ease;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
    position: relative;
    overflow: hidden;
}

.menu-game-progress-sub {
    font-size: 0.68rem;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.2;
}

/* Griglia Voci Menù (Compatta e Ordinata) */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.15rem;
}

.menu-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
}

.menu-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
    text-decoration: none;
}

.menu-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-card-icon {
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f1f5f9;
    flex-shrink: 0;
}

.menu-card-primary .menu-card-icon {
    background: #ecfdf5;
    color: #059669;
}

.menu-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.menu-card-desc {
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.25;
    margin: 0;
}

/* Scheda Installazione App (PWA) */
.menu-install-card {
    background: linear-gradient(135deg, #0b132b 0%, #1c2541 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.5rem;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(11, 19, 43, 0.25);
}

.menu-install-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.menu-install-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.menu-install-titles {
    flex: 1;
}

.menu-install-title {
    margin: 0 0 0.2rem 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
}

.menu-install-desc {
    margin: 0;
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.35;
}

.menu-install-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn-install-device {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 11px;
    font-weight: 600;
    font-size: 0.92rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-install-android {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
}

.btn-install-android:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-install-ios {
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    color: #ffffff;
}

.btn-install-ios:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

.btn-install-device:active {
    transform: scale(0.98);
}

.btn-install-os-icon {
    font-size: 1.2rem;
}

.menu-install-status-bar {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    font-size: 0.8rem;
    color: #6ee7b7;
    text-align: center;
}

@media (max-width: 580px) {
    .menu-install-actions {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }
}

.menu-logout-container {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.btn-menu-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.6rem;
    background: #fff;
    color: #dc2626;
    border: 1.5px solid #fecaca;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-menu-logout:hover {
    background: #fef2f2;
    border-color: #f87171;
    color: #b91c1c;
    text-decoration: none;
}

@media (max-width: 580px) {
    .menu-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* --- Campi modulo --------------------------------------------------------- */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 0.7rem 0.85rem;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    color: #212529;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

select.form-control {
    cursor: pointer;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.btn-row .btn {
    width: auto;
    flex: 1 1 auto;
    min-width: 130px;
}

/* --- Schede di autenticazione (login / registrazione / reset) ------------ */
.auth-container {
    min-height: calc(100vh - 3.6rem);
    display: flex;
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.16) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.14) 0%, transparent 50%),
        linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    padding: 2rem 1rem;
    box-sizing: border-box;
}

.auth-card {
    background: #fff;
    padding: 2.25rem 2rem;
    border-radius: 20px;
    box-shadow: 
        0 20px 45px -10px rgba(15, 23, 42, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 440px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981 0%, #06b6d4 50%, #3b82f6 100%);
}

.auth-card h1 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0 0 0.25rem 0;
    color: #0f172a;
    letter-spacing: -0.3px;
}

.auth-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 1.25rem 0;
    letter-spacing: -0.2px;
}

.auth-footer {
    margin: 1.4rem 0 0 0;
    text-align: center;
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.6;
}

.auth-footer a {
    color: #059669;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.15s ease;
}

.auth-footer a:hover {
    color: #047857;
    text-decoration: underline;
}


/* --- Banner Ambiente (Beta / Test) --- */
.env-banner {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 100;
}

header.top .env-banner {
    order: -1;
    margin: -0.85rem -1rem 0.6rem -1rem;
    width: calc(100% + 2rem);
}

.env-banner-beta {
    background: linear-gradient(90deg, #d97706 0%, #ea580c 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.env-banner-test {
    background: linear-gradient(90deg, #7c3aed 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.env-banner-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    line-height: 1.35;
}

.env-banner-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.env-banner-badge {
    background: rgba(0, 0, 0, 0.28);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.env-banner-desc {
    opacity: 0.95;
    font-weight: 500;
}

.env-switch-link {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    margin-left: 6px;
    display: inline-block;
    white-space: nowrap;
}

.env-switch-link:hover {
    background: rgba(0, 0, 0, 0.45);
    border-color: #ffffff;
    text-decoration: none;
    color: #ffffff;
}

/* --- Header e menu comuni -------------------------------------------------
   Un solo stile per tutte le pagine (tranne scan.php, che resta essenziale).
   -------------------------------------------------------------------------- */
header.top {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    background: #2c3e50;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

header.top.header-hidden {
    transform: translateY(-100%);
    box-shadow: none;
    pointer-events: none;
}

header.top .top-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

header.top h1 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
    white-space: nowrap;
}

/* Logo dell'app al posto del vecchio titolo testuale: l'immagine ha gia'
   le dimensioni nel markup, quindi in CSS basta l'altezza per non
   deformarla. */
header.top h1.top-logo {
    display: flex;
    align-items: center;
    line-height: 0;
}

header.top h1.top-logo img {
    height: 40px;
    width: auto;
    display: block;
}

header.top nav.app-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

header.top nav.app-nav a {
    color: #ecf0f1;
    margin: 0;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
}

header.top nav.app-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
}

header.top nav.app-nav a.on {
    background: #4361ee;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

/* Pagine di autenticazione: il riquadro non deve stare sotto la barra. */
body.has-header .auth-container {
    min-height: calc(100vh - 3.6rem);
    padding-top: 1.5rem;
}

@media (max-width: 480px) {
    header.top {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        text-align: center;
    }

    header.top .top-brand {
        justify-content: center;
    }

    header.top h1.top-logo img {
        height: 34px;
    }

    header.top nav.app-nav {
        justify-content: center;
    }
}


/* --- Profilo: sintesi percentuale delle fasce ---------------------------- */
.fasce-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.fasce-summary-item {
    border-radius: 12px;
    padding: 0.8rem 0.5rem;
    text-align: center;
    border: 1px solid transparent;
}

.fasce-summary-item.conveniente {
    background: #e8f5e9;
    border-color: #c8e6c9;
}

.fasce-summary-item.nella-media {
    background: #fff8e1;
    border-color: #ffecb3;
}

.fasce-summary-item.caro {
    background: #ffebee;
    border-color: #ffcdd2;
}

.fasce-summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.fasce-summary-item.conveniente .fasce-summary-value { color: #1b5e20; }
.fasce-summary-item.nella-media .fasce-summary-value { color: #8a6d00; }
.fasce-summary-item.caro .fasce-summary-value { color: #a71d2a; }

.fasce-summary-label {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #6c757d;
}

/* --- Profilo: sezione sicurezza, aspetto moderno -------------------------- */
.security-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.security-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fb 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.security-icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    background: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.25);
}

.security-text {
    flex: 1;
    min-width: 0;
}

.security-text h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #2c3e50;
}

.security-text p {
    margin: 0.15rem 0 0 0;
    font-size: 0.85rem;
    color: #7f8c8d;
    overflow-wrap: anywhere;
}

.security-action {
    flex-shrink: 0;
    width: auto;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.22);
}

.security-badge {
    flex-shrink: 0;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #c8e6c9;
}

/* --- Adattamenti schermi stretti ------------------------------------------ */
@media (max-width: 480px) {
    .page-container {
        margin: 1rem auto 0;
        /* Il padding inferiore va mantenuto: e' lo spazio riservato al FAB fisso. */
        padding: 0 0.5rem 5.5rem;
    }

    .card {
        border-radius: 12px;
    }

    .card-body {
        padding: 0.85rem;
    }

    .result-body {
        padding: 0.75rem;
        gap: 0.7rem;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    /* Su schermo stretto le tre tessere restano su una riga sola. */
    .stat-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }

    .stat-grid-3 .stat-card {
        padding: 0.7rem 0.35rem;
    }

    .stat-grid-3 .stat-card h3 {
        font-size: 0.6rem;
        letter-spacing: 0.3px;
    }

    .stat-grid-3 .stat-value {
        font-size: 1.2rem;
    }

    .fasce-summary {
        gap: 0.4rem;
    }

    .fasce-summary-value {
        font-size: 1.15rem;
    }

    .fasce-summary-label {
        font-size: 0.62rem;
    }

    .security-item {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .security-action {
        width: 100%;
        text-align: center;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .new-scan-fab {
        bottom: 0.75rem;
        padding: 0.75rem 1.4rem;
        font-size: 0.95rem;
    }
}

/* ---------- Nickname: form di salvataggio nella sezione Sicurezza ---------- */
.nickname-form { display:flex; align-items:center; gap:0.6rem; flex-wrap:wrap; margin-top:0.4rem; }
.nickname-input {
    flex:1 1 220px;
    min-width:170px;
    padding:0.55rem 0.7rem;
    font-size:1rem;
    box-sizing:border-box;
}

/* ---------- Social Login / Registration (Google & Facebook) ---------- */
.social-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0 1rem;
    color: #888;
    font-size: 0.85rem;
}
.social-divider::before, .social-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e0e0e0;
}
.social-divider span {
    padding: 0 0.8rem;
    font-weight: 500;
}
.social-login-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.75rem;
}
.btn-social-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    border: none;
}
.btn-social-google {
    background: #ffffff;
    color: #3c4043;
    border: 1px solid #dadce0 !important;
    box-shadow: 0 1px 2px rgba(60,64,67,0.08);
}
.btn-social-google:hover {
    background: #f8f9fa;
    border-color: #c6c9cc !important;
    box-shadow: 0 1px 3px rgba(60,64,67,0.15);
    color: #202124;
}
.btn-social-facebook {
    background: #1877f2;
    color: #ffffff;
    border: 1px solid #1877f2 !important;
}
.btn-social-facebook:hover {
    background: #166fe5;
    color: #ffffff;
}


/* --- Versione footer per pagine e auth-container --- */
.page-footer {
    text-align: center;
    padding: 0.75rem 1rem 5rem;
    font-size: 0.85rem;
    color: #475569;
    letter-spacing: 0.5px;
    font-weight: 500;
}
.page-footer .version {
    font-weight: 600;
    font-size: 0.85rem;
    color: inherit;
    margin-left: 0.35rem;
}

/* --- Badges Utente: Root vs Livello Gamification --- */
.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.1;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.4px;
    vertical-align: middle;
    margin-left: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-transform: uppercase;
}

.badge-root {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #ffffff;
    border: 1px solid #1d4ed8;
}

.badge-level {
    background: linear-gradient(135deg, #065f46, #059669);
    color: #ffffff;
    border: 1px solid #047857;
}
.auth-container {
    flex-direction: column !important;
}
.auth-container .page-footer {
    color: rgba(255, 255, 255, 0.85);
    padding: 1.5rem 1rem 1rem;
    width: 100%;
}

/* ==========================================================================
   Shrinkflation Alert Card (Sgrammatura)
   ========================================================================== */
.shrinkflation-alert-card {
    background: #fff;
    border: 2px solid #ef4444;
    border-radius: 14px;
    padding: 1.1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.12);
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.shrinkflation-alert-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #dc2626, #f97316);
}

.sf-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.85rem;
    gap: 0.75rem;
}

.sf-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sf-badge-alert {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #b91c1c;
}

.sf-card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
    line-height: 1.2;
}

.sf-loss-pill {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.1);
}

.sf-main-msg {
    font-size: 0.92rem;
    color: #334155;
    margin: 0 0 0.9rem 0;
    line-height: 1.4;
}

.sf-compare-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.85rem;
}

.sf-box {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.sf-box-old {
    text-align: left;
}

.sf-box-new {
    text-align: right;
}

.sf-box-tag {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.15rem;
}

.sf-box-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

.sf-box-new .sf-box-val {
    color: #dc2626;
}

.sf-box-sub {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.sf-arrow {
    font-size: 1.25rem;
    color: #94a3b8;
    font-weight: 700;
    padding: 0 0.3rem;
}

.sf-impact-alert {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #fff1f2;
    border-left: 4px solid #e11d48;
    border-radius: 6px;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.85rem;
}

.sf-impact-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.sf-impact-text {
    font-size: 0.88rem;
    color: #9f1239;
    line-height: 1.35;
}

.sf-explanation {
    font-size: 0.8rem;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    line-height: 1.35;
}

