/* ============================================================
   ADMIN DA COMPUTER — stile di public/index.html (spec redesign §8, Fase D)
   Pannello admin, area capo, area superutente, timbratura web e display QR.
   Si carica DOPO /css/logplus.css e usa solo i suoi token per ruolo
   (surface, surface-alt, body, muted, brand, invert, hair, stati):
   chiaro e scuro arrivano da lì. Nessun colore scritto per nome, tranne
   il bianco fisso del riquadro del QR (si legge meglio, in ogni tema).
   Ogni coppia testo/fondo usata qui è misurata da scripts/contrasto.js.
   Le schermate non cambiano: stessi selettori di prima, solo l'aspetto.
   ============================================================ */

/* ---------- Ponte: i nomi di prima puntano ai token Logplus ----------
   Il markup e il JS di index.html citano ancora questi nomi negli style="";
   così cambiano colore senza toccare le schermate. */
:root {
  --sidebar-w: 200px;
  --primary: var(--brand);
  --secondary: var(--brand);
  --gradient: var(--brand);
  --bg: var(--surface-alt);
  --surface2: var(--surface-alt);
  --border: var(--hair);
  --text-primary: var(--body);
  --text: var(--body);
  --text1: var(--body);
  --text-secondary: var(--muted);
  --text2: var(--muted);
  --text-muted: var(--muted);
  --success: var(--stato-presente);
  --success-bg: var(--stato-presente-bg);
  --warning: var(--stato-ritardo);
  --warning-bg: var(--stato-ritardo-bg);
  --error: var(--stato-assente);
  --error-bg: var(--stato-assente-bg);
  --accent2: var(--stato-assente);
  --accent3: var(--stato-ferie);
  --accent4: var(--stato-ritardo);
  /* --mono era già un carattere senza grazie: resta tale. Le cifre usano --font-mono. */
  --mono: var(--font-sans);
  --sans: var(--font-sans);
  /* Voce attiva e riquadri informativi: brand su questo fondo (coppia misurata). */
  --attivo-bg: var(--stato-ferie-bg);
  --velo: rgba(0, 16, 32, .55);
}

/* ---------- Base ---------- */
body { background: var(--surface-alt); color: var(--body); font-family: var(--font-sans); line-height: 1.45; min-height: 100vh; }
h1, h2, h3, h4, h5 { font-family: var(--font-display); color: var(--body); }

.page { position: relative; z-index: 1; }

.view { display: none; min-height: 100vh; }
.view.active { display: flex; }

/* ---------- Login (admin, capo, superutente) ---------- */
#view-admin-login { align-items: center; justify-content: center; }
.login-box {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--raggio); padding: 48px 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--ombra);
}
.login-box .logo {
  font-size: 13px;
  color: var(--brand); letter-spacing: 2px;
  text-transform: uppercase; margin-bottom: 8px; font-weight: 700;
}
.login-box h1 { font-size: 28px; font-weight: 800; color: var(--body); margin-bottom: 32px; line-height: 1.2; }
.login-card {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--raggio); padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--ombra);
}
.login-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-title { font-family: var(--font-display); font-size: 24px; font-weight: 800; text-align: center; color: var(--body); }
.login-sub { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 24px; }

/* Login admin: testata navy con il marchio Logplus, corpo su surface (markup del Task 3). */
.ad-login-testa { background: var(--invert-deep); color: var(--on-invert); border-radius: 20px 20px 0 0; padding: 28px 32px 32px; text-align: center; }
.ad-login-testa h1 { color: var(--on-invert); }
.ad-login-corpo { background: var(--surface); border: 1px solid var(--hair); border-top: 0; border-radius: 0 0 20px 20px; padding: 28px 32px; box-shadow: var(--ombra); }
.ad-marchio { font-family: var(--font-display); font-weight: 800; letter-spacing: .3px; }
/* Il "+" arancio solo su fondo navy (spec §4.1: l'accento non va mai su chiaro). */
.ad-marchio::after { content: '+'; color: var(--accent); margin-left: 2px; }
.ad-login-marchio { font-size: 15px; color: var(--on-invert-muted); margin-bottom: 12px; }
/* I due campi hanno bordo e gestori onfocus/onblur scritti nel markup (restano, D4):
   qui il bordo dei controlli (≥ 3:1) e quello di focus vincono sui colori scritti a mano. */
#view-admin-login input { background: var(--surface); color: var(--body); border-color: var(--hair-strong) !important; }
#view-admin-login input:focus { border-color: var(--brand) !important; outline: 2px solid var(--brand) !important; outline-offset: 1px; }

/* ---------- Campi ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 700;
  letter-spacing: .5px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--hair-strong);
  border-radius: var(--raggio-piccolo); padding: 11px 14px; color: var(--body);
  font-family: inherit; font-size: 15px; transition: border-color .2s; outline: none;
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--attivo-bg);
}
/* Anello di focus da tastiera: solo quando si naviga a tastiera (non al clic del mouse). */
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .8; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 22px; border-radius: var(--raggio-piccolo); border: 1px solid transparent; cursor: pointer;
  font-family: var(--font-sans); font-weight: 700; font-size: 14px; letter-spacing: .2px;
  transition: background var(--durata) ease, border-color var(--durata) ease, color var(--durata) ease, transform var(--durata) ease;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); width: 100%; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--invert); border-color: var(--invert); color: var(--on-invert); }
.btn-secondary:hover { filter: brightness(1.15); }
.btn-ghost { background: var(--surface); color: var(--body); border-color: var(--hair-strong); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--stato-assente-bg); color: var(--stato-assente); border-color: var(--stato-assente); }
.btn-danger:hover { filter: brightness(.97); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }

.error-msg {
  background: var(--stato-assente-bg); border: 1px solid var(--stato-assente);
  color: var(--stato-assente); border-radius: var(--raggio-piccolo); padding: 10px 14px; font-size: 14px;
  margin-bottom: 16px; display: none;
}
.error-msg.show { display: block; }

/* ---------- Timbratura web (pagina "/") ---------- */
#view-timbratura { flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.timbra-card {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: 20px; padding: 40px 32px;
  width: 100%; max-width: 420px; text-align: center;
  box-shadow: var(--ombra);
}
.timbra-card .logo-mark {
  width: 64px; height: 64px; background: var(--invert-deep);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 28px;
}
.timbra-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.timbra-card .subtitle { font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.clock-display {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 40px; font-weight: 600; color: var(--brand);
  letter-spacing: 2px; margin-bottom: 28px; padding: 16px;
  background: var(--surface-alt); border-radius: 12px; border: 1px solid var(--hair);
}
.timbra-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-pausa { background: var(--stato-ritardo-bg); color: var(--stato-ritardo); border-color: var(--stato-ritardo); }
.btn-pausa:hover { filter: brightness(.97); }

.success-overlay { display: none; flex-direction: column; align-items: center; padding: 24px; }
.success-overlay.show { display: flex; }
.success-icon { font-size: 56px; margin-bottom: 16px; }
.success-tipo { font-size: 13px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 8px; }
.success-tipo.entrata { color: var(--stato-presente); }
.success-tipo.uscita { color: var(--stato-ferie); }
.success-tipo.pausa_inizio { color: var(--stato-ritardo); }
.success-tipo.pausa_fine { color: var(--stato-presente); }
.success-nome { font-family: var(--font-display); font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.success-ora { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 16px; color: var(--muted); }

/* ---------- Barra in alto (area capo e superutente) ---------- */
/* La barra in alto sta sopra il contenuto anche nelle aree capo e superutente
   (prima le due viste andavano in riga, barra e tabella affiancate). */
#view-dashboard, #view-capo, #view-superuser { flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--hair);
  padding: 0 24px; display: flex; align-items: center;
  height: 60px; gap: 16px; position: sticky; top: 0; z-index: 100;
}
.topbar-logo { font-family: var(--font-display); font-size: 14px; font-weight: 800; color: var(--brand); letter-spacing: .3px; white-space: nowrap; }
.nav-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-tab {
  padding: 7px 12px; border-radius: var(--raggio-piccolo); font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--muted); border: none; background: transparent;
  transition: background var(--durata) ease, color var(--durata) ease; white-space: nowrap;
}
.nav-tab.active, .nav-tab:hover { background: var(--attivo-bg); color: var(--brand); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

.dash-content { padding: 28px 24px; flex: 1; max-width: 1200px; margin: 0 auto; width: 100%; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Card numeriche ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--raggio); padding: 20px; box-shadow: var(--ombra); }
.stat-label { font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 32px; font-weight: 600; color: var(--brand); }
.stat-value.blue { color: var(--stato-ferie); }
.stat-value.orange { color: var(--stato-ritardo); }
.stat-value.red { color: var(--stato-assente); }

/* ---------- Tabelle ---------- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.section-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--body); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select {
  background: var(--surface); border: 1px solid var(--hair-strong);
  border-radius: var(--raggio-piccolo); padding: 8px 12px; color: var(--body);
  font-family: inherit; font-size: 14px; outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); }
.filters input:focus-visible, .filters select:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

.table-wrap { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--raggio); overflow: auto; box-shadow: var(--ombra); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead { background: var(--surface-alt); }
th { padding: 12px 16px; text-align: left; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
td { padding: 12px 16px; font-size: 14px; border-top: 1px solid var(--hair); color: var(--body); }
tr:hover td { background: var(--surface-alt); }

/* ---------- Etichette di stato (sempre con parola; colori = stati Logplus) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .2px;
  border: 1px solid transparent;
}
.badge-green { background: var(--stato-presente-bg); color: var(--stato-presente); }
.badge-blue { background: var(--stato-ferie-bg); color: var(--stato-ferie); }
.badge-orange { background: var(--stato-ritardo-bg); color: var(--stato-ritardo); }
.badge-red { background: var(--stato-assente-bg); color: var(--stato-assente); }
.badge-gray { background: var(--stato-uscito-bg); color: var(--stato-uscito); }
.badge-purple { background: var(--attivo-bg); color: var(--brand); }
/* Dentro una riga già tinta con lo stesso colore (es. anomalia non letta), il bordo
   rende l'etichetta un pillolo distinto invece di fondersi con lo sfondo della riga. */
tr .badge-orange { border-color: var(--stato-ritardo); }

/* ---------- Finestre (modali) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--velo);
  z-index: 200; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); color: var(--body); border: 1px solid var(--hair);
  border-radius: 20px; padding: 36px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 16, 32, .3); max-height: 90vh; overflow-y: auto;
}
.modal-card {
  background: var(--surface); color: var(--body); border: 1px solid var(--hair);
  border-radius: 20px; padding: 36px; width: 100%;
  box-shadow: 0 20px 60px rgba(0, 16, 32, .3); max-height: 90vh; overflow-y: auto;
}
.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.modal h3 { font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; margin-top: 20px; }
.modal-footer .btn { flex: 1; }

/* ---------- Dipendenti ---------- */
.add-form { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--raggio); padding: 24px; margin-bottom: 24px; display: none; box-shadow: var(--ombra); }
.add-form.show { display: block; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- Riepilogo ---------- */
.riepilogo-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.riepilogo-stat { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--raggio-piccolo); padding: 16px; text-align: center; box-shadow: var(--ombra); }
.riepilogo-stat .label { font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.riepilogo-stat .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; color: var(--brand); }

/* ---------- QR (scheda admin) ---------- */
#qr-img { border-radius: 12px; max-width: 220px; }
.qr-url {
  font-size: 13px; color: var(--brand); margin: 16px 0;
  word-break: break-all; padding: 8px; background: var(--attivo-bg);
  border-radius: var(--raggio-piccolo); border: 1px solid var(--hair);
}

/* ---------- Posizione GPS (timbratura web) ---------- */
.geo-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 1px;
  padding: 8px 12px; border-radius: var(--raggio-piccolo); margin-bottom: 14px;
  text-transform: uppercase;
}
.geo-status.off { display: none; }
.geo-status.checking { background: var(--stato-ritardo-bg); color: var(--stato-ritardo); }
.geo-status.ok { background: var(--stato-presente-bg); color: var(--stato-presente); }
.geo-status.error { background: var(--stato-assente-bg); color: var(--stato-assente); }
.geo-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: currentColor; }
.checking .geo-dot { animation: pulse 1s infinite; }

/* ---------- Interruttori ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--hair); }
.toggle-label { font-size: 15px; font-weight: 600; }
.toggle-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--hair-strong); border: 1px solid var(--hair-strong);
  border-radius: 24px; cursor: pointer; transition: var(--durata);
}
.toggle-slider:before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 2px; top: 2px; background: var(--surface); border-radius: 50%; transition: var(--durata); box-shadow: 0 1px 2px rgba(0, 16, 32, .25);
}
.toggle-switch input:checked + .toggle-slider { background: var(--brand); border-color: var(--brand); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); background: var(--on-brand); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--accent-text); outline-offset: 3px; }

/* ---------- Riquadri delle impostazioni ---------- */
.settings-box { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--raggio); padding: 24px; margin-bottom: 20px; box-shadow: var(--ombra); }
.settings-box h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.sub { font-size: 13px; color: var(--muted); }
.settings-box .sub { margin-bottom: 20px; }

/* ---------- Varie ---------- */
.empty-state { text-align: center; padding: 48px; color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; letter-spacing: .3px; padding: 0; }
.link-btn:hover { color: var(--brand); }
.pin-section { display: none; background: var(--surface-alt); border: 1px solid var(--hair); border-radius: var(--raggio-piccolo); padding: 20px; margin-top: 12px; text-align: left; }
.pin-section.show { display: block; }

/* ---------- Statistiche del dipendente (timbratura web) ---------- */
.stats-panel {
  background: var(--surface-alt); border: 1px solid var(--hair);
  border-radius: var(--raggio-piccolo); padding: 20px; margin-top: 12px;
  text-align: left; display: none;
}
.stats-panel.show { display: block; }
.stats-panel .month-sel { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.stats-panel .month-sel input { background: var(--surface); border: 1px solid var(--hair-strong); border-radius: 8px; padding: 6px 10px; color: var(--body); font-size: 14px; outline: none; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 16px; }
.mini-stat { background: var(--surface); border: 1px solid var(--hair); border-radius: 8px; padding: 12px; text-align: center; }
.mini-stat .lbl { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.mini-stat .val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; color: var(--brand); }
.richieste-list { font-size: 13px; }
.richiesta-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--hair); gap: 8px; flex-wrap: wrap; }
.richiesta-item:last-child { border-bottom: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .2s ease forwards; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.live-dot { display: inline-block; width: 6px; height: 6px; background: var(--stato-presente); border-radius: 50%; margin-right: 6px; animation: pulse 1.5s infinite; }

@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .nav-tab span { display: none; }
  .topbar-logo { font-size: 11px; }
  .timbra-btns { grid-template-columns: 1fr; }
  .modal { padding: 24px; }
}

/* ---------- Attesa del GPS ---------- */
.gps-loading {
  display: none; position: fixed; inset: 0;
  background: var(--invert-deep); z-index: 500;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
}
.gps-loading.show { display: flex; }
.gps-spinner {
  width: 48px; height: 48px; border: 3px solid var(--invert);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gps-loading-text { font-size: 14px; font-weight: 700; color: var(--on-invert); letter-spacing: 2px; }
.gps-loading-sub { font-size: 13px; color: var(--on-invert-muted); }

/* ---------- Barra laterale dell'admin ---------- */
#view-dashboard.active { display: block; }
.admin-nav-btn { font-family: var(--font-sans); }
@media (max-width: 767px) {
  #admin-sidebar { transform: translateX(-100%); transition: transform .3s; }
  #admin-main { margin-left: 0 !important; }
  #admin-hamburger { display: flex !important; }
  #admin-tab-content { padding: 16px !important; }
}
@media (min-width: 768px) {
  #admin-hamburger { display: none !important; }
  #admin-sidebar-overlay { display: none !important; }
  #admin-sidebar { transform: translateX(0) !important; }
}

/* ---------- Movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  .live-dot, .checking .geo-dot, .gps-spinner { animation: none; }
}

/* ---------- Display QR (schermo da parete o da banco, si guarda da lontano) ----------
   Testata navy con il marchio, orologio grande, QR grande su riquadro SEMPRE bianco
   (nero su bianco in ogni tema: così lo legge ogni telefono), conto alla rovescia ed
   errore ben visibili. Il JS del display (token, rotazione, chiave, nuovi tentativi) non cambia. */
#view-qr-display {
  flex-direction: column; align-items: stretch; justify-content: flex-start;
  background: var(--surface-alt); min-height: 100dvh; width: 100%;
  user-select: none; -webkit-user-select: none;
}
.qr-display-testata {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--invert-deep); color: var(--on-invert);
  padding: clamp(12px, 2.2vh, 24px) clamp(16px, 3vw, 48px);
}
.qr-display-testata .ad-marchio { font-size: clamp(20px, 3.2vh, 34px); color: var(--on-invert); }
.qr-display-testata__titolo { font-family: var(--font-display); font-size: clamp(16px, 2.6vh, 28px); font-weight: 600; color: var(--on-invert-muted); }
.qr-display-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(12px, 2.4vh, 28px); padding: clamp(16px, 3vh, 40px) clamp(12px, 3vw, 32px);
  text-align: center; width: 100%;
}
.qr-display-title {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600;
  font-size: clamp(22px, 4.6vh, 52px); letter-spacing: .5px; color: var(--body);
}
.qr-display-img-wrap {
  background: #FFFFFF; border: 1px solid var(--hair); border-radius: clamp(12px, 2vh, 24px);
  padding: clamp(12px, 2vh, 24px); box-shadow: var(--ombra);
}
.qr-display-img-wrap img {
  display: block;
  width: min(80vw, 56vh, 640px);
  height: min(80vw, 56vh, 640px);
  image-rendering: pixelated;
}
/* Senza QR (in caricamento, o dopo un errore: il JS toglie src) niente riquadro bianco vuoto. */
.qr-display-img-wrap:has(> img:not([src]), > img[src=""]) { display: none; }
.qr-display-countdown {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600;
  font-size: clamp(16px, 2.8vh, 30px);
  padding: clamp(8px, 1.2vh, 14px) clamp(20px, 3vw, 40px); border-radius: 999px;
  background: var(--attivo-bg); color: var(--brand);
  transition: color var(--durata), background var(--durata);
}
.qr-display-countdown.warn { color: var(--stato-ritardo); background: var(--stato-ritardo-bg); }
.qr-display-hint { font-size: clamp(16px, 2.6vh, 28px); font-weight: 600; color: var(--muted); }
.qr-display-error {
  color: var(--stato-assente); background: var(--stato-assente-bg); border: 2px solid var(--stato-assente);
  font-size: clamp(18px, 3vh, 32px); font-weight: 700; line-height: 1.35;
  padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 32px); max-width: min(90vw, 900px);
  border-radius: var(--raggio);
}
/* Telefono o tablet in orizzontale, poco alto: QR a sinistra, il resto accanto. */
@media (orientation: landscape) and (max-height: 500px) {
  .qr-display-card { flex-direction: row; flex-wrap: wrap; gap: 16px; }
  .qr-display-title { width: 100%; }
  .qr-display-img-wrap img { width: min(55vh, 45vw, 280px); height: min(55vh, 45vw, 280px); }
}
@media (prefers-reduced-motion: reduce) {
  .qr-display-countdown { transition: none; }
}
