/* ── Le pagine della webapp 4C, ridisegnate nello stile della pagina Impianto ────────────────
   Si carica DOPO style.css e stile.css. Non c'è una riga di programma dell'ingegnere toccata:
   le sue pagine costruiscono gli stessi elementi di prima, qui cambia come sono disposti e
   disegnati. I titoli in testa e la «giornata» dei canali li aggiunge agx/pagine.js.
   Per tornare a com'era basta togliere da index.html le due righe di pagine.css e pagine.js. */

:root {
  --agx-carta: linear-gradient(160deg, rgba(233, 243, 239, .10), rgba(233, 243, 239, .04));
  --agx-carta-bordo: inset 0 0 0 1px rgba(233, 243, 239, .13), 0 14px 30px rgba(0, 0, 0, .30);
  --agx-incavo: rgba(4, 13, 10, .42);
}

/* ── Testa di pagina: riga piccola, titolo grande in Fraunces, una riga di stato ───────────── */
.agx-pt { padding: 0 2px 16px; }
.agx-pt-sopra { display: flex; align-items: center; gap: 8px; min-height: 18px; font: 500 13px 'IBM Plex Sans', sans-serif; color: #8FB3A9; }
.agx-pt-sopra i { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #2DD4BF; box-shadow: 0 0 0 4px rgba(45, 212, 191, .18); }
.agx-pt-sopra i.fuori { background: #FF8C80; box-shadow: 0 0 0 4px rgba(255, 140, 128, .18); }
.agx-pt-sopra i.attesa { background: #E8A33D; box-shadow: 0 0 0 4px rgba(232, 163, 61, .18); }
.agx-pt h1 { font: 700 32px/1.05 'Fraunces', serif; color: #fff; margin: 3px 0 0; letter-spacing: 0; }
.agx-pt-sotto { margin-top: 7px; font: 400 13.5px/1.35 'IBM Plex Sans', sans-serif; color: #A9C2BA; }
.agx-pt-sotto:empty { display: none; }
.agx-pt-sotto b { color: #5FE0CC; font-weight: 600; }
.agx-pt-sotto b.ambra { color: #F3D9A8; }
.agx-pt-sotto b.rosso { color: #FFB4AB; }
/* il vecchio titolo di pagina lascia il posto alla testa; restano i suoi pulsanti, in alto a destra */
.page { position: relative; }
.page:has(> .agx-pt) > .page-header { position: absolute; top: 6px; right: 0; margin: 0; padding: 0; border: 0; }
.page:has(> .agx-pt) > .page-header h2 { display: none; }

/* scelta dell'impianto: una pillola, senza scatola */
#valv-struct-bar, #ctrl-struct-bar, #sens-struct-bar { padding: 0; background: none; border: 0; gap: 10px; }
#valv-struct-bar label, #ctrl-struct-bar label, #sens-struct-bar label { display: none; }
#valv-struct-sel, #ctrl-struct-sel, #sens-struct-sel { height: 44px; padding: 0 16px; border-radius: 22px; font: 600 14px 'IBM Plex Sans', sans-serif;
  background: rgba(233, 243, 239, .08); border: 0; box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .22); color: #E9F3EF; }
#valv-struct-bar .ctrl-dot { display: none; }   /* lo stato della centralina è nella testa */

/* ══ VALVOLE e CONTROLLI ═══════════════════════════════════════════════════════════════════ */
/* Tutta la pagina scorre (prima scorreva solo l'elenco, sotto 4 barre fisse): in alto restano
   attaccati i due comandi che contano, il modo (timer/manuale) e l'emergenza. */
#page-valvole.active, #page-controlli.active { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-content: start; overflow: visible; }
#page-valvole > *, #page-controlli > * { grid-column: 1 / -1; min-width: 0; }
#page-valvole > .agx-pt, #page-controlli > .agx-pt { grid-row: 1; }
#valv-avviso { grid-row: 2; }
#valv-struct-bar, #ctrl-struct-bar { grid-row: 3; margin-bottom: 12px; }
#valv-action-bar, #ctrl-action-bar { display: contents; }
#btn-valv-sched, #btn-ctrl-sched { grid-row: 4; grid-column: 1; }
#valv-alloff-bar, #ctrl-alloff-bar { grid-row: 4; grid-column: 2; padding: 0; background: none; border: 0; display: block; }
.valv-timer-tools, #btn-ctrl-clear { grid-row: 5; grid-column: 1 / -1; margin-top: 12px; }
#valv-list, #ctrl-list { grid-row: 6; flex: none; overflow: visible; padding: 6px 0 24px; background: none; }
#btn-valv-sched, #btn-ctrl-sched, #valv-alloff-bar, #ctrl-alloff-bar { position: sticky; top: 12px; z-index: 6; }
/* la fascia dietro ai due comandi: compare solo quando la pagina è scorsa (la classe la mette pagine.js) */
#page-valvole::before, #page-controlli::before { content: ''; grid-row: 4; grid-column: 1 / -1; position: sticky; top: 0; z-index: 5; margin: -12px -20px -16px; pointer-events: none;
  background: linear-gradient(rgba(9, 28, 23, .97) 78%, rgba(9, 28, 23, 0)); box-shadow: 0 -24px 0 rgba(9, 28, 23, .97); opacity: 0; transition: opacity .18s; }
body.agx-scorso #page-valvole::before, body.agx-scorso #page-controlli::before { opacity: 1; }

/* il modo: timer attivi (comanda la centralina) oppure manuale */
#btn-valv-sched, #btn-ctrl-sched, #btn-alloff, #btn-alloff-c {
  width: 100%; height: 58px; padding: 0 12px 0 14px; border-radius: 20px; border: 0; margin: 0;
  display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; gap: 1px 8px; align-content: center; justify-items: start; text-align: left;
  font: 700 14px 'IBM Plex Sans', sans-serif; letter-spacing: 0; white-space: nowrap; overflow: hidden; animation: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .38); -webkit-tap-highlight-color: transparent; }
#btn-valv-sched .st-icon, #btn-ctrl-sched .st-icon, #btn-alloff .alloff-icon, #btn-alloff-c .alloff-icon { grid-row: 1 / 3; align-self: center; font-size: 20px; line-height: 1; }
#btn-valv-sched::after, #btn-ctrl-sched::after, #btn-alloff::after, #btn-alloff-c::after { grid-column: 2; font: 500 11px 'IBM Plex Sans', sans-serif; opacity: .78; }
#valv-sched-label, #ctrl-sched-label { font-size: 0; line-height: 0; }
#valv-sched-label::before, #ctrl-sched-label::before, #btn-alloff > span:nth-child(2)::before, #btn-alloff-c > span:nth-child(2)::before { line-height: 1.3; }
#btn-valv-sched.sched-on, #btn-ctrl-sched.sched-on { background: #123B34; color: #5FE0CC; box-shadow: inset 0 0 0 1.5px rgba(45, 212, 191, .6), 0 10px 24px rgba(0, 0, 0, .38); }
#btn-valv-sched.sched-on #valv-sched-label::before, #btn-ctrl-sched.sched-on #ctrl-sched-label::before { content: 'Timer attivi'; font-size: 14px; }
#btn-valv-sched.sched-on::after, #btn-ctrl-sched.sched-on::after { content: 'comanda la centralina'; }
#btn-valv-sched.sched-off, #btn-ctrl-sched.sched-off { background: #3A2C12; color: #F3D9A8; box-shadow: inset 0 0 0 1.5px rgba(232, 163, 61, .7), 0 10px 24px rgba(0, 0, 0, .38); }
#btn-valv-sched.sched-off #valv-sched-label::before, #btn-ctrl-sched.sched-off #ctrl-sched-label::before { content: 'Manuale'; font-size: 14px; }
#btn-valv-sched.sched-off::after, #btn-ctrl-sched.sched-off::after { content: 'apri e chiudi a mano'; }

/* l'emergenza: sempre a portata di dito, rossa, mai confondibile */
#btn-alloff, #btn-alloff-c { background: #3A1815; color: #FFB4AB; box-shadow: inset 0 0 0 1.5px rgba(255, 140, 128, .65), 0 10px 24px rgba(0, 0, 0, .38); }
#btn-alloff > span:nth-child(2), #btn-alloff-c > span:nth-child(2) { font-size: 0; line-height: 0; letter-spacing: 0; }
#btn-alloff > span:nth-child(2)::before, #btn-alloff-c > span:nth-child(2)::before { content: 'Ferma tutto'; font-size: 14px; }
#btn-alloff::after, #btn-alloff-c::after { content: 'emergenza'; }
#btn-alloff .alloff-badge, #btn-alloff-c .alloff-badge { display: none; }
#btn-alloff.active, #btn-alloff-c.active { background: #C1443A; color: #fff; box-shadow: 0 0 0 4px rgba(255, 140, 128, .28), 0 10px 24px rgba(0, 0, 0, .38); animation: agx-pulsa 1.6s ease-in-out infinite; }
#btn-alloff.active > span:nth-child(2)::before, #btn-alloff-c.active > span:nth-child(2)::before { content: 'Emergenza attiva'; }
#btn-alloff.active::after, #btn-alloff-c.active::after { content: 'tocca per disattivare'; opacity: .95; }

/* gli strumenti dei timer: tre pillole leggere */
.valv-timer-tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 0; }
.valv-action-btn { flex: none; height: 38px; padding: 0 16px; border-radius: 19px; border: 0; background: rgba(233, 243, 239, .07); color: #E9F3EF;
  box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .24); font: 600 13px 'IBM Plex Sans', sans-serif; letter-spacing: 0; }
.valv-action-btn .va-icon { display: none; }
.valv-action-btn > span:last-child { display: inline-block; text-transform: lowercase; }
.valv-action-btn > span:last-child::first-letter { text-transform: uppercase; }
.valv-action-btn.danger { background: none; color: #FFB4AB; box-shadow: inset 0 0 0 1.2px rgba(255, 140, 128, .45); }
#btn-valv-clear > span:last-child::after { content: ' i timer'; }
#btn-ctrl-clear { justify-self: start; }

/* un attuatore = un gruppo con il suo nome; i canali sono già aperti (un tocco sul nome li raccoglie) */
.valv-modulo { background: none; border: 0; box-shadow: none; border-radius: 0; overflow: visible; margin: 0 0 6px; }
.valv-modulo-hdr, .valv-modulo-hdr.open, .valv-modulo-hdr:hover { background: none; border: 0; padding: 14px 2px 10px; gap: 10px; }
.valv-mod-name { font: 700 20px 'Fraunces', serif; color: #fff; flex: none; }
.valv-mod-addr { flex: 1; font: 500 11px 'IBM Plex Mono', monospace; color: #7FA196; letter-spacing: .06em; text-transform: uppercase; }
.valv-mod-arrow { order: 3; width: 30px; height: 30px; border-radius: 50%; font-size: 0; background: rgba(233, 243, 239, .07); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .14);
  transform: rotate(0); display: flex; align-items: center; justify-content: center; }
.valv-mod-arrow::before { content: ''; width: 8px; height: 8px; border-right: 2px solid #A9C2BA; border-bottom: 2px solid #A9C2BA; transform: translateY(-2px) rotate(45deg); }
.valv-mod-arrow.open { transform: rotate(-90deg); }
.valv-canali { display: grid; gap: 10px; }
.valv-canali.open { display: none; }
/* quanti canali ha l'attuatore e quanti sono aperti (lo scrive pagine.js) */
.valv-modulo-hdr .agx-conta { flex: 1; min-width: 0; font: 500 12.5px 'IBM Plex Sans', sans-serif; color: #A9C2BA; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.valv-modulo-hdr .agx-conta b { color: #5FE0CC; font-weight: 600; }
.valv-modulo-hdr:has(.agx-conta) .valv-mod-addr { flex: none; }
/* impianto grande (4 attuatori o più): i gruppi partono raccolti, come nella pagina dell'ingegnere, e si aprono col tocco;
   quello che sta bagnando lo apre da sé pagine.js */
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-canali, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-canali { display: none; }
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-canali.open, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-canali.open { display: grid; }
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-mod-arrow, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-mod-arrow { transform: rotate(-90deg); }
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-mod-arrow.open, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-mod-arrow.open { transform: rotate(0); }
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-modulo, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-modulo { margin: 0 0 8px; padding: 0 14px; border-radius: 24px; background: var(--agx-carta); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .12); }
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-canali.open, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-canali.open { padding-bottom: 14px; }
#valv-list:has(> .valv-modulo:nth-child(4)) .valv-canale-card, #ctrl-list:has(> .valv-modulo:nth-child(4)) .valv-canale-card { background: var(--agx-incavo); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .09); }

/* un canale = una scheda: anello di stato, nome, interruttore, la sua giornata, i suoi timer */
.valv-canale-card, .valv-canale-card:last-child { padding: 14px 14px 12px 16px; border: 0; border-radius: 24px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); }
.valv-ch-top { display: grid; grid-template-columns: 46px auto 1fr auto; grid-template-rows: auto auto; column-gap: 0; row-gap: 1px; align-items: center; margin: 0; }
.valv-ch-top .led { grid-row: 1 / 3; width: 36px; height: 36px; border-radius: 50%; background: rgba(233, 243, 239, .05) center / 17px no-repeat; box-shadow: inset 0 0 0 2px rgba(233, 243, 239, .22);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A9C2BA' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M12 3.2c3.2 4.2 6 7.4 6 11a6 6 0 0 1-12 0c0-3.6 2.8-6.800 6-11z'/%3E%3C/svg%3E"); }
.valv-ch-top .led:has(+ .pompa) { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A9C2BA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 4v16M5.100 8l13.800 8M18.900 8L5.100 16'/%3E%3C/svg%3E"); }
.valv-ch-top .led.on { background-color: rgba(45, 212, 191, .2); box-shadow: inset 0 0 0 2px #2DD4BF, 0 0 0 5px rgba(45, 212, 191, .16); animation: agx-pulsa 2.4s ease-in-out infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232DD4BF' stroke='%232DD4BF' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M12 3.2c3.2 4.2 6 7.4 6 11a6 6 0 0 1-12 0c0-3.6 2.8-6.800 6-11z'/%3E%3C/svg%3E"); }
.valv-ch-top .led.on:has(+ .pompa) { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232DD4BF' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 4v16M5.100 8l13.800 8M18.900 8L5.100 16'/%3E%3C/svg%3E"); }
.valv-ch-name { grid-column: 2 / 4; grid-row: 1; font: 600 16.5px/1.2 'IBM Plex Sans', sans-serif; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.valv-ch-top .casc-ch-type { grid-column: 2; grid-row: 2; padding: 0; background: none; border: 0; border-radius: 0; font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .1em; color: #8FB3A9; }
.valv-ch-state { grid-column: 3; grid-row: 2; font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .1em; color: #8FB3A9; }
.valv-ch-state::before { content: '·'; margin: 0 7px; }
.valv-ch-state.on { color: #5FE0CC; font-weight: 600; }

/* l'interruttore: lo stesso pulsante ON/OFF, disegnato come una levetta */
.valv-ch-top .btn-onoff, .tree-canale .btn-onoff { grid-column: 4; grid-row: 1 / 3; position: relative; width: 60px; height: 34px; padding: 0; margin: 0; border: 0; border-radius: 17px; font-size: 0;
  background: rgba(233, 243, 239, .12); box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .26); transition: background .2s; -webkit-tap-highlight-color: transparent; }
.valv-ch-top .btn-onoff::after, .tree-canale .btn-onoff::after { content: ''; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #CFE2DB; box-shadow: 0 2px 5px rgba(0, 0, 0, .4); transition: transform .2s, background .2s; }
.valv-ch-top .btn-onoff.on, .tree-canale .btn-onoff.on { background: #1FB8A5; box-shadow: inset 0 0 0 1.2px #5FE0CC, 0 0 0 4px rgba(45, 212, 191, .16); }
.valv-ch-top .btn-onoff.on::after, .tree-canale .btn-onoff.on::after { transform: translateX(26px); background: #fff; }
/* coi timer attivi il comando a mano è rifiutato dalla centralina: le levette spente lo fanno capire */
#page-valvole:has(#btn-valv-sched.sched-on) .btn-onoff.off, #page-controlli:has(#btn-ctrl-sched.sched-on) .btn-onoff.off { opacity: .42; }

/* la giornata del canale (aggiunta da pagine.js): 24 ore, i timer in ambra, l'ora di adesso */
.agx-giorno { position: relative; height: 26px; margin: 12px 0 0; }
.agx-giorno.vuota { display: none; }
.agx-giorno .pista { position: absolute; left: 0; right: 0; top: 0; height: 10px; border-radius: 5px; background: rgba(233, 243, 239, .09); overflow: hidden; }
.agx-giorno .pista i { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 3px; background: #E8A33D; }
.agx-giorno .pista i.altro { background: rgba(232, 163, 61, .32); }
.agx-giorno .pista i.ora { background: #2DD4BF; }
.agx-giorno .adesso { position: absolute; top: -3px; width: 2px; height: 16px; margin-left: -1px; border-radius: 1px; background: #fff; }
.agx-giorno .ore { position: absolute; left: 0; right: 0; top: 14px; display: flex; justify-content: space-between; font: 500 9px 'IBM Plex Mono', monospace; color: #7FA196; }

/* i timer: pillole ambra con giorno e orario; «+ timer» come pillola tratteggiata */
.valv-timer-section { padding: 0; margin-top: 8px; }
.valv-timer-title { display: none; }
.valv-timer-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.valv-timer-body .timer-row, #disp-detail-panel .timer-row { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 4px 0 12px; border: 0; border-radius: 17px; font-size: 12.5px;
  background: rgba(232, 163, 61, .13); box-shadow: inset 0 0 0 1px rgba(232, 163, 61, .42); }
.valv-timer-body .timer-day, #disp-detail-panel .timer-day { flex: none; font: 600 10.5px 'IBM Plex Mono', monospace; letter-spacing: .06em; text-transform: uppercase; color: #F3D9A8; }
.valv-timer-body .timer-time, #disp-detail-panel .timer-time { flex: none; font: 600 13px 'IBM Plex Mono', monospace; color: #fff; }
.valv-timer-body .timer-edit, .valv-timer-body .timer-del, #disp-detail-panel .timer-edit, #disp-detail-panel .timer-del { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; font-size: 0; background: rgba(233, 243, 239, .1); color: #E9F3EF;
  display: flex; align-items: center; justify-content: center; }
.valv-timer-body .timer-edit::before, #disp-detail-panel .timer-edit::before, .valv-timer-body .timer-del::before, #disp-detail-panel .timer-del::before { content: ''; width: 14px; height: 14px; background: center / contain no-repeat; }
.valv-timer-body .timer-edit::before, #disp-detail-panel .timer-edit::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E9F3EF' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3l4 4L8 20l-5 1 1-5z'/%3E%3C/svg%3E"); }
.valv-timer-body .timer-del::before, #disp-detail-panel .timer-del::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFB4AB' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
/* l'area di tocco è più larga del disegno: matita, crocetta e levetta si prendono anche con un dito grosso */
.valv-timer-body .timer-edit, .valv-timer-body .timer-del, #disp-detail-panel .timer-edit, #disp-detail-panel .timer-del { position: relative; width: 30px; height: 30px; }
.valv-timer-body .timer-edit::after, .valv-timer-body .timer-del::after, #disp-detail-panel .timer-edit::after, #disp-detail-panel .timer-del::after { content: ''; position: absolute; inset: -7px -4px; }
.valv-timer-body .timer-row, #disp-detail-panel .timer-row { height: 40px; border-radius: 20px; gap: 8px; padding-right: 5px; }
.valv-ch-top .btn-onoff::before, .tree-canale .btn-onoff::before { content: ''; position: absolute; inset: -8px; }
.valv-timer-body .timer-empty { font-size: 12.5px; color: #7FA196; padding: 0 4px 0 0; }
.valv-timer-body .btn-timer-add, #disp-detail-panel .btn-timer-add { width: auto; height: 34px; margin: 0; padding: 0 14px; border-radius: 17px; background: none; border: 1.2px dashed rgba(95, 224, 204, .5); color: #5FE0CC; font: 600 12.5px 'IBM Plex Sans', sans-serif; }

/* ══ SENSORI ═══════════════════════════════════════════════════════════════════════════════ */
#page-sensori.active { display: block; }
#sens-struct-bar { margin-bottom: 10px; }
#sens-action-bar { padding: 0; margin: 0 0 14px; background: none; border: 0; justify-content: flex-start; gap: 8px; }
#sens-action-bar .sens-page-title, #sens-action-bar #sens-ctrl-dot { display: none; }
#sens-action-bar .sens-add-btn { height: 40px; padding: 0 16px; border-radius: 20px; font: 600 13px 'IBM Plex Sans', sans-serif; letter-spacing: 0; text-transform: none; }
#sens-action-bar .sens-tool-btn { background: rgba(233, 243, 239, .07) !important; border: 0 !important; box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .24); color: #E9F3EF; }
#btn-new-sensore { order: -1; }
#sensori-list { padding: 0 0 24px; background: none; display: grid; gap: 12px; overflow: visible; }
.sens-card { margin: 0; padding: 16px; border: 0; border-radius: 26px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); }
.sens-card::before { display: none; }
.sens-card-hdr { padding: 0; border: 0; background: none; gap: 12px; align-items: center; }
.sens-card-icon { width: 40px; height: 40px; border-radius: 50%; background: rgba(45, 212, 191, .12); border: 0; box-shadow: inset 0 0 0 1.5px rgba(45, 212, 191, .4); color: #5FE0CC; }
.sens-card-nome { font: 700 20px/1.15 'Fraunces', serif; color: #fff; }
.sens-card-meta { gap: 0; margin-top: 3px; }
.sens-card-meta .sens-tipo-badge, .sens-card-meta .sens-addr-badge { padding: 0; border: 0; background: none; border-radius: 0; font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .08em; text-transform: uppercase; color: #8FB3A9; }
.sens-card-meta .sens-addr-badge::before { content: '·'; margin: 0 7px; }
.sens-card-actions .icon-btn, .struttura-actions .icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 0; background: rgba(233, 243, 239, .07); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .16); color: #C7DDD5; }
.sens-canali-list { padding: 0; margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; background: none; border: 0; }
.sens-canale-row { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 8px; align-items: baseline; padding: 12px 14px 12px; border: 0; border-radius: 18px;
  background: var(--agx-incavo); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .09); }
.sens-ch-num { font: 600 10px 'IBM Plex Mono', monospace; letter-spacing: .1em; color: #5FE0CC; background: none; padding: 0; border: 0; }
.sens-ch-name { font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: #A9C2BA; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sens-ch-value { grid-column: 1 / -1; font: 700 30px/1.05 'Fraunces', serif; color: #fff; text-align: left; background: none; padding: 0; border: 0; }
.sens-ch-value.ok { color: #fff; }
.sens-ch-value.error { color: #FFB4AB; }
.sens-no-canali { padding: 4px 2px; font-size: 13px; color: #7FA196; }

/* ══ AZIENDE (la pagina delle strutture) ══════════════════════════════════════════════════════════════════════════════════ */
#btn-new-struttura { width: auto; height: 40px; padding: 0 16px 0 12px; border-radius: 20px; border: 0; gap: 6px; font-size: 20px; line-height: 1;
  background: rgba(233, 243, 239, .08); box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .26); color: #E9F3EF; }
#btn-new-struttura::after { content: 'Nuova azienda'; font: 600 13px 'IBM Plex Sans', sans-serif; }
#strutture-list { display: grid; gap: 14px; }
#strutture-list .struttura-card { margin: 0; padding: 16px; border: 0; border-radius: 28px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo);
  display: grid; grid-template-columns: 76px 1fr auto; grid-template-areas: 'art info info' 'azioni azioni vai'; gap: 14px 14px; align-items: center; overflow: visible; }
#strutture-list .struttura-card::before, #gestione-corpo .struttura-card::before { display: none; }
#strutture-list .struttura-icon { grid-area: art; width: 76px; height: 64px; border: 0; border-radius: 0; background: center / contain no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 76 64'%3E%3Cpath d='M38 14l32 16-32 16L6 30z' fill='%230A1D18'/%3E%3Cpath d='M6 30v6l32 16V46zM70 30v6L38 52V46z' fill='%2306120F'/%3E%3Cpath d='M38 10l32 16-32 16L6 26z' fill='%2319423A' stroke='%232F6F62' stroke-width='1'/%3E%3Cpath d='M38 13.500l11.500 5.800-11.500 5.700-11.500-5.700zM51.800 20.400l11.500 5.800-11.500 5.700-11.500-5.700zM24.200 20.400l11.500 5.800-11.500 5.700-11.500-5.700zM38 27.300l11.500 5.800L38 38.800l-11.500-5.700z' fill='%2327695C'/%3E%3Cpath d='M38 13.500l11.500 5.800-11.500 5.700-11.500-5.700z' fill='%232DD4BF' fill-opacity='.55'/%3E%3C/svg%3E"); }
#strutture-list .struttura-icon svg { display: none; }
#strutture-list .struttura-info { grid-area: info; }
#strutture-list .struttura-nome { font: 700 22px/1.12 'Fraunces', serif; color: #fff; }
/* lo stato della centralina, scritto: il pallino da solo non si capisce */
.struttura-info .ctrl-dot, .dash-card-hdr .dash-dot { display: inline-flex; align-items: center; gap: 7px; width: auto; height: auto; margin-top: 6px; border-radius: 0; background: none; box-shadow: none; animation: none;
  font: 500 12.5px 'IBM Plex Sans', sans-serif; color: #A9C2BA; }
.struttura-info .ctrl-dot::before, .dash-card-hdr .dash-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #E8A33D; }
.struttura-info .ctrl-dot::after { content: 'In attesa della centralina'; }
.struttura-info .ctrl-dot.online::before, .dash-card-hdr .dash-dot.online::before { background: #2DD4BF; box-shadow: 0 0 0 4px rgba(45, 212, 191, .18); }
.struttura-info .ctrl-dot.online::after, .dash-card-hdr .dash-dot.online::after { content: 'In linea'; color: #5FE0CC; }
.struttura-info .ctrl-dot.offline::before, .dash-card-hdr .dash-dot.offline::before { background: #FF8C80; }
.struttura-info .ctrl-dot.offline::after { content: 'Fuori linea'; color: #FFB4AB; }
.dash-card-hdr .dash-dot.offline::after { content: 'Nessun dato'; color: #FFB4AB; }
#strutture-list .struttura-actions { grid-area: azioni; gap: 8px; }
#strutture-list .btn-go { grid-area: vai; height: 44px; padding: 0 22px; border-radius: 22px; font: 700 13px 'IBM Plex Sans', sans-serif; letter-spacing: .06em; box-shadow: 0 3px 0 #B97A1F; }

/* ══ DASHBOARD ═════════════════════════════════════════════════════════════════════════════ */
#dashboard-cards { display: grid; gap: 14px; padding: 0; }
.dash-card { margin: 0; border: 0; border-radius: 28px; overflow: hidden; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); }
.dash-card-hdr { padding: 16px 18px 4px; background: none; border: 0; align-items: flex-start; flex-direction: column; gap: 0; }
.dash-struct-name { font: 700 22px/1.12 'Fraunces', serif; color: #fff; }
.dash-sections { display: block; padding: 0 12px 12px; }
.dash-section { padding: 10px 6px 4px; border: 0; background: none; }
.dash-section-title { font-size: 0; margin: 0 0 8px; padding: 0; border: 0; }
.dash-section-title::before { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .12em; text-transform: uppercase; color: #8FB3A9; }
.dash-section:first-child .dash-section-title::before { content: 'Aperti adesso'; }
.dash-section:last-child .dash-section-title::before { content: 'Letture'; }
.dash-none { font: 400 13.5px 'IBM Plex Sans', sans-serif; font-style: normal; color: #7FA196; }
.dash-canali-body { display: flex; flex-wrap: wrap; gap: 6px; }
.dash-canale-row, .dash-canale-row.on { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border: 0; border-radius: 18px; background: rgba(45, 212, 191, .14); box-shadow: inset 0 0 0 1.2px rgba(45, 212, 191, .5); }
.dash-ch-mod, .dash-ch-name { min-width: 0; width: auto; }
.dash-ch-mod { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .06em; text-transform: uppercase; color: #8FD9C9; flex: none; }
.dash-ch-name { font: 600 14px 'IBM Plex Sans', sans-serif; color: #fff; flex: none; }
.dash-ch-badge, .dash-ch-badge.on { order: -1; width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; font-size: 0; background: #2DD4BF; box-shadow: 0 0 0 4px rgba(45, 212, 191, .2); animation: agx-pulsa 1.6s ease-in-out infinite; }
.dash-sensori-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.dash-sens-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 11px 14px; border: 0; border-radius: 18px; background: var(--agx-incavo); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .09); }
.dash-sens-key { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: #A9C2BA; }
.dash-sens-val, .dash-sens-val.ok { font: 700 26px/1.05 'Fraunces', serif; color: #fff; }
.dash-sens-val.error { color: #FFB4AB; }

/* ══ GESTIONE ══════════════════════════════════════════════════════════════════════════════ */
/* le schede: un selettore a pillola come «Plastico / Giornata» */
#gestione-corpo > .btn-row:has(.g-scheda) { display: flex; flex-wrap: nowrap; gap: 0; padding: 3px; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  border-radius: 21px; background: rgba(233, 243, 239, .08); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .1); }
#gestione-corpo > .btn-row:has(.g-scheda)::-webkit-scrollbar { display: none; }
#gestione-corpo .g-scheda { flex: none; height: 36px; padding: 0 15px; border-radius: 18px; background: #E9F3EF; color: #0B2520; box-shadow: none; font: 600 13px 'IBM Plex Sans', sans-serif; }
#gestione-corpo .g-scheda.neutral { background: none; color: #A9C2BA; }
#gestione-corpo .struttura-card { margin: 0 0 12px; padding: 16px 18px; border: 0; border-radius: 24px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); overflow: visible; }
#gestione-corpo .struttura-card .ctrl-dot { width: 9px; height: 9px; }
#gestione-corpo button { height: 40px; padding: 0 16px; font-size: 13px; }
#gestione-corpo button.small { height: 34px; padding: 0 13px; font-size: 12.5px; }
#gestione-corpo .g-entra, #gestione-corpo .g-entra-u { background: #E8A33D; color: #231503; box-shadow: 0 3px 0 #B97A1F; font-weight: 700; letter-spacing: .04em; }
#gestione-corpo input[type='search'], #gestione-corpo input[type='text'], #gestione-corpo select { height: 44px; border-radius: 22px !important; padding: 0 16px !important; }
#gestione-corpo .settings-section { max-width: 560px; padding: 18px; border-radius: 24px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); }

/* ══ IMPOSTAZIONI ══════════════════════════════════════════════════════════════════════════ */
#page-impostazioni .settings-section, #page-impostazioni #settings-form { max-width: none; padding: 18px; margin-top: 0 !important; border-radius: 26px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); }
#page-impostazioni > .settings-section + .settings-section { margin-top: 14px !important; }
#page-impostazioni .settings-section-title { padding: 0; border: 0; font: 700 19px 'Fraunces', serif; letter-spacing: 0; color: #fff; text-transform: lowercase; }
#page-impostazioni .settings-section-title::first-letter { text-transform: uppercase; }
#page-impostazioni > .settings-section-title { margin: 22px 4px 10px !important; }
#page-impostazioni label { font-size: 12.5px; color: #A9C2BA; }
#page-impostazioni input, #page-impostazioni select { height: 46px; padding: 0 14px; border-radius: 14px; font-size: 15px; background: var(--agx-incavo); border: 0; box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .2); color: #E9F3EF; }
#page-impostazioni input:focus, #page-impostazioni select:focus { box-shadow: inset 0 0 0 1.6px #2DD4BF, 0 0 0 4px rgba(45, 212, 191, .16); }
#page-impostazioni .btn-row button { height: 44px; padding: 0 20px; font-size: 14px; }
#page-impostazioni .settings-hint { font-size: 13px; line-height: 1.45; color: #A9C2BA; }

/* ══ MODULI E CANALI (la pagina che si apre con GO) ════════════════════════════════════════ */
#main-content:has(#page-dispositivi.active) { padding: 20px; }
#page-dispositivi.active { display: block; height: auto; overflow: visible; }
#disp-topbar { position: absolute; top: 4px; right: 0; padding: 0; border: 0; background: none; gap: 8px; }
#disp-topbar #disp-ctrl-dot { display: none; }
#disp-topbar .disp-icon { width: 40px; height: 40px; border: 0; background: rgba(233, 243, 239, .08); box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .24); color: #E9F3EF; }
#disp-topbar .disp-icon.warn { color: #F3D9A8; box-shadow: inset 0 0 0 1.2px rgba(232, 163, 61, .5); }
#disp-toolbar { padding: 0; margin: 0 0 14px; border: 0; background: none; flex-wrap: wrap; }
#disp-toolbar .disp-tool-btn { flex-direction: row; gap: 7px; height: 40px; padding: 0 15px; border: 0; border-radius: 20px; background: rgba(233, 243, 239, .07); box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .24);
  color: #E9F3EF; font: 600 12.5px 'IBM Plex Sans', sans-serif; letter-spacing: .02em; animation: none; }
#disp-toolbar .disp-tool-icon { font-size: 15px; }
#disp-toolbar .btn-sched-toggle.sched-on { background: rgba(45, 212, 191, .14); box-shadow: inset 0 0 0 1.4px rgba(45, 212, 191, .6); color: #5FE0CC; }
#disp-toolbar .btn-sched-toggle.sched-off { background: rgba(232, 163, 61, .16); box-shadow: inset 0 0 0 1.4px rgba(232, 163, 61, .7); color: #F3D9A8; }
#disp-body { display: grid; grid-template-columns: 1fr; gap: 14px; overflow: visible; }
#disp-tree-panel { width: auto; min-width: 0; padding: 0; border: 0; background: none; overflow: visible; }
#disp-tree { display: grid; gap: 10px; }
.tree-modulo { border-radius: 22px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); overflow: hidden; }
.tree-modulo-header { padding: 12px 12px 12px 16px; gap: 10px; font: 700 18px 'Fraunces', serif; color: #fff; }
.tree-modulo-header:hover { background: none; }
.tree-mod-name { flex: 1; }
.tree-modulo-header .icon-btn { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; font-size: 14px; background: rgba(233, 243, 239, .07); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .16); color: #C7DDD5; }
.tree-modulo-header .tree-mod-edit, .tree-modulo-header .tree-mod-del { font-size: 0; background: rgba(233, 243, 239, .07) center / 15px no-repeat; }
.tree-modulo-header .tree-mod-edit { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C7DDD5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3l4 4L8 20l-5 1 1-5z'/%3E%3C/svg%3E"); }
.tree-modulo-header .tree-mod-del { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C7DDD5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'/%3E%3C/svg%3E"); }
.tree-arrow { color: #5FE0CC; }
.tree-canali { padding: 0 8px 8px; }
.tree-canale { min-height: 48px; padding: 6px 8px 6px 10px; gap: 10px; border-radius: 16px; font-size: 14.5px; color: #E9F3EF; flex-wrap: nowrap; }
.tree-canale + .tree-canale { margin-top: 2px; }
.tree-canale:hover { background: rgba(233, 243, 239, .05); }
.tree-canale.sel { background: rgba(45, 212, 191, .12); box-shadow: inset 0 0 0 1.4px rgba(45, 212, 191, .55); border-radius: 16px; }
.tree-canale .led { width: 12px; height: 12px; }
.tree-canale .led.off { background: rgba(233, 243, 239, .25); }
.tree-canale .led.on { background: #2DD4BF; box-shadow: 0 0 0 4px rgba(45, 212, 191, .2); }
.tree-canale .canale-alias { font-size: 14.5px; color: #E9F3EF; }
.tree-canale .btn-onoff { width: 52px; height: 30px; border-radius: 15px; flex: none; }
.tree-canale .btn-onoff::after { width: 22px; height: 22px; }
.tree-canale .btn-onoff.on::after { transform: translateX(22px); }
#disp-detail-panel { padding: 18px; border-radius: 26px; background: var(--agx-carta); box-shadow: var(--agx-carta-bordo); overflow: visible; min-height: 150px; }
#disp-detail-panel .detail-placeholder { min-height: 120px; color: #7FA196; font-size: 13.5px; }
#disp-detail-panel .detail-canale-header { border: 0; margin-bottom: 12px; padding: 0; }
#disp-detail-panel .detail-canale-title { font: 700 22px 'Fraunces', serif; color: #fff; letter-spacing: 0; }
#disp-detail-panel .detail-canale-sub { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .08em; text-transform: uppercase; color: #8FB3A9; margin-top: 4px; }
#disp-detail-panel .detail-timer-section-title { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .12em; color: #8FB3A9; margin-bottom: 8px; }
#disp-detail-panel .timer-row { margin: 0 6px 6px 0; }
#disp-detail-panel .timer-empty { font-size: 13px; color: #7FA196; padding: 0 0 8px; }

/* ══ MAPPA ═════════════════════════════════════════════════════════════════════════════════ */
#page-mappa .page-header h2 { font-size: 26px; }
#mappa-titolo { text-transform: none; }   /* il nome dell'impianto resta scritto com'è, non tutto minuscolo */
#mappa-carta { border: 0; border-radius: 26px; box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .16), 0 14px 30px rgba(0, 0, 0, .35); overflow: hidden; }
#mappa-barra button { height: 40px; padding: 0 16px; }
.mappa-riga { padding: 12px 14px; border: 0; border-radius: 18px; font-size: 13.5px; background: var(--agx-carta); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .12); }
.mappa-colore { width: 18px; height: 18px; border-radius: 6px; }
.mappa-stato { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .08em; text-transform: uppercase; }

/* ══ FINESTRE ══════════════════════════════════════════════════════════════════════════════ */
.modal-box { overflow: hidden; }
.modal-header { padding: 18px 20px 12px; background: none; border: 0; text-transform: lowercase; }
.modal-header > span { display: inline-block; }
.modal-header > span::first-letter { text-transform: uppercase; }
.modal-header .modal-close { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: rgba(233, 243, 239, .08); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .18); color: #C7DDD5; font-size: 13px; text-transform: none; }
.modal-body { padding: 4px 20px 16px; }
.modal-body label { font-size: 12.5px; color: #A9C2BA; }
.modal-body input:not([type='checkbox']):not([type='radio']), .modal-body select, .modal-body textarea { min-height: 44px; padding: 0 14px; border-radius: 14px; font-size: 15px; background: var(--agx-incavo); border: 0; box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .2); color: #E9F3EF; }
.modal-body textarea { padding: 10px 14px; }
.modal-body label.row-label { flex-direction: row; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none; color: #E9F3EF; }
.modal-body label.row-label input[type='checkbox'] { width: 22px; height: 22px; margin: 0; flex: none; }
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus { box-shadow: inset 0 0 0 1.6px #2DD4BF, 0 0 0 4px rgba(45, 212, 191, .16); }
.modal-footer { padding: 12px 20px 18px; background: none; border: 0; gap: 10px; }
.modal-footer button { height: 46px; padding: 0 22px; font: 700 13.5px 'IBM Plex Sans', sans-serif; letter-spacing: .04em; }
.modal-footer button:first-child:not(.neutral):not(.danger) { background: #E8A33D; color: #231503; box-shadow: 0 3px 0 #B97A1F; flex: 1; }
.casc-mini { height: 36px; padding: 0 14px; border-radius: 18px; background: rgba(233, 243, 239, .08); box-shadow: inset 0 0 0 1.2px rgba(233, 243, 239, .24); color: #E9F3EF; border: 0; font: 600 12.5px 'IBM Plex Sans', sans-serif; }
.cascata-channels-title { font: 500 10.5px 'IBM Plex Mono', monospace; letter-spacing: .12em; text-transform: uppercase; color: #8FB3A9; }
.casc-ch-row { border: 0; border-radius: 16px; background: var(--agx-incavo); box-shadow: inset 0 0 0 1px rgba(233, 243, 239, .1); }
.casc-ch-row.selected { background: rgba(232, 163, 61, .14); box-shadow: inset 0 0 0 1.4px rgba(232, 163, 61, .6); }
.casc-order-badge { background: #E8A33D; color: #231503; font-family: 'Fraunces', serif; }
.casc-preview-row, .sposta-row { border: 0; border-radius: 14px; background: var(--agx-incavo); }
.casc-preview-time { font-family: 'IBM Plex Mono', monospace; color: #F3D9A8; }

/* ══ DAL TELEFONO AL PC ════════════════════════════════════════════════════════════════════ */
@media (max-width: 420px) {
  #main-content, #main-content:has(#page-dispositivi.active) { padding: 16px; }
  #page-valvole::before, #page-controlli::before { margin-left: -16px; margin-right: -16px; }
  .valv-modulo-hdr:has(.agx-conta) .valv-mod-addr { display: none; }   /* sul telefono l'indirizzo del modulo lascia il posto al conto dei canali */
  .agx-pt h1 { font-size: 30px; }
}
@media (min-width: 720px) {
  #strutture-list, #dashboard-cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); align-items: start; }
  #sensori-list { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); align-items: start; }
  .valv-canali { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); align-items: start; }
}
@media (min-width: 1024px) {
  .agx-pt h1 { font-size: 42px; }
  .agx-pt { padding-bottom: 20px; }
  /* Valvole: i due comandi in alto a destra, accanto al titolo; gli strumenti sulla stessa riga dell'impianto */
  #page-valvole.active, #page-controlli.active { grid-template-columns: 1fr 230px 230px; column-gap: 12px; }
  #page-valvole > .agx-pt, #page-controlli > .agx-pt { grid-column: 1; }
  #btn-valv-sched, #btn-ctrl-sched { grid-row: 1; grid-column: 2; align-self: end; margin-bottom: 22px; position: static; }
  #valv-alloff-bar, #ctrl-alloff-bar { grid-row: 1; grid-column: 3; align-self: end; margin-bottom: 22px; position: static; }
  #page-valvole::before, #page-controlli::before { display: none; }
  #valv-struct-bar, #ctrl-struct-bar { max-width: 420px; }
  .valv-timer-tools, #btn-ctrl-clear { margin-top: 0; }
  /* Impostazioni su due colonne */
  #page-impostazioni.active { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; align-items: start; }
  #page-impostazioni > .agx-pt, #page-impostazioni > .page-header { grid-column: 1 / -1; }
  #page-impostazioni > #profilo-form { grid-column: 1; grid-row: 2 / span 3; }
  #page-impostazioni > .settings-section:not(#profilo-form) { grid-column: 2; grid-row: 2; margin-top: 0 !important; }
  #page-impostazioni > .settings-section-title { grid-column: 2; grid-row: 3; }
  #page-impostazioni > #settings-form { grid-column: 2; grid-row: 4; }
  /* Moduli e canali: elenco a sinistra, il canale scelto a destra */
  #main-content:has(#page-dispositivi.active) { padding: 28px 36px; }
  #page-dispositivi.active { max-width: 1120px; margin: 0 auto; }
  #disp-body { grid-template-columns: minmax(340px, 420px) 1fr; align-items: start; }
  #disp-detail-panel { position: sticky; top: 0; }
  #gestione-corpo .struttura-card, #gestione-corpo .form-row, #gestione-corpo input[type='search'] { max-width: 760px; }
}

/* ══ VARCO: pulsante APRI (impulso, firmware impulso4c, 15/11/2026) ═══════════════════════════
   Un canale Varco non ha la levetta: ha APRI, in ambra come le azioni principali. Durante
   l'impulso diventa verde-acqua e pulsa, come quello che è vivo. */
.btn-apri { height: 34px; min-width: 72px; padding: 0 14px; margin: 0; border: 0; border-radius: 17px; cursor: pointer;
  font: 600 12.5px 'IBM Plex Sans', sans-serif; letter-spacing: .08em; color: #231503; background: #E8A33D;
  box-shadow: 0 0 0 4px rgba(232, 163, 61, .16); transition: background .2s; -webkit-tap-highlight-color: transparent; }
.btn-apri:disabled { cursor: default; opacity: .8; }
.btn-apri.in-corso { color: #fff; background: #1FB8A5; box-shadow: inset 0 0 0 1.2px #5FE0CC, 0 0 0 4px rgba(45, 212, 191, .16); animation: agx-pulsa 1.2s ease-in-out infinite; opacity: 1; }
.valv-ch-top .btn-apri { grid-column: 4; grid-row: 1 / 3; }
.tree-canale .btn-apri { flex: none; height: 30px; min-width: 64px; padding: 0 10px; font-size: 11.5px; }
.mappa-riga .btn-apri { min-width: 76px; }
/* configurazione del modulo: la durata compare sotto il nome solo per i Varco */
.cfgmod-ch-top .cfgmod-ch-impulso-l { grid-column: 2 / 4; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; margin: 0; text-align: left; }
.cfgmod-ch-top .cfgmod-ch-impulso { width: 80px; margin: 0; padding: 4px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg4); color: var(--text); }

/* ── IdroCheck (idro.js, firmware idro4c): goccia sul LED del canale, anomalia, taratura ── */
.idro-goccia { flex: none; width: 13px; height: 13px; border-radius: 0 50% 50% 50%; transform: rotate(45deg); box-sizing: border-box;
  border: 1.6px solid #8FB3A9; background: transparent; }
.idro-goccia.acqua { background: #2DD4BF; border-color: #5FE0CC; box-shadow: 0 0 6px rgba(45, 212, 191, .7); }
.idro-goccia.secco { background: rgba(233, 243, 239, .06); }
.idro-goccia.err, .idro-goccia.attesa { border-color: #5b6672; border-style: dashed; }
.idro-goccia.ntr { border-color: #F2B84B; }
.idro-goccia.anm { background: #E5484D; border-color: #FF8A8E; box-shadow: 0 0 8px rgba(229, 72, 77, .8); animation: agx-pulsa 1.2s ease-in-out infinite; }
.valv-ch-top .led { grid-column: 1; }   /* con la goccia nella stessa cella il LED resta al suo posto */
.valv-ch-top .idro-goccia { grid-column: 1; grid-row: 1 / 3; align-self: end; justify-self: start; margin: 0 0 0 26px; position: relative; z-index: 1; }
.idro-anomalia { box-shadow: inset 0 0 0 1.5px #E5484D, 0 0 0 3px rgba(229, 72, 77, .18) !important; }
.tree-canale.idro-anomalia { flex-wrap: wrap; }
.idro-scritta { flex-basis: 100%; margin: 4px 0 0 46px; font: 600 11.5px 'IBM Plex Sans', sans-serif; color: #FF8A8E; }
.cfgmod-ch-top .cfgmod-ch-idro-l { grid-column: 2 / 4; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; margin: 0; text-align: left; }
.cfgmod-ch-top .cfgmod-ch-idro { width: 70px; margin: 0; padding: 4px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg4); color: var(--text); }
.cfgmod-ch-top .cfgmod-ch-tara { margin: 0; padding: 3px 10px; font-size: 11px; }
.idro-barra { height: 12px; border-radius: 6px; background: rgba(233, 243, 239, .08); overflow: hidden; margin-bottom: 6px; }
.idro-barra i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #1FB8A5, #5FE0CC); transition: width .4s; }
.idro-riga { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12.5px; }
.idro-riga b { flex: 1; }
.idro-tar .ok { color: #5FE0CC; } .idro-tar .ko { color: #FF8A8E; }

/* IdroCheck in Mappa e Impianto */
.mappa-riga .idro-goccia { display: inline-block; vertical-align: middle; width: 11px; height: 11px; margin-left: 4px; }
.mappa-riga.idro-anomalia { flex-wrap: wrap; border-radius: 10px; }
.mappa-riga .idro-scritta { margin: 2px 0 0 22px; }
.agx-idro-riga .idro-goccia { display: inline-block; width: 9px; height: 9px; margin-left: 6px; vertical-align: middle; }
.agx-idro .idro-goccia { display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: middle; }
.agx-idro { margin: 4px 0 0; font-size: 12.5px; color: #A9C2BA; }
