:root {
  --bg: #080b11;
  --bg-2: #0d121b;
  --panel: #121926;
  --panel-2: #172033;
  --line: #243044;
  --text: #e7edf7;
  --muted: #8fa0b8;
  --faint: #5f7089;
  --cyan: #37e0cf;
  --pink: #ff4d9d;
  --green: #4ade80;
  --red: #fb7185;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(55, 224, 207, .10), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(255, 77, 157, .08), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: rgba(55, 224, 207, .08); border: 1px solid rgba(55, 224, 207, .15); padding: .1em .35em; border-radius: 6px; font-size: .92em; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .55rem; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.02em; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .08em; color: #c9d6e8; }
h3 { font-size: .95rem; margin-top: 1.1rem; color: #d7e3f4; }
p { margin: .35rem 0 .8rem; }
ul { margin: .4rem 0; padding-left: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(8, 11, 17, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-size: 1.02rem; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--cyan); font-weight: 700; }
.brand-mark { color: var(--pink); font-size: 1.35rem; line-height: 1; }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a {
  color: var(--muted); padding: .42rem .8rem; border-radius: 9px; font-weight: 600; font-size: .92rem;
}
.nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.active { color: #061018; background: var(--cyan); }
.local-badge { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); border: 1px solid var(--line); padding: .15rem .5rem; border-radius: 99px; }

.wrap { width: min(1300px, 100% - 2rem); margin: 1.4rem auto 3rem; }
.footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.2rem clamp(1rem, 4vw, 2.5rem) 2rem; border-top: 1px solid var(--line); color: var(--faint); font-size: .82rem; }

/* ---------- panels / layout ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}
.panel-error { border-color: rgba(251, 113, 133, .45); background: linear-gradient(180deg, rgba(251, 113, 133, .08), var(--bg-2)); }
.error-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-top: 1px dashed var(--line); }
.error-row:first-of-type { border-top: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head p { margin: .2rem 0 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.head-actions form { display: inline-flex; gap: .5rem; align-items: center; margin: 0; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.crumbs { color: var(--muted); font-size: .85rem; margin-bottom: .55rem; }
.badges { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; margin-top: .55rem; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: .52rem .85rem; font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: .15s ease; white-space: nowrap;
}
.btn:hover { border-color: #34465f; background: #1c2740; text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #041016; }
.btn-primary:hover { background: #6ff0e2; border-color: #6ff0e2; }
.btn-danger { border-color: rgba(251, 113, 133, .45); color: #ffc0cb; background: rgba(251, 113, 133, .08); }
.btn-danger:hover { background: rgba(251, 113, 133, .17); border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-small { padding: .32rem .6rem; font-size: .82rem; border-radius: 7px; }
.btn-lg { padding: .7rem 1.4rem; font-size: 1rem; }
.btn[disabled] { opacity: .55; cursor: progress; }

input[type="text"], input[type="search"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; background: #0b111c; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: .55rem .65rem; font: inherit; font-size: .92rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(55, 224, 207, .35); border-color: rgba(55, 224, 207, .6); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.field > span { font-size: .82rem; font-weight: 700; color: #b7c6db; text-transform: uppercase; letter-spacing: .06em; }
.field em { font-style: normal; color: var(--cyan); text-transform: none; letter-spacing: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 800px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .6rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .9rem; cursor: pointer; }
.check input { accent-color: var(--cyan); width: 16px; height: 16px; }
.options { display: flex; gap: 1.1rem; flex-wrap: wrap; padding: .8rem 0 .2rem; }
.meta-form { margin-top: .4rem; }

/* ---------- flashes ---------- */
.flashes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.flash { border-radius: 9px; padding: .65rem .85rem; border: 1px solid var(--line); background: var(--panel); font-size: .9rem; }
.flash-success { border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .08); }
.flash-warn { border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.flash-error { border-color: rgba(251, 113, 133, .4); background: rgba(251, 113, 133, .1); }
.flash-info { border-color: rgba(96, 165, 250, .35); background: rgba(96, 165, 250, .08); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .65rem; margin-bottom: 1rem; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  display: flex; flex-direction: column; gap: .1rem;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 12px; padding: .75rem .85rem;
  color: var(--text); transition: .15s ease; min-height: 92px;
}
.stat:hover { text-decoration: none; transform: translateY(-2px); border-color: #34465f; }
.stat-label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; }
.stat b { font-size: 1.7rem; line-height: 1.1; margin: .15rem 0; }
.stat-note { color: var(--faint); font-size: .75rem; }
.stat-ok b { color: var(--green); }
.stat-bad b { color: var(--red); }
.stat-warn b { color: var(--yellow); }
.stat-muted b { color: var(--muted); }

/* ---------- badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .5rem; border-radius: 99px; font-size: .76rem; font-weight: 700; letter-spacing: .01em; border: 1px solid transparent; white-space: nowrap; }
.badge-ok { color: #97f5b9; background: rgba(74, 222, 128, .12); border-color: rgba(74, 222, 128, .3); }
.badge-bad { color: #ffb3bf; background: rgba(251, 113, 133, .13); border-color: rgba(251, 113, 133, .33); }
.badge-warn { color: #ffe08a; background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .3); }
.badge-info { color: #b6d4ff; background: rgba(96, 165, 250, .12); border-color: rgba(96, 165, 250, .3); }
.badge-muted { color: var(--muted); background: rgba(143, 160, 184, .1); border-color: rgba(143, 160, 184, .22); }
.pill { display: inline-block; padding: .08rem .45rem; border-radius: 99px; font-size: .72rem; font-weight: 700; color: var(--muted); background: rgba(143, 160, 184, .1); border: 1px solid rgba(143, 160, 184, .2); vertical-align: middle; }
.pill-support { color: #ffe08a; border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .08); }

/* ---------- filters ---------- */
.filters { display: flex; gap: .7rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; min-width: 150px; }
.filters .grow { flex: 1 1 220px; }
.filters .btn { margin-bottom: 1px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table.games { width: 100%; border-collapse: collapse; font-size: .89rem; min-width: 840px; }
table.games th { text-align: left; color: var(--faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: .55rem .6rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #101724; }
table.games td { padding: .62rem .6rem; border-bottom: 1px solid rgba(36, 48, 68, .65); vertical-align: top; }
table.games tr:hover td { background: rgba(55, 224, 207, .035); }
table.games tr.row-support td { background: rgba(251, 191, 36, .03); }
.game-title { font-weight: 700; color: var(--text); }
.game-title:hover { color: var(--cyan); }
.notes { color: #c5d3e6; margin-top: .2rem; }
.actions-cell { text-align: right; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.legend { margin-top: .6rem; }

/* ---------- missing ---------- */
.missing-panel summary { cursor: pointer; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.missing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .7rem; margin-top: .9rem; }
.missing-item { border: 1px solid rgba(251, 113, 133, .28); background: rgba(251, 113, 133, .05); border-radius: 10px; padding: .65rem .75rem; }
.missing-file { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .2rem; }
.missing-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.missing-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.missing-list li { border-left: 2px solid rgba(251, 113, 133, .5); padding: .35rem 0 .35rem .7rem; }
.plain-list { list-style: none; padding: 0; }
.plain-list li { padding: .18rem 0; border-bottom: 1px dashed rgba(36, 48, 68, .6); }

/* ---------- key/value ---------- */
dl.kv { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: .35rem .8rem; margin: 0; }
dl.kv dt { color: var(--faint); font-size: .82rem; }
dl.kv dd { margin: 0; word-break: break-word; }

/* ---------- upload ---------- */
.dropzone { position: relative; border: 2px dashed #2b3b54; border-radius: 12px; padding: 1.6rem 1rem; text-align: center; transition: .15s ease; background: rgba(55, 224, 207, .02); }
.dropzone:hover, .dropzone.drag { border-color: var(--cyan); background: rgba(55, 224, 207, .06); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-icon { font-size: 2rem; color: var(--cyan); line-height: 1; margin-bottom: .35rem; }
.link { color: var(--cyan); text-decoration: underline; }
.file-list { margin-top: .8rem; display: flex; flex-direction: column; gap: .25rem; align-items: center; font-size: .86rem; }
.file-list .file-row { display: flex; gap: .55rem; align-items: center; color: var(--muted); }
.upload-form { padding: 1.25rem; }
.progress-wrap { margin-top: 1rem; }
.progress { height: 10px; background: #0a0f18; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .2s ease; }
.upload-results { margin-top: 1rem; }
.result-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.result-list li { display: flex; gap: .55rem; align-items: baseline; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 9px; padding: .5rem .65rem; background: var(--bg-2); }
.result-list li.res-ok { border-color: rgba(74, 222, 128, .3); }
.result-list li.res-bad { border-color: rgba(251, 113, 133, .35); }
.tips ul { color: #c2d0e3; }
.tips li { margin: .35rem 0; }
.test-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.action-stack { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.action-stack form { margin: 0; }
.error-page { text-align: center; padding: 3rem 1rem; }
.error-page h1 { font-size: 4rem; color: var(--pink); }
.zip-list { columns: 2; column-gap: 2rem; padding-left: 1.1rem; }
@media (max-width: 700px) { .zip-list { columns: 1; } }

.system-actions { display: flex; justify-content: space-between; align-items: center; gap: .7rem; flex-wrap: wrap; padding: .55rem .7rem; margin-bottom: .8rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(55, 224, 207, .03); }

/* ---------- duplicati ---------- */
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 800px) { .stats-3 { grid-template-columns: 1fr; } }
.dup-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .25rem; }
.dup-head code { font-size: .9rem; }
.dup-table { min-width: 720px; }

/* ---------- utente in alto ---------- */
.userbox { display: flex; align-items: center; gap: .45rem; }
.userbox form { margin: 0; }
.user-name {
  display: inline-flex; align-items: center; gap: .38rem;
  color: var(--muted); font-size: .84rem; font-weight: 600;
  max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.user-dot.ok { background: var(--green); box-shadow: 0 0 8px rgba(74, 222, 128, .55); }
.user-dot.warn { background: var(--yellow); box-shadow: 0 0 8px rgba(251, 191, 36, .45); }

@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; }
  .nav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
}

/* ---------- login / prima configurazione ---------- */
.auth-body {
  display: grid; place-items: center;
  padding: clamp(1.2rem, 5vw, 3rem) 1rem;
}
.auth-shell { width: min(440px, 100%); display: flex; flex-direction: column; gap: 1rem; }
.auth-brand { justify-content: center; font-size: 1.05rem; }
.auth-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 18px;
  padding: clamp(1.15rem, 4vw, 1.7rem);
  box-shadow: var(--shadow);
}
.auth-head { display: flex; gap: .85rem; align-items: flex-start; margin-bottom: 1rem; }
.auth-head h1 { font-size: 1.35rem; margin-bottom: .2rem; }
.auth-head p { margin: 0; }
.auth-icon {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border-radius: 13px; font-size: 1.35rem;
  background: rgba(55, 224, 207, .08); border: 1px solid rgba(55, 224, 207, .22);
}
.auth-form { display: flex; flex-direction: column; }
.auth-submit { width: 100%; margin-top: .35rem; }
.auth-link { display: block; text-align: center; margin-top: .8rem; }
.auth-foot { text-align: center; margin: .2rem 0 0; }
.auth-hint {
  border-left: 2px solid rgba(74, 222, 128, .55);
  background: rgba(74, 222, 128, .06);
  border-radius: 0 9px 9px 0;
  padding: .55rem .75rem; margin: 0 0 1rem;
  font-size: .82rem; color: #bfe9cd;
}
.auth-note { margin-top: 1rem; }
.auth-note p { margin: .3rem 0; }
.totp-input {
  letter-spacing: .45em; text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.2rem; padding: .6rem .65rem;
}
.codeblock {
  background: #0b111c; border: 1px solid var(--line); border-radius: 9px;
  padding: .7rem .8rem; margin: .4rem 0; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; color: #c9d6e8;
}

/* ---------- 2FA / sessioni ---------- */
.qr-box {
  display: grid; place-items: center;
  width: min(230px, 100%); margin: .5rem auto 1rem;
  padding: .55rem; background: #fff; border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.qr-box svg { width: 100%; height: auto; display: block; }
.sessions-table { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 640px; }
.sessions-table th {
  text-align: left; color: var(--faint); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .08em;
  padding: .5rem .55rem; border-bottom: 1px solid var(--line);
  background: #101724; white-space: nowrap;
}
.sessions-table td { padding: .5rem .55rem; border-bottom: 1px solid rgba(36, 48, 68, .65); vertical-align: middle; }
.sessions-table tr:hover td { background: rgba(55, 224, 207, .035); }
.sessions-table form { margin: 0; }
