:root { --bg:#f5f6f8; --fg:#16191f; --muted:#5a6370; --card:#fff; --line:#d8dce2; --acc:#1d4fd7; --acc-fg:#fff; --err:#b3261e; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f1115; --fg:#e8eaee; --muted:#9aa3b2; --card:#171a21; --line:#2a2f3a; --acc:#5b84f0; --acc-fg:#0b0d12; --err:#ff8a80; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
header form { display: flex; align-items: center; gap: 12px; margin: 0; }
.card { width: calc(100% - 32px); max-width: 440px; margin: 10vh auto; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
h1 { margin: 0 0 4px; font-size: 1.5rem; }
.muted { color: var(--muted); margin: 0 0 16px; }
.err { color: var(--err); font-weight: 600; }
label { display: block; margin: 12px 0; font-weight: 600; }
input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
button { padding: 10px 16px; font: inherit; font-weight: 600; color: var(--acc-fg); background: var(--acc); border: 0; border-radius: 8px; cursor: pointer; }
button.link { padding: 4px 8px; color: var(--acc); background: none; text-decoration: underline; }
form > button { width: 100%; margin-top: 8px; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }

/* tappa 2: navigazione, tabella, moduli */
nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
a { color: var(--acc); }
.wide { max-width: 980px; margin: 24px auto; padding: 0 16px; }
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0 16px; }
.bar form { margin: 0; }
.bar form > button { width: auto; margin: 0; }
.btn { display: inline-block; padding: 10px 16px; font-weight: 600; color: var(--acc-fg); background: var(--acc); border-radius: 8px; text-decoration: none; }
.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { font-size: .85rem; color: var(--muted); }
tbody tr:last-child > * { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .875rem; font-weight: 600; border: 1px solid currentColor; }
.pill.ok { color: #1b7a3a; } .pill.ko { color: var(--err); } .pill.pend, .pill.off { color: var(--muted); }
@media (prefers-color-scheme: dark) { .pill.ok { color: #6fdc8c; } }
fieldset { margin: 0 0 16px; padding: 8px 16px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 6px; font-weight: 700; }
small { display: block; font-weight: 400; }
small.err { font-weight: 600; }
select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.form form > .bar > button { width: auto; margin: 0; }

/* tappa 3: scheda cliente */
section { margin: 28px 0; }
h2 { margin: 0 0 8px; font-size: 1.25rem; }
h3 { margin: 20px 0 8px; font-size: 1rem; }
.dati { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; margin: 0; }
.dati dt { font-size: .85rem; color: var(--muted); }
.dati dd { margin: 0; overflow-wrap: anywhere; }
code { font-size: .85rem; }

/* tappa 4: Nuovo spot */
.pill.warn { color: #a15c00; }
@media (prefers-color-scheme: dark) { .pill.warn { color: #ffb74d; } }
.btn.off { background: var(--line); color: var(--muted); cursor: not-allowed; }
.wide-card { max-width: 720px; margin: 24px auto; }
.avviso { padding: 10px 14px; border: 1px solid var(--acc); border-radius: 8px; background: var(--card); }
.giorni { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0; }
.giorni label.check { margin: 4px 0; }
.passi { list-style: none; margin: 12px 0; padding: 0; }
.passi li { padding: 4px 0; color: var(--muted); }
.passi li.fatto { color: var(--fg); }
.passi li.corso { color: var(--fg); font-weight: 700; }
.passi li.ko { color: var(--err); font-weight: 700; }
.ok-txt { color: #1b7a3a; }
@media (prefers-color-scheme: dark) { .ok-txt { color: #6fdc8c; } }
input[type=file] { padding: 8px; }

/* verifica in due passaggi */
.card.largo { max-width: 520px; margin-top: 5vh; }
.istruzioni { padding-left: 20px; margin: 8px 0; }
.qr { width: 220px; max-width: 100%; margin: 12px auto; }
.qr svg { display: block; width: 100%; height: auto; }
.chiave { text-align: center; overflow-wrap: anywhere; }
.chiave code { font-size: 1rem; letter-spacing: .05em; }
.codici { columns: 2; gap: 24px; padding-left: 28px; margin: 12px 0; }
.codici code { font-size: 1rem; letter-spacing: .05em; }
details.recupero { margin: 20px 0 8px; }
details.recupero summary { cursor: pointer; color: var(--acc); }

/* Scheda radio: eventi «Non gestiti da RemoteControl» in una tendina chiusa (titolo come gli altri h3) */
details.non-gestiti { margin: 20px 0 8px; }
details.non-gestiti > summary { cursor: pointer; font-size: 1rem; font-weight: 700; padding: 4px 0; }
details.non-gestiti[open] > summary { margin-bottom: 8px; }
details.non-gestiti > summary:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* Banner dei server (certificato in scadenza / impronta sconosciuta) */
.avvisi { margin: 0; }
.avviso { margin: 0; padding: 8px 16px; font-weight: 600; }
.avviso.rosso { background: var(--err); color: #fff; }
.avviso.giallo { background: #f5d36b; color: #3d2a00; }

/* Pulsante «Live» rosso, sempre visibile in alto (bersaglio da toccare almeno 44 px) */
a.live-rosso { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 8px 18px; border: 1px solid #f97066; border-radius: 999px; background: #d92d20; color: #fff; font-weight: 700; line-height: 1.2; text-decoration: none; }
a.live-rosso:hover { background: #b42318; color: #fff; }
a.live-rosso:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
a.live-rosso .pallino { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
a.live-rosso small { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; opacity: .9; }
@media (max-width: 520px) { a.live-rosso small { display: none; } }
