/* Estia v2 · interfaccia. Bianco, righe sottili, testo nero; il colore indica stato o categoria.
   Card ≤ 8 px, bottoni a pillola, icone Lucide, letter-spacing 0. */
:root {
  --bg: #ffffff; --side: #f9f9f9; --soft: #f4f4f5; --line: #e8e8ea; --line2: #f1f1f2;
  --ink: #0d0d0d; --ink2: #4f4f55; --mute: #8a8a90;
  --brand: #21aea8;
  --teal: #0e8f88; --teal-bg: #e4f6f4; --blue: #2563eb; --blue-bg: #eaf1ff; --violet: #7c3aed; --violet-bg: #f1ebfe;
  --amber: #b45f06; --amber-bg: #fff3df; --rose: #d61f45; --rose-bg: #ffe9ed; --green: #15803d; --green-bg: #e6f5eb;
  --alarm: #ff5252; --alarm-ink: #a8141c; --alarm-bg: #fff0f0;
  --r: 8px;
  --card: #ffffff; --hover: #fafafa; --campo: #dcdce0; --su-ink: #ffffff; --alone: #ffffff;
  --m-stanza: #ffffff; --m-bordo: #c9ccd1; --m-corr: #fafafa; --m-scale: #f0f0f2; --m-edif: #ffffff; --m-edifb: #b8bcc2; --m-warn: #fff1dc; --m-ok: #e3f3e8;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: 0; }
h1 { font-size: 22px; line-height: 1.25; } h2 { font-size: 16px; } h3 { font-size: 15px; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.i { width: 18px; height: 18px; flex: none; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--mute); } .sm { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Shell ── */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.logo { display: flex; align-items: center; gap: 8px; padding: 6px 10px 18px; }
.logo img { height: 22px; }
.logo span { font-size: 13px; color: var(--mute); }
.nav a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r); color: var(--ink2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: #efeff0; color: var(--ink); }
.nav a.on { background: #ececee; color: var(--ink); }
.nav a .n { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--alarm); color: #fff; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.nav .gl { font-size: 12px; color: var(--mute); padding: 14px 10px 4px; }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; font-size: 13px; line-height: 1.3; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--teal-bg); color: var(--teal); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 16px 32px; min-height: 64px; flex-wrap: wrap; }
.top .t { font-size: 13px; color: var(--mute); }
.top h1 { font-size: 20px; }
.page { padding: 4px 32px 48px; max-width: 1240px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.bnav { display: none; }

/* ── Copertina della struttura (solo in ordinaria) ── */
.hero { position: relative; min-height: 260px; display: flex; align-items: flex-end; background-size: cover; background-position: center; color: #fff; }
.hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .05) 30%, rgba(0, 0, 0, .62)); }
.hero .in { position: relative; padding: 24px 32px; width: 100%; max-width: 1240px; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.hero h1 { font-size: 30px; line-height: 1.15; }
.hero .t { font-size: 15px; opacity: .9; }
.hero .state { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--ink); font-weight: 500; font-size: 14px; }
.hero .state .d { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.hero .btn.emer { height: 40px; }
.hero + .page { padding-top: 24px; }

/* ── Bottoni ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--soft); color: var(--ink); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #e9e9eb; }
.btn.pri { background: var(--ink); color: var(--su-ink); } .btn.pri:hover { background: #2a2a2e; }
.btn.red { background: var(--alarm); color: #fff; } .btn.red:hover { background: #ee3c3c; }
.btn.ok { background: var(--green); color: #fff; }
.btn.line { background: var(--card); border: 1px solid var(--line); }
.btn.line:hover { background: var(--soft); }
.btn.big { height: 48px; padding: 0 22px; font-size: 16px; }
.btn.block { width: 100%; }
.btn .i { width: 16px; height: 16px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.ib { position: relative; width: 36px; height: 36px; border-radius: 999px; border: 0; background: transparent; color: var(--ink2); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.ib:hover { background: var(--soft); color: var(--ink); }
.ib.boxed { background: var(--card); border: 1px solid var(--line); }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--su-ink); font-size: 12px; font-weight: 500; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; z-index: 50; }
.ctl [data-tip]:hover::after { left: auto; right: calc(100% + 8px); bottom: auto; top: 50%; transform: translateY(-50%); }
.hold { position: relative; overflow: hidden; }
.hold::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .18); transform: scaleX(0); transform-origin: left; }
.hold.go::after { transform: scaleX(1); transition: transform 1.5s linear; }
.btn.emer { background: var(--card); border: 1px solid #ffc9c9; color: var(--alarm-ink); }
.btn.emer:hover { background: var(--alarm-bg); }
.btn.emer .i { color: var(--alarm); }

/* ── Banner di stato ── */
.banner { border: 1px solid; border-radius: var(--r); overflow: hidden; }
.banner .bh { display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-size: 16px; flex-wrap: wrap; }
.banner .bb { padding: 12px 16px; background: var(--card); color: var(--ink2); }
.b-ok { border-color: #bfe6cc; } .b-ok .bh { background: var(--green-bg); } .b-ok .bh > .i { color: var(--green); }
.b-warn { border-color: #f6d29b; } .b-warn .bh { background: var(--amber-bg); } .b-warn .bh > .i { color: var(--amber); }
.b-alarm { border-color: #ffc2c2; } .b-alarm .bh { background: var(--alarm-bg); } .b-alarm .bh > .i { color: var(--alarm); }
.b-info { border-color: #cfdcfb; } .b-info .bh { background: var(--blue-bg); } .b-info .bh > .i { color: var(--blue); }

/* ── Tessere numeriche ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "c l" "v v" "s s"; align-items: center; column-gap: 10px; row-gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); text-align: left; min-height: 116px; }
.tile.click { cursor: pointer; } .tile.click:hover { border-color: #cfcfd4; }
.tile .chip { grid-area: c; }
.tile .tl { grid-area: l; color: var(--ink2); font-size: 14px; }
.tile .tv { grid-area: v; font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .ts { grid-area: s; font-size: 13px; color: var(--mute); }
.chip { width: 32px; height: 32px; border-radius: var(--r); display: inline-grid; place-items: center; flex: none; }
.chip .i { width: 17px; height: 17px; }
.t-teal { background: var(--teal-bg); color: var(--teal); } .t-blue { background: var(--blue-bg); color: var(--blue); } .t-violet { background: var(--violet-bg); color: var(--violet); }
.t-amber { background: var(--amber-bg); color: var(--amber); } .t-rose { background: var(--rose-bg); color: var(--rose); } .t-green { background: var(--green-bg); color: var(--green); }
.t-gray { background: var(--soft); color: var(--ink2); } .t-red { background: var(--alarm); color: #fff; }
.tile.alarm { border-color: #ffc2c2; background: var(--alarm-bg); } .tile.alarm .tv { color: var(--alarm-ink); }
.tile.ok .tv { color: var(--green); }

/* ── Liste a righe ── */
.sec-h { display: flex; align-items: center; gap: 10px; min-height: 36px; flex-wrap: wrap; }
.sec-h h2 { flex: 1; }
.list { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line2); min-height: 56px; }
.li:first-child { border-top: 0; }
.li.click { cursor: pointer; } .li.click:hover { background: var(--hover); }
.li .tx { flex: 1; min-width: 0; }
.li .t1 { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.li .t2 { font-size: 13px; color: var(--mute); }
.li .end { display: flex; align-items: center; gap: 6px; flex: none; }
.li.alarm { box-shadow: inset 3px 0 var(--alarm); }
.li.warn { box-shadow: inset 3px 0 #f2a43a; }
.li.done { background: #fbfdfb; }
.li.sel { background: var(--blue-bg); }
.li .meterbox { width: 180px; flex: none; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--mute); }
.meter { height: 6px; background: var(--line2); border-radius: 3px; overflow: hidden; display: flex; width: 100%; }
.meter i { display: block; height: 100%; }
.meter .g { background: var(--green); } .meter .a { background: #f2a43a; } .meter .r { background: var(--alarm); } .meter .k { background: var(--ink); } .meter .b { background: var(--blue); }
.empty { display: flex; align-items: center; gap: 10px; padding: 22px 16px; color: var(--mute); }
.empty .i { color: var(--green); }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--ink2); }
.pill .i { width: 13px; height: 13px; }
.p-alarm { background: var(--alarm-bg); color: var(--alarm-ink); } .p-warn { background: var(--amber-bg); color: var(--amber); } .p-ok { background: var(--green-bg); color: var(--green); }
.p-info { background: var(--blue-bg); color: var(--blue); } .p-dark { background: var(--ink); color: var(--su-ink); } .p-violet { background: var(--violet-bg); color: var(--violet); }
.shp { width: 14px; height: 14px; fill: var(--mute); flex: none; }
.shp.alarm { fill: var(--alarm); } .shp.warn { fill: #f2a43a; } .shp.ok { fill: var(--green); } .shp.move { fill: var(--blue); }
.batt { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.batt .i { width: 15px; height: 15px; } .batt.low { color: var(--amber); } .batt.bad { color: var(--alarm-ink); font-weight: 600; }
.age { font-size: 12px; color: var(--mute); } .age.old { color: var(--alarm-ink); font-weight: 600; }

/* ── Tabelle (gestione) ── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--mute); font-size: 13px; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--hover); }
tr.alarm td:first-child { box-shadow: inset 3px 0 var(--alarm); } tr.warn td:first-child { box-shadow: inset 3px 0 #f2a43a; }
.tw { overflow-x: auto; }

/* ── Controllo segmentato ── */
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-weight: 500; color: var(--ink2); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg .n { font-size: 12px; color: var(--mute); }
.seg button.on .n { color: var(--ink2); }

/* ── Form ── */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink2); font-weight: 500; }
.field input, .field select { height: 42px; border: 1px solid var(--campo); border-radius: var(--r); padding: 0 12px; background: var(--card); font-size: 15px; color: var(--ink); font-weight: 400; }
.search { position: relative; }
.search input { width: 100%; height: 44px; border: 1px solid var(--campo); border-radius: 999px; padding: 0 16px 0 42px; font-size: 15px; background: var(--card); color: var(--ink); }
.search .i { position: absolute; left: 15px; top: 13px; color: var(--mute); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; color: var(--ink2); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: var(--su-ink); }
.chips .i { width: 14px; height: 14px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.toggle input { width: 34px; height: 20px; appearance: none; background: #d6d6da; border-radius: 10px; position: relative; cursor: pointer; margin: 0; flex: none; }
.toggle input::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .15s; }
.toggle input:checked { background: var(--ink); } .toggle input:checked::after { left: 16px; }
.toggle input:disabled { opacity: .45; }
.card { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 18px; }
.cols { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.g2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--mute); } .kv dd { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ── Emergenza ── */
.emtop { display: flex; align-items: center; gap: 12px; padding: 10px 32px; background: var(--alarm); color: #fff; position: sticky; top: 0; z-index: 30; flex-wrap: wrap; }
.emtop b { font-size: 15px; }
.emtop .clock { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.emtop .btn { background: rgba(255, 255, 255, .18); color: #fff; height: 34px; }
.emtop .btn:hover { background: rgba(255, 255, 255, .3); }
.emtop.pre { background: #f2a43a; color: #241400; } .emtop.pre .btn { background: rgba(0, 0, 0, .1); color: #241400; }
.emtop.drill { background: var(--violet); }
.emtop .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
body.em .page .li .btn, body.em .page .btn.big { min-height: 44px; }
.drillmark { position: fixed; left: 50%; transform: translateX(-50%); top: 60px; background: var(--violet); color: #fff; font-weight: 600; font-size: 13px; padding: 6px 12px; border-radius: 999px; z-index: 40; }

/* ── Mappa ── */
.mapbox { position: relative; border: 1px solid var(--line); border-radius: var(--r); background: var(--m-fondo, #fcfcfc); overflow: hidden; }
.mapbox .ctl { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.mapbox .floors { position: absolute; left: 10px; top: 10px; z-index: 3; display: flex; gap: 8px; align-items: center; }
.mapbox .hint { position: absolute; left: 10px; bottom: 10px; z-index: 3; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); background: rgba(255, 255, 255, .94); padding: 6px 10px; border-radius: var(--r); border: 1px solid var(--line2); max-width: calc(100% - 20px); }
.mapbox .hint span { display: inline-flex; align-items: center; gap: 5px; }
.mapbox .hint .i { width: 14px; height: 14px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.mapsvg { width: 100%; height: auto; max-height: 74vh; min-height: 260px; display: block; touch-action: none; cursor: grab; user-select: none; padding: 56px 56px 48px 10px; }
.mapsvg text { font-family: var(--font); text-anchor: middle; pointer-events: none; }
.mapsvg .ground { fill: #f3f4f2; stroke: #e2e4e0; vector-effect: non-scaling-stroke; }
.mapsvg .road { fill: none; stroke: var(--m-stanza); stroke-width: 10; }
.mapsvg .bldbox { fill: var(--m-edif); stroke: var(--m-edifb); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.mapsvg .bld { cursor: pointer; } .mapsvg .bld:hover .bldbox { stroke: var(--ink); }
.mapsvg .sec { fill: transparent; stroke: #d4d6da; stroke-dasharray: 4 3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.mapsvg .sec.t-alarm { fill: rgba(255, 82, 82, .22); stroke: var(--alarm); stroke-dasharray: none; stroke-width: 2; }
.mapsvg .sec.t-warn { fill: rgba(242, 164, 58, .16); } .mapsvg .sec.t-ok { fill: rgba(21, 128, 61, .12); }
.mapsvg .sec.hl { stroke: var(--blue); stroke-width: 2.5; stroke-dasharray: none; }
.mapsvg .bldlbl { text-anchor: start; font-weight: 600; fill: var(--ink); }
.mapsvg .seclbl, .mapsvg .mlbl { fill: var(--ink2); font-weight: 500; paint-order: stroke; stroke: var(--alone); stroke-linejoin: round; }
.mapsvg .room { fill: var(--m-stanza); stroke: var(--m-bordo); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.mapsvg .room:hover { fill: #f6f8fb; }
.mapsvg .room.k-corridor { fill: var(--m-corr); } .mapsvg .room.k-stairs { fill: var(--m-scale); }
.mapsvg .room.t-alarm { fill: #ffdcdc; stroke: var(--alarm); stroke-width: 2; }
.mapsvg .room.t-warn { fill: var(--m-warn); } .mapsvg .room.t-ok { fill: var(--m-ok); }
.mapsvg .room.hazard { stroke: #c9a000; stroke-dasharray: 5 3; stroke-width: 2; }
.mapsvg .room.dim { opacity: .35; }
.mapsvg .room.onplan { fill: rgba(255, 255, 255, 0); stroke: rgba(13, 13, 13, .06); }
.mapsvg .room.onplan:hover { fill: rgba(37, 99, 235, .06); }
.mapsvg .room.onplan.t-alarm { fill: rgba(255, 82, 82, .22); stroke: var(--alarm); }
.mapsvg .room.onplan.t-warn { fill: rgba(242, 164, 58, .16); } .mapsvg .room.onplan.t-ok { fill: rgba(21, 128, 61, .14); }
.mapsvg .room.onplan.hazard { fill: rgba(242, 194, 0, .16); }
.mapsvg .room.hl, .mapsvg .room.onplan.hl { fill: rgba(37, 99, 235, .12); stroke: var(--blue); stroke-width: 3; }
.mapsvg .hazard { fill: rgba(242, 194, 0, .2); stroke: #c9a000; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.mapsvg .rlbl { fill: var(--ink2); }
.mapsvg .onplanlbl { paint-order: stroke; stroke: var(--alone); stroke-linejoin: round; font-weight: 600; fill: var(--ink); }
.mapsvg .exit { cursor: pointer; } .mapsvg .exit.hl use { filter: drop-shadow(0 0 3px var(--ink)) drop-shadow(0 0 1px var(--ink)); }
.mapsvg .hit { fill: transparent; stroke: none; }   /* area di tocco più grande del segnale */ .mapsvg .firesym.idr { cursor: pointer; } .mapsvg .firesym.idr.hl use { filter: drop-shadow(0 0 3px var(--ink)) drop-shadow(0 0 1px var(--ink)); }
.mapsvg .exit use { filter: drop-shadow(0 0 1px rgba(0, 0, 0, .35)); }
/* tag delle persone: cerchio nel colore del gruppo con l'icona; lo stato dal bordo */
.mapsvg .pers .tag-c { stroke: var(--alone); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.mapsvg .pers .tag-i { pointer-events: none; }
.mapsvg .pers.alarm .tag-c, .mapsvg .pers.evento .tag-c { stroke: var(--alarm); stroke-width: 3.5; }
.mapsvg .pers.last .tag-c { stroke-dasharray: 4 3; }
.mapsvg .pers.hl .tag-c { stroke: var(--ink); stroke-width: 4; }
.mapsvg .pers.zona .pulse, .mapsvg .pers.sos .pulse { stroke: var(--alarm); }
.mapsvg .pers.geo .pulse { stroke: #f2a43a; }
.lsym.iso { width: 18px; height: 18px; }
.mapsvg .chip rect { fill: var(--card); stroke: var(--m-bordo); vector-effect: non-scaling-stroke; }
.mapsvg .chip text { font-weight: 600; fill: var(--ink); }
.mapsvg .chip.alarm rect { fill: var(--alarm); stroke: var(--alarm); } .mapsvg .chip.alarm text { fill: #fff; }
.mapsvg .chip.warn rect { fill: #ffe7c7; stroke: #f2a43a; }
.mapsvg .chip.ok rect { fill: var(--green-bg); stroke: var(--green); } .mapsvg .chip.ok text { fill: var(--green); }
.mapsvg .chip.mute text { fill: var(--ink2); }
.mapsvg .sym .symbg { fill: var(--card); stroke: currentColor; stroke-width: 1.5; }
.oksym { color: var(--green); } .firesym { color: #d7262b; } .warnsym { color: #9a7600; } .vvfsym { color: #d7262b; } .mutesym { color: var(--mute); } .cmdsym { color: var(--blue); } .assetsym { color: var(--ink2); } .prisym { color: var(--teal); }
.mapsvg .acnt { font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--alone); stroke-linejoin: round; }
.mapsvg .asset { cursor: pointer; } .mapsvg .asset.hl .symbg { fill: var(--blue-bg); stroke-width: 3; }
.mapsvg .pers { cursor: pointer; }
.mapsvg .pers .acc { fill: rgba(37, 99, 235, .1); stroke: var(--blue); stroke-dasharray: 3 3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.mapsvg .pers.alarm .acc { fill: rgba(255, 82, 82, .12); stroke: var(--alarm); }
.mapsvg .pers.cs { animation: slide 1s linear both; }
@keyframes slide { from { transform: translate(var(--dx), var(--dy)); } to { transform: translate(0, 0); } }
.mapsvg .pulse { fill: none; stroke: var(--alarm); stroke-width: 2; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
.mapsvg .dev { cursor: pointer; }
.mapsvg .dev > * { fill: var(--card); stroke: var(--ink2); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.mapsvg .dev.st-battery > * { fill: #f2a43a; } .mapsvg .dev.st-silent > * { fill: var(--alarm); } .mapsvg .dev.st-fw > * { fill: #cfe0ff; }
.mapsvg .dev.hl > * { stroke: var(--blue); stroke-width: 4; }
.mapsvg image.plan { pointer-events: none; }
.mapsvg.hc .room, .mapsvg.hc .bldbox { stroke: #000; stroke-width: 1.6; }
@media (prefers-reduced-motion: reduce) { .emtop .dot, .pulse, .mapsvg .pers.cs { animation: none !important; } }

/* ── Mappa a tutto spazio, card dei piani e legenda ── */
.page.wide { max-width: none; }
.mapwrap-full { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mapbox.tall .mapsvg { height: calc(100vh - 270px); min-height: 480px; max-height: none; padding: 10px 56px 10px 10px; }
body.em .mapbox.tall .mapsvg { height: calc(100vh - 330px); }
.strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 6px; scrollbar-width: thin; }
.fcard { flex: 0 0 210px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); cursor: pointer; padding: 0; overflow: hidden; scroll-snap-align: start; text-align: left; }
.fcard:hover { border-color: #c9c9ce; }
.fcard.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.fcard .th { display: block; height: 64px; background: var(--hover); border-bottom: 1px solid var(--line2); }
.fcard .th svg { width: 100%; height: 100%; display: block; }
.fcard .ft { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; font-size: 13px; }
.fcard .ft b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legendstrip { padding-bottom: 2px; }
.lcard { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); font-size: 13px; color: var(--ink2); white-space: nowrap; }
.lcard .i { width: 15px; height: 15px; }
.lsym { height: 16px; width: auto; flex: none; }
.mapsvg .trail { fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-dasharray: 4 3; stroke-linecap: round; stroke-linejoin: round; opacity: .75; vector-effect: non-scaling-stroke; }
.mapsvg .trail.alarm { stroke: var(--alarm); }
.mapsvg .focusring, .mapsvg .focusring2 { fill: none; stroke: var(--blue); stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.mapsvg .focusring2 { transform-box: fill-box; transform-origin: center; animation: ring 1.6s ease-out infinite; }
@keyframes ring { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mapsvg .focusring2 { animation: none; } }
@media (max-width: 860px) { .mapbox.tall .mapsvg, body.em .mapbox.tall .mapsvg, body.scuro .mapbox.tall .mapsvg { height: auto; max-height: 70vh; min-height: 260px; padding: 8px 52px 8px 8px; } .fcard { flex-basis: 150px; } }

/* ── Pannello demo (fuori dal prodotto) ── */
.demo-btn { position: fixed; right: 16px; bottom: 16px; z-index: 60; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.demo-pop { position: fixed; right: 16px; bottom: 66px; z-index: 61; width: 320px; max-height: calc(100vh - 90px); overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(0, 0, 0, .14); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.demo-pop h3 { display: flex; align-items: center; gap: 8px; }
.demo-pop .btn { justify-content: flex-start; }

/* ── Modale, toast ── */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal .box { background: var(--card); border-radius: var(--r); max-width: 560px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 20px 48px rgba(0, 0, 0, .18); }
.modal .box.wide { max-width: 900px; }
.modal .mh { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.modal .mh h2 { flex: 1; font-size: 18px; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); cursor: pointer; text-align: left; width: 100%; color: var(--ink); }
.choice:hover { border-color: #c9c9ce; }
.choice b { display: block; margin-bottom: 2px; }
.choice span { color: var(--ink2); font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--su-ink); padding: 10px 14px; border-radius: 999px; display: flex; gap: 12px; align-items: center; z-index: 110; font-size: 14px; max-width: calc(100vw - 32px); }
.toast button { background: transparent; color: #9fe3dc; border: 0; font-weight: 600; cursor: pointer; }
.sheet h3 { margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; font-size: 15px; }
.sheet h3 .n { background: var(--ink); color: var(--su-ink); width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; }
.sheet ul { margin: 0; padding-left: 18px; }
.read { font-size: 18px; line-height: 1.55; }

/* ── Telefono (addetto) ── */
body.phone .app { grid-template-columns: 1fr; max-width: 420px; margin: 20px auto; border: 1px solid var(--line); border-radius: 28px; overflow: hidden; min-height: 860px; box-shadow: 0 20px 60px rgba(0, 0, 0, .1); position: relative; }
body.phone .side { display: none; }
body.phone .top { padding: 14px 18px; }
body.phone .page { padding: 4px 18px 96px; font-size: 16px; }
body.phone .emtop { padding: 10px 18px; }
body.phone .hero { min-height: 190px; } body.phone .hero .in { padding: 18px; flex-direction: column; align-items: flex-start; gap: 10px; } body.phone .hero .grow { width: 100%; } body.phone .hero h1 { font-size: 24px; }
body.phone .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.phone .bnav { display: grid; position: sticky; bottom: 0; }
.bnav { grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card); border-top: 1px solid var(--line); z-index: 25; }
.bnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 62px; font-size: 12px; color: var(--mute); text-decoration: none; font-weight: 500; }
.bnav a.on { color: var(--ink); }
.task { background: var(--ink); color: var(--su-ink); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.task .big { font-size: 22px; font-weight: 600; }
.task .meter { background: rgba(255, 255, 255, .18); }

/* ── Responsive ── */
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .bnav { display: grid; position: fixed; left: 0; right: 0; bottom: 0; }
  .top { padding: 14px 16px; } .page { padding: 4px 16px 90px; }
  .hero { min-height: 200px; } .hero .in { padding: 18px 16px; } .hero h1 { font-size: 24px; }
  .emtop { padding: 10px 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .tile { min-height: 0; } .tile .tv { font-size: 26px; }
  .li { flex-wrap: wrap; } .li .end { margin-left: auto; } .li .meterbox { width: 90px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .tile { padding: 12px; } .tile .tl { font-size: 13px; }
  .hero .in { flex-direction: column; align-items: flex-start; gap: 12px; } .hero .grow { width: 100%; }
  .demo-btn { bottom: 76px; } .demo-pop { bottom: 124px; }
  .emtop .hide-sm { display: none; }
}
@media print {
  .side, .bnav, .top, .emtop, .demo-btn, .demo-pop, .noprint, .hero { display: none !important; }
  .app { display: block; } .modal { position: static; background: none; padding: 0; } .modal .box { max-height: none; box-shadow: none; }
}

/* ── Grafici della home (ordinaria) ───────────────────────────────────────────
   Una tinta per serie (--teal, contrasto ≥3:1 sul bianco), testi nei colori del testo, griglia leggera. */
.gr-schede { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 4px; }
.gr-scheda { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 16px 18px 18px; min-width: 0; }
.gr-scheda--larga { grid-column: 1 / -1; }
.gr-testa { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.gr-testa h2 { flex: 1; font-size: 15px; }
.gr-tip { position: absolute; z-index: 5; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 220px; display: none; flex-direction: column; gap: 3px;
  padding: 8px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .1); font-size: 12px; color: var(--ink2); pointer-events: none; }
.gr-tip > b { color: var(--ink); font-size: 12px; }
.gr-tip span { display: flex; align-items: center; gap: 6px; } .gr-tip span b { margin-left: auto; padding-left: 10px; color: var(--ink); }
.gr-tip--sx { left: auto; right: 0; transform: none; }
.gr-l { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--teal); flex: none; }
.gr-l--media { border-top: 2px dashed var(--mute); }
.gr-legenda { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink2); }
.gr-legenda span { display: flex; align-items: center; gap: 6px; }

/* linea: presenze oggi */
.gr-linea { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: 180px auto; }
.gr-y { position: relative; grid-row: 1; } .gr-y span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--mute); font-variant-numeric: tabular-nums; }
.gr-piano { position: relative; grid-row: 1; grid-column: 2; }
.gr-piano svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gr-griglia { stroke: var(--line2); stroke-width: 1; vector-effect: non-scaling-stroke; } .gr-base { stroke: var(--line); }
.gr-area { fill: var(--teal); opacity: .1; }
.gr-tratto { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.gr-media { fill: none; stroke: var(--mute); stroke-width: 1.5; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.gr-ora { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px #fff, 0 0 0 6px rgba(14, 143, 136, .18); }
.gr-etichetta { position: absolute; transform: translate(-50%, calc(-100% - 12px)); font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; background: rgba(255, 255, 255, .85); padding: 0 4px; border-radius: 4px; pointer-events: none; }
.gr-x { grid-column: 2; position: relative; height: 22px; } .gr-x span { position: absolute; top: 6px; transform: translateX(-50%); font-size: 11px; color: var(--mute); }
.gr-x span:first-child { transform: none; } .gr-x span:last-child { transform: translateX(-100%); }
.gr-banda { position: absolute; top: 0; bottom: 0; outline: none; }
.gr-guida { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px solid var(--line); display: none; }
.gr-punto { position: absolute; left: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px #fff; display: none; }
.gr-banda:hover .gr-guida, .gr-banda:hover .gr-punto, .gr-banda:focus .gr-guida, .gr-banda:focus .gr-punto { display: block; }
.gr-banda:hover .gr-tip, .gr-banda:focus .gr-tip { display: flex; }
.gr-banda .gr-tip { bottom: auto; top: 6px; }

/* barre: chi è presente */
.gr-barre { display: grid; gap: 9px; }
.gr-barra { display: grid; grid-template-columns: minmax(0, 190px) 1fr 40px; align-items: center; gap: 12px; font-size: 13px; }
.gr-nome { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-traccia { height: 10px; background: var(--line2); border-radius: 5px; overflow: hidden; }
.gr-traccia i { display: block; height: 100%; background: var(--teal); border-radius: 5px; }
.gr-val { text-align: right; font-variant-numeric: tabular-nums; }

/* colonne: segnalazioni */
.gr-colonne { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; height: 190px; }
.gr-col { position: relative; display: grid; grid-template-rows: 1fr 20px; align-items: end; justify-items: center; outline: none; }
.gr-colv { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; padding-bottom: 5px; }
.gr-colb { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; border-bottom: 1px solid var(--line); }
.gr-colb i { display: block; width: 100%; max-width: 30px; max-height: calc(100% - 18px); background: var(--teal); border-radius: 4px 4px 0 0; min-height: 0; }
.gr-colx { font-size: 11px; color: var(--mute); white-space: nowrap; align-self: start; padding-top: 4px; }
.gr-col:hover .gr-tip, .gr-col:focus .gr-tip { display: flex; }
.gr-col:hover .gr-colb i { background: #0b726c; }

@media (max-width: 860px) {
  .gr-schede { grid-template-columns: 1fr; }
  .gr-linea { grid-template-rows: 150px auto; grid-template-columns: 34px 1fr; }
  .gr-barra { grid-template-columns: 1fr 34px; row-gap: 4px; column-gap: 10px; }
  .gr-nome { grid-column: 1 / -1; white-space: normal; }
  .gr-barre { gap: 12px; }
  .gr-colonne { height: 160px; gap: 5px; }
  .gr-colx { font-size: 10px; }
}
body.phone .gr-schede { grid-template-columns: 1fr; }
body.phone .gr-barra { grid-template-columns: 1fr 34px; row-gap: 4px; column-gap: 10px; } body.phone .gr-nome { grid-column: 1 / -1; white-space: normal; }

/* ══ Home a moduli (ordinaria) ═══════════════════════════════════════════════════════════════════════
   Aree della struttura: un piano per scheda in un carosello orizzontale (scroll-snap) con puntini;
   sotto, i moduli di gestione in griglia. */
.aree-h { margin-top: 6px; } .aree-h .seg { flex: none; }
.aree-frecce { display: flex; gap: 6px; } .aree-frecce .ib:disabled { opacity: .35; cursor: default; }
.aree { display: flex; gap: 12px; column-gap: 12px; width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; overscroll-behavior-x: contain; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; outline: none; }
.aree::-webkit-scrollbar { display: none; }
.area-scheda { flex: 0 0 calc((100% - 12px) / 2.15); scroll-snap-align: start; display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
  text-align: left; cursor: pointer; color: var(--ink); font: inherit; min-width: 0; transition: border-color .2s, box-shadow .2s; }
.area-scheda:hover { border-color: #cfd1d6; box-shadow: 0 4px 16px rgba(0, 0, 0, .05); }
.area-testa { display: flex; align-items: baseline; gap: 8px; } .area-testa b { font-size: 15px; } .area-testa span { font-size: 12px; color: var(--mute); }
.area-mappa { display: block; height: 190px; border-radius: 6px; background: var(--hover); overflow: hidden; padding: 8px; }
.am-svg { width: 100%; height: 100%; display: block; }
.am-stanza { stroke: var(--card); stroke-width: .35; } .am-stanza--pianta { opacity: .82; }
.am-neutra { fill: var(--line2); stroke: var(--card); stroke-width: .35; }
.am-pianta { opacity: .35; }
.area-dati { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--ink2); }
.area-dati > span { display: inline-flex; align-items: center; gap: 5px; } .area-dati .i { width: 15px; height: 15px; color: var(--mute); }
.area-dati b { color: var(--ink); font-variant-numeric: tabular-nums; }
.area-avviso, .area-ok { margin-left: auto; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; }
.area-avviso { background: var(--amber-bg); color: var(--amber); } .area-avviso .i { color: var(--amber) !important; }
.area-ok { background: var(--green-bg); color: var(--green); } .area-ok .i { color: var(--green) !important; }
.aree-piede { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 8px; min-height: 22px; }
.aree-dots { display: flex; gap: 2px; }
.aree-dots button { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.aree-dots button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #c9ccd1; transition: width .25s, background .25s; }
.aree-dots button.on::before { width: 20px; border-radius: 4px; background: var(--ink); }
.aree-piede.una .aree-dots { display: none; }
.am-legenda { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--mute); margin-left: auto; }
.am-scala { display: block; width: 120px; height: 8px; border-radius: 4px; }

.mods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mod { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 16px 18px 18px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.mod--larga { grid-column: span 2; }
.mod-testa { display: flex; align-items: center; gap: 10px; }
.mod-tit { min-width: 0; } .mod-tit h2 { font-size: 15px; } .mod-tit span { display: block; font-size: 12px; color: var(--mute); }
.mod-cifre { display: flex; gap: 22px; flex-wrap: wrap; }
.mod-cifre div { display: flex; flex-direction: column; } .mod-cifre b { font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.mod-cifre span { font-size: 12px; color: var(--mute); }
.mod-righe { display: grid; gap: 0; border-top: 1px solid var(--line2); }
.mod-righe span { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.mod-righe em { font-style: normal; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .mod-righe b { font-variant-numeric: tabular-nums; }
.mod-nota { margin: auto 0 0; font-size: 12px; color: var(--mute); }
.mod-lista { border: 0; border-radius: 0; margin: 0 -18px -18px; } .mod-lista .li:first-child { border-top: 1px solid var(--line2); }
.mod .gr-linea { grid-template-rows: 170px auto; }
.mod--larga .gr-colonne { height: 170px; }
.mod--larga .or-griglia i { min-height: 12px; aspect-ratio: auto; height: 14px; }
.sp { width: 100%; height: 56px; display: block; overflow: visible; }
.sp-banda { fill: var(--green-bg); }
.sp-linea { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sp-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--mute); margin-top: -10px; }
.acc-col { display: flex; align-items: flex-end; gap: 2px; height: 64px; border-bottom: 1px solid var(--line); }
.acc-col i { flex: 1; background: var(--teal); border-radius: 2px 2px 0 0; opacity: .85; } .acc-col i.ora { opacity: 1; background: var(--ink); }
.or-griglia { display: grid; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 2px; align-items: center; }
.or-griglia i { aspect-ratio: 1; border-radius: 2px; min-height: 8px; }
.or-g { font-size: 11px; color: var(--mute); } .or-g.oggi { color: var(--ink); font-weight: 600; }
.or-h { font-size: 10px; color: var(--mute); white-space: nowrap; overflow: visible; }
.or-legenda { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--mute); }
.or-legenda i { width: 90px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #f1f2f3, #0e8f88); }
.aria { position: relative; display: grid; gap: 8px; }
.aria-r { display: grid; grid-template-columns: minmax(0, 120px) 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.aria-r em { font-style: normal; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .aria-r b { text-align: right; font-variant-numeric: tabular-nums; }
.aria-soglia { display: none; }

@media (max-width: 1180px) { .mods { grid-template-columns: repeat(2, minmax(0, 1fr)); } .area-scheda { flex-basis: calc((100% - 12px) / 1.6); } }
@media (max-width: 860px) {
  .mods { grid-template-columns: 1fr; } .mod--larga { grid-column: auto; }
  .area-scheda { flex-basis: 86%; } .aree-frecce { display: none; } .aree-h .seg { order: 3; width: 100%; }
  .am-legenda { margin-left: 0; }
}
body.phone .mods { grid-template-columns: 1fr; } body.phone .mod--larga { grid-column: auto; } body.phone .area-scheda { flex-basis: 86%; } body.phone .aree-frecce { display: none; }

/* ══ Emergenza: tema scuro ═══════════════════════════════════════════════════════════════════════════
   Tutta l'app passa al nero quando l'emergenza è confermata: si capisce a colpo d'occhio che è in corso.
   La barra rossa in alto resta; il colore resta riservato agli stati. */
body.em, body.scuro {
  --bg: #0b0d10; --side: #101318; --soft: #1b1f26; --line: #2a3039; --line2: #1c2128;
  --ink: #f3f4f6; --ink2: #b6bcc6; --mute: #8a919c;
  --card: #12161b; --hover: #1a1f27; --campo: #343b45; --su-ink: #0b0d10; --alone: #0b0d10;
  --m-stanza: #161b22; --m-bordo: #3a424d; --m-corr: #12161c; --m-scale: #1e242c; --m-edif: #161b22; --m-edifb: #4a525e; --m-warn: #3a2a10; --m-ok: #10291a;
  --teal: #2cc4bb; --teal-bg: #0f2e2c; --blue: #6b9bff; --blue-bg: #14223f; --violet: #a78bfa; --violet-bg: #251b40;
  --amber: #f2a43a; --amber-bg: #33250f; --rose: #ff6b86; --rose-bg: #3b1520; --green: #44c46e; --green-bg: #11291a;
  --alarm-ink: #ff8a8a; --alarm-bg: #3a1416;
  background: var(--bg); color: var(--ink); color-scheme: dark;
}
body.em .side, body.scuro .side { background: var(--side); }
body.em .nav a:hover, body.em .nav a.on, body.scuro .nav a:hover, body.scuro .nav a.on { background: #1b2028; color: var(--ink); }
body.em .btn.pri:hover, body.scuro .btn.pri:hover { background: #d9dce1; }
body.em, body.scuro { --m-fondo: #0f1317; }
body.em .mapsvg image.plan, body.em .fcard image, body.scuro .mapsvg image.plan, body.scuro .fcard image { filter: invert(1) hue-rotate(180deg) brightness(.8) contrast(.9); }
body.em .task, body.scuro .task { background: #1a1f27; color: var(--ink); border: 1px solid #343b45; }
body.em .task .meter, body.scuro .task .meter { background: rgba(255, 255, 255, .12); }
body.em .mapbox .hint, body.scuro .mapbox .hint { background: rgba(18, 22, 27, .94); }
body.em .modal, body.scuro .modal { background: rgba(0, 0, 0, .6); }
body.em .area-scheda:hover, body.scuro .area-scheda:hover { border-color: #3a424d; }
body.em .main { box-shadow: inset 0 3px 0 var(--alarm); }


/* ══ Mappa: scheda della selezione e schermo intero ══════════════════════════════════════════════════
   Toccando una persona, una stanza, un oggetto o un dispositivo la scheda compare SOPRA la mappa
   (in basso a sinistra sul computer, pannello dal basso sul telefono), senza dover scorrere la pagina. */
.mapinfo { position: absolute; z-index: 4; left: 12px; bottom: 12px; width: min(420px, calc(100% - 80px)); max-height: 58%; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .16); animation: sale .25s var(--curva, ease-out); }
@keyframes sale { from { opacity: 0; transform: translateY(8px); } }
.mapinfo .list { border: 0; border-radius: 12px; }
.mapinfo .li:first-child { border-top: 0; padding-right: 48px; }
.mapinfo-x { position: absolute; top: 8px; right: 8px; z-index: 1; }
.mapinfo .li.sel { align-items: flex-start; } .mapinfo .sel-forma { padding-top: 3px; }
.mapinfo .t1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mapbox.con-info .hint { display: none; }
.mapbox.full { position: fixed; inset: 0; z-index: 80; border-radius: 0; border: 0; }
.mapbox.tall.full .mapsvg { width: 100%; height: 100vh !important; height: 100dvh !important; max-height: none !important; min-height: 0 !important; aspect-ratio: auto !important; padding: 12px 64px 12px 12px; }
body.mappa-piena { overflow: hidden; }
body.mappa-piena .demo-btn { z-index: 90; }
/* telefono: la mappa è bassa, la scheda va subito sotto la planimetria (stesso riquadro); a schermo intero torna sopra */
@media (max-width: 860px) {
  .mapinfo { position: relative; left: auto; bottom: auto; width: auto; max-height: none; margin: 0 8px 8px; border-radius: 12px; box-shadow: none; }
  .mapbox.full .mapinfo { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; max-height: 50%; box-shadow: 0 12px 32px rgba(0, 0, 0, .3); }
}
body.phone .mapinfo { position: relative; left: auto; bottom: auto; width: auto; max-height: none; margin: 0 8px 8px; box-shadow: none; }
body.phone .mapbox.full .mapinfo { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; max-height: 50%; }

/* ══ Vigili del Fuoco · centro di controllo ══════════════════════════════════════════════════════════ */
.cc { display: flex; flex-direction: column; gap: 14px; }
.cc-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.cc-kpi { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "c l" "v v" "s s"; align-items: center; column-gap: 10px; row-gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.cc-kpi .chip { grid-area: c; } .cc-kl { grid-area: l; font-size: 13px; color: var(--ink2); } .cc-kpi b { grid-area: v; font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; } .cc-ks { grid-area: s; font-size: 12px; color: var(--mute); }
.cc-griglia { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.cc-box { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 14px 16px 16px; min-width: 0; }
.cc-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; } .cc-h h2 { flex: 1; font-size: 15px; } .cc-h .i { width: 13px; height: 13px; vertical-align: -2px; }
.cc-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; } .cc-col .cc-h { margin-bottom: 0; min-height: 30px; }
.cc-svg { width: 100%; height: auto; display: block; max-height: 520px; }
.cc-prov { fill: var(--soft); stroke: var(--line); stroke-width: .4; }
.cc-strada { fill: none; stroke: var(--line); stroke-width: .8; } .cc-strada--min { stroke-width: .45; stroke-dasharray: 1.4 1; }
.cc-lago { fill: rgba(91, 140, 255, .18); }
.cc-sede rect { fill: var(--blue); } .cc-sede text, .cc-pin text { font-size: 2.6px; fill: var(--ink2); text-anchor: middle; font-weight: 600; paint-order: stroke; stroke: var(--card); stroke-width: .6px; }
.cc-pin .cc-punto { fill: var(--mute); stroke: var(--card); stroke-width: .5; }
.cc-pin--pre .cc-punto { fill: var(--amber); } .cc-pin--em .cc-punto { fill: var(--alarm); } .cc-pin--em text { fill: var(--ink); font-size: 3px; }
.cc-onda { fill: none; stroke: var(--alarm); stroke-width: .5; transform-origin: center; animation: onda 2s ease-out infinite; transform-box: fill-box; }
.cc-onda--2 { animation-delay: 1s; }
@keyframes onda { from { transform: scale(.4); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
.cc-rotta { fill: none; stroke: var(--blue); stroke-width: .7; stroke-dasharray: 1.6 1.2; }
.cc-mezzo rect { fill: var(--alarm); stroke: var(--card); stroke-width: .4; }
.cc-leg { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink2); margin-top: 6px; } .cc-leg span { display: inline-flex; align-items: center; gap: 6px; }
.cc-l { width: 9px; height: 9px; border-radius: 50%; display: inline-block; } .cc-l--em { background: var(--alarm); } .cc-l--pre { background: var(--amber); } .cc-l--ok { background: var(--mute); } .cc-l--sede { background: var(--blue); border-radius: 2px; }
.cc-ev { border: 1px solid rgba(255, 82, 82, .55); border-radius: var(--r); background: linear-gradient(180deg, rgba(255, 82, 82, .12), transparent 60%), var(--card); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.cc-ev-t { display: flex; align-items: center; gap: 12px; } .cc-ev-t b { display: block; font-size: 16px; } .cc-ev-t span { font-size: 12px; color: var(--ink2); }
.cc-live { width: 10px; height: 10px; border-radius: 50%; background: var(--alarm); flex: none; animation: blink 1s steps(2) infinite; }
.cc-clock { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--alarm-ink); }
.cc-ev-n { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cc-ev-n div { display: flex; flex-direction: column; } .cc-ev-n b { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; } .cc-ev-n span { font-size: 12px; color: var(--ink2); }
.cc-ev-n .al b { color: var(--alarm-ink); }
.cc-bar { height: 6px; }
.cc-ev-s, .cc-ev-a { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink2); }
.cc-ev-s > span:first-child { display: inline-flex; align-items: center; gap: 6px; } .cc-ev-s .i { width: 16px; height: 16px; }
.cc-rischio { display: inline-flex; align-items: center; gap: 6px; color: var(--amber); font-weight: 500; } .cc-rischio .i { width: 16px; height: 16px; }
.cc-ev-a .btn { margin-left: auto; }
.cc-calma { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 36px 16px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--ink2); }
.cc-calma .i { width: 28px; height: 28px; color: var(--green); } .cc-calma span { font-size: 13px; color: var(--mute); max-width: 320px; }
.cc-crono { display: flex; flex-direction: column; }
.cc-cr { display: grid; grid-template-columns: 44px 14px 1fr; gap: 8px; align-items: start; padding: 7px 0; }
.cc-ora { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; padding-top: 1px; }
.cc-pal { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); margin-top: 5px; }
.cc-cr--alarm .cc-pal { background: var(--alarm); } .cc-cr--warn .cc-pal { background: var(--amber); } .cc-cr--ok .cc-pal { background: var(--green); }
.cc-cr b { display: block; font-size: 13px; font-weight: 500; } .cc-cr div span { font-size: 12px; color: var(--mute); }
.cc-lista { border: 0; margin: 0 -16px -16px; border-radius: 0; } .cc-lista .li:first-child { border-top: 1px solid var(--line2); }
@media (max-width: 1180px) { .cc-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cc-griglia { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .cc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ══ Vigili del Fuoco · squadra in intervento (telefono) ═════════════════════════════════════════════ */
.sq-testa { display: flex; flex-direction: column; gap: 4px; } .sq-testa .pill { align-self: flex-start; } .sq-testa b { font-size: 20px; } .sq-testa > span:last-child { font-size: 13px; color: var(--ink2); }
.sq-arrivo { border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.sq-lab { font-size: 13px; color: var(--ink2); } .sq-eta { font-size: 46px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; } .sq-km { font-size: 14px; color: var(--ink2); }
.sq-strada { position: relative; height: 8px; border-radius: 4px; background: var(--soft); margin: 22px 6px 6px; }
.sq-strada i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--blue); }
.sq-strada span { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: var(--alarm); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 4px var(--card); }
.sq-strada span .i { width: 16px; height: 16px; }
.sq-capi { display: flex; justify-content: space-between; font-size: 11px; color: var(--mute); }
.sq-h { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink2); margin-top: 6px; }
.sq-numeri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sq-numeri div { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 12px; display: flex; flex-direction: column; }
.sq-numeri b { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; } .sq-numeri span { font-size: 12px; color: var(--ink2); }
.sq-numeri .al { border-color: rgba(255, 82, 82, .55); background: rgba(255, 82, 82, .1); } .sq-numeri .al b { color: var(--alarm-ink); }
.sq-numeri--neutri b { font-size: 22px; }
.sq-riga { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line2); min-height: 60px; } .list .sq-riga:first-child { border-top: 0; }
.sq-riga .tx { flex: 1; min-width: 0; } .sq-riga .t1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sq-riga--rischio { background: rgba(242, 164, 58, .08); }
.sq-forma { width: 22px; display: grid; place-items: center; }
.sq-rosso { color: var(--alarm-ink); font-size: 18px; }
.sq-tabs { width: 100%; } .sq-tabs button { flex: 1; }
.sq-cta { min-height: 56px; font-size: 16px; margin-top: 6px; }
.sq-vuoto { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 16px; color: var(--ink2); }
.sq-vuoto .i { width: 34px; height: 34px; color: var(--mute); } .sq-vuoto span { font-size: 14px; color: var(--mute); max-width: 300px; }
.sq-vuoto--ok .i { color: var(--green); }
.sq-ok { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border-radius: 12px; background: var(--green-bg); color: var(--green); font-weight: 600; }

.sq-tabs button { white-space: nowrap; }
body.phone .mapbox.tall .mapsvg { height: auto; max-height: 70vh; min-height: 260px; padding: 8px 52px 8px 8px; }

/* la mappa gestisce da sé pizzico e trascinamento: la pagina non si ingrandisce */
.mapbox, .mapbox * { -webkit-user-select: none; } .mapbox .ctl, .mapbox .mapinfo { touch-action: manipulation; }

/* allarme zona pericolosa (ordinaria) e configurazione delle zone */
.emtop.zona { background: var(--alarm); }
.li.zp { align-items: flex-start; } .li.zp .tx { min-width: 0; }
.zp-g { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; } .zp-g button .i { width: 13px; height: 13px; }
.zp-g button.on { background: var(--alarm); border-color: var(--alarm); color: #fff; }

/* scheda dell'idrante */
.mapinfo .idr-scheda { max-height: none; }
.id-testa { align-items: center; } .id-iso { width: 30px; height: 30px; flex: none; border-radius: 3px; }
.id-corpo { padding: 4px 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.id-sez h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin-bottom: 6px; font-weight: 600; }
.id-griglia { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.id-griglia .id-v { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.id-griglia .id-v b { font-size: 18px; font-variant-numeric: tabular-nums; } .id-griglia .id-v span, .id-griglia .id-v em { font-size: 11px; color: var(--mute); font-style: normal; }
.id-righe .id-v { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.id-righe .id-v span { color: var(--ink2); } .id-righe .id-v b { font-weight: 500; text-align: right; } .id-righe .id-v em { grid-column: 1 / -1; font-style: normal; font-size: 12px; color: var(--mute); }
.id-ko { color: var(--alarm-ink); font-weight: 600; }
.id-check { display: grid; gap: 4px; font-size: 13px; color: var(--ink2); } .id-check li { display: flex; align-items: center; gap: 8px; } .id-check .i { width: 15px; height: 15px; color: var(--green); }
.id-nota { font-size: 11px; color: var(--mute); margin-top: 4px; }
.mapinfo:has(.idr-scheda) { width: min(460px, calc(100% - 80px)); max-height: 78%; }
