:root {
  --bg: #0f1216;
  --panel: #181d23;
  --panel2: #20262e;
  --line: #2b323c;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --accent: #2f8cff;
  --ok: #2ecc71;
  --warn: #f5a623;
  --bad: #ff5a5f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input { font: inherit; }
button {
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--panel2); color: var(--text);
  display: inline-flex; align-items: center; gap: 8px;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .45; cursor: default; filter: none; }
button.primary { background: var(--accent); color: #fff; }
button.ok { background: var(--ok); color: #06210f; }
button.bad { background: var(--bad); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { padding: 6px 10px; font-size: 13px; }
button.off { background: var(--bad); color: #fff; }
input[type=text], input[type=password] {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Schermata centrale (ingresso, attesa, messaggi) */
.center {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px;
}
.card h1 { font-size: 20px; margin: 0 0 6px; }
.card p { margin: 0 0 18px; }
.card form { display: grid; gap: 12px; }
.card label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.brand { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%; margin: 6px 0 16px;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Visore cliente */
.viewer { position: fixed; inset: 0; display: flex; flex-direction: column; }
.viewer .stage { flex: 1; position: relative; background: #000; min-height: 0; }
.viewer video { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer .overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 16px; color: var(--muted); background: rgba(0,0,0,.85);
}
.bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--panel); border-top: 1px solid var(--line); flex-wrap: wrap;
}
.bar .grow { flex: 1; min-width: 120px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10; max-width: calc(100% - 32px);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px;
}

/* Pannello operatore */
.op { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.op header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.op header h1 { font-size: 20px; margin: 0; flex: 1; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
@media (max-width: 820px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.preview { background: #000; border-radius: 10px; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); }
.preview video { width: 100%; height: 100%; object-fit: contain; }
.link { display: flex; gap: 8px; margin-top: 14px; }
.link input { flex: 1; min-width: 0; }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--panel2); border-radius: 10px; flex-wrap: wrap; }
.item .name { flex: 1; min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.knock { outline: 2px solid var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { outline-color: transparent; } }
.level { width: 40px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; }
.level i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
.empty { color: var(--muted); font-size: 14px; }
.panel + .panel { margin-top: 16px; }

/* Marchio Design & Servizi (pagina cliente) */
.center { flex-direction: column; gap: 18px; }
.card .logo {
  display: block; background: #fff; margin: -28px -28px 22px; padding: 18px 28px;
  border-radius: var(--radius) var(--radius) 0 0; text-align: center;
}
.card .logo img { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto; }
.note { margin: 16px 0 0 !important; font-size: 13px; color: var(--muted); }
.note a, .foot a { color: var(--text); }
.foot { font-size: 13px; color: var(--muted); text-align: center; }
.foot a { text-decoration: none; border-bottom: 1px solid var(--line); }
.foot a:hover { border-bottom-color: var(--text); }
.bycredit { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.bycredit:hover { color: var(--text); }

/* Informativa */
.legal { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.legal .logo { display: inline-block; background: #fff; padding: 12px 18px; border-radius: 10px; margin-bottom: 18px; }
.legal .logo img { display: block; width: 220px; height: auto; }
.legal h1 { font-size: 24px; margin: 0 0 6px; }
.legal h2 { font-size: 17px; margin: 28px 0 8px; }
.legal p, .legal li { color: #c9d1db; }
.legal a { color: var(--accent); }

/* Registrazione */
.recpill {
  position: absolute; top: 12px; left: 12px; z-index: 2; max-width: calc(100% - 24px);
  background: rgba(20,0,0,.8); color: #fff; border: 1px solid var(--bad); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.recpill::before, .recdot::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); flex: none;
  animation: blink 1.2s ease-in-out infinite;
}
.recdot { display: inline-flex; align-items: center; gap: 6px; color: var(--bad); font-size: 12px; font-weight: 600; }
@keyframes blink { 50% { opacity: .25; } }
button.rec-on { background: var(--bad); color: #fff; }
.modal {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal .card { max-width: 480px; }
.modal .card p { margin-bottom: 12px; }
