:root {
  --bg: #f3f6f9; --surface: #ffffff; --surface-2: #eaf0f6; --border: #d8e1ea;
  --text: #1b2a3b; --muted: #627285; --accent: #25507f; --accent-2: #2f65a0; --accent-ink: #fff;
  --brand-green: #62bf5a;
  --ok: #3f9a38; --danger: #b3261e; --warn-bg: #fdf0ea; --ok-bg: #edf7ec;
  --shadow: 0 1px 2px rgba(27,42,59,.06), 0 4px 16px rgba(27,42,59,.05);
  --radius: 10px; --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151d; --surface: #17202b; --surface-2: #1f2a37; --border: #2c3a4a;
    --text: #e6edf4; --muted: #95a3b3; --accent: #62bf5a; --accent-2: #78cc70; --accent-ink: #0d1a0c;
    --ok: #62bf5a; --danger: #ef6b62; --warn-bg: #3a2219; --ok-bg: #18301a;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .15rem; display: flex; align-items: center; gap: .5rem; }
h2 { font-size: 1.05rem; margin: 0; }
b { font-weight: 700; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-size: 1.1rem; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand b, .login h1 b { color: var(--accent); }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a, .me a { color: var(--muted); padding: .35rem .7rem; border-radius: 7px; }
.nav a.on, .me a.on { background: var(--surface-2); color: var(--text); }
.nav a:hover, .me a:hover { text-decoration: none; color: var(--text); }
.me { display: flex; align-items: center; gap: .25rem; }
.me form { margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.actions, .row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }
.back { display: inline-block; margin-bottom: .75rem; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.right { text-align: right; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.narrow { max-width: 460px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .85rem; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; width: 100%; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=search] { width: 260px; max-width: 100%; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 500; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: progress; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: .35rem .5rem; }
button.link:hover { color: var(--text); }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); border: 1px solid var(--ok); word-break: break-all; }
.flash.error { background: var(--warn-bg); border-color: var(--danger); }

.stats { display: flex; gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; min-width: 120px; box-shadow: var(--shadow); }
.stat span { font-size: 1.6rem; font-weight: 700; display: block; line-height: 1.2; }
.stat small { color: var(--muted); }

.table-wrap { padding: 0; overflow-x: auto; }
.table-wrap h2 { padding: 1rem 1.2rem .25rem; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.grid td { padding: .6rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid tr.warn td { background: var(--warn-bg); }
.grid tr[hidden] { display: none; }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

.reveal { background: var(--surface); border: 1px dashed var(--accent); border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem; display: flex; gap: .75rem; align-items: center; }
.reveal[hidden] { display: none; }
.linkbox { display: flex; gap: .5rem; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; }
.linkbox code { flex: 1; overflow-wrap: anywhere; font-family: var(--mono); font-size: .85rem; }
.danger-zone { display: flex; justify-content: flex-end; }

.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login h1 { justify-content: center; font-size: 1.7rem; margin-top: .5rem; }
.login form { text-align: left; margin-top: 1.25rem; }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .5rem 1rem; border-radius: 8px; font-size: .9rem; z-index: 20; }

@media (max-width: 640px) {
  .topbar { gap: .5rem 1rem; padding: .6rem 1rem; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .grid th:nth-child(5), .grid td:nth-child(5), .grid th:nth-child(6), .grid td:nth-child(6) { display: none; }
  input[type=search] { width: 100%; }
  .actions { width: 100%; }
}
.login .qr { display: block; margin: 1rem auto; width: 200px; height: 200px; border-radius: 8px; }
.login code { font-size: .95rem; letter-spacing: .03em; }

/* marchio 2G Sistemi */
.topbar { border-bottom: 3px solid var(--brand-green); }
.brand-logo { display: block; height: 34px; width: auto; }
.login .logo-2g { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto .9rem; }
