/* FleetWatch — console di monitoraggio. Scuro per impostazione del sistema, chiaro o scuro a scelta (data-theme). */

:root {
  color-scheme: light;
  --page: #F4F6F8;
  --panel: #FFFFFF;
  --panel-2: #F7F9FA;
  --chip: #EEF2F5;
  --ink: #141A21;
  --ink-2: #39434E;
  --muted: #5A6672;
  --line: #DDE3E9;
  --line-2: #E8ECF0;
  --field-line: #C3CCD5;
  --hover: #F1F4F7;
  --track: #E3E8ED;
  --bar: #2B93BD;
  --accent: #1C7FA6;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDF0F8;
  --accent-soft-ink: #0F5C7C;
  --link: #1A6F93;

  --ok: #1E7A4C;   --ok-dot: #2FA36A;  --ok-bg: rgba(47, 163, 106, .12);
  --warn: #8A5300; --warn-dot: #D98A1A; --warn-bg: rgba(217, 138, 26, .14);
  --crit: #B3302D; --crit-dot: #D9433F; --crit-bg: rgba(217, 67, 63, .11);
  --off: #4E5966;  --off-dot: #6F7A86;  --off-bg: rgba(111, 122, 134, .13);
  --mark-ink: #FFFFFF;

  --font: "IBM Plex Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0F1419;
    --panel: #161C23;
    --panel-2: #131920;
    --chip: #1D252E;
    --ink: #E6EAEE;
    --ink-2: #C9D1D9;
    --muted: #9AA5B1;
    --line: #26303A;
    --line-2: #1F2730;
    --field-line: #2E3843;
    --hover: #1A2129;
    --track: #26303A;
    --bar: #4FB3D9;
    --accent: #4FB3D9;
    --accent-ink: #06222E;
    --accent-soft: #17394A;
    --accent-soft-ink: #A5DDF2;
    --link: #6CC4E6;
    --ok: #7FD8A8;   --ok-dot: #3FBF7F;  --ok-bg: rgba(63, 191, 127, .14);
    --warn: #EDB55C; --warn-dot: #E5A23A; --warn-bg: rgba(229, 162, 58, .15);
    --crit: #F58A87; --crit-dot: #F0605D; --crit-bg: rgba(240, 96, 93, .15);
    --off: #B4BDC7;  --off-dot: #8A95A1;  --off-bg: rgba(138, 149, 161, .16);
    --mark-ink: #0B1014;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0F1419;
  --panel: #161C23;
  --panel-2: #131920;
  --chip: #1D252E;
  --ink: #E6EAEE;
  --ink-2: #C9D1D9;
  --muted: #9AA5B1;
  --line: #26303A;
  --line-2: #1F2730;
  --field-line: #2E3843;
  --hover: #1A2129;
  --track: #26303A;
  --bar: #4FB3D9;
  --accent: #4FB3D9;
  --accent-ink: #06222E;
  --accent-soft: #17394A;
  --accent-soft-ink: #A5DDF2;
  --link: #6CC4E6;
  --ok: #7FD8A8;   --ok-dot: #3FBF7F;  --ok-bg: rgba(63, 191, 127, .14);
  --warn: #EDB55C; --warn-dot: #E5A23A; --warn-bg: rgba(229, 162, 58, .15);
  --crit: #F58A87; --crit-dot: #F0605D; --crit-bg: rgba(240, 96, 93, .15);
  --off: #B4BDC7;  --off-dot: #8A95A1;  --off-bg: rgba(138, 149, 161, .16);
  --mark-ink: #0B1014;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1rem; font-weight: 650; margin-bottom: 10px; }
h3 { font-size: 1rem; font-weight: 650; margin-bottom: 10px; }
h4 { font-size: .9rem; font-weight: 600; }
p { margin: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-size: .95em; }
.dim { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.noscript { padding: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { flex: none; display: block; }
.txt-crit { color: var(--crit); font-weight: 600; }
.txt-warn { color: var(--warn); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#main:focus { outline: none; }

.skip { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 8px 12px; background: var(--panel); border-radius: 8px; }
.skip:focus { top: 8px; }

/* ---------- controlli ---------- */

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--field-line);
  border-radius: 8px;
  padding: .5rem .7rem;
  min-height: 40px;
}
input[type="checkbox"] { min-height: 0; padding: 0; width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--field-line);
  border-radius: 10px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--crit); border-color: var(--crit); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .86rem; border-radius: 8px; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 10px;
  color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); text-decoration: none; }

.link { font: inherit; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; }
.mono.link { font-family: var(--mono); font-size: .95em; font-weight: 600; }
.sub { color: var(--muted); font-size: .8rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ---------- accesso ---------- */

.login { max-width: 24rem; margin: 14vh auto 0; padding: 28px 24px; display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.login .brand { font-size: 1.4rem; margin-bottom: 4px; }
.login label { font-weight: 600; }
.login .btn { justify-self: start; }
.form-err { margin: 0; color: var(--crit); min-height: 1.4em; }

/* ---------- intestazione ---------- */

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-weight: 500;
  padding: 0 14px; min-height: 40px; border-radius: 8px;
}
.tabs a .ico { display: none; }
.tabs a:hover { color: var(--ink); background: var(--hover); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--chip); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bell-n {
  position: absolute; top: 5px; right: 5px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--crit-dot); color: #fff;
  font: 700 10px/17px var(--font); text-align: center;
}

.banner { padding: 10px 24px; background: var(--warn-bg); color: var(--warn); font-weight: 550; border-bottom: 1px solid var(--line); }

main { max-width: 1360px; margin: 0 auto; padding: 24px 24px 72px; }
.page { display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head p { margin-top: 4px; }

.bottom-nav { display: none; }

/* ---------- indicatori di stato (testo + simbolo, mai solo colore) ---------- */

.st-ok { --st: var(--ok); --st-dot: var(--ok-dot); --st-bg: var(--ok-bg); }
.st-warn { --st: var(--warn); --st-dot: var(--warn-dot); --st-bg: var(--warn-bg); }
.st-crit { --st: var(--crit); --st-dot: var(--crit-dot); --st-bg: var(--crit-bg); }
.st-off { --st: var(--off); --st-dot: var(--off-dot); --st-bg: var(--off-bg); }

.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--st-dot, var(--accent)); }
.st-off .dot, .st-off > .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--off-dot); }

.badge, .alert { display: inline-flex; align-items: center; gap: .45rem; }
.badge { color: var(--st); font-weight: 600; white-space: nowrap; }
.badge .mark, .alert .mark, .health .mark, .sev .mark, .callout > .mark {
  display: inline-grid; place-items: center;
  width: 1.05rem; height: 1.05rem; flex: none;
  border-radius: 50%;
  background: var(--st-dot);
  color: var(--mark-ink);
  font: 700 .72rem/1 var(--font);
}
.st-off .mark, .st-off > .mark { background: transparent; box-shadow: inset 0 0 0 2px var(--off-dot); }
.alert { color: var(--st); font-weight: 550; align-items: flex-start; }
.alert .mark { margin-top: .12rem; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--chip); color: var(--st); font-size: .82rem; font-weight: 500; white-space: nowrap;
}

/* ---------- riepilogo ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); min-width: 0; }
.tile-l { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; }
.tile-v { margin-top: 4px; font: 500 1.75rem/1.2 var(--mono); color: var(--st, var(--ink)); }
.tile-x { font-size: 1.1rem; color: var(--muted); }
.tile-f { margin-top: 4px; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.dev-tile.lvl-warn .tile-v { color: var(--warn); }
.dev-tile.lvl-crit .tile-v { color: var(--crit); }
.spark { display: block; width: 100%; height: 36px; margin-top: 6px; }
.spark path { fill: none; stroke: var(--bar); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.dev-tile.lvl-warn .spark path { stroke: var(--warn-dot); }
.dev-tile.lvl-crit .spark path { stroke: var(--crit-dot); }

/* ---------- filtri ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 420px; color: var(--muted); }
.search .ico { position: absolute; left: 13px; pointer-events: none; }
.search-in { width: 100%; height: 42px; padding-left: 38px; border-radius: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 500; color: var(--ink-2); background: var(--panel);
  border: 1px solid var(--field-line); border-radius: 999px;
  min-height: 40px; padding: 0 14px; cursor: pointer;
}
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-soft-ink); border-color: var(--accent); }
.chip-n { font: .78rem var(--mono); opacity: .8; font-variant-numeric: tabular-nums; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--field-line); border-radius: var(--radius); display: grid; gap: 12px; justify-items: center; }

/* ---------- riquadri cliente (home) ---------- */

.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.ccard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.ccard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--st-dot); background: var(--panel-2); }
.ccard-name { margin: 0; font-size: 1.02rem; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health { display: inline-flex; align-items: center; gap: 8px; flex: none; height: 28px; padding: 0 11px; border-radius: 999px; background: var(--st-bg); color: var(--st); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.cdevs { list-style: none; margin: 0; padding: 4px 0; }
.cdev { padding: 7px 14px; }
.cdev + .cdev { border-top: 1px solid var(--line-2); }
.cdev-link { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--ink); font-weight: 550; }
.cdev-link:hover { text-decoration: none; }
.cdev-link:hover .cdev-name { text-decoration: underline; }
.cdev-st { display: inline-grid; place-items: center; width: 1.05rem; flex: none; }
.cdev-st .mark { display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: var(--st-dot); color: var(--mark-ink); font: 700 .72rem/1 var(--font); }
.cdev.st-off .cdev-st .mark { background: transparent; box-shadow: inset 0 0 0 2px var(--off-dot); }
.cdev-ico { display: inline-flex; flex: none; color: var(--muted); }
.cdev-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdev-issues { list-style: none; margin: 4px 0 2px; padding: 0 0 0 calc(1.05rem + 9px + 16px + 9px); display: grid; gap: 2px; }
.cdev-issues li { font-size: .84rem; color: var(--st); overflow-wrap: anywhere; }
.cdev-issues li.dim { color: var(--muted); }
.cdev-issues li.st-warn { --st: var(--warn); }
.cdev-issues li.st-crit { --st: var(--crit); }
.cdev-issues li.st-off { --st: var(--off); }

/* agent da aggiornare: segnalazione neutra, non è un allarme */
.cdev-upd { margin: 4px 0 2px; padding-left: calc(1.05rem + 9px + 16px + 9px); font-size: .84rem; color: var(--ink-2); display: flex; gap: 6px; align-items: baseline; }
.upd-ic { color: var(--accent); font-weight: 700; flex: none; }
.chip-ver { margin-left: auto; color: var(--muted); }
.callout.upd { background: var(--accent-soft); border-color: var(--accent); }
.callout.upd strong { color: var(--accent-soft-ink); }
.callout.upd p { margin: 0; }
.ver-label { display: block; margin: 14px 0 6px; font-weight: 600; }
#ver-dlg input { width: 100%; }

.meter { display: inline-flex; flex-direction: column; gap: 5px; white-space: nowrap; min-width: 0; }
.meter-num { font: .9rem var(--mono); font-variant-numeric: tabular-nums; }
.meter-track { width: 100%; max-width: 80px; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--bar); }
.meter.warn .meter-fill { background: var(--warn-dot); }
.meter.crit .meter-fill { background: var(--crit-dot); }
.meter.warn .meter-num { color: var(--warn); font-weight: 600; }
.meter.crit .meter-num { color: var(--crit); font-weight: 600; }
.tbl .meter { flex-direction: row; align-items: center; gap: 8px; }
.tbl .meter-track { width: 64px; height: 6px; }

/* ---------- allarmi ---------- */

.seg { display: inline-flex; border: 1px solid var(--field-line); border-radius: 8px; overflow: hidden; }
.seg-btn { font: inherit; font-size: .85rem; color: var(--ink-2); background: var(--panel); border: 0; padding: .3rem .75rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--field-line); }
.seg-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-soft-ink); }
.seg-lg .seg-btn { min-height: 40px; padding: 0 16px; font-size: .92rem; font-weight: 500; }

.alarms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.alarm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.sev { display: inline-flex; align-items: center; gap: 8px; width: 7.2rem; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--st-bg); color: var(--st); font-size: .8rem; font-weight: 600; flex: none; }
.alarm-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.alarm-msg { font-weight: 600; overflow-wrap: anywhere; }
.alarm-sub { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.alarm-when { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: .85rem; min-width: 9rem; text-align: right; }
.alarm-acts { display: flex; gap: 8px; }

/* ---------- pagina dispositivo ---------- */

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.crumbs [aria-current] { color: var(--ink-2); }
.dev-head { display: flex; align-items: center; gap: 16px; min-width: 0; }
.dev-icon { flex: none; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-soft-ink); }
.dev-title { min-width: 0; }
.dev-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dev-title h1 { font-family: var(--mono); font-weight: 500; font-size: 1.6rem; overflow-wrap: anywhere; }
.dev-title h1:focus { outline: none; }
.dev-badges { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dev-badges .badge { height: 28px; padding: 0 12px; border-radius: 999px; background: var(--st-bg); }
#dw-sub { margin-top: 4px; }

.dev-alerts { display: grid; gap: 10px; }
.dev-alerts:empty { display: none; }
#dw-head:empty { display: none; }
.callout { display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--st-bg); border: 1px solid var(--line); }
.callout.st-off { grid-template-columns: auto 1fr; align-items: start; }
.callout.st-off > .mark { margin-top: 3px; }
.callout-t { margin: 0; font-size: 1rem; color: var(--st); }
.dw-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dw-alerts .alert { display: flex; gap: 10px; align-items: center; }
.dw-alerts .alert .mark { margin-top: 0; }
.alert-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.ack-foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.ack-note { display: grid; gap: 4px; color: var(--muted); font-size: .85rem; flex: 1 1 280px; }
.ack-note input { width: 100%; min-width: 0; }
.ack-done { color: var(--muted); }
.ack-done summary { cursor: pointer; min-height: 32px; display: list-item; }
.ack-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.ack-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: start; }
.ack-meta { grid-column: 1; font-size: .85rem; }
.ack-list .btn { grid-column: 2; grid-row: 1 / span 2; }

.dev-cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.dev-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.dev-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
#dw-body, #dw-net, #dw-info, #dw-edit { display: flex; flex-direction: column; gap: 20px; }
#dw-body:empty, #dw-net:empty, #dw-sw:empty, #dw-edit:empty { display: none; }

.dw-sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.dw-sec:empty { display: none; }
.dw-sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.dw-sec-head h3 { margin: 0; }

.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* ---------- tabelle ---------- */

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th {
  text-align: left; font-weight: 600; color: var(--muted); white-space: nowrap; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 0 14px 8px 0; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 9px 14px 9px 0; border-bottom: 1px solid var(--line-2); vertical-align: top; overflow-wrap: break-word; }
.tbl-wrap > .tbl { min-width: 540px; }
.tbl td .mono, .tbl td.num { white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-sm { font-size: .86rem; }
.tbl-sm td { padding: 7px 12px 7px 0; }

/* ---------- grafici ---------- */

.chart-block { margin: 14px 0 18px; }
.chart-block:last-child { margin-bottom: 0; }
.chart-t { font-size: .9rem; font-weight: 600; margin: 0 0 4px; }
.chart-wrap { position: relative; }
svg.chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.chart .axis { fill: var(--muted); font: 11px var(--font); }
svg.chart .line { fill: none; stroke: var(--bar); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
svg.chart .dot { fill: var(--bar); }
svg.chart .dot.hover { stroke: var(--panel); stroke-width: 2; }
svg.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.tip {
  position: absolute; top: 0; z-index: 2;
  transform: translate(8px, -2px);
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--field-line); border-radius: 6px;
  padding: 3px 8px; font-size: .8rem; white-space: nowrap; pointer-events: none;
}
.tip.flip { transform: translate(calc(-100% - 8px), -2px); }
.chart-sum { margin: 2px 0 0; font-size: .82rem; }
.chart-data { margin-top: 4px; font-size: .85rem; }
.chart-data summary, .bk-hist summary { cursor: pointer; color: var(--link); }

.res { display: grid; grid-template-columns: 4rem 1fr 3.2rem; gap: 2px 12px; align-items: center; margin: 9px 0; }
.res-track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.res-fill { display: block; height: 100%; background: var(--bar); }
.res-v { text-align: right; font-variant-numeric: tabular-nums; }
.res-d { grid-column: 2 / 4; font-size: .82rem; }

.edit-grid { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 8px 12px; align-items: center; }
.edit-grid input, .edit-grid select { width: 100%; min-width: 0; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- software ---------- */

.sw-input { width: 100%; max-width: 34rem; margin: 8px 0 14px; }
.sw-count { margin: 0 0 8px; font-weight: 600; }
.sw-list { max-height: 24rem; overflow: auto; margin-top: 6px; }
.sw.page #sw-out { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.sw.page #sw-out:has(> p.dim:only-child) { background: none; border: 0; padding: 0; }
.sw.page .sw-input { margin: 0; height: 42px; }

/* ---------- finestra di aggiunta ---------- */

dialog {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; width: min(680px, calc(100vw - 24px));
}
dialog::backdrop { background: rgba(5, 10, 15, .55); }
dialog h2 { font-size: 1.15rem; }
.cmd { margin: 16px 0; }
.cmd-l { margin: 0 0 4px; font-weight: 600; }
.cmd pre { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.cmd code { font-family: var(--mono); font-size: .82rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- backup ---------- */

.bk-silent { margin-left: 10px; }
.bk-hist { margin-top: 12px; }
.bk-tbl td:last-child { min-width: 12rem; }
.bk-hook, .bk-form, .bk-jobs, .bk-reveal { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.bk-form h4, .bk-jobs h4 { margin: 0 0 8px; }
.bk-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 4px; }
.bk-form .btn, .bk-form .dim { margin-top: 8px; }
.num-in { width: 6rem; }
.bk-acts { display: inline-flex; gap: 8px; }
.bk-warn { margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.bk-job-list { list-style: none; margin: 0; padding: 0; }
.bk-job { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.bk-job:last-child { border-bottom: 1px solid var(--line-2); }
.bk-job-name { flex: 1 0 100%; font-weight: 600; overflow-wrap: anywhere; }
.bk-job label { color: var(--muted); }
.bk-job .bk-acts { margin-left: auto; }

/* ---------- telefono ---------- */

.only-sm-sr { display: none; }

@media (max-width: 720px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .top { padding: 8px 16px; gap: 8px; }
  .tabs { display: none; }
  .hide-sm { display: none; }
  .only-sm-sr { display: inline; }
  .top-actions .btn-primary { width: 42px; height: 42px; min-height: 0; padding: 0; }
  .top-actions .bell { display: none; }
  main { padding: 16px 16px 32px; }
  h1 { font-size: 1.4rem; }
  .page { gap: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile-v { font-size: 1.4rem; }
  .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; }
  .chip { flex: none; }
  .cgrid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .alarm { padding: 12px 14px; gap: 8px 12px; }
  .alarm-when { align-items: flex-start; text-align: left; min-width: 0; flex: 1 1 auto; }
  .alarm-acts { margin-left: auto; }
  .dev-head { gap: 12px; }
  .dev-icon { width: 44px; height: 44px; }
  .dev-title h1 { font-size: 1.3rem; }
  .dw-sec { padding: 14px; }
  .facts { grid-template-columns: 7rem minmax(0, 1fr); }
  .tbl .meter-track { display: none; }

  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .bottom-nav a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; color: var(--muted); font-size: .72rem; font-weight: 500;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .bottom-nav .bell-n { top: 4px; right: calc(50% - 22px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
