/* ===== Font per il marchio (elegante, maiuscoletto) ===== */
@import url('fonts/fonts.css');

/* ===== Base ===== */
* { box-sizing: border-box; }
:root {
    --gold: #cf9a3d;
    --gold-light: #f0c264;
    --gold-dark: #9c7124;
    --silver: #c9ccd1;
    --silver-light: #e8eaee;
    --bg: #0b0c0f;
    --bg-alt: #111318;
    --card-bg: rgba(21, 23, 28, 0.86);
    --card-bg-alt: rgba(27, 30, 36, 0.92);
    --text: #f2ede2;
    --muted: #9b968d;
    --border: rgba(255, 255, 255, 0.08);
    --border-gold: rgba(207, 154, 61, 0.45);
    --primary: #cf9a3d;
    --danger: #e35353;
    --success: #34c76f;
}
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
}
body {
    background: transparent;
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    min-height: 100vh;
}
body { display: flex; flex-direction: column; }
/* Sfondo di tutto il software: immagine fissa a tutto schermo con velo scuro per la leggibilità
   (livello fisso invece di background-attachment, che su iPhone non funziona) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(8, 9, 12, 0.78), rgba(8, 9, 12, 0.88)),
        url('img/sfondo.jpg') center / cover no-repeat;
    pointer-events: none;
}
/* Nelle pagine di accesso l'immagine resta più visibile */
body.auth-bg::before {
    background:
        radial-gradient(ellipse at center, rgba(8, 9, 12, 0.55), rgba(8, 9, 12, 0.80)),
        url('img/sfondo.jpg') center / cover no-repeat;
}
a { color: var(--gold-light); }
/* Titoli di pagina: piccoli, in maiuscoletto Cinzel e grigio (uguali in tutto il software) */
h1 {
    font-size: 0.95rem;
    margin: 0;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    letter-spacing: 0.08em;
    color: var(--muted);
}
h2 { font-size: 1.15rem; margin: 28px 0 12px; color: var(--gold-light); }
.muted { color: var(--muted); font-weight: 400; }

/* ===== Logo ===== */
/* Marchio quadrato (solo simbolo) */
.logo-mark {
    display: block;
    width: 32px;
    height: 32px;
    flex: none;
    object-fit: contain;
}
.logo-mark-lg { width: 64px; height: 64px; }

/* Lockup orizzontale: simbolo + wordmark (500x120) */
.logo-lockup {
    display: block;
    height: 28px;
    width: auto;
    max-width: 100%;
    flex: none;
    object-fit: contain;
}
.logo-lockup-lg { height: 52px; }

@media (max-width: 480px) {
    .logo-lockup { height: 24px; }
    .logo-lockup-lg { height: 40px; }
}

/* ===== Barra superiore ===== */
.topbar {
    background: linear-gradient(180deg, rgba(17, 19, 24, 0.92), rgba(11, 12, 15, 0.82));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text);
    border-bottom: 1px solid var(--border-gold);
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--gold-light);
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
}
.brand:hover { opacity: 0.85; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.92rem;
}
.nav-icon { display: none; font-size: 1rem; }
.topbar nav a:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.topbar nav a.active { background: rgba(207, 154, 61, 0.14); color: var(--gold-light); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 10px; }

/* ===== Layout ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 48px;
    width: 100%;
    flex: 1;
}
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.footer {
    text-align: center;
    padding: 16px;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}
.footer-powered {
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
    opacity: 0.75;
    transition: opacity 0.2s, transform 0.2s;
}
.footer-powered:hover,
.footer-powered:focus-visible { opacity: 1; transform: scale(1.12); }
.footer-powered img { display: block; width: 20px; height: 20px; }

/* ===== Schede ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.card-gold {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold), 0 8px 24px rgba(207, 154, 61, 0.10);
    background: linear-gradient(160deg, rgba(207, 154, 61, 0.10), var(--card-bg) 65%);
}
.card-silver {
    border-color: var(--silver);
    box-shadow: 0 0 0 1px rgba(201, 204, 209, 0.5), 0 8px 24px rgba(255, 255, 255, 0.04);
    background: linear-gradient(160deg, rgba(201, 204, 209, 0.08), var(--card-bg) 65%);
}
.card-platinum {
    border-color: #b9d3e6;
    box-shadow: 0 0 0 1px rgba(185, 211, 230, 0.55), 0 8px 24px rgba(185, 211, 230, 0.06);
    background: linear-gradient(160deg, rgba(185, 211, 230, 0.10), var(--card-bg) 65%);
}
.card-palladium {
    border-color: #8f99a8;
    box-shadow: 0 0 0 1px rgba(143, 153, 168, 0.55), 0 8px 24px rgba(143, 153, 168, 0.06);
    background: linear-gradient(160deg, rgba(143, 153, 168, 0.12), var(--card-bg) 65%);
}
.card-title { font-weight: 700; margin-bottom: 12px; }
.card.placeholder { color: var(--muted); text-align: center; padding: 32px; }
.chart-card canvas { max-width: 100%; }

.quote-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px dashed var(--border);
}
.quote-row:first-of-type { border-top: 0; }
.qlabel { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.qvals { display: flex; gap: 14px; }
.qv { font-variant-numeric: tabular-nums; font-weight: 600; }
.qv small { color: var(--muted); font-weight: 400; margin-right: 2px; }
.quote-main .qv { font-size: 1.4rem; }
.quote-delta { padding: 4px 0 2px; }

.delta {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}
.delta-pos, .delta.delta-pos { color: var(--success); border-color: rgba(52, 199, 111, 0.4); }
.delta-neg, .delta.delta-neg { color: var(--danger); border-color: rgba(227, 83, 83, 0.4); }
.delta-zero, .delta.delta-zero { color: var(--muted); }

/* ===== Stato aggiornamento ===== */
.refresh-info { display: flex; align-items: center; gap: 8px; }
.dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.dot-ok   { background: #22c55e; }
.dot-warn { background: #f59e0b; }
.dot-err  { background: #ef4444; }
.dot-wait { background: #6b7280; }

/* ===== Tabelle ===== */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.table th, .table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.table thead th {
    background: var(--card-bg-alt);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gold-light);
}
.table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ===== Moduli ===== */
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 0.9rem; color: var(--text); }
input[type="text"], input[type="password"], select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--card-bg-alt);
    color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.filters {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px 16px;
    margin-bottom: 20px;
}
.filters label { margin: 0; }
.filters select { width: auto; min-width: 140px; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.15); }
.btn-primary {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: #1a1207;
    border-color: transparent;
}
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-small { padding: 5px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 18px; }

/* ===== Messaggi ===== */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    border: 1px solid transparent;
}
.alert-error   { background: rgba(227, 83, 83, 0.14); color: #ffb4b4; border-color: rgba(227, 83, 83, 0.35); }
.alert-success { background: rgba(52, 199, 111, 0.14); color: #9df0bb; border-color: rgba(52, 199, 111, 0.35); }
.alert-info    { background: rgba(94, 170, 255, 0.14); color: #a9d1ff; border-color: rgba(94, 170, 255, 0.35); }

/* ===== Pagina di accesso ===== */
.auth-card {
    max-width: 380px;
    margin: 8vh auto 0;
    background: var(--card-bg);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 80px rgba(207, 154, 61, 0.08);
    text-align: center;
}
.auth-card form { text-align: left; }
.auth-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; }

/* ===== Colonne pagina utenti ===== */
.columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
    margin-top: 16px;
}

/* ===== Badge stato / ruolo ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    vertical-align: middle;
}
.badge-admin   { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.badge-active  { background: rgba(52, 199, 111, 0.18); color: #9df0bb; }
.badge-blocked { background: rgba(227, 83, 83, 0.18); color: #ffb4b4; }

/* ===== Azioni tabella utenti ===== */
.actions { white-space: nowrap; }
.actions form { display: inline-block; margin: 0 0 0 4px; }
.btn-warn { background: #f59e0b; color: #1a1207; border-color: transparent; }

/* ===== Form ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
}
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.sep { border: 0; border-top: 1px dashed var(--border); margin: 18px 0 4px; }

/* ===== Tabella profilo ===== */
.table-plain { border: 0; }
.table-plain th {
    width: 40%;
    color: var(--muted);
    font-weight: 600;
    background: transparent;
}

/* ===== Collegamenti al sito ufficiale ===== */
.quicklinks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 4px;
}
.quicklink {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.quicklink:hover { border-color: var(--gold); transform: translateY(-2px); }
.quicklink-icon { font-size: 1.6rem; }
.quicklink-title { font-weight: 700; color: var(--gold-light); }
.quicklink-desc { color: var(--muted); font-size: 0.85rem; }
.quicklink-arrow { margin-top: auto; color: var(--gold); font-weight: 700; }

.company-card {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: stretch;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-top: 16px;
}
.company-text { flex: 1 1 240px; min-width: 220px; }
.company-text h3 {
    font-family: 'Cinzel', Georgia, serif;
    color: var(--gold-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px;
    font-size: 1.1rem;
}
.company-text p { color: var(--muted); margin: 0 0 10px; font-size: 0.9rem; line-height: 1.5; }
.company-photos {
    flex: 1 1 320px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.company-photos img {
    width: 100%;
    height: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
}


/* ===== Pagina Contattaci ===== */
.contact-intro { margin: -4px 0 18px; }
.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.contact-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 16px 18px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.contact-tile:hover, .contact-tile:focus-visible { border-color: var(--gold); transform: translateY(-2px); }
.contact-ico {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 8px;
    border-radius: 50%;
    border: 1px solid var(--border-gold);
    background: radial-gradient(circle at 30% 30%, rgba(240, 194, 100, 0.22), rgba(207, 154, 61, 0.06));
}
.contact-ico svg { width: 24px; height: 24px; fill: var(--gold-light); }
.contact-label {
    font-family: 'Cinzel', Georgia, serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    color: var(--gold);
}
.contact-value { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.contact-hint { color: var(--muted); font-size: 0.8rem; }

.location-card {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 2fr;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.location-info { padding: 22px; display: flex; flex-direction: column; }
.location-info h3 {
    font-family: 'Cinzel', Georgia, serif;
    color: var(--gold-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px;
    font-size: 1.05rem;
}
.location-address { margin: 0 0 16px; line-height: 1.55; font-size: 1rem; }
.location-hours { margin: 0 0 20px; font-size: 0.88rem; }
.location-hours dt { color: var(--gold); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.location-hours dd { margin: 2px 0 12px; color: var(--muted); }
.location-btn { margin-top: auto; align-self: flex-start; text-decoration: none; }
.location-map { min-height: 340px; border-left: 1px solid var(--border); }
.location-map iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 340px;
    border: 0;
    /* Mappa in tonalità scura, in linea con il resto dell'app */
    filter: invert(0.9) hue-rotate(180deg) saturate(0.6) brightness(0.95);
}

.social-row { display: flex; flex-wrap: wrap; gap: 14px; }
.social-link {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.social-link svg {
    flex: none;
    width: 42px;
    height: 42px;
    padding: 9px;
    border-radius: 12px;
    fill: #fff;
}
.social-facebook svg { background: #1877f2; }
.social-instagram svg { background: linear-gradient(45deg, #f9ce34, #ee2a7b 50%, #6228d7); }
.social-link span { display: flex; flex-direction: column; }
.social-link small { color: var(--muted); font-size: 0.82rem; }
.social-link:hover, .social-link:focus-visible { border-color: var(--gold); transform: translateY(-2px); }

@media (max-width: 700px) {
    /* Su cellulare riquadri compatti: icona a sinistra, testo a destra */
    .contact-grid { gap: 10px; }
    .contact-tile {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 14px;
        row-gap: 1px;
        text-align: left;
        padding: 14px 16px;
    }
    .contact-ico { grid-row: 1 / span 3; margin: 0; width: 46px; height: 46px; align-self: center; }
    .location-card { grid-template-columns: 1fr; }
    .location-map { border-left: 0; border-top: 1px solid var(--border); min-height: 280px; }
    .location-map iframe { min-height: 280px; }
    .location-btn { align-self: stretch; text-align: center; }
}

/* ===== Nav inferiore su mobile (come nel mockup) ===== */
/* ===== Link secondari delle pagine di accesso ===== */
.auth-forgot { text-align: right; margin-top: 8px; font-size: 0.85rem; }
.auth-forgot a, .auth-alt a { color: var(--gold-light); text-decoration: none; }
.auth-forgot a:hover, .auth-alt a:hover { text-decoration: underline; }
.auth-alt {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
}
.auth-card-wide { max-width: 520px; }
.auth-card h1 { margin-bottom: 8px; }
.auth-card .auth-intro { color: var(--muted); font-size: 0.9rem; margin: 0 0 18px; }
.badge-pending { background: rgba(240, 194, 100, 0.18); color: var(--gold-light); }

/* ===== Impostazioni email (profilo amministratore) ===== */
.mail-settings { margin-top: 16px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); }
label.check input { width: auto; margin: 0; }

/* ===== Barra superiore: logo grande e centrato sopra il menù ===== */
.topbar-inner { justify-content: space-between; row-gap: 6px; }
.topbar .brand { flex: 1 0 100%; justify-content: center; padding: 6px 0 2px; }
.topbar .logo-lockup { height: 56px; }
@media (max-width: 700px) {
    .topbar-inner { position: relative; }
    .topbar .logo-lockup { height: 42px; }
    /* Su mobile resta solo il pulsante Esci, a destra del logo centrato */
    .userbox { position: absolute; right: 16px; top: 0; bottom: 0; }
    .userbox .username { display: none; }
}


/* ===== Grafico storico interattivo ===== */
.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.chart-head .card-title { margin: 0; }
.chart-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chart-tools .btn { min-width: 34px; }
.chart-tools .btn:disabled { opacity: 0.4; cursor: default; }
.btn-live.active { border-color: var(--success); color: #9df0bb; background: rgba(52, 199, 111, 0.12); }
.live-status { font-size: 0.8rem; color: var(--muted); margin-right: 4px; }
.live-status::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 1px;
    background: var(--muted);
}
.live-ok::before   { background: var(--success); animation: livePulse 2s infinite; }
.live-warn::before { background: var(--gold-light); }
.live-err::before  { background: var(--danger); }
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(52, 199, 111, 0.6); }
    70%  { box-shadow: 0 0 0 7px rgba(52, 199, 111, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 199, 111, 0); }
}
.chart-wrap { position: relative; }
.chart-wrap canvas { display: block; cursor: crosshair; touch-action: pan-y; }
.chart-wrap canvas.dragging { cursor: grabbing; }
.chart-tooltip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    min-width: 190px;
    padding: 10px 12px;
    background: rgba(11, 12, 15, 0.94);
    border: 1px solid var(--border-gold);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-size: 0.82rem;
}
.chart-tooltip .tt-date { color: var(--gold-light); font-weight: 600; margin-bottom: 6px; }
.chart-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; line-height: 1.6; }
.chart-tooltip .tt-row > span:first-child { color: var(--muted); }
.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: var(--muted);
}
.chart-empty[hidden] { display: none; }
.chart-hint { font-size: 0.78rem; margin: 10px 0 0; }
.touch-only { display: none; }
@media (hover: none) { .touch-only { display: inline; } .hint-mouse { display: none; } }
@media (max-width: 600px) {
    .chart-tools { width: 100%; }
    .chart-tools .live-status { flex: 1 0 100%; margin-bottom: 4px; }
    .chart-tools .btn-live { margin-right: auto; }
}
.row-new td { animation: rowFlash 2.5s ease-out; }
@keyframes rowFlash { from { background: rgba(207, 154, 61, 0.22); } to { background: transparent; } }

/* ===== Riquadri semitrasparenti sopra l'immagine di sfondo ===== */
.card, .auth-card, .table-wrap, .filters, .quicklink, .company-card,
.contact-tile, .location-card, .social-link {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}


/* Primo sottotitolo subito sotto il titolo di pagina */
.page-head + h2 { margin-top: 0; }

/* ===== Menù a tendina su mobile ===== */
.menu-toggle { display: none; }
@media (max-width: 700px) {
    /* Barra in alto sempre visibile; niente backdrop-filter sulla barra, altrimenti
       diventerebbe il riferimento degli elementi "fixed" e sposterebbe i contenuti */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 60;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(11, 12, 15, 0.94);
    }
    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 36px;
        padding: 0 9px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--border);
        border-radius: 8px;
        cursor: pointer;
    }
    .menu-toggle span {
        display: block;
        height: 2px;
        border-radius: 2px;
        background: var(--gold-light);
        transition: transform 0.25s ease, opacity 0.2s ease;
    }
    /* Le tre linee diventano una X quando il menù è aperto */
    .menu-open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
    .menu-open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    .topbar nav {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        flex-direction: column;
        gap: 2px;
        padding: 8px 12px 14px;
        background: #0f1014;
        border-bottom: 1px solid var(--border-gold);
        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
    }
    .menu-open nav {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
    }
    .topbar nav a {
        font-size: 1rem;
        padding: 12px 14px;
        border-radius: 10px;
        gap: 12px;
    }
    .nav-icon { display: inline-block; width: 1.4em; text-align: center; font-size: 1.1rem; }
    /* Velo scuro sul resto della pagina quando il menù è aperto */
    .menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(0, 0, 0, 0.5);
    }
}

/* ===== Notifiche amministratore: campanella, badge, pannello e avvisi ===== */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}
.nav-badge[hidden] { display: none; }
.notif { position: relative; }
.notif-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
}
.notif-btn:hover, .notif-btn[aria-expanded="true"] { color: var(--gold-light); border-color: var(--border-gold); }
.notif-btn.has-pending { color: var(--gold-light); }
.notif-btn.has-pending svg { animation: bellRing 1.2s ease-in-out 2; transform-origin: 50% 10%; }
.notif-btn .nav-badge { position: absolute; top: -7px; right: -8px; margin: 0; }
@keyframes bellRing {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(14deg); }
    40% { transform: rotate(-12deg); }
    60% { transform: rotate(8deg); }
    80% { transform: rotate(-4deg); }
}
.notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 70;
    width: 320px;
    padding: 14px;
    background: #0f1014;
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}
.notif-panel[hidden] { display: none; }
.notif-head { font-weight: 700; color: var(--gold-light); margin-bottom: 8px; }
.notif-list { list-style: none; margin: 0 0 12px; padding: 0; max-height: 300px; overflow-y: auto; }
.notif-item a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}
.notif-item a:hover { background: rgba(207, 154, 61, 0.10); }
.notif-sub, .notif-time { font-size: 0.8rem; color: var(--muted); }
.notif-time { font-size: 0.75rem; }
.notif-empty { color: var(--muted); font-size: 0.88rem; padding: 6px 10px; }
.notif-go { display: block; text-align: center; }
.notif-device { margin-top: 10px; }
.notif-device .btn { width: 100%; }
.notif-state { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }
.notif-state:empty { display: none; }

.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: #0f1014;
    border: 1px solid var(--gold);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 24px rgba(207, 154, 61, 0.15);
    animation: toastIn 0.3s ease-out;
}
.toast-out { opacity: 0; transform: translateX(20px); transition: opacity 0.25s, transform 0.25s; }
.toast-icon { font-size: 1.3rem; line-height: 1.2; }
.toast-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast-text strong { color: var(--gold-light); }
.toast-text span { overflow-wrap: anywhere; }
.toast-sub { font-size: 0.8rem; color: var(--muted); }
.toast-actions { display: flex; align-items: center; gap: 6px; }
.toast-close {
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}
.toast-close:hover { color: var(--text); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

@media (max-width: 700px) {
    .topbar .logo-lockup { height: 38px; }
    .userbox { gap: 8px; }
    /* Il pannello occupa quasi tutta la larghezza dello schermo */
    .notif-panel { position: fixed; top: 64px; left: 12px; right: 12px; width: auto; }
    /* Campanella a sinistra, accanto al pulsante del menù, per non coprire il logo */
    .notif { position: absolute; left: 64px; top: 0; bottom: 0; display: flex; align-items: center; }
    .toast-stack { top: auto; bottom: 16px; right: 16px; }
}

/* La barra in alto (con pannello notifiche e menù) deve stare sopra ai riquadri della pagina,
   che con il backdrop-filter creano propri livelli */
@media (min-width: 701px) {
    .topbar { position: relative; z-index: 60; }
    .notif { margin-right: -12px; }
    /* Gli avvisi compaiono sotto la barra, senza coprire la campanella */
    .toast-stack { top: 140px; }
}
