/* Controllo Accessi - tema scuro editoriale. Nessuna dipendenza esterna. */
:root {
  --bg: #0f1013;
  --bg-2: #15171b;
  --bg-3: #1c1f25;
  --line: #2a2e36;
  --line-2: #363b45;
  --text: #ecebe6;
  --text-2: #a9aab0;
  --text-3: #6f7178;
  --accent: #e8b84a;
  --ok: #3ccf7a;
  --warn: #f2b84b;
  --bad: #ef5a5a;
  --info: #5aa8ef;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Georgia", "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; margin-top: 1.4em; }
h3 { font-size: 15px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
p { margin: 0 0 1em; }
code { background: var(--bg-3); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 20px; }
.mb { margin-bottom: 20px; }

/* ---------- Layout app ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 16px; }
.brand img { height: 28px; width: auto; }
.brand:hover { text-decoration: none; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 14px; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line-2); color: var(--text); border-radius: 8px; width: 38px; height: 38px; font-size: 18px; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 56px); }
.sidenav { background: var(--bg-2); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 56px; height: calc(100vh - 56px); }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-size: 14px; }
.sidenav a:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.sidenav a.active { background: var(--bg-3); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.sidenav-foot { margin-top: auto; padding: 12px; font-size: 12px; }
.main { padding: 28px 32px 60px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-2); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: none; position: fixed; top: 56px; left: 0; right: 0; height: auto; z-index: 30; border-bottom: 1px solid var(--line); }
  .sidenav.open { display: flex; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar-user span { display: none; }
  .main { padding: 18px 16px 60px; }
  h1 { font-size: 22px; }
}

/* ---------- Card, griglie, tiles ---------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card h2:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 700px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .n { font-size: 28px; font-weight: 600; line-height: 1.1; }
.tile .l { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.tile.ok .n { color: var(--ok); } .tile.warn .n { color: var(--warn); } .tile.bad .n { color: var(--bad); } .tile.accent .n { color: var(--accent); }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--text-2); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: var(--bg-3); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-3); }

/* ---------- Badge ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(60,207,122,.4); background: rgba(60,207,122,.08); }
.badge.warn { color: var(--warn); border-color: rgba(242,184,75,.4); background: rgba(242,184,75,.08); }
.badge.bad { color: var(--bad); border-color: rgba(239,90,90,.4); background: rgba(239,90,90,.08); }
.badge.info { color: var(--info); border-color: rgba(90,168,239,.4); background: rgba(90,168,239,.08); }
.badge.muted { color: var(--text-3); }

/* ---------- Form ---------- */
label { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 14px; }
label > input, label > select, label > textarea { margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], input[type=date], input[type=datetime-local], input[type=url], input[type=color], input:not([type]), select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 15px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,184,74,.15); }
textarea { min-height: 120px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type=color] { padding: 2px; height: 40px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: -2px; margin-right: 6px; }
label.check { display: flex; align-items: center; gap: 4px; color: var(--text); }
.help { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
form.inline { display: inline; }
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input, .search-bar select { width: auto; min-width: 200px; flex: 1; }

/* ---------- Bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: #242830; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #141414; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); border-color: rgba(239,90,90,.4); background: transparent; }
.btn-danger:hover { background: rgba(239,90,90,.1); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #0c2416; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- Flash ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-size: 14px; }
.flash-success { background: rgba(60,207,122,.1); border-color: rgba(60,207,122,.4); color: #9fe6bd; }
.flash-error { background: rgba(239,90,90,.1); border-color: rgba(239,90,90,.4); color: #f3a3a3; }
.flash-info { background: rgba(90,168,239,.1); border-color: rgba(90,168,239,.4); color: #b3d6f7; }
.flash-warn { background: rgba(242,184,75,.1); border-color: rgba(242,184,75,.4); color: #f6d79b; }

/* ---------- Tabs, paginazione ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.pager a { padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 6px; color: var(--text); }

/* ---------- Pagine pubbliche ---------- */
.auth-page, .public-page { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; min-height: 100vh; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand img { max-height: 48px; margin-bottom: 10px; }
.auth-title { font-size: 22px; margin: 0; }
.public-foot { margin-top: 24px; font-size: 12px; }

.invite { width: 100%; max-width: 520px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.invite-hero { padding: 28px 28px 20px; border-bottom: 1px solid var(--line); }
.invite-hero .kicker { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.invite-hero h1 { font-family: var(--font-serif); font-weight: 500; font-size: 30px; line-height: 1.15; margin: 0 0 10px; }
.invite-hero .meta { color: var(--text-2); font-size: 15px; }
.invite-body { padding: 24px 28px 28px; }
.invite-img { width: 100%; display: block; }
.qr-box { background: #fff; border-radius: 12px; padding: 16px; display: inline-block; margin: 10px auto; }
.qr-box img, .qr-box svg { display: block; width: 220px; height: 220px; }
.invite-status { padding: 12px 14px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.invite-status.ok { background: rgba(60,207,122,.12); color: var(--ok); }
.invite-status.warn { background: rgba(242,184,75,.12); color: var(--warn); }
.invite-status.bad { background: rgba(239,90,90,.12); color: var(--bad); }
.rsvp-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
@media (max-width: 480px) { .invite-hero, .invite-body { padding-left: 20px; padding-right: 20px; } }

/* ---------- Scanner ---------- */
.scanner-page { margin: 0; background: #000; color: #fff; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.scanner-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #111; font-size: 14px; gap: 10px; }
.scanner-top .counter { font-variant-numeric: tabular-nums; color: var(--text-2); }
.scanner-top .counter b { color: #fff; font-size: 16px; }
.scanner-top .net { font-size: 11px; margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }
.scanner-top .net.ok { color: var(--ok); } .scanner-top .net.warn { color: var(--warn); } .scanner-top .net.bad { color: var(--bad); font-weight: 700; }
.scanner-view { position: relative; flex: 1; background: #000; min-height: 50vh; }
#reader { width: 100%; height: 100%; }
#reader video { object-fit: cover; width: 100% !important; height: 100% !important; }
.scanner-view .torch { position: absolute; right: 12px; bottom: 12px; z-index: 5; width: 48px; height: 48px; border-radius: 50%; background: rgba(0,0,0,.5); border-color: rgba(255,255,255,.35); font-size: 20px; padding: 0; }
.scanner-view .torch.on { background: var(--accent); }
.reader-pane { display: none; position: absolute; inset: 0; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; background: #0f1013; }
.reader-mode .reader-pane { display: flex; }
.reader-mode #reader, .reader-mode .torch { display: none !important; }
.reader-pane .reader-icon { font-size: 46px; letter-spacing: 2px; color: var(--accent); line-height: 1; margin-bottom: 10px; }
.reader-pane .reader-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.reader-pane input { max-width: 360px; text-align: center; font-size: 18px; margin-top: 12px; font-family: ui-monospace, Menlo, monospace; }
.wedge-view { display: flex; align-items: center; justify-content: center; padding: 24px; }
.wedge-box { width: 100%; max-width: 640px; text-align: center; }
.wedge-box input { font-size: 22px; padding: 18px; text-align: center; margin: 14px 0 10px; background: #0f1013; border: 2px solid var(--line-2); color: #fff; }
.wedge-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(232,184,74,.2); }
.scanner-result { position: fixed; inset: 0; z-index: 50; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.scanner-result.show { display: flex; }
.scanner-result.ok { background: #1c7a44; }
.scanner-result.warn { background: #b57d12; }
.scanner-result.bad { background: #a92b2b; }
.scanner-result .big { font-size: 44px; font-weight: 700; line-height: 1; margin-bottom: 8px; }
.scanner-result .name { font-size: 30px; font-weight: 600; margin: 8px 0 4px; }
.scanner-result .detail { font-size: 17px; opacity: .92; margin: 2px 0; }
.scanner-result .notes { margin-top: 10px; background: rgba(0,0,0,.25); padding: 8px 14px; border-radius: 8px; font-size: 16px; }
.scanner-result .result-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.scanner-result .btn { background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.3); color: #fff; }
.scanner-result .btn-strong { background: #fff; color: #111; border-color: #fff; }
.scanner-bottom { display: flex; gap: 8px; padding: 10px 12px; background: #111; }
.scanner-bottom .btn { flex: 1; }
.scanner-search { position: fixed; inset: 0; background: #0f1013; z-index: 40; display: none; flex-direction: column; padding: 14px; }
.scanner-search.show { display: flex; }
.scanner-search input { font-size: 18px; padding: 14px; }
.scanner-search .list { overflow-y: auto; flex: 1; margin-top: 10px; }
.scanner-search .item { padding: 12px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.scanner-search .item .who { font-size: 17px; }
.scanner-search .item .sub { color: var(--text-2); font-size: 13px; }
.pin-card { max-width: 360px; margin: 10vh auto; padding: 24px; }
.pin-card input { font-size: 28px; text-align: center; letter-spacing: .3em; }

/* ---------- Varie ---------- */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.progress { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
details summary { cursor: pointer; color: var(--text-2); }
.var-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.var-list code { cursor: pointer; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }

/* ---------- Stampa etichette ---------- */
@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
}
