:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dde1e7; --text: #1b2430; --muted: #5d6b7d;
  --accent: #2563eb; --accent-text: #ffffff; --ok: #15803d; --ok-bg: #dcfce7; --warn: #a16207; --warn-bg: #fef3c7;
  --err: #b91c1c; --err-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 8px rgba(15, 23, 42, .04);
  --radius: 12px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #172029; --surface-2: #1f2a35; --border: #2b3947; --text: #e6ebf1; --muted: #93a1b3;
    --accent: #5b8def; --accent-text: #0b1220; --ok: #4ade80; --ok-bg: #12351f; --warn: #fbbf24; --warn-bg: #3a2c0a;
    --err: #f87171; --err-bg: #3d1717; --info: #7aa7ff; --info-bg: #14264a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #172029; --surface-2: #1f2a35; --border: #2b3947; --text: #e6ebf1; --muted: #93a1b3;
  --accent: #5b8def; --accent-text: #0b1220; --ok: #4ade80; --ok-bg: #12351f; --warn: #fbbf24; --warn-bg: #3a2c0a;
  --err: #f87171; --err-bg: #3d1717; --info: #7aa7ff; --info-bg: #14264a; --shadow: none;
}
* { 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; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; margin-bottom: .75rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); font-size: .86em; }
.boot { padding: 2rem; color: var(--muted); }

/* struttura */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; }
.brand img { width: 26px; height: 26px; }
.host { color: var(--muted); font-weight: 400; font-size: .9rem; }
.spacer { flex: 1; }
.tabs { display: flex; gap: .25rem; padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { appearance: none; border: 0; background: none; color: var(--muted); padding: .75rem .9rem; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }

/* carte */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: .9rem; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.apps { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.tile .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 1.35rem; font-weight: 650; margin: .15rem 0; }
.tile .sub { color: var(--muted); font-size: .88rem; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: .5rem; }
.bar > span { display: block; height: 100%; width: var(--w, 0%); background: var(--accent); }
.bar.warn > span { background: var(--warn); }
.bar.err > span { background: var(--err); }

/* etichette */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 550; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.err, .chip.error { background: var(--err-bg); color: var(--err); }
.chip.info { background: var(--info-bg); color: var(--info); }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err, .dot.error { background: var(--err); }

/* app */
.app h3 { display: flex; align-items: center; gap: .5rem; }
.app .domains { color: var(--muted); font-size: .88rem; margin: .1rem 0 .6rem; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .9rem; margin: .5rem 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
details { margin-top: .5rem; } summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
details ul { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
details li { margin: .25rem 0; overflow-wrap: anywhere; }

/* avvisi */
.alerts { display: grid; gap: .5rem; }
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .9rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.alert.warn { background: var(--warn-bg); border-color: transparent; }
.alert.err { background: var(--err-bg); border-color: transparent; }
.alert.info { background: var(--info-bg); border-color: transparent; }
.alert .t { font-weight: 600; } .alert .d { color: var(--muted); font-size: .9rem; }

/* tabelle */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 550; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* moduli e pulsanti */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .5rem .9rem; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { margin-bottom: .9rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.msg { padding: .6rem .8rem; border-radius: 8px; font-size: .92rem; margin: .6rem 0; }
.msg.err { background: var(--err-bg); color: var(--err); } .msg.ok { background: var(--ok-bg); color: var(--ok); } .msg.info { background: var(--info-bg); color: var(--info); }
pre.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .8rem; overflow: auto; max-height: 60vh; white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; }
.muted { color: var(--muted); }

/* accesso */
.login { max-width: 400px; margin: 10vh auto 0; padding: 0 1rem; }
.login .card { padding: 1.5rem; }
.login h1 { font-size: 1.4rem; margin-bottom: .25rem; }

@media (max-width: 600px) {
  .host { display: none; }
  main { padding-top: 1rem; }
}

.narrow { max-width: 260px; }
[hidden] { display: none !important; }
ol { margin: .4rem 0; padding-left: 1.2rem; } ol li { margin: .35rem 0; }
.keybox { font-size: 1.15rem; letter-spacing: .06em; word-spacing: .4em; padding: .4rem 0 .6rem; overflow-wrap: anywhere; }

/* barra di avanzamento */
.progress { height: 14px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; width: var(--w, 0%); background: var(--accent); transition: width .6s ease; }
.progress.indet > span { background-image: linear-gradient(45deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%);
  background-size: 28px 28px; animation: stripes 1s linear infinite; }
@keyframes stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }
@media (prefers-reduced-motion: reduce) { .progress.indet > span { animation: none; } }
.stages { list-style: none; padding: 0; margin: .25rem 0 0; display: grid; gap: .2rem; font-size: .9rem; color: var(--muted); }
.stages li::before { content: "○ "; }
.stages li.done { color: var(--ok); } .stages li.done::before { content: "✔ "; }
.stages li.now { color: var(--text); font-weight: 600; } .stages li.now::before { content: "● "; color: var(--accent); }
.stages li.stopped { color: var(--warn); } .stages li.stopped::before { content: "■ "; }
