:root {
  --bg: #080e1a;
  --panel: #0f1829;
  --panel-2: #142036;
  --line: #1f2d47;
  --line-2: #2a3b5c;
  --text: #e6edf7;
  --muted: #8b9bb7;
  --dim: #5d6e8c;
  --accent: #2dd4bf;
  --green: #22c55e;
  --yellow: #eab308;
  --amber: #f59e0b;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #38bdf8;
  --violet: #a78bfa;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, "Segoe UI", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.c-green { color: var(--green); } .c-yellow { color: var(--yellow); } .c-orange { color: var(--orange); }
.c-red { color: var(--red); } .c-blue { color: var(--blue); } .c-accent { color: var(--accent); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.rail {
  width: 76px; flex: none; background: #060b15; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: stretch; padding: 10px 6px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.rail-logo { color: var(--accent); display: grid; place-items: center; height: 44px; margin-bottom: 8px; }
.rail a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px;
  border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 10.5px; text-align: center;
}
.rail a .ico { font-size: 18px; filter: grayscale(.4); }
.rail a:hover { background: var(--panel); color: var(--text); }
.rail a.active { background: var(--panel-2); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.rail a.locked { display: none; }   /* ogni ruolo vede solo i propri moduli */
.rail-spacer { flex: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: #0a1222;
  position: sticky; top: 0; z-index: 20;
}
.tb-title { font-size: 15px; }
.tb-title .sep { color: var(--dim); margin: 0 4px; }
.tb-title #modTitle { color: var(--accent); }
.tb-ctrls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sel { display: flex; flex-direction: column; font-size: 10.5px; color: var(--muted); gap: 2px; }
select, input[type=text], input[type=number], input[type=date], textarea {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px; color: var(--text);
}
select { max-width: 280px; }
.live-badge { font-family: var(--mono); font-size: 11.5px; padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line-2); background: transparent; cursor: pointer; }
.live-badge.sim { color: var(--amber); }
.live-badge.on { color: var(--green); border-color: rgba(34,197,94,.5); }
.live-badge.hist { color: var(--accent); border-color: rgba(45,212,191,.5); }
.clock { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; }

.scenario {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 18px;
  border-bottom: 1px solid var(--line); background: #0a1120; font-size: 12px;
}
.sc-lbl { color: var(--amber); font-weight: 600; margin-right: 6px; }
.scenario button {
  background: transparent; border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.scenario button:hover { color: var(--text); border-color: var(--accent); }
.scenario button.on { background: rgba(45,212,191,.12); border-color: var(--accent); color: var(--accent); }
.sc-note { color: var(--muted); margin-left: 8px; flex: 1 1 300px; }
.scenario.hist button { display: none; }
.scenario.live button { display: none; }
.scenario.live .sc-lbl { color: var(--green); }
[hidden] { display: none !important; }

/* ---------- Origine del dato (prov.js) ---------- */
.prov { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--dim); vertical-align: 0; cursor: help; margin-left: 3px; flex: none; }
.prov.prov-real { background: var(--green); border-color: var(--green); }
.prov.prov-mixed { background: linear-gradient(90deg, var(--amber) 50%, transparent 50%); border-color: var(--amber); }
.prov.prov-sim { background: transparent; border-color: #94a3b8; }
.prov:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.prov-pop { position: fixed; z-index: 120; max-width: 380px; background: #0b1324; border: 1px solid var(--line-2); border-radius: 9px; padding: 10px 12px;
  font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.55); display: none; pointer-events: none; }
.prov-pop.show { display: block; }
.prov-pop .prov-t { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.prov-pop .prov-t.prov-real { color: var(--green); } .prov-pop .prov-t.prov-mixed { color: var(--amber); } .prov-pop .prov-t.prov-sim { color: #cbd5e1; }
.prov-pop .prov-h { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
.prov-pop ul { margin: 2px 0 0 16px; padding: 0; }
.prov-pop li { margin: 1px 0; }
.prov-pop .mono { font-size: 11px; color: #a5f3fc; }
.scenario.hist .sc-lbl { color: var(--accent); }

.view { display: none; padding: 16px 18px 28px; }
.view.active { display: block; }

/* ---------- Cards / UI ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-h h3 { font-size: 13.5px; }
.card-h .sub { font-size: 11.5px; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.btn {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 12px;
  cursor: pointer; color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: #0f766e; border-color: #14b8a6; }
.btn.primary:hover { background: #0d9488; }
.btn.go { background: #15803d; border-color: #22c55e; }
.btn.warn { background: #92400e; border-color: var(--amber); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; }
.pill.go { color: var(--green); } .pill.caution { color: var(--yellow); } .pill.nogo { color: var(--red); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-family: var(--mono); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 5px 10px; cursor: pointer; color: var(--muted); font-size: 12px; }
.seg button.on { background: var(--panel-2); color: var(--accent); }
.formula { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: #0a1222; border: 1px dashed var(--line-2); border-radius: 7px; padding: 6px 8px; }
.alert-card { border-radius: 9px; padding: 11px 12px; border: 1px solid; }
.alert-card.red { background: rgba(239,68,68,.09); border-color: rgba(239,68,68,.55); }
.alert-card.amber { background: rgba(245,158,11,.09); border-color: rgba(245,158,11,.55); }
.alert-card.green { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.5); }
.alert-card.blue { background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.5); }
.alert-card h4 { font-size: 13px; margin-bottom: 4px; }
input[type=range] { accent-color: var(--accent); width: 100%; }

/* ---------- KPI bar ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px;
  display: flex; gap: 11px; align-items: center; position: relative; overflow: hidden; cursor: default;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--k, var(--dim)); }
.kpi .ring { width: 46px; height: 46px; flex: none; }
.kpi .lab { font-size: 11px; color: var(--muted); }
.kpi .val { font-size: 19px; font-weight: 700; font-family: var(--mono); color: var(--k); }
.kpi .val small { font-size: 11px; font-weight: 500; color: var(--muted); }
.kpi .note { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-dim { --k: var(--dim); } .k-green { --k: var(--green); } .k-yellow { --k: var(--yellow); } .k-orange { --k: var(--orange); } .k-red { --k: var(--red); }

/* ---------- M1 ---------- */
.m1-grid { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 14px; }
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #0b1410; height: 560px; perspective: 1400px; }
.map-stage { position: absolute; inset: 0; transform-origin: 50% 60%; transition: transform .6s ease; }
.map-wrap.tilt .map-stage { transform: rotateX(48deg) scale(.92) translateY(-30px); }
.map-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-tools { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.map-tools .btn { padding: 5px 8px; font-size: 12px; background: rgba(15,24,41,.88); }
.map-title { position: absolute; left: 56px; top: 12px; z-index: 5; background: rgba(8,14,26,.8); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; font-size: 12px; }
.layer-panel {
  position: absolute; right: 10px; top: 10px; z-index: 5; width: 232px; max-height: calc(100% - 20px); overflow: auto;
  background: rgba(8,14,26,.92); border: 1px solid var(--line-2); border-radius: 9px; padding: 10px; font-size: 12px;
}
.layer-panel h4 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 8px 0 4px; }
.layer-panel h4:first-child { margin-top: 0; }
.layer-panel label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
.layer-panel input { accent-color: var(--accent); }
.legend { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.legend .ramp { height: 10px; border-radius: 3px; margin: 4px 0 2px; }
.legend .ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; }
.marker {
  position: absolute; z-index: 4; transform: translate(-50%, -100%); cursor: pointer;
  font-size: 11px; display: flex; flex-direction: column; align-items: center;
}
.marker .pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.marker .pin span { transform: rotate(45deg); font-size: 12px; }
.marker.weather .pin { background: #0284c7; } .marker.wet .pin { background: #7c3aed; }
.marker.soil .pin { background: #a16207; } .marker.trap .pin { background: #dc2626; }
.map-pop {
  position: absolute; z-index: 8; background: rgba(8,14,26,.96); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 10px 12px; font-size: 12px; min-width: 210px; box-shadow: 0 8px 24px rgba(0,0,0,.5); display: none;
}
.map-pop .x { position: absolute; right: 8px; top: 4px; cursor: pointer; color: var(--muted); }
.map-hint { position: absolute; left: 10px; bottom: 10px; z-index: 5; font-size: 11px; color: var(--muted); background: rgba(8,14,26,.8); padding: 4px 8px; border-radius: 6px; }
.side { display: flex; flex-direction: column; gap: 12px; }
.timeline { margin-top: 14px; display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 14px; }
.tl-ctrl { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.tl-ctrl .when { font-family: var(--mono); font-size: 12px; min-width: 150px; color: var(--accent); }
.tl-chart { height: 170px; }

/* ---------- M2 ---------- */
.m2-grid { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 14px; }
.m2-bottom { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr) minmax(0,1fr); gap: 14px; margin-top: 14px; }
.chart-lg { height: 360px; }
.no-forecast { height: 100%; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; padding: 0 24px;
  border: 1px dashed var(--line-2); border-radius: 8px; color: var(--muted); font-size: 12.5px; }
.no-forecast b { color: var(--text); font-size: 13px; }
.chart-md { height: 260px; }
.sample-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: end; }
.sample-form label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.sample-form input { width: 86px; }
.analog { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; }
.analog .sim { font-family: var(--mono); font-size: 18px; color: var(--green); font-weight: 700; }
.bar-sim { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0; }
.bar-sim i { display: block; height: 100%; background: var(--green); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 4px 0; }
.check .ok { color: var(--green); font-weight: 700; } .check .ko { color: var(--red); font-weight: 700; }

/* ---------- M3 ---------- */
.m3-top { display: grid; grid-template-columns: 430px minmax(0,1fr); gap: 14px; }
.swo-grid { display: grid; grid-template-columns: 54px repeat(24, minmax(0,1fr)); gap: 2px; font-size: 10px; }
.swo-grid .hd { color: var(--dim); text-align: center; font-family: var(--mono); }
.swo-grid .day { color: var(--muted); font-size: 11px; align-self: center; }
.swo-cell { height: 26px; border-radius: 3px; cursor: pointer; display: grid; place-items: center; font-family: var(--mono); font-size: 9px; color: rgba(0,0,0,.65); font-weight: 600; }
.swo-cell.go { background: #22c55e; } .swo-cell.caution { background: #eab308; } .swo-cell.nogo { background: #b91c1c; color: rgba(255,255,255,.55); }
.swo-cell.past { opacity: .25; }
.swo-cell.sel { outline: 2px solid #fff; outline-offset: 1px; }
.swo-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.swo-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.m3-bottom { display: grid; grid-template-columns: 220px minmax(0,1fr) 320px; gap: 14px; margin-top: 14px; }
.tank { width: 100%; height: 250px; }
.whatif-out { display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); }
.whatif-out .big { font-size: 26px; font-weight: 700; }

/* ---------- M4 ---------- */
.m4-grid { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 14px; }
.chat { display: flex; flex-direction: column; height: 640px; }
.chat-log { flex: 1; overflow: auto; padding: 4px 4px 10px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; }
.msg.user { align-self: flex-end; background: #134e4a; border: 1px solid #0f766e; border-bottom-right-radius: 3px; }
.msg.ai { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line-2); border-bottom-left-radius: 3px; }
.msg.ai p { margin: 0 0 7px; } .msg.ai p:last-child { margin: 0; }
.msg.ai ul { margin: 4px 0 7px 18px; padding: 0; }
.msg .who { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
.gates { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.gate { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; border: 1px solid; }
.gate.pass { color: var(--green); border-color: rgba(34,197,94,.5); }
.gate.fail { color: var(--red); border-color: rgba(239,68,68,.6); }
.gate.warn { color: var(--amber); border-color: rgba(245,158,11,.6); }
.action-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 8px; margin-top: 10px; }
.acard { background: #0a1222; border: 1px solid var(--line-2); border-radius: 9px; padding: 10px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.acard h5 { margin: 0; font-size: 12.5px; }
.acard .id { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.acard.done { border-color: var(--green); }
.chat-input { display: flex; gap: 8px; margin-top: 8px; }
.chat-input textarea { flex: 1; resize: none; height: 44px; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.suggest button { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; }
.suggest button:hover { color: var(--text); border-color: var(--accent); }
.packet { font-family: var(--mono); font-size: 11px; background: #0a1222; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 230px; overflow: auto; white-space: pre; color: #a5f3fc; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- M5 (mobile) ---------- */
.m5-wrap { display: grid; grid-template-columns: 410px minmax(0,1fr); gap: 22px; align-items: start; }
.phone {
  width: 390px; height: 800px; border-radius: 44px; background: #000; padding: 12px; border: 2px solid #334155;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); position: relative;
}
.screen {
  width: 100%; height: 100%; border-radius: 34px; overflow: hidden; background: #000; color: #fff;
  display: flex; flex-direction: column; font-size: 15px;
}
.ph-status { display: flex; justify-content: space-between; align-items: center; padding: 12px 22px 6px; font-size: 13px; font-weight: 600; }
.conn { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; cursor: pointer; border: 2px solid; }
.conn.ok { color: #4ade80; border-color: #4ade80; } .conn.off { color: #fbbf24; border-color: #fbbf24; }
.ph-head { padding: 4px 18px 10px; border-bottom: 2px solid #1f2937; }
.ph-head .t { font-size: 20px; font-weight: 700; }
.ph-head .s { color: #cbd5e1; font-size: 13px; }
.ph-body { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.ph-nav { display: grid; grid-template-columns: repeat(4,1fr); border-top: 2px solid #1f2937; background: #050505; }
.ph-nav button { min-height: 64px; background: transparent; border: 0; color: #9ca3af; font-size: 12px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ph-nav button .i { font-size: 22px; }
.ph-nav button.on { color: #facc15; }
.big-btn { min-height: 56px; border-radius: 14px; border: 3px solid #fff; background: #111; color: #fff; font-size: 17px; font-weight: 700; cursor: pointer; width: 100%; padding: 8px 12px; }
.big-btn.yellow { background: #facc15; color: #000; border-color: #facc15; }
.big-btn.green { background: #16a34a; border-color: #4ade80; }
.big-btn.blue { background: #1d4ed8; border-color: #60a5fa; }
.ph-card { border: 2px solid #374151; border-radius: 16px; padding: 12px 14px; background: #0a0a0a; }
.ph-card.hl { border-color: #facc15; }
.ph-card h4 { font-size: 16px; margin-bottom: 6px; }
.ph-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #1f2937; font-size: 15px; }
.ph-row:last-child { border: 0; }
.ph-row b { font-size: 18px; color: #facc15; font-family: var(--mono); }
.viewfinder { position: relative; border-radius: 16px; overflow: hidden; border: 2px solid #374151; background: #111; aspect-ratio: 4/3.4; }
.viewfinder canvas { width: 100%; height: 100%; display: block; }
.viewfinder .reticle { position: absolute; inset: 14%; border: 3px dashed rgba(250,204,21,.85); border-radius: 14px; pointer-events: none; }
.diag { border-radius: 14px; padding: 12px; border: 3px solid; }
.diag.alert { border-color: #ef4444; background: #1f0a0a; } .diag.ok { border-color: #4ade80; background: #052e16; } .diag.low { border-color: #fbbf24; background: #1f1505; }
.gauge { width: 100%; }
.m5-side { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Log ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.tbl td.hash { font-family: var(--mono); font-size: 10.5px; color: var(--dim); word-break: break-all; max-width: 220px; }

/* ---------- Toast / Modal ---------- */
/* Sintesi per la Direzione (js/m0-direzione.js) */
body[data-role=dir] #scenario { display: none; }
.dir-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; padding: 18px 20px; }
.dir-hero h2 { font-size: 22px; margin-bottom: 4px; }
.dir-light { width: 46px; height: 46px; border-radius: 50%; flex: none; box-shadow: 0 0 0 6px rgba(255,255,255,.04), 0 0 24px var(--lc); background: var(--lc); }
.l-green { --lc: var(--green); } .l-yellow { --lc: var(--yellow); } .l-red { --lc: var(--red); }
.dir-tiles { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.dir-tile { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--tc); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.dir-tile .lab { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dir-tile .val { font-size: 30px; font-weight: 700; color: var(--tc); margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dir-tile .val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.dir-tile .sub { font-size: 12.5px; color: var(--text); opacity: .85; }
.t-green { --tc: var(--green); } .t-yellow { --tc: var(--yellow); } .t-red { --tc: var(--red); } .t-dim { --tc: var(--dim); }
.dir-grid { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 14px; margin-bottom: 14px; }
.dir-dec { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.dir-dec .ico { font-size: 22px; width: 30px; text-align: center; flex: none; }
.dir-dec .txt { flex: 1; min-width: 0; }
.dir-none { color: var(--green); font-size: 13px; padding: 10px 0; }
.dir-days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dir-day { text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 10px 6px; }
.dir-day.bad { border-color: rgba(245,158,11,.6); background: rgba(245,158,11,.06); }
.dir-day .ico { font-size: 26px; margin: 4px 0; }
.dir-tbl tr[data-parcel] { cursor: pointer; } .dir-tbl tr.cur td { background: var(--panel-2); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; }
.d-green { background: var(--green); } .d-yellow { background: var(--yellow); } .d-red { background: var(--red); }
.dir-bar { height: 12px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.dir-bar i { display: block; height: 100%; background: var(--green); } .dir-bar i.amber { background: var(--amber); } .dir-bar i.red { background: var(--red); }
.dir-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.dir-actions .btn { text-align: center; text-decoration: none; }
@media (max-width: 1250px) { .dir-tiles { grid-template-columns: repeat(2, minmax(0,1fr)); } .dir-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .dir-tile .val { font-size: 21px; white-space: normal; } .dir-hero h2 { font-size: 18px; } .dir-dec { flex-wrap: wrap; } }

/* Suggerimenti al passaggio del mouse (js/help.js) */
.help-tgl { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--dim); font-weight: 700; cursor: pointer; }
.help-tgl.on { color: var(--accent); border-color: var(--accent); background: rgba(45,212,191,.08); }
.help-hint { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 8px); width: max-content; max-width: min(560px, calc(100vw - 32px)); z-index: 90;
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--accent); border-radius: 8px; padding: 9px 14px;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 6px 20px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.help-hint.show { opacity: 1; transform: translate(-50%, 0); }
.help-hint b { display: block; color: var(--accent); font-size: 12px; margin-bottom: 2px; }
.help-hint span { color: var(--text); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; max-width: 380px; box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: tin .25s ease; }
.toast.warn { border-left-color: var(--amber); } .toast.err { border-left-color: var(--red); } .toast.ok { border-left-color: var(--green); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.modal-back.open { display: flex; }
.modal { max-width: 640px; width: 100%; max-height: 86vh; overflow: auto; }
.modal pre { font-family: var(--mono); font-size: 11px; background: #0a1222; padding: 10px; border-radius: 8px; overflow: auto; max-height: 340px; color: #a5f3fc; }

.denied { max-width: 620px; margin: 40px auto; }
.denied h2 { margin-bottom: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1250px) {
  .m1-grid, .m2-grid, .m4-grid, .timeline { grid-template-columns: 1fr; }
  .m3-top { grid-template-columns: 1fr; }
  .m3-bottom, .m2-bottom { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .m5-wrap { grid-template-columns: 1fr; justify-items: center; }
}
@media (max-width: 760px) {
  /* Telefono: i moduli in una barra fissa in basso, controlli compatti, tutto in una colonna */
  .app { display: block; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 40; width: auto; height: 58px;
    flex-direction: row; justify-content: space-around; align-items: center; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .rail-logo, .rail-spacer { display: none; }
  .rail a { flex: 1; padding: 4px 0; font-size: 9.5px; }
  .rail a .lbl { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 64px; }
  .rail a.active { box-shadow: inset 0 2px 0 var(--accent); }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar { position: static; padding: 8px 12px; gap: 8px; }
  .tb-title { font-size: 14px; }
  .tb-title .sep, .tb-title #modTitle { display: none; }
  .tb-ctrls { display: flex; flex-wrap: wrap; gap: 6px 8px; width: 100%; }
  .tb-ctrls .sel { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .tb-ctrls .sel select { width: 100%; min-width: 0; padding-top: 5px; padding-bottom: 5px; }
  .tb-ctrls .live-badge { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; padding: 6px 8px; }
  .tb-ctrls .clock { display: none; }   /* data e ora sono già nel badge e nella barra dello scenario */
  .scenario { padding: 8px 12px; gap: 6px; }
  .sc-note { margin-left: 0; flex-basis: 100%; }
  .view { padding: 12px; }
  .view .grid > *, .m1-grid > *, .m2-grid > *, .m3-top > *, .m3-bottom > *, .m4-grid > *, .m5-wrap > * { min-width: 0; }
  .card-h { flex-wrap: wrap; }
  .card-h > div { display: flex; flex-wrap: wrap; gap: 6px; }
  .btn { white-space: normal; max-width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .kpi { padding: 9px 10px 9px 12px; }
  .kpi .ring { display: none; }
  .kpi .val { font-size: 17px; }
  .m3-bottom, .m2-bottom { grid-template-columns: 1fr; }
  /* mappa: il pannello dei layer scende sotto la mappa invece di coprirla */
  .map-wrap { height: auto; overflow: visible; border: 0; background: none; }
  .map-stage { position: relative; height: 360px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #0b1410; }
  .map-title { left: 52px; right: 10px; font-size: 11px; }
  .layer-panel { position: static; width: auto; max-height: none; margin-top: 10px; }
  .chat { height: 70vh; }
  .phone { width: 100%; max-width: 390px; }
  .swo-grid { grid-template-columns: 40px repeat(24, minmax(0,1fr)); }
  .swo-cell { font-size: 0; }
  .help-hint { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .toasts { left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .modal-back { padding: 8px; }
  .modal { max-height: 92vh; }
  .tbl { display: block; overflow-x: auto; }
  .modal .kv { grid-template-columns: 1fr; gap: 0 }
  .modal .kv dt { margin-top: 6px; }
  .modal .kv dd { text-align: left; }
}
