/* =====================================================================
   DimmaWeb — struttura classica (sidebar + topbar + card), rivista
   Blu del logo · chiaro/scuro · angoli morbidi · micro-interazioni
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Manrope', system-ui, sans-serif; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden;
  transition: background .35s ease, color .35s ease;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
/* rete di sicurezza: ogni icona <use> senza regola specifica resta piccola (evita SVG giganti) */
svg { width: 16px; height: 16px; flex-shrink: 0; }
/* L'SVG overlay di Leaflet (polyline dei tracciati percorsi) NON deve subire la regola svg{16px} sopra:
   altrimenti il vector layer viene schiacciato a 16px e la traccia sparisce. */
.leaflet-overlay-pane svg, .leaflet-pane > svg { width: auto !important; height: auto !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:root { --mono: 'IBM Plex Mono', ui-monospace, monospace; --r: 16px; --r-sm: 10px; --r-xs: 8px;
  --ecoall-role-none: #b6c1d0; --ecoall-role-gate: #2f8fd6; --ecoall-role-lock: #d6412b; --ecoall-role-door-left: #7b57d6; --ecoall-role-door-right: #b04ec2; --ecoall-role-led: #1f9d57; --ecoall-role-aux: #c98a0c; --ecoall-role-tof: #1592a8; --ecoall-role-latch: #e0762b; --ecoall-role-motor: #495a99; --ecoall-role-operator: #0f8a6a; }
[data-theme="dark"] { --ecoall-role-none: #3f4d61; --ecoall-role-gate: #4f92da; --ecoall-role-lock: #f4675a; --ecoall-role-door-left: #9a7ce8; --ecoall-role-door-right: #cd72dc; --ecoall-role-led: #37c978; --ecoall-role-aux: #eab84e; --ecoall-role-tof: #38c3d8; --ecoall-role-latch: #f2925a; --ecoall-role-motor: #7488c9; --ecoall-role-operator: #33b593; }
[data-theme="light"] {
  --bg: #eaeef4; --card: #ffffff; --card-2: #f5f8fc; --sunk: #eef2f8;
  --sidebar: #ffffff; --sidebar-line: #e7ecf3;
  --text: #16202e; --text-2: #48576b; --muted: #8592a4; --faint: #b6c1d0;
  --line: #e6ebf2; --line-2: #d8e0ea;
  --brand: #28589f; --brand-2: #3a6bb5; --brand-ink: #1a3c6e; --on-brand: #ffffff;
  --wash: rgba(40,88,159,.06); --wash-2: rgba(40,88,159,.1);
  --success: #1f9d57; --warning: #c98a0c; --danger: #d6412b; --info: #1592a8; --offline: #90a0b3;
  --shadow-sm: 0 1px 2px rgba(20,40,80,.05), 0 1px 3px rgba(20,40,80,.05);
  --shadow: 0 8px 26px rgba(20,40,80,.09);
  --shadow-lg: 0 24px 60px rgba(20,40,80,.20);
  --map-bg: #e4e9f0; --map-line: #d7dee8; --map-road: #ffffff;
  --veil: linear-gradient(120deg, rgba(20,32,50,.42), rgba(20,32,50,.16));
}
[data-theme="dark"] {
  --bg: #0d1522; --card: #17212f; --card-2: #121b28; --sunk: #0f1826;
  --sidebar: #101a27; --sidebar-line: #1f2c3c;
  --text: #e9eff7; --text-2: #aab7c8; --muted: #74839a; --faint: #3f4d61;
  --line: #212d3d; --line-2: #2c3a4d;
  --brand: #4f92da; --brand-2: #6fa8e4; --brand-ink: #82b2ea; --on-brand: #08182b;
  --wash: rgba(79,146,218,.13); --wash-2: rgba(79,146,218,.2);
  --success: #37c978; --warning: #eab84e; --danger: #f4675a; --info: #38c3d8; --offline: #6b7c92;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 10px 30px rgba(0,0,0,.4);
  --shadow-lg: 0 26px 60px rgba(0,0,0,.6);
  --map-bg: #0e1826; --map-line: #18232f; --map-road: #1c2a3a;
  --veil: linear-gradient(120deg, rgba(6,11,18,.6), rgba(6,11,18,.32));
}

.brandmark { background: #fff center/78% no-repeat; background-image: url('logo-dimma.jpg'); border-radius: 9px; }

/* =====================================================================
   SHELL
   ===================================================================== */
.app { display: grid; grid-template-columns: 252px 1fr; height: 100vh; }

/* --- sidebar --- */
.side { background: var(--sidebar); border-right: 1px solid var(--sidebar-line); display: flex; flex-direction: column; min-height: 0; }
.side .brand { display: flex; align-items: center; gap: 12px; padding: 0 22px; height: 75px; box-sizing: border-box; border-bottom: 1px solid var(--sidebar-line); flex-shrink: 0; }
.side .brand .brandmark { width: 38px; height: 38px; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.side .brand b { font: 800 21px/1 'Manrope'; letter-spacing: 1.5px; color: var(--text); }
.side .brand small { display: block; font: 600 9px/1 var(--mono); letter-spacing: 2px; color: var(--muted); margin-top: 5px; }
.side nav { position: relative; flex: 1; min-height: 0; padding: 14px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; scrollbar-width: none; -ms-overflow-style: none; }
/* scrollbar nascosta (lo scroll resta funzionante) */
.side nav::-webkit-scrollbar { width: 0; height: 0; }
.nav-ind { position: absolute; left: 0; top: 0; width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--brand); transform: translateY(0); transition: transform .34s cubic-bezier(.5,.05,.15,1); opacity: 0; pointer-events: none; z-index: 1; }
.nav-ind.ready { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .nav-ind { transition: none; } }
.side .sec { font: 700 10px/1 'Manrope'; letter-spacing: 1.6px; text-transform: uppercase; color: var(--faint); padding: 14px 12px 8px; }
.nav { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font: 600 14px/1 'Manrope'; position: relative; transition: background .18s, color .18s, transform .18s; }
.nav .ni { display: inline-flex; color: var(--muted); transition: color .18s, transform .25s; }
.nav .ni svg { width: 20px; height: 20px; }
.nav .cnt { margin-left: auto; font: 700 10px/1 var(--mono); color: var(--muted); background: var(--sunk); padding: 4px 7px; border-radius: 20px; }
.nav:hover { background: var(--wash); color: var(--text); }
.nav:hover .ni { color: var(--brand); transform: translateX(1px); }
.nav.on { background: var(--wash); color: var(--brand); font-weight: 700; }
.nav.on .ni { color: var(--brand); }

.side .sfoot { border-top: 1px solid var(--sidebar-line); padding: 16px; display: flex; flex-direction: column; gap: 14px; flex-shrink: 0; }
.coscope { display: flex; flex-direction: column; gap: 7px; }
.coscope-lbl { display: flex; align-items: center; gap: 6px; font: 700 9px/1 var(--mono); letter-spacing: 1.4px; text-transform: uppercase; color: var(--faint); }
.coscope-lbl svg { width: 13px; height: 13px; color: var(--brand); }
.coscope-sel { position: relative; }
.coscope-sel select { -webkit-appearance: none; appearance: none; width: 100%; font: 700 12.5px/1 'Manrope'; color: var(--text); background: var(--sunk); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 34px 10px 12px; cursor: pointer; transition: border-color .16s, background .16s; }
.coscope-sel select:hover { border-color: var(--brand); background: var(--wash); }
.coscope-sel select:focus { outline: none; border-color: var(--brand); }
.coscope-sel select option { background: var(--card); color: var(--text); }
[data-theme="dark"] .coscope-sel select { color-scheme: dark; }
.coscope-chev { position: absolute; top: 50%; inset-inline-end: 11px; transform: translateY(-50%); display: inline-flex; color: var(--muted); pointer-events: none; }
.coscope-chev svg { width: 15px; height: 15px; }
.langsw { display: flex; gap: 5px; }
.langsw button { flex: 1; font: 700 11px/1 var(--mono); letter-spacing: .5px; color: var(--muted); padding: 8px 0; border: 1px solid var(--line); background: var(--card); border-radius: 8px; transition: color .18s, border-color .18s, background .18s; }
.langsw button:hover { color: var(--brand); border-color: var(--brand); }
.langsw button.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.userchip { display: flex; align-items: center; gap: 11px; width: 100%; text-align: start; border: 1px solid var(--line-2); background: var(--sunk); border-radius: var(--r-sm); padding: 8px 11px; cursor: pointer; transition: border-color .16s, background .16s; }
.userchip:hover { border-color: var(--brand); background: var(--wash); }
.userchip .ucgo { margin-inline-start: auto; display: inline-flex; color: var(--muted); }
.userchip .ucgo svg { width: 15px; height: 15px; }
.userchip:hover .ucgo { color: var(--brand); }
.userchip .av { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: flex; align-items: center; justify-content: center; font: 800 16px/1 'Manrope'; flex-shrink: 0; }
.userchip .un { font: 700 14px/1 'Manrope'; color: var(--text); }
.userchip .ur { font: 600 9px/1 var(--mono); letter-spacing: 1px; color: var(--muted); margin-top: 5px; }
.btn-out { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px; border: 1px solid var(--line-2); background: transparent; border-radius: var(--r-sm); color: var(--text-2); font: 700 12px/1 'Manrope'; transition: all .18s; }
.btn-out svg { width: 16px; height: 16px; }
.btn-out:hover { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* --- toggle switch (theme) --- */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--sunk); border-radius: var(--r-sm); }
.switch .sl { display: flex; align-items: center; gap: 8px; font: 700 12px/1 'Manrope'; color: var(--text-2); }
.switch .sl svg { width: 16px; height: 16px; color: var(--muted); }
.tgl { width: 48px; height: 27px; border-radius: 20px; border: none; background: var(--line-2); position: relative; transition: background .25s; flex-shrink: 0; }
.tgl::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .28s cubic-bezier(.4,1.4,.5,1); }
[data-theme="dark"] .tgl { background: var(--brand); }
[data-theme="dark"] .tgl::after { transform: translateX(21px); }

/* --- main / topbar --- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 16px; padding: 16px 26px; border-bottom: 1px solid var(--line); background: var(--card); position: relative; z-index: 30; }
/* tooltip degli elementi in cima (es. campana allarmi): si aprono verso il BASSO, altrimenti escono sopra il bordo pagina (sotto la barra del browser) */
.top [data-tip]::after { bottom: auto; top: calc(100% + 8px); transform: translateX(-50%) translateY(-4px); }
.top [data-tip]:hover::after { transform: translateX(-50%) translateY(0); }
.top .tt h1 { margin: 0; font: 800 20px/1.1 'Manrope'; letter-spacing: -.3px; color: var(--text); }
.top .tt p { margin: 5px 0 0; font: 500 12.5px/1 'Manrope'; color: var(--muted); }
.search { margin-left: auto; display: flex; align-items: center; gap: 9px; background: var(--sunk); border: 1.5px solid transparent; border-radius: 12px; padding: 10px 14px; width: 240px; transition: width .28s cubic-bezier(.4,0,.2,1), border-color .2s, background .2s, box-shadow .2s; }
.search svg { width: 16px; height: 16px; color: var(--muted); transition: color .2s; }
.search input { border: none; background: transparent; outline: none; color: var(--text); font: 500 13.5px/1 'Manrope'; width: 100%; }
.search input::placeholder { color: var(--muted); }
.search:focus-within { width: 300px; border-color: var(--brand); background: var(--card); box-shadow: 0 0 0 4px var(--wash); }
.search:focus-within svg { color: var(--brand); }
.iconbtn { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; position: relative; transition: all .18s; }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.iconbtn .rd { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--card); }
.top .av { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: flex; align-items: center; justify-content: center; font: 800 16px/1 'Manrope'; }

/* --- content --- */
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 26px 40px; }
.view > * { max-width: 1860px; margin-left: auto; margin-right: auto; }
/* le tabelle scrollano orizzontalmente quando lo spazio è poco, invece di schiacciarsi */
.card:has(> .tbl) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.vhead { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.vhead h2 { margin: 0; font: 800 22px/1 'Manrope'; letter-spacing: -.4px; color: var(--text); }
.vhead .va { margin-left: auto; display: flex; gap: 10px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--r-sm); font: 700 13px/1 'Manrope'; border: 1px solid var(--line-2); background: var(--card); color: var(--text); transition: all .18s; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.primary { border: none; background: var(--brand); color: var(--on-brand); position: relative; overflow: hidden; }
.btn.primary::after { content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-18deg); transition: left .55s ease; }
.btn.primary:hover { background: var(--brand-2); transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 40%, transparent); }
.btn.primary:hover::after { left: 130%; }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: transform .2s, box-shadow .2s, border-color .2s; }
.stat::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, var(--wash), transparent 60%); opacity: 0; transition: opacity .25s; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.stat:hover::before { opacity: 1; }
.stat .si { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 11px; background: var(--wash); color: var(--brand); position: relative; }
.stat.ok .si { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.stat.warn .si { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.stat.amber .si { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.stat .si svg { width: 22px; height: 22px; }
.stat .sv { font: 800 28px/1 'Manrope'; letter-spacing: -1px; color: var(--text); position: relative; }
.stat .sv small { font-size: 18px; color: var(--muted); }
.stat .sk { font: 600 12px/1 'Manrope'; color: var(--muted); margin-top: 6px; position: relative; }
.stat .sd { position: absolute; top: 18px; right: 20px; font: 700 12px/1 var(--mono); }
/* clickable stat + critical/check UI */
.stat.clk { cursor: pointer; }
.stat.clk .sgo { position: absolute; top: 16px; right: 16px; width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s; }
.stat.clk .sgo svg { width: 14px; height: 14px; }
.stat.clk:hover .sgo { opacity: 1; transform: translateX(0); }
.emptyok { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 30px; font: 600 13.5px/1.4 'Manrope'; color: var(--success); }
.emptyok svg { width: 17px; height: 17px; }
.ckbody { gap: 12px !important; }
.ckrow { display: grid; grid-template-columns: 1.3fr 1.6fr auto; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--sunk); }
.ckdev { display: flex; align-items: center; gap: 11px; }
.ckdev .dic.sm { width: 40px; height: 40px; border-radius: 11px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ckdev .dic.sm svg { width: 20px; height: 20px; }
.ckmeta { min-width: 0; }
.ckmeta .dn { font: 700 14px/1.15 'Manrope'; color: var(--text); }
.ckmeta .did { font: 600 11px/1 var(--mono); color: var(--muted); margin-top: 5px; }
.ckdev .pill { margin-inline-start: 4px; }
.ckissues { display: flex; flex-wrap: wrap; gap: 6px; }
.ibadge { display: inline-flex; align-items: center; gap: 5px; font: 600 11.5px/1.2 'Manrope'; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent); border-radius: 8px; padding: 5px 8px; }
.ibadge svg { width: 12px; height: 12px; flex-shrink: 0; }
.ckact { display: flex; justify-content: flex-end; }
.ckact .btn.sm { white-space: nowrap; }
/* account modal */
.acctbody { gap: 18px !important; }
.acctprofile { display: flex; align-items: center; gap: 14px; padding: 4px 2px 16px; border-bottom: 1px solid var(--line); }
.acctprofile .av.lg { width: 52px; height: 52px; border-radius: 15px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: flex; align-items: center; justify-content: center; font: 800 22px/1 'Manrope'; flex-shrink: 0; }
.acctprofile .apmeta .dn { font: 800 17px/1.1 'Manrope'; color: var(--text); }
.acctprofile .apmeta .ur { font: 700 9px/1 var(--mono); letter-spacing: 1px; color: var(--brand); margin-top: 6px; }
.acctprofile .apmeta .did { font: 600 12px/1 var(--mono); color: var(--muted); margin-top: 7px; }
.asec { display: flex; flex-direction: column; gap: 11px; }
.asech { display: flex; align-items: center; gap: 8px; font: 700 11px/1 'Manrope'; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.asech svg { width: 14px; height: 14px; color: var(--brand); }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.arow .al { font: 600 13.5px/1 'Manrope'; color: var(--text-2); }
.seg { display: inline-flex; gap: 4px; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segbtn { display: inline-flex; align-items: center; gap: 6px; font: 700 12.5px/1 'Manrope'; color: var(--muted); background: transparent; border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer; transition: color .16s, background .16s; }
.segbtn svg { width: 14px; height: 14px; }
.segbtn:hover { color: var(--text); }
.segbtn.on { background: var(--brand); color: var(--on-brand); }
.asub { font: 500 12px/1.5 'Manrope'; color: var(--muted); margin: -4px 0 4px; }

/* ===== Menu personale: tab + profilo + privacy/GDPR ===== */
.acct-tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.acct-tab { border: none; background: transparent; color: var(--muted); font: 700 13px/1 'Manrope'; padding: 13px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .16s, border-color .16s; }
.acct-tab:hover { color: var(--text); }
.acct-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.acct-msg { padding: 10px 13px; border-radius: 10px; font: 600 12.5px/1.4 'Manrope'; }
.acct-msg.success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.acct-msg.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.profile-form { display: flex; flex-direction: column; gap: 14px; }
.profile-form .fg { display: flex; flex-direction: column; gap: 6px; }
.profile-form .fg label { font: 700 11px/1 'Manrope'; letter-spacing: .3px; color: var(--muted); }
.profile-form .fg input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--sunk); color: var(--text); font: 500 13.5px/1 'Manrope'; }
.profile-form .fg input:disabled { opacity: .7; cursor: not-allowed; }
.profile-form .fg small { font: 500 11px/1 'Manrope'; color: var(--muted); }
.acct-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.privacy-info { display: flex; gap: 13px; align-items: flex-start; padding: 4px 0 8px; }
.privacy-info > svg { width: 26px; height: 26px; color: var(--brand); flex-shrink: 0; margin-top: 2px; }
.privacy-info h3 { margin: 0 0 4px; font: 800 15px/1.2 'Manrope'; color: var(--text); }
.privacy-info p { margin: 0; font: 500 12.5px/1.5 'Manrope'; color: var(--muted); }
.privacy-action { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; }
.privacy-action .action-info h4 { margin: 0 0 4px; font: 700 13.5px/1.2 'Manrope'; color: var(--text); }
.privacy-action .action-info p { margin: 0; font: 500 12px/1.45 'Manrope'; color: var(--muted); }
.privacy-action.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.privacy-action .btn { flex-shrink: 0; }
.legal-section { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.legal-links { display: flex; flex-direction: column; gap: 2px; }
.legal-link { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border-radius: 10px; color: var(--text-2); font: 600 13px/1 'Manrope'; text-decoration: none; cursor: pointer; transition: background .14s, color .14s; }
.legal-link svg { width: 15px; height: 15px; color: var(--muted); }
.legal-link:hover { background: var(--sunk); color: var(--brand); }
.legal-link:hover svg { color: var(--brand); }

/* dialog eliminazione account */
.del-ov { z-index: 95; }
.modal.del-dlg { width: 460px; }
.modal .mh .mi.danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.del-instr { margin: 0 0 12px; font: 600 13px/1.5 'Manrope'; color: var(--text-2); }
.del-input { width: 100%; padding: 11px 13px; border: 1px solid var(--danger); border-radius: 10px; background: var(--sunk); color: var(--text); font: 700 14px/1 'Manrope'; letter-spacing: 1px; }

/* ===== Pagine legali ===== */
.modal.legal { width: 720px; }
.legaldoc { gap: 0 !important; font: 400 13.5px/1.6 'Manrope'; color: var(--text-2); }
.legaldoc .legal-upd { font: 600 11px/1 var(--mono); color: var(--muted); margin: 0 0 6px; }
.legaldoc section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.legaldoc section:last-child { border-bottom: none; }
.legaldoc h2 { font: 800 15px/1.3 'Manrope'; color: var(--text); margin: 0 0 10px; }
.legaldoc h3 { font: 700 13px/1.3 'Manrope'; color: var(--text); margin: 14px 0 6px; }
.legaldoc p { margin: 0 0 8px; }
.legaldoc ul { margin: 6px 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 5px; }
.legaldoc strong { color: var(--text); }
.legaldoc a { color: var(--brand); }
.legaldoc a.legal-x { cursor: pointer; text-decoration: underline; }
.legal-tw { overflow-x: auto; margin: 8px 0; }
.legal-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.legal-table th, .legal-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: start; }
.legal-table th { background: var(--sunk); color: var(--text); font-weight: 700; }

/* ===== Banner cookie ===== */
.cookie-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; padding: 20px; pointer-events: none; }
.cookie-banner { pointer-events: auto; width: 560px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px 22px; animation: cookieup .3s cubic-bezier(.3,1.1,.5,1); }
@keyframes cookieup { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.cookie-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cookie-head svg { width: 24px; height: 24px; color: var(--brand); }
.cookie-head h3 { margin: 0; font: 800 16px/1.1 'Manrope'; color: var(--text); }
.cookie-desc { margin: 0 0 16px; font: 500 12.5px/1.55 'Manrope'; color: var(--muted); }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cookie-actions .btn { flex: 1 1 auto; justify-content: center; }
.cookie-custom { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.cookie-opt { display: flex; align-items: center; gap: 12px; }
.cookie-opt-i { flex: 1; }
.cookie-opt-i h4 { margin: 0 0 3px; font: 700 12.5px/1.2 'Manrope'; color: var(--text); }
.cookie-opt-i p { margin: 0; font: 500 11.5px/1.4 'Manrope'; color: var(--muted); }
.cookie-tg { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.cookie-tg input { opacity: 0; width: 0; height: 0; }
.cookie-sl { position: absolute; inset: 0; background: var(--line-2, var(--line)); border-radius: 22px; transition: background .18s; cursor: pointer; }
.cookie-sl::before { content: ''; position: absolute; width: 16px; height: 16px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .18s; }
.cookie-tg input:checked + .cookie-sl { background: var(--brand); }
.cookie-tg input:checked + .cookie-sl::before { transform: translateX(18px); }
.cookie-tg input:disabled + .cookie-sl { opacity: .6; cursor: not-allowed; }
.cookie-tgl { font: 700 10px/1 var(--mono); color: var(--muted); min-width: 52px; text-align: end; }
.cookie-custom-f { display: flex; justify-content: flex-end; }

/* account/legal: header · tab · footer fissi, scorre solo il corpo */
.modal.acct, .modal.legal { display: flex; flex-direction: column; overflow: hidden; }
/* altezza FISSA: cambiando tab il modal non cambia più dimensione */
.modal.acct { height: min(600px, calc(100dvh - 40px)); }
.modal.legal { height: min(640px, calc(100dvh - 40px)); }
.modal.acct > .mb, .modal.legal > .mb { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal.acct > .mh, .modal.acct > .acct-tabs, .modal.acct > .mf,
.modal.legal > .mh, .modal.legal > .mf { flex: 0 0 auto; }

/* scrollbar dei modal: sottile, arrotondata, discreta (light + dark) */
.modal, .modal .mb, .legaldoc, .cookie-banner { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
.modal::-webkit-scrollbar, .modal .mb::-webkit-scrollbar, .legaldoc::-webkit-scrollbar, .cookie-banner::-webkit-scrollbar { width: 11px; height: 11px; }
.modal::-webkit-scrollbar-track, .modal .mb::-webkit-scrollbar-track, .legaldoc::-webkit-scrollbar-track, .cookie-banner::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb, .modal .mb::-webkit-scrollbar-thumb, .legaldoc::-webkit-scrollbar-thumb, .cookie-banner::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 42%, transparent); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
.modal::-webkit-scrollbar-thumb:hover, .modal .mb::-webkit-scrollbar-thumb:hover, .legaldoc::-webkit-scrollbar-thumb:hover, .cookie-banner::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 68%, transparent); background-clip: padding-box; }
.alist { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; }
.alist li { font: 500 13px/1.5 'Manrope'; color: var(--text-2); }
.anote { font: 500 11.5px/1.4 'Manrope'; color: var(--faint); font-style: italic; padding-top: 4px; }
/* alarm management */
.rulegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
/* Moduli azienda (modal) */
.modlist { display: flex; flex-direction: column; }
.modrow { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.modrow:last-child { border-bottom: 0; }
.modrow .modic { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 8px; background: var(--wash); color: var(--brand); flex-shrink: 0; }
.modrow .modic svg { width: 16px; height: 16px; }
.modrow .modlbl { font: 700 13px/1 'Manrope'; color: var(--text); }
.modrow .tglbtn { margin-inline-start: auto; }
/* colonna azioni: padding ridotto così i pulsanti (fino a 3: moduli/modifica/elimina) non fanno scrollare la tabella */
.tbl th:last-child, .tbl td:last-child { padding-inline: 10px; }
/* tabelle Utenti/Aziende/Gruppi: niente scroll orizzontale (i pochi px sono arrotondamenti sub-pixel, non contenuto) */
.card.um-card { overflow-x: hidden; }
/* scheda tecnica veicolo GPS (modal info CAN) */
.caninfo { margin-bottom: 4px; }
.caninfo-h { display: flex; align-items: center; gap: 8px; font: 800 12px/1 'Manrope'; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 12px; }
.caninfo-h svg { width: 15px; height: 15px; color: var(--brand); }
.fwtag { font: 600 10px/1 var(--mono); color: var(--muted); background: var(--wash); padding: 2px 5px; border-radius: 5px; margin-left: 4px; }
/* password temporanea (reset) */
.pwbox { display: flex; align-items: center; gap: 10px; margin-top: 12px; background: var(--sunk); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; }
.pwbox code { flex: 1; font: 700 15px/1.3 var(--mono); color: var(--brand); letter-spacing: .5px; word-break: break-all; }
/* Storico allarmi (tab in Gestione allarmi) */
.almhist-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.almhist-filters select, .almhist-filters input[type="date"] { font: 600 12.5px/1 'Manrope'; color: var(--text); background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.almhist-date { display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 'Manrope'; color: var(--muted); letter-spacing: .4px; }
.almhist-note { display: flex; align-items: center; gap: 8px; font: 500 12px/1.4 'Manrope'; color: var(--muted); background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 14px; }
.almhist-note svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--brand); }
.rulecard, .subcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; transition: border-color .16s, box-shadow .16s; }
.rulecard:hover, .subcard:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.rulecard.off { opacity: .6; }
.rulehd { display: flex; align-items: center; gap: 11px; }
.rulehd .ri { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rulehd .ri svg { width: 19px; height: 19px; }
.rmeta { min-width: 0; flex: 1; }
.rmeta .rn { font: 700 14.5px/1.15 'Manrope'; color: var(--text); }
.rmeta .rt { font: 600 11.5px/1.3 'Manrope'; color: var(--muted); margin-top: 4px; }
.rmeta .rt b { color: var(--text-2); }
.tglbtn { width: 42px; height: 24px; border-radius: 20px; border: none; background: var(--line-2); position: relative; cursor: pointer; flex-shrink: 0; transition: background .22s; }
.tglbtn .tgldot { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .22s; }
.tglbtn.on { background: var(--brand); }
.tglbtn.on .tgldot { transform: translateX(18px); }
[dir="rtl"] .tglbtn.on .tgldot { transform: translateX(-18px); }
.rulecond { display: flex; align-items: center; gap: 8px; font: 600 12.5px/1.3 var(--mono); color: var(--text-2); background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.rulecond svg { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; }
.rulefoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rtrig { display: inline-flex; align-items: center; gap: 6px; font: 700 11.5px/1 'Manrope'; color: var(--success); }
.rtrig svg { width: 13px; height: 13px; }
.rtrig.on { color: var(--danger); }
.rulefoot .rowact { display: flex; gap: 6px; }
.rulefoot .rowact button { width: 32px; height: 32px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: color .16s, border-color .16s; }
.rulefoot .rowact button svg { width: 15px; height: 15px; }
.rulefoot .rowact button:hover { color: var(--brand); border-color: var(--brand); }
.rulefoot .rowact button.del:hover { color: var(--danger); border-color: var(--danger); }
.subdevs { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.sm { display: inline-flex; align-items: center; gap: 5px; font: 600 11.5px/1 'Manrope'; color: var(--text-2); background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.chip.sm svg { width: 12px; height: 12px; color: var(--brand); }
.gmhint { font: 500 13px/1.5 'Manrope'; color: var(--muted); max-width: 720px; margin: 0 0 18px; }
/* device picker (subgroup modal) */
.devpick { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--sunk); }
.devpick .dpitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; transition: background .14s; }
.dpitem:hover { background: var(--wash); }
.dpitem.on { background: var(--wash); }
.devpick .dpitem input { width: 17px; height: 17px; min-width: 17px; padding: 0; accent-color: var(--brand); flex-shrink: 0; }
.dpitem .di.sm { width: 30px; height: 30px; border-radius: 9px; background: var(--card); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dpitem .di.sm svg { width: 16px; height: 16px; }
.dpn { flex: 1; min-width: 0; font: 600 13px/1.2 'Manrope'; color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.dpn small { font: 600 10px/1 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* bell dropdown */
.bellwrap { position: relative; }
.iconbtn.has { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.bellct { position: absolute; top: -5px; inset-inline-end: -5px; box-sizing: border-box; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font: 800 10px/1 var(--mono); display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--card); }
.bellpop { position: absolute; top: calc(100% + 10px); inset-inline-end: 0; z-index: 60; width: min(360px, 90vw); background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .2s cubic-bezier(.3,1,.4,1); }
.bellhd { display: flex; align-items: center; gap: 8px; font: 700 11px/1 'Manrope'; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); }
.bellhd svg { width: 14px; height: 14px; color: var(--danger); }
.bellhd .cnt { margin-inline-start: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font: 800 10px/18px var(--mono); text-align: center; }
.bellrows { max-height: 340px; overflow-y: auto; }
.bellrow { display: flex; align-items: center; gap: 11px; width: 100%; text-align: start; padding: 11px 16px; border: none; background: transparent; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .14s; }
.bellrow:hover { background: var(--wash); }
.bellrow .bdot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.bdot.sev-high { background: var(--danger); } .bdot.sev-med { background: var(--warning); } .bdot.sev-low { background: var(--success); }
.bmeta { flex: 1; min-width: 0; }
.bmeta .bn { font: 700 13px/1.15 'Manrope'; color: var(--text); }
.bmeta .bm { font: 600 11px/1.3 'Manrope'; color: var(--muted); margin-top: 3px; }
.bellrow > svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.bellempty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 26px; font: 600 12.5px/1 'Manrope'; color: var(--success); }
.bellempty svg { width: 15px; height: 15px; }
.bellall { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; border: none; background: var(--sunk); color: var(--brand); font: 700 12.5px/1 'Manrope'; cursor: pointer; transition: background .14s; }
.bellall svg { width: 14px; height: 14px; }
.bellall:hover { background: var(--wash); }
/* subgroup differentiation + picker */
.subcard { border-inline-start: 3px solid var(--brand-2); }
.sgtag { display: inline-block; vertical-align: middle; margin-inline-start: 6px; font: 800 8.5px/1 var(--mono); letter-spacing: .8px; color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 13%, transparent); border-radius: 5px; padding: 3px 6px; }
.pgroups { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.pgroups .pgh { font: 700 10px/1 'Manrope'; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); margin-inline-end: 4px; }
.chip.sm.pg { border-style: dashed; }
.chip.sm.pg small { font: 800 10px/1 var(--mono); color: var(--brand); margin-inline-start: 2px; }
.picksearch { position: relative; display: flex; align-items: center; margin-bottom: 8px; }
.picksearch svg { position: absolute; inset-inline-start: 11px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.fg .picksearch input, .picksearch input { width: 100%; padding: 10px 12px 10px 34px; border: 1.5px solid var(--line-2); background: var(--sunk); border-radius: var(--r-sm); color: var(--text); font: 500 13px/1 'Manrope'; outline: none; }
.picksearch input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--wash); }
.pickcount { color: var(--brand); font-family: var(--mono); font-weight: 800; }
/* picker: barra filtri tipo + azioni rapide */
.pickbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pickchip { font: 700 11.5px/1 'Manrope'; color: var(--muted); background: var(--sunk); border: 1px solid var(--line); border-radius: 20px; padding: 7px 12px; cursor: pointer; transition: all .14s; }
.pickchip:hover { color: var(--text); border-color: var(--line-2); }
.pickchip.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.pickactions { display: flex; gap: 14px; margin-bottom: 8px; padding-inline-start: 2px; }
.picklink { display: inline-flex; align-items: center; gap: 5px; font: 700 12px/1 'Manrope'; color: var(--brand); background: none; border: none; padding: 2px 0; cursor: pointer; }
.picklink svg { width: 13px; height: 13px; }
.picklink:hover { text-decoration: underline; }
.pickempty { display: none; padding: 26px; text-align: center; font: 600 13px/1 'Manrope'; color: var(--muted); }
.dpitem .dpchk { display: inline-flex; color: var(--brand); opacity: 0; transition: opacity .14s; }
.dpitem .dpchk svg { width: 16px; height: 16px; }
.dpitem.on .dpchk { opacity: 1; }
.dpitem.on { background: var(--wash); }

/* generic card */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; }
#tripscard { overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 214px); }
/* col calendario aperto NON tagliare il popup: quando la card è corta (nessun viaggio) il calendario sfora sotto */
#tripscard:has(.daterange.open) { overflow: visible; }
.tripscroll { position: relative; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.trip.clk { cursor: pointer; }
.trip.sel { background: var(--wash); }
.trip.sel .tic { background: var(--brand); color: #fff; }
/* Linea blu animata accanto al viaggio selezionato (come l'indicatore del menu veicoli) */
.trip-ind { position: absolute; left: 0; top: 0; width: 3px; height: 0; background: var(--brand); border-radius: 0 3px 3px 0; transform: translateY(0); opacity: 0; pointer-events: none; z-index: 2; transition: transform .3s cubic-bezier(.5,.05,.15,1), height .3s cubic-bezier(.5,.05,.15,1); }
.trip-ind.ready { opacity: 1; }
[dir="rtl"] .trip-ind { left: auto; right: 0; border-radius: 3px 0 0 3px; }
@media (prefers-reduced-motion: reduce) { .trip-ind { transition: none; } }
/* scrollbar sottile (uguale per lista percorsi e menu veicoli) */
.tripscroll::-webkit-scrollbar, .raillist::-webkit-scrollbar { width: 6px; }
.tripscroll::-webkit-scrollbar-thumb, .raillist::-webkit-scrollbar-thumb { border: none; background: color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 6px; }
.tripscroll::-webkit-scrollbar-track, .raillist::-webkit-scrollbar-track { background: transparent; }
.tripall { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 5px; font: 700 11px/1 'Manrope'; color: var(--brand); background: var(--wash); border: none; border-radius: 8px; padding: 6px 9px; cursor: pointer; opacity: .55; transition: opacity .15s; }
.tripall.on { opacity: 1; }
.tripall svg { width: 13px; height: 13px; }
/* popup punto percorso: velocità + ora */
.rtpt { display: flex; flex-direction: column; gap: 3px; font: 700 13px/1.1 'Manrope'; }
.rtpt span { display: inline-flex; align-items: center; gap: 4px; font: 600 11px/1 'Manrope'; color: var(--muted); }
.rtpt span svg { width: 12px; height: 12px; }
.card .ch { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.card .ch .ci { color: var(--brand); display: inline-flex; }
.card .ch .ci svg { width: 18px; height: 18px; }
.card .ch h3 { margin: 0; font: 700 15px/1 'Manrope'; color: var(--text); }
.card .ch .cnt { margin-left: auto; font: 700 11px/1 var(--mono); color: var(--muted); background: var(--sunk); padding: 5px 10px; border-radius: 20px; }

/* dashboard duo */
.duo { display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: 16px; margin-bottom: 20px; }

/* dashboard: altezza FISSA in base allo schermo (indipendente dal n° di allarmi).
   Mappa e pannello allarmi occupano sempre la stessa altezza: la mappa riempie,
   il pannello allarmi scrolla internamente se la lista è lunga. */
/* dashboard: le colonne si allineano alla griglia 4-col delle stat (stesso gap 16px, stessa larghezza contenitore)
   → Mappa flotta occupa 3 colonne (finisce a filo di "Da verificare"), Storico Allarmi 1 colonna (= "Riempimento medio") */
.dashduo { grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr; align-items: stretch; height: calc(100vh - 268px); min-height: 420px; }
.dashduo > .card.map { grid-column: span 3; }
.dashduo > .card:not(.map) { grid-column: span 1; }
.dashduo > .card { height: 100%; min-height: 0; }
.dashduo > .card.map { display: flex; flex-direction: column; }
.dashduo > .card.map > .mapf { height: auto; flex: 1 1 auto; min-height: 0; }
/* anteprima mappa: bordo squadrato in alto (a filo con l'header), arrotondato in basso (lo arrotonda il clip della card) */
.dashduo > .card.map > .mapf.livemap { border-radius: 0; }
.dashduo > .card:not(.map) { display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
/* Storico Allarmi: scrollbar nascosta (lo scroll resta funzionante) */
.dashduo > .card:not(.map)::-webkit-scrollbar { width: 0; height: 0; }
.dashduo > .card:not(.map) > .ch { position: sticky; top: 0; z-index: 2; background: var(--card); flex: 0 0 auto; }
.dashduo > .card:not(.map) > .arow { flex: 0 0 auto; }
/* stato vuoto allarmi: messaggio centrato che riempie il pannello */
.alarms-empty { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; text-align: center; padding: 24px; }
.alarms-empty .ae-ic { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--sunk); color: var(--brand); }
.alarms-empty .ae-ic svg { width: 24px; height: 24px; }
.alarms-empty .ae-t { font: 800 15px/1.25 'Manrope'; color: var(--text); }
.alarms-empty .ae-s { font: 500 12.5px/1.55 'Manrope'; color: var(--muted); max-width: 250px; }
.alarms-empty .ae-link { color: var(--brand); font-weight: 700; cursor: pointer; text-decoration: none; }
.alarms-empty .ae-link:hover { text-decoration: underline; }

/* map */
.map .mapf { height: 340px; position: relative; overflow: hidden;
  background: linear-gradient(var(--map-line) 1px, transparent 1px), linear-gradient(90deg, var(--map-line) 1px, transparent 1px), var(--map-bg);
  background-size: 44px 44px, 44px 44px; }
.mroad { position: absolute; background: var(--map-road); box-shadow: 0 0 0 1px var(--map-line); }
.pin { position: absolute; transform: translate(-50%,-100%); cursor: pointer; transition: transform .18s; }
.pin i { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2.5px solid var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.pin i svg { transform: rotate(45deg); width: 15px; height: 15px; color: #fff; }
.pin:hover { transform: translate(-50%,-104%) scale(1.06); }
.pin.sel i { width: 40px; height: 40px; z-index: 5; box-shadow: 0 0 0 5px var(--wash-2), 0 3px 8px rgba(0,0,0,.35); }
.mzoom { position: absolute; top: 12px; left: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.mzoom button { display: block; width: 30px; height: 30px; border: none; background: transparent; color: var(--text); font-size: 17px; }
.mzoom button:first-child { border-bottom: 1px solid var(--line); }
.mzoom button:hover { background: var(--wash); color: var(--brand); }
.mtag { position: absolute; bottom: 10px; right: 12px; font: 500 10px/1 'Manrope'; color: var(--muted); background: color-mix(in srgb, var(--card) 80%, transparent); padding: 4px 8px; border-radius: 6px; }

/* alarm list */
.arow { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); transition: background .15s; }
.arow:last-child { border-bottom: none; }
.arow:hover { background: var(--card-2); }
.arow .adot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.arow .an { font: 700 13px/1 'Manrope'; color: var(--text); }
.arow .am { font: 500 11px/1.3 var(--mono); color: var(--muted); margin-top: 4px; }
.arow .ax { margin-left: auto; font: 600 11px/1 'Manrope'; color: var(--muted); white-space: nowrap; }
.arow .adot.sev-high { background: var(--danger); }
.arow .adot.sev-med { background: var(--warning); }
.arow .adot.sev-low { background: var(--success); }
.arow.clk { cursor: pointer; }

/* filters */
.filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; position: relative; z-index: 20; }
.chip { padding: 9px 15px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--card); color: var(--text-2); font: 700 12.5px/1 'Manrope'; transition: all .16s; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 34%, transparent); }

/* device cards grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.dcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.dcard:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--brand); }
.dcard .dh { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dcard .dic { width: 44px; height: 44px; border-radius: 13px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform .25s; }
.dcard:hover .dic { transform: scale(1.06) rotate(-3deg); }
.dcard .dic svg { width: 22px; height: 22px; }
.dcard .dn { font: 700 15px/1.1 'Manrope'; color: var(--text); }
.dcard .did { font: 600 11px/1 var(--mono); color: var(--muted); margin-top: 5px; }
.dcard .db { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.dcard .meta { display: flex; align-items: center; justify-content: space-between; font: 500 12px/1 'Manrope'; color: var(--muted); }
.dcard .meta b { color: var(--text); font-weight: 700; font-family: var(--mono); }

/* fill bars */
.fillrow { display: flex; align-items: center; gap: 10px; }
.fillrow .fk { font: 700 10px/1 var(--mono); color: var(--muted); width: 30px; }
.bar { flex: 1; height: 8px; border-radius: 6px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; transition: width .6s cubic-bezier(.3,1,.4,1); }
.fillrow .fp { font: 700 11px/1 var(--mono); width: 36px; text-align: right; color: var(--text); }

/* table */
.tbl { width: 100%; min-width: 660px; border-collapse: collapse; table-layout: fixed; }
.tbl thead th { text-align: center; font: 700 11px/1.2 'Manrope'; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 15px 22px; border-bottom: 1px solid var(--line-2); overflow: hidden; text-overflow: ellipsis; background: var(--card-2); white-space: nowrap; }
.tbl thead th.sortable { cursor: pointer; user-select: none; transition: color .16s, background .16s; }
.tbl thead th.sortable:hover { color: var(--brand); background: var(--wash); }
.tbl thead th.sorted { color: var(--brand); }
.thc { display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.sar { font-size: 11px; opacity: .55; font-family: var(--mono); }
.sortable:hover .sar, .sorted .sar { opacity: 1; }
.tbl thead th:first-child .thc { justify-content: center; }

/* advanced filters */
.advwrap { position: relative; display: inline-flex; }
.chip.advtoggle { display: inline-flex; align-items: center; gap: 7px; }
.chip.advtoggle svg { width: 14px; height: 14px; }
.chip.advtoggle.has { border-color: var(--brand); color: var(--brand); }
.chip.advtoggle.open { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.chip.advtoggle.open svg { color: var(--on-brand); }
/* badge conteggio: altezza <= icona (14px) così l'apparizione del "1" NON allunga il chip/la barra filtri */
.advcount { display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 14px; padding: 0 4px; border-radius: 7px; background: var(--brand); color: var(--on-brand); font: 800 9px/1 var(--mono); }
.chip.advtoggle.open .advcount { background: var(--on-brand); color: var(--brand); }
.advpanel { position: absolute; top: calc(100% + 9px); inset-inline-start: 0; z-index: 40; width: min(500px, 90vw); background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 18px 44px -18px rgba(0,0,0,.4); padding: 14px; display: flex; flex-direction: column; gap: 9px; transform-origin: top left; animation: advpop .16s cubic-bezier(.3,1,.4,1); }
@keyframes advpop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
[dir="rtl"] .advpanel { transform-origin: top right; }
.advhd { font: 700 11px/1.3 'Manrope'; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.advhd svg { width: 13px; height: 13px; color: var(--brand); }
.advempty { font: 500 13px/1.4 'Manrope'; color: var(--muted); padding: 4px 2px; }
.advrow { display: flex; align-items: center; gap: 7px; }
.advrow select, .advrow input { font: 600 12.5px/1 'Manrope'; color: var(--text); background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; height: 36px; }
.advrow select { flex: 1.7; min-width: 0; cursor: pointer; }
.advrow select.advop { flex: 1.2; text-align: left; }
.advrow input.advval { flex: 0 0 76px; }
.advrow input.advval.bt { flex: 0 0 58px; }
.advrow input.advval.dt { flex: 1; min-width: 0; padding: 8px 7px; }
.advcombo { flex: 1.1; min-width: 0; position: relative; display: flex; align-items: center; }
.advcombo .advsrchi { position: absolute; inset-inline-start: 9px; display: inline-flex; color: var(--muted); pointer-events: none; }
.advcombo .advsrchi svg { width: 13px; height: 13px; }
.advrow input.advval.advsrch { flex: 1; width: 100%; padding-inline-start: 28px; }
.advrow input.advval.advsrch::placeholder { color: var(--faint); }
.advdash { flex: 0 0 auto; color: var(--muted); font-weight: 700; padding: 0 1px; }
.advrow select.advval { flex: 1.1; }
.advis { flex: 0 0 auto; font: 600 12px/1 'Manrope'; color: var(--muted); padding: 0 3px; }
.advx { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--muted); transition: color .16s, border-color .16s; }
.advx:hover { color: var(--danger); border-color: var(--danger); }
.advx svg { width: 14px; height: 14px; }
.advact { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.btn.sm { padding: 8px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.sm.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm.ghost:hover { color: var(--danger); }
[dir="rtl"] .advpanel { inset-inline-start: auto; inset-inline-end: 0; }
.tbl tbody td { padding: 17px 22px; border-bottom: 1px solid var(--line); font: 500 13px/1.3 'Manrope'; color: var(--text-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
/* refresh animation */
.btn.is-refreshing { pointer-events: none; }
.btn.is-refreshing svg { animation: dw-spin .7s linear infinite; transform-origin: center; }
@keyframes dw-spin { to { transform: rotate(360deg); } }
.tbl tbody tr.row-out { opacity: .22; transition: opacity .22s ease; }
.tbl tbody tr.row-in { animation: dw-rowin .42s cubic-bezier(.2,.7,.3,1) both; }
@keyframes dw-rowin { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.tbl tbody tr.clk { cursor: pointer; transition: background .15s; }
.tbl tbody tr.clk:hover { background: var(--card-2); }
.tbl tbody td { text-align: center; }
.tbl th:first-child, .tbl td:first-child { width: 24%; }
.tbl td:first-child { text-align: left; }
.tbl td .dev { justify-content: flex-start; }
.tbl td .mini, .tbl td .abils { justify-content: center; }
.tbl td .rowact { justify-content: center; }
.tbl td .barwrap { margin-left: auto; margin-right: auto; }
.tbl td.telem { text-align: center; }
.tbl td.telem .barwrap { margin-left: auto; margin-right: auto; }
.fillrow.tavg { margin-top: 2px; padding-top: 8px; border-top: 1px dashed var(--line-2); }
.fillrow.tavg .fk { color: var(--text-2); width: auto; }
.fillrow.tavg .tavg-v { margin-left: auto; font: 800 13px/1 var(--mono); color: var(--text); }

/* vertical fill silos */
.silos { display: flex; align-items: flex-end; justify-content: center; gap: 15px; flex-wrap: wrap; padding: 2px 0; }
.silo { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 30px; }
.silo-pct { font: 700 11px/1 var(--mono); color: var(--text-2); }
.silo-tube { position: relative; width: 21px; height: 54px; border-radius: 6px; background: var(--sunk); border: 1px solid var(--line); overflow: hidden; display: flex; align-items: flex-end; }
.silo-tube i { display: block; width: 100%; border-radius: 0 0 5px 5px; transition: height .6s cubic-bezier(.3,1,.4,1); }
.silo-lab { font: 800 10px/1.15 var(--mono); letter-spacing: .06em; text-align: center; height: 23px; display: flex; align-items: flex-start; justify-content: center; }
.silo.crit .silo-pct { color: var(--danger); }
.silo.crit .silo-tube { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.silo-avg { align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding-inline-start: 13px; margin-inline-start: 2px; border-inline-start: 1px dashed var(--line-2); }
.silo-avg .k { font: 700 9px/1 var(--mono); letter-spacing: .1em; color: var(--muted); }
.silo-avg b { font: 800 16px/1 'Manrope'; color: var(--text); }
.dev { display: flex; align-items: center; gap: 12px; }
.dev .di { width: 38px; height: 38px; border-radius: 11px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dev .di svg { width: 19px; height: 19px; }
.dev .dn { font: 700 13px/1 'Manrope'; color: var(--text); }
.dev .did { font: 600 11px/1 var(--mono); color: var(--muted); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 20px; font: 700 11px/1 'Manrope'; }
.pill .pd { width: 7px; height: 7px; border-radius: 50%; }
.s-online { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); } .s-online .pd, .adot.s-online { background: var(--success); }
.s-alarm { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); } .s-alarm .pd, .adot.s-alarm { background: var(--danger); }
.s-offline { background: color-mix(in srgb, var(--offline) 18%, transparent); color: var(--offline); } .s-offline .pd, .adot.s-offline { background: var(--offline); }
.s-inactive { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); } .s-inactive .pd, .adot.s-inactive { background: var(--warning); }
.s-passive { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); } .s-passive .pd { background: var(--muted); }
.mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 12px 16px; width: 100%; }
.mini > div { text-align: center; }
.mini .k { font: 600 9px/1 var(--mono); letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.mini .v { font: 700 14px/1 var(--mono); color: var(--text); margin-top: 6px; }
.rowact { display: flex; gap: 6px; justify-content: flex-end; }
.rowact button { width: 32px; height: 32px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: all .16s; }
.rowact button svg { width: 15px; height: 15px; }
.rowact button:hover { border-color: var(--brand); color: var(--brand); }
.rowact button.del:hover { border-color: var(--danger); color: var(--danger); }
/* azioni della lista "In attesa": bottoni TESTO (Approva/Rifiuta) — non i 32x32 di .rowact */
.pdact { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.pdact .btn { flex: 0 0 auto; white-space: nowrap; }
.role { display: inline-block; padding: 4px 10px; border-radius: 20px; font: 700 10.5px/1.3 var(--mono); letter-spacing: .4px; }
.abils { display: flex; flex-wrap: wrap; gap: 6px; }
.abil { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 20px; background: var(--wash); color: var(--brand); font: 700 10px/1 'Manrope'; letter-spacing: .3px; }
.abil svg { width: 12px; height: 12px; }
.abil.off { background: var(--sunk); color: var(--faint); }

/* tabs */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line-2); margin-bottom: 18px; }
.tab { display: flex; align-items: center; gap: 8px; padding: 0 2px 13px; border: none; background: none; color: var(--muted); font: 700 14px/1 'Manrope'; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .18s; }
.tab .tc { font: 700 10px/1 var(--mono); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }

/* tooltip */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); background: var(--text); color: var(--bg); font: 600 11px/1 'Manrope'; padding: 7px 10px; border-radius: 7px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; box-shadow: var(--shadow); }
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* spinner / loader */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 90px 0; color: var(--muted); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--line-2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.loading span { font: 600 12px/1 var(--mono); letter-spacing: 1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* enter animation */
.view > * { animation: rise .4s cubic-bezier(.3,1,.4,1) both; }
/* l'editor contiene la savebar fixed: nessun transform residuo (fill-mode) che
   creerebbe un containing block e sfalserebbe il position:fixed della barra */
.view > .ecoall-editor { animation: none; }
.view > *:nth-child(2) { animation-delay: .05s; }
.view > *:nth-child(3) { animation-delay: .1s; }
.view > *:nth-child(4) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* modal */
.overlay { position: fixed; inset: 0; padding: 20px; background: color-mix(in srgb, var(--bg) 10%, rgba(6,12,22,.55)); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 90; animation: ov .2s ease; }
@keyframes ov { from { opacity: 0; } }
.modal { width: 560px; max-width: calc(100vw - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; overflow-x: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop .26s cubic-bezier(.3,1.3,.5,1); }
.modal.wide { width: 620px; }
.modal.sm { width: 440px; }
.btn.danger { border: none; background: var(--danger); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 82%, #000); color: #fff; transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--danger) 38%, transparent); }
.confmsg { margin: 0; font: 500 14.5px/1.6 'Manrope'; color: var(--text-2); }
.confmsg b { color: var(--text); font-weight: 800; }
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.97); } }
.modal .mh { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .mh .mi { width: 40px; height: 40px; border-radius: 12px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.modal .mh .mi svg { width: 20px; height: 20px; }
.modal .mh h3 { margin: 0; font: 800 17px/1.1 'Manrope'; color: var(--text); }
.modal .mh .msub { font: 600 10px/1 var(--mono); color: var(--muted); margin-top: 5px; }
.modal .mh .x { margin-left: auto; width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; border-radius: 10px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: all .16s; }
.modal .mh .x svg { width: 16px; height: 16px; }
.modal .mh .x:hover { border-color: var(--danger); color: var(--danger); }
.modal .mb { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fg label { display: block; font: 700 11px/1 'Manrope'; color: var(--text-2); margin-bottom: 9px; }
.fg label .req { color: var(--danger); }
.fg input, .fg select { width: 100%; padding: 11px 14px; border: 1.5px solid var(--line-2); background: var(--sunk); border-radius: var(--r-sm); color: var(--text); font: 500 13.5px/1 'Manrope'; outline: none; transition: border-color .18s, box-shadow .18s; }
.fg input:focus, .fg select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--wash); }
.modal .mf { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }

/* device detail */
.dsum { display: flex; align-items: center; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dsum .dic { width: 54px; height: 54px; border-radius: 15px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dsum .dic svg { width: 27px; height: 27px; }
.dsum .dn { font: 800 18px/1.1 'Manrope'; color: var(--text); }
.dsum .did { font: 600 12px/1 var(--mono); color: var(--muted); margin-top: 6px; }
.dsum .dx { margin-left: auto; }
.dsum .x { width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; border-radius: 10px; color: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dsum .x svg { width: 16px; height: 16px; }
.dsum .x:hover { border-color: var(--danger); color: var(--danger); }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; padding: 8px 12px; }
.dcell { padding: 13px 12px; }
.dcell .dk { font: 700 9px/1 'Manrope'; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dcell .dk svg { width: 13px; height: 13px; }
.dcell .dv { font: 700 14px/1 'Manrope'; color: var(--text); margin-top: 9px; }
.dcell .dv.mono { font-family: var(--mono); font-size: 13px; }
.dtele { padding: 6px 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.dtele .dtl { font: 700 9px/1 'Manrope'; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* =====================================================================
   LOGIN — centrato su video
   ===================================================================== */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--bg); }
.lbg { position: absolute; inset: 0; overflow: hidden; background: var(--bg) center/cover no-repeat; background-image: url("login-poster.jpg"); }
.lbg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lbg::after { content: ""; position: absolute; inset: 0; background: var(--veil); }
.ltop { position: absolute; top: 26px; left: 30px; right: 30px; display: flex; align-items: center; justify-content: space-between; z-index: 3; }
.ltop .lm { display: flex; align-items: center; gap: 12px; }
.ltop .lm .brandmark { width: 40px; height: 40px; box-shadow: var(--shadow); }
.ltop .lm b { font: 800 20px/1 'Manrope'; letter-spacing: 1.5px; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.4); }
.ltop .m { width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(255,255,255,.28); background: rgba(0,0,0,.25); color: #fff; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); transition: background .18s; }
.ltop .m svg { width: 19px; height: 19px; }
.ltop .m:hover { background: rgba(0,0,0,.4); }
.lcard { position: relative; z-index: 2; width: 410px; background: color-mix(in srgb, var(--card) 90%, transparent); border: 1px solid color-mix(in srgb, var(--line-2) 70%, transparent); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 40px 42px 34px; backdrop-filter: blur(18px) saturate(1.2); animation: pop .4s cubic-bezier(.3,1.2,.5,1); }
.lcard .lc { display: flex; justify-content: center; margin-bottom: 20px; }
.lcard .lc .brandmark { width: 56px; height: 56px; border-radius: 15px; box-shadow: var(--shadow); }
.lcard h1 { margin: 0; text-align: center; font: 800 26px/1.15 'Manrope'; letter-spacing: -.5px; color: var(--text); }
.lcard .sub { margin: 10px 0 30px; text-align: center; font: 500 14px/1.5 'Manrope'; color: var(--muted); }
.lcard label { display: block; font: 700 11px/1 'Manrope'; color: var(--text-2); margin: 0 0 9px; }
.lcard .inp { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line-2); background: var(--sunk); border-radius: 12px; padding: 0 14px; margin-bottom: 18px; transition: border-color .18s, box-shadow .18s; }
.lcard .inp svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.lcard .inp input { flex: 1; border: none; background: transparent; outline: none; color: var(--text); font: 500 17px/1 'Manrope'; padding: 13px 0; }
.lcard .inp:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--wash); }
.lcard .inp:focus-within svg { color: var(--brand); }
/* Chrome/WebKit autofill: mantiene lo sfondo del tema (niente textbox bianca in dark) */
.lcard .inp input:-webkit-autofill,
.lcard .inp input:-webkit-autofill:hover,
.lcard .inp input:-webkit-autofill:focus,
.lcard .inp input:-webkit-autofill:active,
.fg input:-webkit-autofill, .fg input:-webkit-autofill:hover, .fg input:-webkit-autofill:focus,
.picksearch input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--sunk) inset;
  box-shadow: 0 0 0 1000px var(--sunk) inset;
  caret-color: var(--text);
  border-radius: inherit;
  transition: background-color 9999s ease-in-out 0s;
}
/* font più grande e STABILE (stesso valore anche in stato autofill, così non "salta" al primo click) */
.lcard .inp input, .lcard .inp input:-webkit-autofill { font: 500 17px/1 'Manrope', sans-serif !important; }
.lcard .lbtn { width: 100%; margin-top: 8px; padding: 14px; border: none; border-radius: 12px; background: var(--brand); color: var(--on-brand); font: 700 14px/1 'Manrope'; letter-spacing: .3px; display: flex; align-items: center; justify-content: center; gap: 10px; position: relative; overflow: hidden; transition: background .18s, transform .18s, box-shadow .18s; }
.lcard .lbtn svg { width: 17px; height: 17px; }
.lcard .lerr { display: flex; align-items: center; gap: 8px; font: 600 12.5px/1.35 'Manrope'; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: 10px; padding: 9px 11px; margin-top: 2px; }
.lcard .lerr svg { width: 15px; height: 15px; flex-shrink: 0; }
.lcard .lbtn::after { content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.4), transparent); transform: skewX(-18deg); transition: left .6s; }
.lcard .lbtn:hover { background: var(--brand-2); transform: translateY(-1px); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 40%, transparent); }
.lcard .lbtn:hover::after { left: 130%; }
.lcard .lbtn .sp { width: 17px; height: 17px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.lcard .llang { margin-top: 20px; display: flex; gap: 6px; justify-content: center; }
.lcard .llang span { font: 700 11px/1 var(--mono); letter-spacing: .5px; color: var(--muted); padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.lcard .llang span.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.lcard .lfine { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); text-align: center; font: 500 12px/1.6 'Manrope'; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { *, ::after, ::before { animation-duration: .01ms !important; } }

/* logo originale vettorizzato (trasparente, si fonde col tema) */
.logomark { display: inline-block; background: center/contain no-repeat; background-image: url('logo-mark.png'); }
.logo-sm { width: 34px; height: 34px; }
.logo-lg { width: 54px; height: 54px; }
.logo-top { width: 34px; height: 34px; color: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,.45)); }

/* summary strip (pagine dispositivi, compatto) */
.summary { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 13px 18px; margin-bottom: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); }
.summary span { display: inline-flex; align-items: center; gap: 8px; font: 600 13px/1 'Manrope'; color: var(--muted); }
.summary span b { color: var(--text); font-weight: 800; font-family: var(--mono); font-size: 15px; }
.summary span svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.summary .sq { width: 9px; height: 9px; border-radius: 3px; }

/* map header expand */
.ch .exp { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: all .16s; }
.ch .exp svg { width: 17px; height: 17px; }
.ch .exp:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }

/* mappa a schermo intero */
.mapov { padding: 3vh 3vw; }
.mapfull { width: 100%; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; animation: pop .28s cubic-bezier(.3,1.2,.5,1); }
.mapfull .mfh { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mapfull .mfh h3 { margin: 0; font: 800 18px/1 'Manrope'; color: var(--text); display: flex; align-items: center; gap: 10px; }
.mapfull .mfh h3 svg { width: 20px; height: 20px; color: var(--brand); }
.mapfull .legend { display: flex; gap: 16px; margin-left: 8px; }
.mapfull .legend span { display: inline-flex; align-items: center; gap: 7px; font: 700 12px/1 'Manrope'; color: var(--text-2); }
.mapfull .legend .sq { width: 9px; height: 9px; border-radius: 3px; }
.mapfull .x { margin-left: auto; width: 36px; height: 36px; border: 1px solid var(--line); background: transparent; border-radius: 10px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.mapfull .x svg { width: 17px; height: 17px; }
.mapfull .x:hover { border-color: var(--danger); color: var(--danger); }
.mapbig { flex: 1; position: relative; overflow: hidden; background: linear-gradient(var(--map-line) 1px, transparent 1px), linear-gradient(90deg, var(--map-line) 1px, transparent 1px), var(--map-bg); background-size: 62px 62px, 62px 62px; }
.mapbig .mroad { position: absolute; background: var(--map-road); box-shadow: 0 0 0 1px var(--map-line); }

/* mappa live page + percorsi */
.mapf.big { height: calc(100vh - 214px); min-height: 420px; }
/* Leaflet: contenitore mappa reale */
.livemap { border-radius: 14px; overflow: hidden; }
/* pannello filtri sovrapposto alla mappa */
.card.map { position: relative; }
.mapfilters { position: absolute; top: 12px; inset-inline-start: 12px; z-index: 500; width: 246px; max-width: calc(100% - 78px); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line-2); border-radius: 13px; box-shadow: 0 10px 30px -12px rgba(0,0,0,.45); overflow: hidden; transition: width .16s; }
.mapfilters .mfclose { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 13px; border: none; background: transparent; color: var(--text); font: 800 11px/1 'Manrope'; letter-spacing: .5px; text-transform: uppercase; cursor: pointer; border-bottom: 1px solid var(--line); }
.mapfilters .mfclabel { display: inline-flex; align-items: center; gap: 8px; }
.mapfilters .mfclabel svg { width: 14px; height: 14px; color: var(--brand); }
.mapfilters .mfchev { display: inline-flex; color: var(--muted); transition: transform .18s; }
.mapfilters .mfchev svg { width: 15px; height: 15px; }
.mapfilters { transition: width .34s cubic-bezier(.4,0,.2,1); overflow: hidden; }
.mapfilters .mfclose { white-space: nowrap; }
.mapfilters.collapsed { width: 176px; }
.mapfilters .mfbody-wrap { overflow: hidden; width: 246px; }
.mfbody { transition: max-height .34s cubic-bezier(.4,0,.2,1), opacity .2s ease, padding .34s cubic-bezier(.4,0,.2,1); }
.mapfilters.collapsed .mfbody { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }
.mapfilters.collapsed .mfclose { border-bottom: none; }
.mapfilters.collapsed .mfchev { transform: rotate(-90deg); }
.mfbody { padding: 12px 13px; display: flex; flex-direction: column; gap: 13px; max-height: 60vh; overflow-y: auto; }
.mfgrp { display: flex; flex-direction: column; gap: 8px; }
.mfh { font: 700 10px/1 'Manrope'; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.mfchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mfchip { display: inline-flex; align-items: center; gap: 5px; font: 700 11px/1 'Manrope'; color: var(--muted); background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; cursor: pointer; transition: all .13s; opacity: .55; }
.mfchip svg { width: 12px; height: 12px; }
.mfchip .sq { width: 8px; height: 8px; border-radius: 2px; }
.mfchip:hover { color: var(--text); border-color: var(--line-2); }
.mfchip.on { opacity: 1; color: var(--text); background: var(--wash); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.mfact { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 2px; }
.mfcount { font: 700 10.5px/1 var(--mono); color: var(--muted); }
/* selettore livelli mappa (segmentato, in alto a destra) */
.maplayers { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 500; display: flex; gap: 3px; padding: 4px; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line-2); border-radius: 11px; box-shadow: 0 10px 30px -12px rgba(0,0,0,.45); }
.mlbtn { display: inline-flex; align-items: center; gap: 6px; font: 700 11.5px/1 'Manrope'; color: var(--muted); background: transparent; border: none; border-radius: 8px; padding: 7px 11px; cursor: pointer; transition: all .13s; }
.mlbtn svg { width: 14px; height: 14px; }
.mlbtn span { white-space: nowrap; }
.mlbtn:hover { color: var(--text); background: var(--wash); }
.mlbtn.on { color: var(--on-brand); background: var(--brand); }
@media (max-width: 680px) { .mlbtn span { display: none; } .mlbtn { padding: 8px; } }
/* percorsi: contenitore mappa posizionato per i controlli flottanti (tipo mappa + puntini/direzione) */
.rmapwrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
.routetools { position: absolute; top: 12px; inset-inline-start: 12px; z-index: 1200; display: flex; gap: 3px; padding: 4px; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line-2); border-radius: 11px; box-shadow: 0 10px 30px -12px rgba(0,0,0,.45); }
/* controlli in cima-sinistra della mappa: il tooltip si apre verso il BASSO e ancorato a SINISTRA
   (cresce verso destra dentro la mappa), altrimenti finisce clippato sopra l'header o oltre il bordo sinistro */
.routetools [data-tip]::after { bottom: auto; top: calc(100% + 8px); left: 0; right: auto; transform: translateX(0) translateY(-4px); }
.routetools [data-tip]:hover::after { transform: translateX(0) translateY(0); }
/* verso di marcia: ant-path (tratteggio che scorre lungo la traccia) + freccia direzione */
.rt-antpath { stroke-dasharray: 8 12; animation: rtflow 1s linear infinite; }
@keyframes rtflow { to { stroke-dashoffset: -20; } }
@media (prefers-reduced-motion: reduce) { .rt-antpath { animation: none; } }
.rtarrow { background: none; border: 0; }
.livemap.leaflet-container { background: var(--map-bg); font: inherit; }
.leaflet-container a { color: var(--brand); }
.lpin { background: none !important; border: none !important; }
.lpinb { position: relative; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50% 50% 50% 0; background: var(--pc); box-shadow: 0 3px 7px rgba(6,12,22,.45); border: 2.5px solid #fff; transform: rotate(-45deg); transition: transform .15s; }
.lpinb svg { width: 14px; height: 14px; color: #fff; transform: rotate(45deg); }
.lpin.sel { z-index: 1000 !important; }
/* quando un popup è aperto, nascondi il tooltip di hover del pin (niente sovrapposizione) */
.leaflet-map-pane:has(.leaflet-popup) .leaflet-tooltip { display: none !important; }
.lpin.sel .lpinb { transform: rotate(-45deg) scale(1.22); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 40%, transparent), 0 3px 8px rgba(6,12,22,.5); z-index: 5; }
[data-theme="dark"] .lpinb { border-color: #1a2536; }
/* popup dispositivo sulla mappa */
.mpopwrap .leaflet-popup-content-wrapper { background: var(--card); color: var(--text); border: 1px solid var(--line-2); border-radius: 13px; box-shadow: 0 14px 40px -14px rgba(0,0,0,.5); }
.mpopwrap .leaflet-popup-content { margin: 16px 18px; }
.mpopwrap .leaflet-popup-tip { background: var(--card); border: 1px solid var(--line-2); }
.mpopwrap a.leaflet-popup-close-button { color: var(--muted); font-size: 20px; padding: 8px 9px 0 0; }
.mpopwrap a.leaflet-popup-close-button:hover { color: var(--danger); background: transparent; }
.mpop { display: flex; flex-direction: column; gap: 14px; font-family: 'Manrope'; }
.mpoph { display: flex; align-items: center; gap: 12px; }
.mpoph .mpi { width: 40px; height: 40px; border-radius: 12px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mpoph .mpi svg { width: 20px; height: 20px; }
.mpn { font: 800 15.5px/1.2 'Manrope'; color: var(--text); }
.mpid { font: 600 11px/1 var(--mono); color: var(--muted); margin-top: 5px; }
.mpst { display: flex; }
.mpgrid { display: flex; flex-direction: column; gap: 9px; border-top: 1px solid var(--line); padding-top: 13px; }
.mprow { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.mpk { font: 600 12.5px/1.2 'Manrope'; color: var(--muted); }
.mpv { font: 700 13px/1.2 var(--mono); color: var(--text-2); }
.mpbtn { width: 100%; justify-content: center; margin-top: 4px; padding: 10px 14px; }
/* controlli Leaflet in tema scuro */
[data-theme="dark"] .leaflet-bar a, [data-theme="dark"] .leaflet-control-zoom a { background: var(--card); color: var(--text); border-bottom-color: var(--line); }
[data-theme="dark"] .leaflet-bar a:hover, [data-theme="dark"] .leaflet-control-zoom a:hover { background: var(--wash); color: var(--brand); }
[data-theme="dark"] .leaflet-bar { border-color: var(--line-2); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
/* cluster marker (raggruppamento) */
.marker-cluster { background: transparent; }
.marker-cluster div { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin: 0; border-radius: 50%; background: var(--brand); color: var(--on-brand); border: 3px solid color-mix(in srgb, var(--brand) 30%, #fff); box-shadow: 0 3px 10px -2px color-mix(in srgb, var(--brand) 60%, transparent); }
.marker-cluster span { font: 800 13px/1 'Manrope'; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: transparent; }
.marker-cluster-medium div { width: 44px; height: 44px; background: var(--brand-2, var(--brand)); }
.marker-cluster-large div { width: 50px; height: 50px; background: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, #fff); box-shadow: 0 3px 10px -2px color-mix(in srgb, var(--danger) 60%, transparent); }
[data-theme="dark"] .marker-cluster div { border-color: color-mix(in srgb, var(--brand) 45%, #000); }
.mapf.big2 { height: calc(100vh - 316px); min-height: 340px; }
.maplegend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.maplegend span { display: inline-flex; align-items: center; gap: 7px; font: 700 12px/1 'Manrope'; color: var(--text-2); }
.maplegend .sq { width: 9px; height: 9px; border-radius: 3px; }
.routeline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wp { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--card); border: 2px solid var(--brand); transform: translate(-50%,-50%); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.trip { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); transition: background .15s; }
.trip:last-child { border-bottom: none; }
.trip:hover { background: var(--card-2); }
.trip .tic { width: 34px; height: 34px; border-radius: 10px; background: var(--wash); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.trip .tic svg { width: 16px; height: 16px; }
.trip .th { font: 700 13px/1 var(--mono); color: var(--text); }
.trip .ts { font: 600 11px/1.3 'Manrope'; color: var(--muted); margin-top: 4px; }
.trip .tk { margin-left: auto; text-align: right; }
.trip .tk b { font: 800 14px/1 var(--mono); color: var(--text); }
.trip .tk span { display: block; font: 600 10px/1 'Manrope'; color: var(--muted); margin-top: 4px; }
.tripdate { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.daterange { position: relative; }
.drtrigger { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 13px; background: var(--sunk); border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; transition: border-color .16s, background .16s; }
.drtrigger:hover { border-color: var(--brand); background: var(--wash); }
.daterange.open .drtrigger { border-color: var(--brand); background: var(--wash); }
.drtrigger .dricon { display: inline-flex; color: var(--brand); flex-shrink: 0; }
.drtrigger .dricon svg { width: 17px; height: 17px; }
.drvals { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.drseg { display: flex; flex-direction: column; gap: 3px; font: 700 13px/1 'Manrope'; color: var(--text); }
.drseg em { font: 700 9px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--faint); font-style: normal; }
.drdash { width: 12px; height: 2px; border-radius: 2px; background: var(--line-2); flex-shrink: 0; }
.drchev { margin-inline-start: auto; display: inline-flex; color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.drchev svg { width: 15px; height: 15px; }
.daterange.open .drchev { transform: rotate(180deg); }
.calpop { position: absolute; top: calc(100% + 8px); inset-inline-start: 0; z-index: 600; width: 300px; max-width: 100%; padding: 14px; background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 18px 44px -14px rgba(0,0,0,.5); animation: calin .16s ease; }
@keyframes calin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.calhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.caltitle { font: 800 14px/1 'Manrope'; color: var(--text); text-transform: capitalize; }
.calnav { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--sunk); border-radius: 9px; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: color .15s, border-color .15s; }
.calnav:hover { color: var(--brand); border-color: var(--brand); }
.calnav svg { width: 15px; height: 15px; }
.calnav[data-action="cal-prev"] svg { transform: rotate(90deg); }
.calnav[data-action="cal-next"] svg { transform: rotate(-90deg); }
.calwds { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.calwd { text-align: center; font: 700 10px/1 var(--mono); text-transform: uppercase; color: var(--faint); padding: 4px 0; }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calday { aspect-ratio: 1; border: none; background: transparent; border-radius: 9px; font: 600 12.5px/1 'Manrope'; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .13s, color .13s; }
.calday.empty { pointer-events: none; }
.calday:not(.empty):hover { background: var(--wash); }
.calday.inrange { background: color-mix(in srgb, var(--brand) 15%, transparent); border-radius: 0; color: var(--brand); }
.calday.sel { background: var(--brand); color: var(--on-brand); font-weight: 800; }
.calday.sel.start { border-radius: 9px 0 0 9px; }
.calday.sel.end { border-radius: 0 9px 9px 0; }
.calday.sel.start.end { border-radius: 9px; }
.calfoot { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); font: 600 11.5px/1.3 'Manrope'; color: var(--muted); text-align: center; }
.trip .th .trday { font: 700 10px/1 var(--mono); color: var(--muted); background: var(--wash); padding: 3px 6px; border-radius: 5px; margin-inline-start: 6px; }
.tripempty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 20px; color: var(--muted); font: 600 13px/1.4 'Manrope'; text-align: center; }
.tripempty svg { width: 26px; height: 26px; opacity: .5; }
[dir="rtl"] .calday.sel.start { border-radius: 0 9px 9px 0; }
[dir="rtl"] .calday.sel.end { border-radius: 9px 0 0 9px; }
[dir="rtl"] .calnav[data-action="cal-prev"] svg { transform: rotate(-90deg); }
[dir="rtl"] .calnav[data-action="cal-next"] svg { transform: rotate(90deg); }

/* ricerca laterale mappa / percorsi (scala a 1000+) */
.mapwrap { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 16px; }
.percwrap { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; align-items: start; }
.maprail { display: flex; flex-direction: column; overflow: hidden; max-height: calc(100vh - 214px); }
/* Percorsi su desktop/2K: riempi tutta la larghezza della sezione (niente cap 1860) e
   allinea l'altezza della mappa a quella delle colonne laterali (la mappa riempie sotto l'header). */
@media (min-width: 981px) {
  .perc-head, .percwrap { max-width: none; }
  .percwrap .duo .card.map { display: flex; flex-direction: column; height: calc(100vh - 214px); }
  .percwrap .duo .card.map .rmapwrap { flex: 1 1 auto; min-height: 0; }
  .percwrap .duo .card.map .rmapwrap .mapf.big { flex: 1 1 auto; height: auto; min-height: 0; }
}
.railsearch { display: flex; align-items: center; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.railsearch svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.railsearch input { border: none; background: transparent; outline: none; color: var(--text); font: 500 13px/1 'Manrope'; width: 100%; }
.railsearch input::placeholder { color: var(--muted); }
.raillist { position: relative; overflow-y: auto; }
.rail-ind { position: absolute; left: 0; top: 0; width: 3px; height: 0; background: var(--brand); border-radius: 0 3px 3px 0; transform: translateY(0); opacity: 0; pointer-events: none; z-index: 2; transition: transform .3s cubic-bezier(.5,.05,.15,1), height .3s cubic-bezier(.5,.05,.15,1); }
.rail-ind.ready { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .rail-ind { transition: none; } }
.railitem { display: flex; align-items: center; gap: 10px; padding: 11px 15px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .14s; }
.railitem:last-child { border-bottom: none; }
.railitem:hover { background: var(--card-2); }
.railitem.on { background: var(--wash); }
.railitem .ri { width: 30px; height: 30px; border-radius: 9px; background: var(--sunk); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.railitem .ri svg { width: 16px; height: 16px; }
.railitem .rn { font: 700 12.5px/1 'Manrope'; color: var(--text); }
.railitem .rid { font: 600 10px/1 var(--mono); color: var(--muted); margin-top: 4px; }
.railitem .rdot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pin.dim { opacity: .2; filter: grayscale(.5); }
.unitbtn { display: inline-flex; align-items: center; gap: 6px; font: 700 12px/1 var(--mono); color: var(--brand); background: var(--wash); border: 1px solid transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; transition: background .14s, border-color .14s; }
.unitbtn:hover { background: var(--sunk); border-color: var(--brand); }
.unitbtn svg { width: 13px; height: 13px; }
.grpmb { display: flex; flex-direction: column; gap: 18px; max-height: 60vh; overflow-y: auto; }
.grptype { display: flex; flex-direction: column; gap: 6px; }
.grptypeh { display: flex; align-items: center; gap: 8px; font: 700 11px/1 'Manrope'; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 0 2px 2px; }
.grptypeh svg { width: 15px; height: 15px; color: var(--brand); }
.grptypeh .cnt { margin-left: auto; font: 700 10px/1 var(--mono); color: var(--muted); background: var(--sunk); padding: 4px 7px; border-radius: 20px; }
.grprow { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: background .14s, border-color .14s; }
.grprow:hover { background: var(--card-2); border-color: var(--line-2); }
.grprow .ri { width: 32px; height: 32px; border-radius: 9px; background: var(--sunk); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.grprow .ri svg { width: 16px; height: 16px; }
.grprow .rn { font: 700 13px/1.2 'Manrope'; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grprow .rid { font: 600 10.5px/1 var(--mono); color: var(--muted); margin-top: 4px; }

/* =====================================================================
   RESPONSIVE — da 8K a smartphone
   ===================================================================== */

/* --- ≤1180: sidebar collassa a rail di sole icone --- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 76px 1fr; }
  .side .brand { justify-content: center; padding: 18px 0; }
  .side .brand > div { display: none; }
  .side .brand .brandmark, .side .brand .logomark { width: 34px; height: 34px; }
  .side nav { padding: 12px 12px; }
  .side .sec { display: none; }
  .nav { justify-content: center; gap: 0; font-size: 0; padding: 12px 0; }
  .nav .ni svg { width: 21px; height: 21px; }
  .nav .cnt { display: none; }
  .side .sfoot { padding: 12px 10px; align-items: center; }
  .langsw { flex-wrap: wrap; gap: 4px; width: 100%; }
  .langsw button { flex: 1 1 40%; padding: 7px 0; }
  .userchip { justify-content: center; }
  .userchip > div, .userchip .ucgo { display: none; }
  .switch { padding: 9px; justify-content: center; }
  .switch .sl { gap: 0; font-size: 0; }
  .btn-out { font-size: 0; gap: 0; padding: 11px 0; }
  .view > * { max-width: none; }
}

/* --- ≤980: le griglie a due colonne si impilano --- */
@media (max-width: 980px) {
  .duo, .mapwrap { grid-template-columns: 1fr; }
  .percwrap { grid-template-columns: 1fr; }
  .maprail { max-height: 420px; }
  #tripscard { max-height: 60vh; }
  .duo .map .mapf, .mapwrap .map .mapf.big { min-height: 340px; }
  .top { padding: 14px 18px; gap: 12px; }
  .search { width: 190px; }
  .search:focus-within { width: 220px; }
}

/* --- ≤760: tablet stretto / phone landscape --- */
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .view { padding: 18px 16px 34px; }
  .vhead h2 { font-size: 19px; }
  .top .tt p { display: none; }
  .top .tt h1 { font-size: 17px; }
  .search { width: 44px; padding: 10px; }
  .search input { display: none; }
  .search:focus-within { width: 44px; }
  .grid { grid-template-columns: 1fr; }
  .frow, .dgrid { grid-template-columns: 1fr; }
}

/* --- ≤460: phone --- */
@media (max-width: 460px) {
  .app { grid-template-columns: 62px 1fr; }
  .stats { grid-template-columns: 1fr; }
  .view { padding: 14px 12px 28px; }
  .vhead { gap: 10px; }
  .top { padding: 12px 12px; }
  .modal { width: calc(100vw - 24px); }
}

/* --- ultra-wide: il contenuto usa tutto ma resta leggibile e centrato --- */
@media (min-width: 2100px) {
  .view { padding: 34px 40px 56px; }
}

/* =====================================================================
   RTL — arabo
   ===================================================================== */
[dir="rtl"] .nav-ind { left: auto; right: 0; border-radius: 4px 0 0 4px; }
[dir="rtl"] .rail-ind { left: auto; right: 0; border-radius: 3px 0 0 3px; }
[dir="rtl"] .search { margin-left: 0; margin-right: auto; }
[dir="rtl"] .stat .sd { right: auto; left: 20px; }
[dir="rtl"] .tbl td:first-child { text-align: right; }
[dir="rtl"] .tbl th, [dir="rtl"] .tbl td { text-align: center; }
[dir="rtl"] .card .ch .cnt, [dir="rtl"] .nav .cnt { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mzoom { left: auto; right: 12px; }
[dir="rtl"] .mtag { right: auto; left: 12px; }
[dir="rtl"] .lcard .lbtn svg { transform: scaleX(-1); }
@media (max-width: 1180px) {
}

/* ===================== ECOALL ===================== */
.eco-sub { font: 600 12px/1 var(--mono); color: var(--muted); margin-top: 6px; letter-spacing: .3px; }
.eco-tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.eco-tabs-ind { position: absolute; bottom: -1px; left: 0; height: 2.5px; background: var(--brand); border-radius: 3px 3px 0 0; transition: transform .3s cubic-bezier(.5,.05,.15,1), width .3s cubic-bezier(.5,.05,.15,1); opacity: 0; }
.eco-tab { position: relative; flex-shrink: 0; padding: 12px 16px; background: none; border: none; font: 700 13px/1 'Manrope'; color: var(--muted); cursor: pointer; transition: color .16s; }
.eco-tab:hover { color: var(--text-2); }
.eco-tab.on { color: var(--brand); }
@media (prefers-reduced-motion: reduce) { .eco-tabs-ind { transition: none; } }
.eco-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.eco-search { position: relative; flex: 1; min-width: 200px; display: flex; align-items: center; }
.eco-search svg { position: absolute; inset-inline-start: 12px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.eco-search input { width: 100%; padding: 10px 12px 10px 36px; font: 600 13px/1 'Manrope'; color: var(--text); background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-sm); transition: border-color .16s; }
[dir="rtl"] .eco-search input { padding: 10px 36px 10px 12px; }
.eco-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--wash); }
.eco-pills { display: flex; gap: 6px; }
.eco-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; font: 700 12px/1 'Manrope'; color: var(--text-2); background: var(--card); border: 1px solid var(--line-2); border-radius: 20px; cursor: pointer; transition: all .16s; }
.eco-pill:hover { border-color: var(--brand); }
.eco-pill.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.eco-pill--on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.eco-pill.active .eco-pill-count { color: var(--on-brand); }
.eco-pill-count { font: 800 11px/1 var(--mono); color: var(--muted); }
.eco-refresh { margin-inline-start: auto; }
.eco-ibtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--line-2); background: var(--card); border-radius: 9px; color: var(--text-2); cursor: pointer; transition: all .15s; }
.eco-ibtn:hover { color: var(--brand); border-color: var(--brand); background: var(--wash); }
.eco-ibtn svg { width: 16px; height: 16px; }
.eco-ibtn--danger:hover { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.eco-refresh.is-refreshing svg { animation: eco-spin .7s linear; }
@keyframes eco-spin { to { transform: rotate(360deg); } }
.eco-tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); }
.eco-tbl { width: 100%; border-collapse: collapse; min-width: 900px; }
.eco-tbl thead th { text-align: start; font: 700 10.5px/1 var(--mono); letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 13px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.eco-tbl tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line); font: 600 13px/1.3 'Manrope'; color: var(--text-2); vertical-align: middle; }
.eco-tbl tbody tr:last-child td { border-bottom: none; }
.eco-row.is-offline { opacity: .68; }
.eco-nowrap { white-space: nowrap; }
.eco-muted { color: var(--muted); }
.eco-c-status { width: 54px; }
.eco-state { display: inline-flex; align-items: center; gap: 6px; }
.eco-led { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.eco-led--on { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
.eco-led--off { background: var(--offline); }
.eco-cfg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.eco-dev { display: flex; flex-direction: column; gap: 3px; }
.eco-plate { font: 700 12px/1 var(--mono); color: var(--text); background: var(--sunk); padding: 3px 7px; border-radius: 6px; display: inline-block; width: fit-content; }
.eco-name { font: 700 13px/1.2 'Manrope'; color: var(--text); }
.eco-co { font: 600 11px/1 'Manrope'; color: var(--muted); }
.eco-fw { font: 700 12px/1 var(--mono); color: var(--text-2); }
.eco-prof { display: inline-flex; align-items: center; gap: 6px; }
.eco-pv { font: 800 11px/1 var(--mono); color: var(--brand); background: var(--wash); padding: 3px 7px; border-radius: 6px; }
.eco-hash { font: 600 11px/1 var(--mono); color: var(--muted); }
.eco-chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.eco-chip { display: inline-flex; align-items: center; gap: 5px; font: 700 10.5px/1 var(--mono); padding: 4px 8px; border-radius: 20px; border: 1px solid var(--line-2); color: var(--text-2); }
.eco-chip-led { width: 6px; height: 6px; border-radius: 50%; }
.eco-chip--ok .eco-chip-led { background: var(--success); }
.eco-chip--off { opacity: .6; }
.eco-chip--off .eco-chip-led { background: var(--offline); }
.eco-chip--fail { border-color: var(--danger); color: var(--danger); }
.eco-chip--fail .eco-chip-led { background: var(--danger); }
.eco-din { display: inline-flex; gap: 3px; }
.eco-tick { width: 7px; height: 20px; border-radius: 3px; background: var(--tick); }
.eco-tick--idle { background: var(--ecoall-role-none); opacity: .5; }
.eco-pending { font: 700 11px/1 var(--mono); color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); padding: 4px 8px; border-radius: 20px; white-space: nowrap; }
.eco-c-actions { width: 1%; }
.eco-actions { display: flex; gap: 6px; }
.eco-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 20px; text-align: center; }
.eco-empty-ic { display: inline-flex; color: var(--muted); opacity: .5; }
.eco-empty-ic svg { width: 40px; height: 40px; }
.eco-empty-t { font: 800 16px/1 'Manrope'; color: var(--text); }
.eco-empty-x { font: 600 13px/1.5 'Manrope'; color: var(--muted); max-width: 380px; }
@media (max-width: 900px) { .eco-c-fw, .eco-c-profile, .eco-c-relays { display: none; } .eco-tbl { min-width: 0; } }
/* config tab */
.eco-cfg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.eco-cfg-head h3 { margin: 0; font: 800 17px/1 'Manrope'; color: var(--text); }
.eco-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.eco-tpl { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color .16s, box-shadow .16s; }
.eco-tpl:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.eco-tpl-top { display: flex; align-items: center; gap: 11px; }
.eco-tpl-ic { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 10px; background: var(--wash); color: var(--brand); }
.eco-tpl-ic svg { width: 20px; height: 20px; }
.eco-tpl-name { font: 800 14px/1.2 'Manrope'; color: var(--text); }
.eco-tpl-co { font: 600 11px/1 var(--mono); color: var(--muted); margin-top: 3px; }
.eco-tpl-desc { font: 600 12.5px/1.5 'Manrope'; color: var(--text-2); flex: 1; }
.eco-tpl-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 700 10.5px/1 var(--mono); color: var(--muted); border-top: 1px solid var(--line); padding-top: 11px; }
.eco-tpl-app { color: var(--brand); }
/* bulk tab */
.eco-bulk { max-width: 640px; }
.eco-bulk h3 { margin: 0 0 18px; font: 800 17px/1 'Manrope'; color: var(--text); }
.eco-bulk-step { margin-bottom: 20px; }
.eco-bulk-lbl { display: block; font: 700 11px/1 var(--mono); letter-spacing: .5px; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.eco-select { width: 100%; padding: 11px 12px; font: 700 13px/1 'Manrope'; color: var(--text); background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; }
.eco-select:focus { outline: none; border-color: var(--brand); }
[data-theme="dark"] .eco-select { color-scheme: dark; }
.eco-bulk-list { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px; max-height: 280px; overflow-y: auto; }
.eco-bulk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; transition: background .13s; }
.eco-bulk-item:hover { background: var(--wash); }
.eco-bulk-cb { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.eco-bulk-foot { margin-top: 8px; }
/* command / profile modal */
.eco-modal-b { display: flex; flex-direction: column; gap: 6px; max-height: 68vh; overflow-y: auto; }
.eco-statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 8px; }
.eco-stat { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card-2); }
.eco-stat-ic { display: inline-flex; color: var(--brand); }
.eco-stat-ic svg { width: 18px; height: 18px; }
.eco-stat-k { font: 700 9.5px/1 var(--mono); letter-spacing: .5px; text-transform: uppercase; color: var(--faint); }
.eco-stat-v { font: 800 14px/1.2 'Manrope'; color: var(--text); margin-top: 4px; }
.eco-sec-h { font: 800 11px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 16px 0 10px; }
.eco-relays { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.eco-relay { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px; background: var(--card-2); }
.eco-relay--prot { opacity: .82; }
.eco-relay-h { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
.eco-relay-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--ecoall-role-none); flex-shrink: 0; }
.eco-relay-ch { font: 800 11px/1 var(--mono); color: var(--text); }
.eco-relay-role { font: 600 11px/1 'Manrope'; color: var(--muted); margin-inline-start: auto; }
.eco-relay-btns { display: flex; gap: 5px; }
.eco-rb { flex: 1; padding: 7px 4px; font: 700 10.5px/1 var(--mono); color: var(--text-2); background: var(--card); border: 1px solid var(--line-2); border-radius: 7px; cursor: pointer; transition: all .14s; }
.eco-rb:hover { border-color: var(--brand); color: var(--brand); }
.eco-rb--on:hover { border-color: var(--success); color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); }
.eco-rb--off:hover { border-color: var(--offline); color: var(--text-2); }
.eco-relay-prot { font: 600 11px/1.4 'Manrope'; color: var(--muted); font-style: italic; }
.eco-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.eco-qbtn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; font: 700 12px/1 'Manrope'; color: var(--text-2); background: var(--card); border: 1px solid var(--line-2); border-radius: 9px; cursor: pointer; transition: all .15s; }
.eco-qbtn:hover { border-color: var(--brand); color: var(--brand); background: var(--wash); }
.eco-qbtn svg { width: 15px; height: 15px; }
.eco-status { }
.eco-prob, .eco-ok { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-radius: var(--r-sm); font: 700 13px/1.3 'Manrope'; }
.eco-prob { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.eco-ok { color: var(--success); background: color-mix(in srgb, var(--success) 9%, transparent); }
.eco-prob svg, .eco-ok svg { width: 17px; height: 17px; flex-shrink: 0; }
.eco-rolelist { display: flex; flex-direction: column; gap: 4px; }
.eco-rolerow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card-2); }
.eco-role-lbl { font: 700 13px/1 'Manrope'; color: var(--text); }
.eco-sev { display: inline-block; font: 700 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .5px; padding: 4px 9px; border-radius: 20px; }
.eco-sev--info { color: var(--info); background: color-mix(in srgb, var(--info) 13%, transparent); }
.eco-sev--warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }
.eco-sev--critical { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
/* toast */
.eco-toast-host { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.eco-toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--card); border: 1px solid var(--line-2); border-inline-start: 3px solid var(--brand); border-radius: var(--r-sm); box-shadow: var(--shadow); font: 700 13px/1.3 'Manrope'; color: var(--text); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; max-width: 340px; }
.eco-toast.show { opacity: 1; transform: translateY(0); }
.eco-toast svg { width: 16px; height: 16px; color: var(--brand); flex-shrink: 0; }
[dir="rtl"] .eco-toast { transform: translateY(10px); }

/* ===== EcoALL editor (full page + canvas) ===== */
.ecoall-editor { padding-bottom: 90px; }
.ee-eyebrow { font: 800 10px/1 var(--mono); letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); }
.ee-breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.ee-crumb-root { font: 700 13px/1 'Manrope'; color: var(--brand); background: none; border: none; cursor: pointer; padding: 0; }
.ee-crumb-root:hover { text-decoration: underline; }
.ee-crumb-sep { display: inline-flex; color: var(--faint); }
.ee-crumb-sep svg { width: 15px; height: 15px; }
[dir="rtl"] .ee-crumb-sep svg { transform: scaleX(-1); }
.ee-crumb-current { font: 700 13px/1 'Manrope'; color: var(--text-2); }
.ee-hero { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.ee-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; }
.ee-hero-top:not(:last-child) { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.ee-hero-id { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; min-width: 0; flex: 1 1 auto; }
.ee-hero-name { margin: 0; font: 800 20px/1.1 'Manrope'; color: var(--text); }
.ee-hero-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ee-pill { display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 'Manrope'; padding: 5px 10px; border-radius: 20px; border: 1px solid var(--line-2); color: var(--text-2); }
.ee-pill-led { width: 7px; height: 7px; border-radius: 50%; background: var(--offline); }
.ee-pill.is-online { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.ee-pill.is-online .ee-pill-led { background: var(--success); }
.ee-plate { font: 700 11px/1 var(--mono); color: var(--text); background: var(--sunk); padding: 5px 9px; border-radius: 6px; }
.ee-plate--soft { color: var(--brand); background: var(--wash); }
.ee-tpl { display: flex; flex-direction: column; gap: 6px; min-width: 190px; flex: 0 0 auto; margin-inline-start: auto; }
.ee-hero-viz { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 16px; align-items: start; }
.ee-viz-slot { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ee-viz-slot-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.ee-flow-expand { display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 'Manrope'; color: var(--brand); background: var(--wash); border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer; transition: border-color .15s; }
.ee-flow-expand:hover { border-color: var(--brand); }
.ee-flow-expand svg { width: 14px; height: 14px; }
.ee-board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
.ee-ch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; background: var(--card); border: 1px solid var(--line-2); border-radius: 9px; cursor: pointer; transition: all .14s; }
.ee-ch:hover { border-color: var(--brand); }
.ee-ch.is-sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--wash); }
.ee-ch-top { width: 22px; height: 8px; border-radius: 3px; background: var(--brand); }
.ee-ch.is-idle .ee-ch-top { background: var(--ecoall-role-none); opacity: .5; }
.ee-ch-n { font: 800 10px/1 var(--mono); color: var(--text); }
.ee-ch-role { font: 600 8.5px/1.2 'Manrope'; color: var(--muted); text-align: center; min-height: 20px; }
.ee-flow-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card-2); padding: 8px 4px; }
.ee-flow-svg { display: block; width: 100%; height: auto; min-width: 640px; }
.ee-flow-scroll--big .ee-flow-svg { min-width: 820px; }
.ee-fnode { cursor: pointer; }
.ee-fnode-body { fill: var(--card); stroke: var(--line-2); stroke-width: 1.2; transition: stroke .15s; }
.ee-fnode:hover .ee-fnode-body { stroke: var(--brand); }
.ee-fnode.is-dim { opacity: .5; }
.ee-fnode.is-pa .ee-fnode-body { fill: var(--wash); }
.ee-fn-eyebrow { font: 800 8px/1 var(--mono); letter-spacing: .5px; text-transform: uppercase; fill: var(--faint); }
.ee-fn-title { font: 700 12px/1 'Manrope'; fill: var(--text); }
.ee-fn-sub { font: 600 8px/1 'Manrope'; fill: var(--muted); }
.ee-fn-pill { fill: var(--wash); }
.ee-fn-pilltext { font: 700 9px/1 var(--mono); fill: var(--brand); }
.ee-flink { fill: none; stroke: var(--line-2); stroke-width: 2; }
.ee-flink.is-dim { opacity: .4; stroke-dasharray: 4 4; }
.ee-dot-ok { fill: var(--success); }
.ee-dot-ko { fill: var(--danger); }
.ee-dot-halo { opacity: .16; pointer-events: none; }
.ee-fnode--ctx { cursor: pointer; }
.ee-ctx-body { stroke-dasharray: 5 4; }
.ee-flink.is-dashed { stroke-dasharray: 4 4; opacity: .7; }
.ee-fn-ctxtitle { font: 700 10px/1 'Manrope'; fill: var(--text); }
.ee-fn-ctxsub { font: 600 7.5px/1 'Manrope'; fill: var(--muted); }
.ee-fn-big { font: 800 17px/1 'Manrope'; fill: var(--text); }
.ee-fn-idx { font: 700 8px/1 var(--mono); fill: var(--faint); }
.ee-fn-light { font: 600 7px/1 'Manrope'; fill: var(--text-2); }
.ee-fn-off { font: 600 7px/1 'Manrope'; fill: var(--faint); }
.ee-fn-badge { fill: var(--card); stroke: var(--line-2); stroke-width: 1; }
.ee-fn-badge-t { font: 700 9.5px/1 var(--mono); fill: var(--text); }
.ee-ic-on { color: var(--brand); }
.ee-ic-off { color: var(--muted); opacity: .3; }
.ee-sev-info { color: var(--info); }
.ee-sev-warning { color: var(--warning); }
.ee-sev-critical { color: var(--danger); }
.ee-main { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; }
.ee-rail { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; box-shadow: var(--shadow-sm); }
.ee-rail-eyebrow { padding: 2px 8px 8px; }
.ee-rail-nav { display: flex; flex-direction: column; gap: 3px; }
.ee-rail-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: none; border: none; border-radius: 8px; cursor: pointer; text-align: start; transition: background .14s, box-shadow .14s; }
.ee-rail-item:hover { background: var(--wash); }
.ee-rail-item.is-active { background: var(--wash); box-shadow: inset 3px 0 0 0 var(--brand); }
.ee-nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex-shrink: 0; }
.ee-rail-item.is-active .ee-nav-dot { background: var(--brand); }
.ee-nav-dot.is-err { background: var(--danger); }
.ee-nav-label { font: 700 13px/1 'Manrope'; color: var(--text-2); flex: 1; }
.ee-rail-item.is-active .ee-nav-label { color: var(--brand); }
.ee-nav-count { font: 800 10px/1 var(--mono); color: #fff; background: var(--danger); padding: 3px 6px; border-radius: 20px; }
.ee-content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ee-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 16px; }
.ee-card-head { margin-bottom: 14px; }
.ee-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ee-field:last-child { margin-bottom: 0; }
.ee-label { font: 700 12px/1 'Manrope'; color: var(--text-2); }
.ee-hint { font: 600 11px/1.4 'Manrope'; color: var(--muted); }
.ee-input { width: 100%; padding: 9px 11px; font: 600 13px/1 'Manrope'; color: var(--text); background: var(--card-2); border: 1px solid var(--line-2); border-radius: 8px; }
.ee-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--wash); }
[data-theme="dark"] select.ee-input { color-scheme: dark; }
.ee-textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.ee-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 18px; }
.ee-switch { display: flex; align-items: center; gap: 11px; cursor: pointer; padding: 4px 0; }
.ee-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ee-switch-track { position: relative; width: 40px; height: 22px; border-radius: 12px; background: var(--line-2); flex-shrink: 0; transition: background .18s; }
.ee-switch-thumb { position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.ee-switch input:checked + .ee-switch-track { background: var(--brand); }
.ee-switch input:checked + .ee-switch-track .ee-switch-thumb { transform: translateX(18px); }
[dir="rtl"] .ee-switch input:checked + .ee-switch-track .ee-switch-thumb { transform: translateX(-18px); }
.ee-switch-text { display: flex; flex-direction: column; gap: 2px; }
.ee-switch-label { font: 700 13px/1 'Manrope'; color: var(--text); }
.ee-seg { display: inline-flex; background: var(--sunk); border: 1px solid var(--line-2); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.ee-seg button { padding: 7px 12px; font: 700 12px/1 'Manrope'; color: var(--text-2); background: none; border: none; border-radius: 6px; cursor: pointer; transition: all .14s; }
.ee-seg button:hover { color: var(--text); }
.ee-seg button.ee-seg-on { background: var(--card); color: var(--brand); box-shadow: var(--shadow-sm); }
.ee-checks { display: flex; gap: 8px; flex-wrap: wrap; }
.ee-check { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; font: 700 12px/1 'Manrope'; color: var(--text-2); }
.ee-check input { accent-color: var(--brand); }
.ee-check.is-off { opacity: .45; }
.ee-tof-list, .ee-seq { display: flex; flex-direction: column; gap: 10px; }
.ee-tof { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; }
.ee-tof .ee-field { margin-bottom: 0; }
.ee-seq-row { display: grid; grid-template-columns: 28px 1.4fr 1fr 1fr 34px; gap: 8px; align-items: center; }
.ee-seq-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; background: var(--wash); color: var(--brand); font: 800 11px/1 var(--mono); }
.ee-add-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; font: 700 12px/1 'Manrope'; color: var(--brand); background: var(--wash); border: 1px dashed color-mix(in srgb, var(--brand) 40%, transparent); border-radius: 8px; cursor: pointer; align-self: flex-start; }
.ee-add-btn svg { width: 14px; height: 14px; }
.ee-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--line-2); background: var(--card); border-radius: 7px; color: var(--muted); cursor: pointer; }
.ee-icon-btn--danger:hover { color: var(--danger); border-color: var(--danger); }
.ee-icon-btn svg { width: 15px; height: 15px; }
.ee-relays-tbl { display: flex; flex-direction: column; gap: 10px; }
.ee-relay-edit { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--card-2); transition: border-color .15s, box-shadow .15s; }
.ee-relay-edit.is-sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--wash); }
.ee-relay-edit-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ee-relay-edit-h strong { font: 800 13px/1 var(--mono); color: var(--text); }
.ee-relay-dot { width: 11px; height: 11px; border-radius: 3px; background: var(--ecoall-role-none); }
.ee-relay-edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.ee-relay-edit-grid .ee-field { margin-bottom: 0; }
.ee-empty-mini { font: 600 12.5px/1.5 'Manrope'; color: var(--muted); padding: 10px 0; }
.ee-savebar { position: fixed; bottom: 0; inset-inline-start: var(--side-w, 252px); right: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--card); border-top: 1px solid var(--line-2); box-shadow: 0 -8px 24px -12px rgba(0,0,0,.3); transition: transform .28s cubic-bezier(.5,.05,.15,1); z-index: 40; }
.ee-savebar:not([data-visible="1"]) { transform: translateY(120%); }
.ee-savebar[data-visible="1"] { transform: translateY(0); }
.ee-savebar-dirty { font: 700 13px/1 'Manrope'; color: var(--text-2); }
.ee-savebar-err { display: inline-flex; align-items: center; gap: 8px; font: 700 13px/1 'Manrope'; color: var(--danger); }
.ee-savebar-err svg { width: 16px; height: 16px; }
.ee-savebar-actions { display: flex; gap: 10px; }
/* fullscreen flow */
.ee-flow-fs { position: fixed; inset: 0; z-index: 2500; background: var(--bg); display: flex; flex-direction: column; }
.ee-flow-fs-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); background: var(--card); }
.ee-flow-fs-title { display: flex; align-items: center; gap: 10px; }
.ee-flow-fs-title strong { font: 800 15px/1 'Manrope'; color: var(--text); }
.ee-flow-fs-close { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--line-2); background: var(--card); border-radius: 9px; color: var(--text-2); cursor: pointer; }
.ee-flow-fs-close:hover { color: var(--danger); border-color: var(--danger); }
.ee-flow-fs-close svg { width: 18px; height: 18px; }
.ee-flow-fs-body { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.ee-flow-fs-canvas { padding: 24px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.ee-flow-fs-hint { font: 600 12.5px/1.4 'Manrope'; color: var(--muted); }
.ee-flow-fs-canvas .ee-flow-scroll { flex: 0 0 auto; }
.ee-flow-fs-drawer { border-inline-start: 1px solid var(--line-2); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.ee-flow-fs-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 14px; border-bottom: 1px solid var(--line); }
.ee-fs-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; font: 700 12px/1 'Manrope'; color: var(--text-2); background: var(--sunk); border: 1px solid transparent; border-radius: 20px; cursor: pointer; }
.ee-fs-tab.is-active { color: var(--brand); border-color: var(--brand); background: var(--wash); }
.ee-flow-fs-drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 860px) { .ee-hero-viz { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .ee-main { grid-template-columns: 1fr; } .ee-rail { position: static; } .ee-rail-nav { flex-direction: row; flex-wrap: wrap; } .ee-flow-fs-body { grid-template-columns: 1fr; } .ee-savebar { inset-inline-start: 0; } }

/* selettore target tessera: gruppi / sottogruppi / dispositivi (multi-select) */
.tgtpick { margin-top: 8px; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; contain: paint; isolation: isolate; position: relative; padding: 6px; display: flex; flex-direction: column; gap: 2px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 10px; }
.tgtgrp { display: flex; flex-direction: column; }
.tgth { position: sticky; top: -6px; z-index: 5; font: 800 9px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--faint); margin: 0 -6px; padding: 12px 15px 6px; background: var(--card-2); }
.tgtitem { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; cursor: pointer; transition: background .12s; }
#tess-tgt .tgtitem { display: flex; align-items: center; gap: 10px; }
.tgtitem input { width: auto; flex: 0 0 auto; margin: 0; accent-color: var(--brand); }.tgtitem:hover { background: var(--wash); }
.tgtic { display: inline-flex; align-items: center; justify-content: center; width: 20px; flex-shrink: 0; color: var(--text-2); }
.tgtic svg { width: 16px; height: 16px; }
.tgtlbl { font: 700 12.5px/1.2 'Manrope'; color: var(--text); }
.tgtlbl small { font: 600 11px/1 var(--mono); color: var(--muted); margin-inline-start: 6px; }
.tgtempty { font: 600 12px/1.4 'Manrope'; color: var(--muted); padding: 2px 9px 8px; }

/* ---------- Telemetria CAN veicoli (modal "i") ---------- */
.cinfo-btn { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: auto; font: 700 11.5px/1 'Manrope'; color: var(--brand); background: var(--wash); border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer; transition: background .14s, border-color .14s; }
.cinfo-btn:hover { background: var(--sunk); border-color: var(--brand); }
.cinfo-btn svg { width: 14px; height: 14px; }
/* CAN modal: dimensione FISSA (non cambia aprendo/chiudendo le sezioni) + scrollbar nascosta */
.canmodal { max-width: 620px; height: min(600px, calc(100dvh - 40px)); display: flex; flex-direction: column; overflow: hidden; }
.canbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px; margin: 6px 0; scrollbar-width: none; -ms-overflow-style: none; }
.canbody::-webkit-scrollbar { width: 0; height: 0; }
.canstate { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 20px; color: var(--muted); font: 600 13px/1.4 'Manrope'; text-align: center; }
.canstate.empty svg { width: 22px; height: 22px; opacity: .6; }
.canstate .sp { width: 18px; height: 18px; border: 2.5px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.cantiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cantile { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.cantile .ctl { font: 700 10.5px/1 'Manrope'; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.cantile .ctv { font: 800 20px/1 'Manrope'; color: var(--text); letter-spacing: -.5px; display: flex; align-items: baseline; gap: 4px; }
.cantile .ctv span { font: 700 11px/1 'Manrope'; color: var(--muted); }
.cansecs { display: flex; flex-direction: column; gap: 8px; }
.cansec { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.cansec-h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; background: transparent; border: none; cursor: pointer; color: var(--text); font: 700 13px/1 'Manrope'; }
.cansec-h:hover { background: var(--card-2); }
.cansec-ic { display: inline-flex; color: var(--brand); }
.cansec-ic svg { width: 16px; height: 16px; }
.cansec-t { flex: 1; text-align: start; }
.cansec-n { font: 700 10px/1 var(--mono); color: var(--muted); background: var(--sunk); padding: 4px 8px; border-radius: 20px; }
.cansec-chev { display: inline-flex; color: var(--muted); transition: transform .18s; }
.cansec-chev svg { width: 15px; height: 15px; }
.cansec.open .cansec-chev { transform: rotate(180deg); }
.cansec-body { border-top: 1px solid var(--line); padding: 2px 14px 6px; }
.canrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font: 500 13px/1.3 'Manrope'; }
.canrow:last-child { border-bottom: none; }
.canrow .cank { color: var(--text-2); }
.canrow .cank.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.canrow .canv { color: var(--text); font-weight: 700; text-align: end; }
.canpill { display: inline-block; font: 800 10.5px/1 'Manrope'; letter-spacing: .5px; padding: 5px 9px; border-radius: 20px; }
.canpill.on { color: #fff; background: var(--success); }
.canpill.off { color: var(--muted); background: var(--sunk); border: 1px solid var(--line-2); }
