/* Verifeed 3.0 — veste grafica. Nessuna dipendenza esterna: solo CSS e font di sistema. */

:root {
  color-scheme: light dark;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e6ee;
  --border-strong: #cfd5e1;
  --text: #182033;
  --muted: #667085;
  --primary: #2459d6;
  --primary-hover: #1b47ad;
  --primary-soft: #e8efff;
  --on-primary: #ffffff;

  --ok: #137a45;       --ok-bg: #e4f5ec;
  --warn: #8f5a00;     --warn-bg: #fdf2d9;
  --danger: #b42318;   --danger-bg: #fdeceb;
  --neutral: #475467;  --neutral-bg: #eceff4;

  --sidebar: #0e1a2e;
  --sidebar-text: #b9c6dc;
  --sidebar-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, .07);
  --sidebar-active: rgba(91, 141, 239, .22);

  --logo-punti: #000000;
  --logo-testo: #152934;
  --logo-tratto: #0099ff;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b111b;
    --surface: #131c2a;
    --surface-2: #172233;
    --border: #243247;
    --border-strong: #324560;
    --text: #e6ebf3;
    --muted: #94a3b8;
    --primary: #5b8def;
    --primary-hover: #7aa3f5;
    --primary-soft: #1a2b4a;
    --on-primary: #0b111b;

    --ok: #5fd39a;       --ok-bg: #12301f;
    --warn: #f0c36d;     --warn-bg: #33270b;
    --danger: #f59a92;   --danger-bg: #3a1714;
    --neutral: #aab4c4;  --neutral-bg: #1f2a3b;

    --logo-punti: #e6ebf3;
    --logo-testo: #e6ebf3;
    --logo-tratto: #19a4ff;

    --sidebar: #09101a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Struttura dell'applicazione ---------- */

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 24px; color: var(--sidebar-strong); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; font-size: .72rem; color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 0 6px; margin-left: 2px; }
.logo-completo { display: block; height: 26px; width: auto; flex: none; }
.logo-punti { fill: var(--logo-punti); }
.logo-testo { fill: var(--logo-testo); }
.logo-tratto { fill: var(--logo-tratto); }
/* Il menu laterale è sempre scuro: logo chiaro in entrambi i temi. */
.sidebar { --logo-punti: #ffffff; --logo-testo: #ffffff; --logo-tratto: #19a4ff; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-strong); }

.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.utente { padding: 0 10px 10px; }
.utente strong { display: block; color: var(--sidebar-strong); font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utente span { display: block; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer form { margin: 0; }
.sidebar-footer .nav a, .sidebar-footer button.voce {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 12px; border: 0; border-radius: 8px; background: none;
  color: var(--sidebar-text); font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.sidebar-footer button.voce:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); }

.main { min-width: 0; padding: 28px 36px 56px; }
.container { max-width: 1120px; margin: 0 auto; }
.container.stretta { max-width: 680px; margin-left: 0; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header .sopra { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.page-header .azioni { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Schede ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); font-size: .85rem; color: var(--muted); }

/* ---------- Riepilogo (dashboard) ---------- */

.riepilogo { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tessera { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-left-width: 4px; }
.tessera .numero { font-size: 1.9rem; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.tessera .etichetta { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.tessera.ok { border-left-color: var(--ok); }
.tessera.warn { border-left-color: var(--warn); }
.tessera.danger { border-left-color: var(--danger); }
.tessera.neutral { border-left-color: var(--border-strong); }

/* ---------- Tabelle ---------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td .sub { display: block; font-size: .82rem; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .azioni-riga { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table .nome { font-weight: 600; }

dl.kv { display: grid; grid-template-columns: 190px 1fr; margin: 0; }
dl.kv dt, dl.kv dd { margin: 0; padding: 12px 20px; border-bottom: 1px solid var(--border); }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dt:last-of-type, dl.kv dd:last-of-type { border-bottom: 0; }

.solo-mobile { display: none; }

/* ---------- Badge ---------- */

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }

/* ---------- Pulsanti ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.3; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--on-primary);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; color: var(--on-primary); }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
form.inline { display: inline; margin: 0; }

/* ---------- Moduli ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .field select, .field textarea {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.field .help { color: var(--muted); font-size: .84rem; margin: 6px 0 0; }
.field .help ul { margin: 4px 0 0; padding-left: 18px; }
.field .error, .errore-form { color: var(--danger); font-size: .86rem; margin: 6px 0 0; }
.field.ha-errore input, .field.ha-errore select, .field.ha-errore textarea { border-color: var(--danger); }
.errore-form { background: var(--danger-bg); border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; font-size: .92rem; }
.form-azioni { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

.spunta { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-weight: 500; font-size: .92rem; cursor: pointer; }
.spunta input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

/* ---------- Avvisi ---------- */

.alert { display: flex; gap: 10px; padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; border: 1px solid transparent; font-size: .93rem; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--primary-soft); color: var(--primary); }

.vuoto { text-align: center; padding: 44px 20px; color: var(--muted); }
.vuoto .ico { width: 34px; height: 34px; margin-bottom: 10px; opacity: .6; }
.vuoto strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Segreti (token, password, codici) ---------- */

.segreto { display: flex; gap: 10px; align-items: stretch; }
.segreto code { flex: 1; word-break: break-all; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; user-select: all; font-size: .95rem; }
.codici { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; list-style: none; margin: 0 0 16px; padding: 0; }
.codici li { font-family: var(--mono); padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; text-align: center; letter-spacing: .04em; }
.qr { width: 250px; padding: 10px; background: #fff; border-radius: 10px; border: 1px solid var(--border); margin: 4px 0 14px; }
.qr svg { display: block; width: 100%; height: auto; }

.comandi { margin: 0 0 12px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: .82rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Pagine di accesso ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px;
  background: radial-gradient(900px 500px at 15% -10%, var(--primary-soft), transparent 60%), var(--bg); }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 26px; }
.auth-brand .logo-completo { height: 42px; }
.auth-box .card-body { padding: 28px; }
.auth-box h1 { font-size: 1.25rem; margin-bottom: 6px; }
.auth-box .sotto { color: var(--muted); margin-bottom: 20px; font-size: .93rem; }
.auth-piede { text-align: center; margin-top: 16px; font-size: .88rem; color: var(--muted); }
.auth-box .alert { margin-bottom: 14px; }

/* ---------- Schermi piccoli ---------- */

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; }
  .brand { padding: 0 10px 0 4px; }
  .logo-completo { height: 22px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 7px 10px; }
  .sidebar-footer { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 4px; }
  .utente { display: none; }
  .main { padding: 20px 16px 40px; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { border-bottom: 0; padding-bottom: 0; }
  .riepilogo { grid-template-columns: repeat(2, 1fr); }
  .nascondi-mobile { display: none; }
  .solo-mobile { display: block; }
  .table th, .table td { padding-left: 14px; padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
