:root { --bg: #0f172a; --panel: #1e293b; --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8; --ok: #16a34a; --ko: #dc2626; --warn: #d97706; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 6px 4px; }
.topbar nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.topbar form { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; padding: 6px 4px; }
.container { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 4px 0 16px; }
.small-title { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.card { background: var(--panel); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.card.narrow { max-width: 400px; margin: 40px auto; }
.list { list-style: none; padding: 0; margin: 0; }
.event-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: #fca5a5; }
.stack { display: grid; gap: 12px; } .row { display: flex; gap: 8px; flex-wrap: wrap; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local] { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #334155; background: #0b1222; color: var(--text); font-size: 16px; }
.btn { padding: 10px 14px; border-radius: 8px; border: 1px solid #334155; background: #0b1222; color: var(--text); font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b1222; font-weight: 600; }
.btn.big { padding: 14px; font-size: 17px; } .btn.small { padding: 6px 10px; font-size: 13px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #334155; color: var(--text); white-space: nowrap; }
.badge.offline { background: var(--warn); color: #0b1222; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stats div { background: var(--panel); border-radius: 10px; padding: 8px; text-align: center; }
.stats span { display: block; font-size: 22px; font-weight: 700; } .stats small { color: var(--muted); font-size: 12px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.btn.mode.active { background: var(--accent); border-color: var(--accent); color: #0b1222; font-weight: 600; }
.camera-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; margin-bottom: 10px; }
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder { position: absolute; inset: 15% 12%; border: 2px solid rgba(255,255,255,.7); border-radius: 12px; pointer-events: none; }
.camera-toggle { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); }
.result { border-radius: 12px; padding: 18px 16px; margin-bottom: 10px; text-align: center; transition: background .15s; }
.result.idle { background: var(--panel); } .result.ok { background: var(--ok); } .result.ko { background: var(--ko); } .result.warn { background: var(--warn); color: #0b1222; } .result.busy { background: #334155; }
.result-title { font-size: 28px; font-weight: 800; letter-spacing: .5px; }
.result-name { font-size: 20px; margin-top: 4px; } .result-meta { font-size: 13px; opacity: .85; margin-top: 4px; }
.manual { display: flex; gap: 8px; margin-bottom: 12px; } .manual input { flex: 1; }
details.card summary { cursor: pointer; font-weight: 600; }
.recent { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.recent li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #334155; }
.recent li.ok .status { color: #86efac; } .recent li.ko .status { color: #fca5a5; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #334155; vertical-align: top; }
.table tr.ok td:nth-child(3) { color: #86efac; } .table tr.ko td:nth-child(3) { color: #fca5a5; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
@media (max-width: 480px) { .topbar nav { gap: 6px; font-size: 13px; } .result-title { font-size: 24px; } }
/* v2: dashboard e pannello */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.flash.ok { background: #14532d; color: #dcfce7; } .flash.ko { background: #7f1d1d; color: #fee2e2; }
.card.once { border: 2px solid var(--accent); } .card.once code { font-size: 16px; background: #0b1222; padding: 2px 6px; border-radius: 6px; }
.qr-box { display: grid; gap: 8px; justify-items: start; margin-top: 8px; } #qr-once { background: #fff; padding: 10px; border-radius: 8px; }
.hidden { display: none !important; } .center { text-align: center; }
.container.wide { max-width: 1100px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } @media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
select, textarea { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #334155; background: #0b1222; color: var(--text); font-size: 15px; }
select[multiple] { min-height: 120px; }
.table-wrap { overflow-x: auto; }
.inline { display: inline; } .inline button { margin-left: 4px; }
.check { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.check input { width: auto; }
.chips span { display: inline-block; background: #334155; border-radius: 999px; padding: 2px 8px; font-size: 12px; margin: 2px 4px 2px 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; } .filters label { min-width: 140px; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; font-size: 14px; } .pagination a, .pagination span { padding: 4px 8px; background: var(--panel); border-radius: 6px; }
@media print { .topbar, nav, .flash, main > *:not(.once) { display: none !important; } body { background: #fff; color: #000; } .card.once { border: 0; color: #000; } .card.once code { background: #eee; color: #000; } }
.admin-foot { margin-top: 32px; padding-top: 12px; border-top: 1px solid #334155; font-size: 13px; color: var(--muted); }
.admin-foot a { color: var(--muted); text-decoration: none; } .admin-foot a.active { color: var(--text); }
/* v3: scanner a tutto schermo */
body.scanner-page { overflow: hidden; }
body.scanner-page .topbar, body.scanner-page .admin-foot { display: none; }
body.scanner-page .container { max-width: none; padding: 0; }
.scan-screen { position: fixed; inset: 0; background: #000; }
.scan-screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-top { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: linear-gradient(rgba(0,0,0,.75), rgba(0,0,0,0)); color: #fff; }
.scan-gates { flex: 1; min-width: 0; display: grid; } .scan-gates strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .scan-gates span { font-size: 12px; opacity: .8; }
.scan-counter { text-align: center; line-height: 1; } .scan-counter span { display: block; font-size: 26px; font-weight: 800; } .scan-counter small { font-size: 11px; opacity: .8; }
.scan-screen .viewfinder { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(78vw, 360px); aspect-ratio: 1; inset: auto; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.scan-hint { position: absolute; left: 0; right: 0; top: calc(42% + min(39vw, 180px) + 14px); text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px #000; margin: 0; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 8px; padding: 12px 12px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.8)); }
.scan-btn { flex: 1; position: relative; padding: 14px 6px; border-radius: 12px; border: 1px solid rgba(255,255,255,.35); background: rgba(15,23,42,.7); color: #fff; font-size: 15px; font-weight: 600; }
.scan-btn.on { background: var(--accent); color: #0b1222; border-color: var(--accent); }
.scan-btn .dot { position: absolute; top: 6px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.result-overlay { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: #fff; z-index: 5; }
.result-overlay.ok { background: #16a34a; } .result-overlay.ko { background: #dc2626; } .result-overlay.warn { background: #d97706; color: #0b1222; } .result-overlay.busy { background: rgba(51,65,85,.92); }
.result-overlay .result-title { font-size: 64px; font-weight: 900; letter-spacing: 1px; line-height: 1; }
.result-overlay .result-name { font-size: 30px; font-weight: 600; margin-top: 16px; } .result-overlay .result-meta { font-size: 17px; opacity: .9; margin-top: 10px; }
.result-overlay .result-tap { position: absolute; bottom: calc(20px + env(safe-area-inset-bottom)); font-size: 13px; opacity: .7; }
.camera-off { position: absolute; inset: 0; display: grid; place-content: center; gap: 16px; text-align: center; padding: 90px 24px; background: var(--bg); z-index: 4; }
.manual-overlay { position: absolute; left: 12px; right: 12px; bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--panel); border-radius: 14px; padding: 14px; display: grid; gap: 12px; z-index: 7; }
.manual-overlay input { font-size: 22px; letter-spacing: 1px; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 85vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); z-index: 8; box-shadow: 0 -8px 30px rgba(0,0,0,.5); }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #475569; margin: 4px auto 12px; }
.sheet-foot { justify-content: space-between; align-items: center; margin-top: 6px; }
.recent li.ok .status { color: #86efac; } .recent li.ko .status { color: #fca5a5; }
@media (min-width: 900px) { .scan-screen { max-width: 480px; margin: 0 auto; left: 50%; transform: translateX(-50%); } }
