:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1d2330;
  --muted: #687080;
  --line: #e4e7ec;
  --accent: #6d4a65;
  --accent-ink: #ffffff;
  --accent-soft: #f4eef3;
  --ok: #17794e;
  --ok-soft: #e7f5ee;
  --warn: #9a5b05;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 13px; }

/* barra in alto */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }

/* intestazione pagina e schede */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* blocchi */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card .card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card .card-head h2 { margin: 0; }
.help { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 650; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.two { display: grid; gap: 20px; grid-template-columns: 1.4fr 1fr; align-items: start; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

/* tabelle */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td .muted, .muted { color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; }

/* moduli */
form.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 550; }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

button, .btn {
  font: inherit; font-weight: 550; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid #cfd4dc; background: #fff; color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { background: #f7f8fa; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.07); background: var(--accent); }
button.small { padding: 5px 10px; font-size: 13px; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--muted); }
button.link:hover { color: var(--ink); background: none; }

/* stati */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef0f3; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.flash { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe3cf; padding: 10px 14px; border-radius: 8px; margin-bottom: 20px; }
.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f3c6c1; padding: 10px 14px; border-radius: 8px; }

/* pagine di accesso */
.auth { max-width: 400px; margin: 9vh auto 0; }
.auth .brand { justify-content: center; margin-bottom: 22px; font-size: 18px; }
.auth .card { padding: 28px; }
.auth h1 { font-size: 20px; margin-bottom: 6px; }

/* codici e link da copiare */
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret input { font-family: var(--mono); }
.code-big { font-family: var(--mono); font-size: 30px; letter-spacing: .12em; text-align: center; padding: 18px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius); margin: 8px 0 14px; }

/* procedura */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 2px 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); grid-row: span 3; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 13px; }
.steps .t { font-weight: 600; }
.steps .e { color: var(--muted); font-size: 14px; }
.steps .meta { font-size: 12px; color: var(--muted); }
pre.json { margin: 0; padding: 16px 20px; font: 12.5px/1.5 var(--mono); background: #fafbfc; overflow: auto; max-height: 520px; }
details > summary { cursor: pointer; padding: 14px 20px; font-weight: 600; }
details[open] > summary { border-bottom: 1px solid var(--line); }
.auth.wide { max-width: 560px; }
.auth.mid { max-width: 480px; }
.spaced { margin-top: 16px; }
form.inline { display: inline; }
.page-head form.inline + form.inline { margin-left: 6px; }
.nowrap { white-space: nowrap; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
label.check input { margin-top: 4px; }
label.check .hint { display: block; }
textarea.code { font: 12.5px/1.5 var(--mono); white-space: pre; tab-size: 2; }
.error div + div { margin-top: 4px; }
