/* Alarm Manager Cloud — interfaccia della web app */

:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --bg-2: #11151c;
  --card: #161b24;
  --card-2: #1c2230;
  --linea: #262d3b;
  --testo: #eef1f6;
  --testo-2: #a3abbb;
  --testo-3: #6d7688;
  --rosso: #ff4d5e;
  --rosso-bg: #ff4d5e1f;
  --verde: #2fd07c;
  --verde-bg: #2fd07c1c;
  --ambra: #ffb547;
  --ambra-bg: #ffb5471f;
  --blu: #6ea8ff;
  --neutro: #8390a6;
  --ombra: 0 10px 40px #0008;
  --raggio: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f4f7;
    --bg-2: #eceef3;
    --card: #ffffff;
    --card-2: #f5f6f9;
    --linea: #e2e5ec;
    --testo: #141821;
    --testo-2: #555e70;
    --testo-3: #8a93a5;
    --rosso: #e5283b;
    --rosso-bg: #e5283b14;
    --verde: #11a55a;
    --verde-bg: #11a55a14;
    --ambra: #c97a00;
    --ambra-bg: #c97a0014;
    --blu: #2f6fe0;
    --neutro: #7d889c;
    --ombra: 0 10px 40px #1a22330f;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--testo);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { display: block; }
.nascosto { display: none !important; }

/* ── viste ──────────────────────────────────────────────────────────────── */
.vista { display: none; }
.vista.visibile { display: block; }
.vista-avvio.visibile { display: grid; place-items: center; min-height: 100dvh; }
.avvio-logo { width: 72px; height: 72px; border-radius: 18px; animation: respiro 1.6s ease-in-out infinite; }
@keyframes respiro { 50% { transform: scale(.93); opacity: .7; } }

/* ── bottoni e campi ────────────────────────────────────────────────────── */
.bottone {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px;
  font-weight: 600; font-size: 15.5px; letter-spacing: -.01em;
  transition: transform .12s, filter .15s, background .15s, opacity .15s;
  user-select: none; -webkit-user-select: none;
}
.bottone:active { transform: scale(.98); }
.bottone:disabled { opacity: .5; pointer-events: none; }
.bottone svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottone.largo { width: 100%; }
.bottone.primario { background: var(--testo); color: var(--bg); }
.bottone.secondario { background: var(--card-2); border: 1px solid var(--linea); }
.bottone.fantasma { color: var(--testo-2); }
.bottone.pericolo { background: var(--rosso); color: #fff; }
.bottone.successo { background: var(--verde); color: #fff; }
.bottone.pericolo-testo { color: var(--rosso); background: var(--rosso-bg); }
.bottone.in-corso { position: relative; color: transparent !important; }
.bottone.in-corso::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--bg); border-right-color: transparent; animation: gira .7s linear infinite;
}
.bottone.secondario.in-corso::after { border-color: var(--testo); border-right-color: transparent; }
@keyframes gira { to { transform: rotate(360deg); } }

.campo { display: grid; gap: 7px; }
.campo > span { font-size: 13px; font-weight: 600; color: var(--testo-2); }
.campo input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--linea); outline: none;
  font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.campo input:focus { border-color: var(--blu); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blu) 20%, transparent); }
.campo-pwd { position: relative; }
.campo-pwd input { padding-right: 48px; }
.pwd-occhio { position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--testo-3); }
.pwd-occhio svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.campo-riga { display: flex; gap: 8px; }
.campo-riga input { flex: 1; min-width: 0; }

.scheda {
  background: var(--card); border: 1px solid var(--linea); border-radius: var(--raggio);
  padding: 18px;
}
.scheda h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.scheda-testa { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.riga-bottoni { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.riga-bottoni .bottone { flex: 1; }

/* ── accesso ────────────────────────────────────────────────────────────── */
.vista-accesso.visibile { display: grid; place-items: center; min-height: 100dvh; padding: 32px 16px calc(24px + env(safe-area-inset-bottom)); }
.accesso-box { width: 100%; max-width: 400px; text-align: center; }
.accesso-logo { width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 18px; box-shadow: 0 12px 32px #e5283b40; }
.accesso-box h1 { font-size: 26px; letter-spacing: -.02em; }
.accesso-sotto { color: var(--testo-2); margin: 8px 0 26px; line-height: 1.45; font-size: 15px; }
#form-accesso { text-align: left; display: grid; gap: 16px; padding: 20px; box-shadow: var(--ombra); }
.errore-form { color: var(--rosso); font-size: 14px; min-height: 0; }
.errore-form:empty { display: none; }
.separatore { display: flex; align-items: center; gap: 12px; color: var(--testo-3); font-size: 13px; margin: 20px 0; }
.separatore::before, .separatore::after { content: ""; flex: 1; height: 1px; background: var(--linea); }
.accesso-nota { color: var(--testo-3); font-size: 12.5px; line-height: 1.5; margin-top: 22px; }

/* ── app ────────────────────────────────────────────────────────────────── */
.vista-app.visibile { display: block; }
.testata {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  max-width: 560px; margin: 0 auto;
}
.marchio { display: flex; align-items: center; gap: 11px; }
.marchio img { width: 36px; height: 36px; border-radius: 10px; }
.marchio b { display: block; font-size: 15.5px; letter-spacing: -.01em; }
.marchio span { display: block; font-size: 12.5px; color: var(--testo-3); }
.icona-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--linea); color: var(--testo-2);
}
.icona-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.contenuto {
  max-width: 560px; margin: 0 auto;
  padding: 6px 16px calc(28px + env(safe-area-inset-bottom));
  display: grid; gap: 14px;
}

.chip-agente {
  justify-self: center; display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 550;
  background: var(--card); border: 1px solid var(--linea); color: var(--testo-2);
}
.chip-agente .punto { width: 8px; height: 8px; border-radius: 50%; background: var(--neutro); }
.chip-agente.online .punto { background: var(--verde); box-shadow: 0 0 0 0 var(--verde); animation: pulsa 2.4s infinite; }
.chip-agente.offline { color: var(--rosso); border-color: color-mix(in srgb, var(--rosso) 35%, var(--linea)); }
.chip-agente.offline .punto { background: var(--rosso); }
@keyframes pulsa { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--verde) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

/* ── centrale (lucchetto) ───────────────────────────────────────────────── */
.centrale { --c: var(--neutro); --c-bg: color-mix(in srgb, var(--neutro) 12%, transparent);
  text-align: center; padding: 18px 0 6px; display: grid; justify-items: center; gap: 18px; }
.centrale.attivo { --c: var(--rosso); --c-bg: var(--rosso-bg); }
.centrale.disattivo { --c: var(--verde); --c-bg: var(--verde-bg); }
.centrale.attesa { --c: var(--ambra); --c-bg: var(--ambra-bg); }

.lucchetto {
  position: relative; width: min(64vw, 236px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .25s cubic-bezier(.2, .8, .3, 1);
}
.lucchetto:disabled { cursor: default; }
.lucchetto.premuto { transform: scale(.955); }
.lucchetto:focus-visible { outline: 3px solid var(--blu); outline-offset: 6px; }
.anello { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.anello circle { fill: none; stroke-width: 7; }
.anello-fondo { stroke: color-mix(in srgb, var(--c) 22%, transparent); transition: stroke .4s; }
.anello-carica {
  stroke: var(--c); stroke-linecap: round;
  stroke-dasharray: 653.5; stroke-dashoffset: 653.5;
  transition: stroke-dashoffset .35s ease-out, stroke .4s;
}
.lucchetto.premuto .anello-carica { stroke-dashoffset: 0; transition: stroke-dashoffset var(--tieni, 1.1s) linear; }
.centrale.attesa .anello-carica { stroke-dasharray: 120 533.5; stroke-dashoffset: 0; transform-origin: 110px 110px; animation: gira 1.1s linear infinite; }

.lucchetto-disco {
  position: absolute; inset: 16px; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--c) 26%, var(--card)) 0%, var(--card) 70%);
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--linea));
  box-shadow: 0 20px 60px color-mix(in srgb, var(--c) 28%, transparent), inset 0 1px 0 #ffffff14;
  transition: background .5s, box-shadow .5s, border-color .5s;
}
.lucchetto-icona { width: 42%; height: 42%; overflow: visible; }
.lucchetto-icona .corpo { fill: var(--c); transition: fill .4s; }
.lucchetto-icona .foro { fill: var(--card); stroke: var(--card); stroke-width: 3.4; stroke-linecap: round; }
.lucchetto-icona .arco {
  fill: none; stroke: var(--c); stroke-width: 6; stroke-linecap: round;
  transition: transform .45s cubic-bezier(.3, 1.5, .5, 1), opacity .25s, stroke .4s;
}
.lucchetto-icona .aperto { opacity: 0; transform: translateY(0); }
.centrale.disattivo .chiuso { opacity: 0; transform: translateY(-5px); }
.centrale.disattivo .aperto { opacity: 1; transform: translateY(-5px); }

.centrale-stato { display: grid; gap: 4px; }
.etichetta-stato { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--testo-3); }
.centrale-stato h1 { font-size: 30px; letter-spacing: -.025em; color: var(--c); transition: color .4s; }
.centrale-stato p { color: var(--testo-2); font-size: 14px; }
.centrale-aiuto { font-size: 14px; color: var(--testo-3); min-height: 20px; }
.centrale-aiuto b { color: var(--testo); font-weight: 600; }
.centrale-aiuto.scuoti { animation: scuoti .4s; }
@keyframes scuoti { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.doppio { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.doppio .bottone { font-size: 14px; padding: 0 10px; position: relative; overflow: hidden; }
.doppio .bottone::before {
  content: ""; position: absolute; inset: 0; background: #ffffff38;
  transform: scaleX(0); transform-origin: left; transition: transform .3s;
}
.doppio .bottone.premuto::before { transform: scaleX(1); transition: transform var(--tieni, 1.1s) linear; }

/* ── avanzamento ────────────────────────────────────────────────────────── */
.avanzamento h2 { margin-bottom: 14px; }
.passi { list-style: none; display: grid; gap: 0; }
.passi li { display: flex; gap: 12px; position: relative; padding-bottom: 16px; color: var(--testo-3); }
.passi li:last-child { padding-bottom: 0; }
.passi li::before {
  content: ""; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 2px; background: var(--linea);
}
.passi li:last-child::before { display: none; }
.passi .segno {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--linea);
  display: grid; place-items: center; background: var(--card); position: relative; z-index: 1;
}
.passi b { display: block; font-size: 14.5px; font-weight: 600; }
.passi small { display: block; font-size: 12.5px; margin-top: 2px; }
.passi li.fatto { color: var(--testo); }
.passi li.fatto .segno { background: var(--verde); border-color: var(--verde); }
.passi li.fatto .segno::after { content: ""; width: 9px; height: 5px; border: 2.2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.passi li.fatto::before { background: var(--verde); }
.passi li.corrente { color: var(--testo); }
.passi li.corrente .segno { border-color: var(--ambra); border-right-color: transparent; animation: gira .9s linear infinite; }
.passi li.errore { color: var(--rosso); }
.passi li.errore .segno { background: var(--rosso); border-color: var(--rosso); }
.passi li.errore .segno::after { content: "!"; color: #fff; font-weight: 800; font-size: 13px; }
.av-nota { font-size: 13px; color: var(--testo-2); margin-top: 12px; }
.av-nota:empty { display: none; }

.avviso {
  background: var(--ambra-bg); color: var(--ambra); border: 1px solid color-mix(in srgb, var(--ambra) 30%, transparent);
  border-radius: 14px; padding: 12px 14px; font-size: 13.5px; line-height: 1.45;
}

/* ── invito passkey ─────────────────────────────────────────────────────── */
.invito { display: flex; gap: 14px; align-items: flex-start; }
.invito-icona { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--blu) 16%, transparent); color: var(--blu); }
.invito-icona svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.invito p { color: var(--testo-2); font-size: 13.5px; margin-top: 4px; line-height: 1.45; }

/* ── attività ───────────────────────────────────────────────────────────── */
.attivita { list-style: none; }
.attivita li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--linea); }
.attivita li:first-child { border-top: 0; }
.attivita li.vuoto { color: var(--testo-3); font-size: 14px; justify-content: center; padding: 18px 0 8px; }
.att-icona { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; }
.att-icona svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.att-icona.attivo { background: var(--rosso-bg); color: var(--rosso); }
.att-icona.disattivo { background: var(--verde-bg); color: var(--verde); }
.att-testo { flex: 1; min-width: 0; }
.att-testo b { display: block; font-size: 14.5px; font-weight: 600; }
.att-testo small { display: block; font-size: 12.5px; color: var(--testo-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.pill.ok { background: var(--verde-bg); color: var(--verde); }
.pill.ko { background: var(--rosso-bg); color: var(--rosso); }
.pill.att { background: var(--ambra-bg); color: var(--ambra); }
.pill.neu { background: var(--card-2); color: var(--testo-3); }

.piede { text-align: center; color: var(--testo-3); font-size: 12px; line-height: 1.5; padding: 6px 12px 0; }

/* ── foglio dispositivi ─────────────────────────────────────────────────── */
.velo { position: fixed; inset: 0; background: #0009; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20; }
.velo.aperto { opacity: 1; pointer-events: auto; }
.foglio {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto; max-height: 88dvh; overflow: auto;
  background: var(--bg); border-radius: 24px 24px 0 0; border: 1px solid var(--linea); border-bottom: 0;
  transform: translateY(105%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}
.foglio.aperto { transform: none; }
.foglio-maniglia { width: 38px; height: 5px; border-radius: 3px; background: var(--linea); margin: 9px auto 0; }
.foglio-testa { display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 4px; }
.foglio-testa h2 { font-size: 20px; letter-spacing: -.02em; }
.foglio-corpo { padding: 6px 18px 0; display: grid; gap: 10px; }
.foglio-corpo h3 { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--testo-3); margin-top: 12px; }
.scheda.interna { display: grid; gap: 16px; }
.riga-passkey { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.riga-passkey b { display: block; font-size: 14.5px; }
.riga-passkey small { display: block; font-size: 12.5px; color: var(--testo-3); margin-top: 2px; }
.riga-passkey small.ok { color: var(--verde); }
.dispositivi { list-style: none; background: var(--card); border: 1px solid var(--linea); border-radius: var(--raggio); }
.dispositivi li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--linea); }
.dispositivi li:first-child { border-top: 0; }
.disp-icona { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--card-2); display: grid; place-items: center; color: var(--testo-2); }
.disp-icona svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.disp-testo { flex: 1; min-width: 0; }
.disp-testo b { display: flex; align-items: center; gap: 6px; font-size: 14.5px; }
.disp-testo small { display: block; font-size: 12.5px; color: var(--testo-3); }
.tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--blu) 16%, transparent); color: var(--blu); }
.revoca { color: var(--rosso); font-size: 13.5px; font-weight: 600; padding: 8px 4px; }
.nota { color: var(--testo-3); font-size: 12.5px; line-height: 1.45; }
#f-esci { margin-top: 14px; }

/* ── dialogo e toast ────────────────────────────────────────────────────── */
.dialogo { position: fixed; inset: 0; z-index: 40; display: none; place-items: center; padding: 24px; background: #000a; }
.dialogo.aperto { display: grid; animation: compari .18s ease-out; }
.dialogo-box { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--linea); border-radius: 20px; padding: 22px; box-shadow: var(--ombra); }
.dialogo-box h2 { font-size: 18px; letter-spacing: -.01em; }
.dialogo-box p { color: var(--testo-2); font-size: 14.5px; margin-top: 8px; line-height: 1.5; }
@keyframes compari { from { opacity: 0; transform: scale(.97); } }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 440px); padding: 12px 16px; border-radius: 14px;
  background: var(--testo); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: var(--ombra);
  transition: opacity .2s, transform .25s;
}
.toast.visibile { opacity: 1; transform: translate(-50%, 0); }
.toast.errore { background: var(--rosso); color: #fff; }

@media (min-width: 700px) {
  .contenuto { padding-top: 18px; }
  .foglio { bottom: auto; top: 50%; border-radius: 24px; border-bottom: 1px solid var(--linea);
    transform: translateY(-46%) scale(.98); opacity: 0; pointer-events: none; transition: transform .25s, opacity .2s; max-width: 480px; }
  .foglio.aperto { transform: translateY(-50%); opacity: 1; pointer-events: auto; }
  .foglio-maniglia { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
