:root {
  --bg: #07080b;
  --panel: rgba(18, 20, 27, .78);
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #eceef3;
  --muted: #8b90a0;
  --danger: #ff7a7a;
  --ok: #62d6a0;
  --discord: #5865f2;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(55% 45% at 18% 8%, rgba(120, 140, 255, .18), transparent 62%),
    radial-gradient(45% 45% at 88% 88%, rgba(255, 120, 180, .11), transparent 62%),
    var(--bg);
}
.shell { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card {
  width: 100%; max-width: 410px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
}
.card.wide { max-width: 520px; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: conic-gradient(from 210deg, #9aa8ff, #ff8fc4, #9aa8ff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.brand-name { font: 700 15px var(--mono); letter-spacing: .04em; }

h1 { margin: 0 0 6px; font: 700 24px/1.2 var(--mono); letter-spacing: -.01em; }
.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.sub strong { color: var(--text); word-break: break-all; font-weight: 600; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input:not([type]) {
  width: 100%; height: 44px; padding: 0 14px;
  color: var(--text); background: rgba(0, 0, 0, .35);
  border: 1px solid var(--line); border-radius: 10px;
  font: 15px var(--sans); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #555a6b; }
input:focus-visible { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(154, 168, 255, .22); }
input.code { font: 700 22px var(--mono); letter-spacing: .5em; text-align: center; padding-left: 20px; }

.pw { position: relative; }
.pw input { padding-right: 88px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 32px; padding: 0 10px; background: transparent; border: 0; border-radius: 8px;
  color: var(--muted); font: 600 12px var(--sans); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.pw-toggle:focus-visible { outline: 2px solid #9aa8ff; outline-offset: 1px; }

.row { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 14px; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: #fff; }

.cf-slot { display: flex; justify-content: center; min-height: 0; margin-bottom: 14px; }
.cf-placeholder {
  width: 100%; min-height: 65px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 10px 14px; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--line-strong); border-radius: 10px; background: rgba(0, 0, 0, .25);
}

.btn {
  width: 100%; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  font: 600 14px var(--sans); cursor: pointer;
  transition: transform .08s, opacity .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: #fff; color: #0a0b0f; border-color: #fff; }
.btn.primary:hover:not(:disabled) { background: #e9ebf2; }
.btn.discord { background: var(--discord); color: #fff; border-color: var(--discord); }
.btn.discord:hover:not(:disabled) { background: #4752d6; }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, .06); }
.btn:focus-visible, .link:focus-visible { outline: 2px solid #9aa8ff; outline-offset: 2px; }

.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.link { background: none; border: 0; padding: 0; color: var(--text); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.switch { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

.msg { margin: 0 0 16px; padding: 10px 12px; border-radius: 10px; font-size: 13px; border: 1px solid; }
.msg.err { color: var(--danger); background: rgba(255, 90, 90, .08); border-color: rgba(255, 90, 90, .3); }
.msg.ok { color: var(--ok); background: rgba(98, 214, 160, .08); border-color: rgba(98, 214, 160, .3); }

/* dashboard */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; margin: 18px 0 24px; padding: 16px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: var(--ok); border-color: rgba(98, 214, 160, .35); }

/* gestione utenti (solo admin) */
.card.xwide { max-width: 900px; }
.admin { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.admin h2 { margin: 0 0 4px; font: 700 17px var(--mono); }
.tablewrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; }
table.users { width: 100%; border-collapse: collapse; font-size: 13px; }
table.users th, table.users td { padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.users th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.users tr:last-child td { border-bottom: 0; }
table.users select { height: 32px; padding: 0 8px; color: var(--text); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 8px; font: inherit; }
table.users select:disabled { opacity: .55; }
.mini { height: 30px; padding: 0 10px; margin-right: 6px; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 8px; font: 600 12px var(--sans); cursor: pointer; }
.mini:hover { background: rgba(255, 255, 255, .07); }
.mini.danger { color: var(--danger); border-color: rgba(255, 90, 90, .35); }
.mini:disabled { opacity: .4; cursor: not-allowed; }

@media (max-width: 420px) {
  .card { padding: 22px 18px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
