/* ==========================================================================
   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 {
    max-width: 720px;
    margin: 1.5rem auto 0;
    /* 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;
}

.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: 12px;
    padding: 1rem 1.25rem;
    margin: 0 1.5rem 1rem;
    border: 2px solid;
    font-weight: 600;
}
.boycott-ok {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}
.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-ok-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-ok .boycott-cta {
    color: #155724;
}

/* --- 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.5rem 1rem 5rem;
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.6px;
}

.page-footer .version {
    font-weight: 700;
}

/* --- 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);
}

/* --- 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: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem 1rem;
}

.auth-card {
    background: #fff;
    padding: 1.75rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 1.4rem;
    margin: 0 0 0.25rem 0;
    color: #2c3e50;
}

.auth-card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 1.25rem 0;
}

.auth-footer {
    margin: 1.25rem 0 0 0;
    text-align: center;
    font-size: 0.88rem;
    color: var(--muted);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

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


/* --- 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);
}

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;
}
