/* SAEG Monitoring — layout: barra laterale scura + area contenuti chiara a schede */
:root {
  --bg: #F3F4F3;
  --panel: #FFFFFF;
  --ink: #131313;
  --ink-2: #5B5F5E;
  --line: #E3E5E4;
  --side: #141716;
  --side-ink: #C9CDCB;
  --accent: #325C8D;
  --accent-soft: #E8EEF5;
  --prod: #F2A33A;
  --auto: #36A7A4;
  --imm: #8CBF5F;
  --prel: #8E9391;
  --cons: #325C8D;
  --ok: #2E7D32; --ok-bg: #E7F3E4;
  --warn: #9A5600; --warn-bg: #FFF2DE;
  --bad: #B3261E; --bad-bg: #FBE6E4;
  --info: #1F4E7A; --info-bg: #E8EEF5;
  --radius: 10px;
  --font: Arimo, "Helvetica Neue", Arial, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
button, input, select { font: inherit; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-art { background: var(--side); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.login-art img { width: 150px; }
.login-art h1 { font-size: 40px; line-height: 1.15; font-weight: 700; max-width: 14ch; }
.login-art p { color: var(--side-ink); max-width: 46ch; line-height: 1.6; margin: 0; }
.login-art .sun { position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(242,163,58,.14); }
.login-box { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-form { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.login-form h2 { font-size: 26px; }
.login-form .sub { color: var(--ink-2); margin: -10px 0 4px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.field input { height: 48px; border: 1px solid #CFD3D1; border-radius: 8px; padding: 0 14px; background: #fff; font-size: 16px; }
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent; background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: #2a2e2c; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #CFD3D1; }
.btn.secondary:hover { background: #F3F4F3; }
.btn.big { height: 50px; font-size: 16px; }
.error { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.hint { color: var(--ink-2); font-size: 13px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; gap: 4px; padding: 24px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; flex-direction: column; gap: 10px; padding: 0 8px 20px; border-bottom: 1px solid #2A2E2C; margin-bottom: 12px; }
.side .brand img { width: 110px; }
.side .client { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #8E9391; }
.side .client b { display: block; font-size: 16px; letter-spacing: 0; text-transform: none; color: #fff; margin-top: 2px; }
.side .group-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #6F7472; padding: 14px 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: 44px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-weight: 600; }
.side a.nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.side a.nav:hover { background: #1F2321; color: #fff; }
.side a.nav.on { background: #fff; color: var(--ink); }
.side a.nav .badge { margin-left: auto; }
.side .plant-pick { margin: 4px 0 6px; }
.side .plant-pick select { width: 100%; height: 44px; border-radius: 8px; border: 1px solid #2E3331; background: #1F2321; color: #fff; padding: 0 10px; font-weight: 600; }
.side .spacer { flex: 1; }
.side .foot { font-size: 12px; color: #6F7472; padding: 12px 10px 0; border-top: 1px solid #2A2E2C; display: grid; gap: 10px; }
.side .foot button { background: none; border: 1px solid #2E3331; color: var(--side-ink); border-radius: 8px; height: 40px; cursor: pointer; font-weight: 600; }
.side .foot button:hover { color: #fff; border-color: #4A4F4D; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.badge.muted { background: #DEE1DF; color: var(--ink); }

.topbar { display: none; }
.main { padding: 32px clamp(16px, 3vw, 40px) 64px; display: flex; flex-direction: column; gap: 24px; min-width: 0; max-width: 1400px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 30px; font-weight: 700; }
.crumbs { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12px; font-weight: 700; background: #E9EBEA; color: #3F4342; white-space: nowrap; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lead { color: var(--ink-2); margin: 6px 0 0; max-width: 75ch; line-height: 1.5; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card h2 { font-size: 18px; font-weight: 700; }
.card .card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.card .note { font-size: 13px; color: var(--ink-2); margin: 0; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

/* status banner */
.status { display: flex; align-items: flex-start; gap: 14px; padding: 16px 20px; border-radius: var(--radius); border: 1px solid; line-height: 1.5; }
.status .dot { width: 12px; height: 12px; border-radius: 6px; margin-top: 5px; flex-shrink: 0; }
.status.ok { background: var(--ok-bg); border-color: #C6E2BF; } .status.ok .dot { background: #4E9A3F; }
.status.warn { background: var(--warn-bg); border-color: #F0D3A6; } .status.warn .dot { background: #D98200; }
.status.bad { background: var(--bad-bg); border-color: #F1C1BC; } .status.bad .dot { background: var(--bad); }
.status b { font-weight: 700; }
.status .act { margin-left: auto; font-weight: 700; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 4px; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.gray { background: #ECEEED; color: #3F4342; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .k-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.kpi .k-label i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.kpi .k-value { font-size: 28px; font-weight: 700; }
.kpi .k-value small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-left: 4px; }
.kpi .k-sub { font-size: 13px; color: var(--ink-2); }
.up { color: var(--ok); font-weight: 700; } .down { color: var(--bad); font-weight: 700; }

/* plant cards */
.pod { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pod-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.pod-head .who { flex: 1 1 280px; display: grid; gap: 4px; }
.eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); font-weight: 700; }
.pod-head h2 { font-size: 20px; }
.stat { display: grid; gap: 2px; }
.stat span { font-size: 12px; color: var(--ink-2); }
.stat b { font-size: 20px; }
.pod-kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.pod-kids .plant { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.plant { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: inherit; transition: box-shadow .15s, border-color .15s; }
a.plant:hover { box-shadow: 0 4px 18px rgba(0,0,0,.07); border-color: #C8CCCA; }
.plant .p-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.plant .p-name { font-size: 17px; font-weight: 700; }
.plant .p-text { color: #2E3230; line-height: 1.5; font-size: 14px; min-height: 42px; }
.plant .p-nums { display: flex; flex-wrap: wrap; gap: 20px; align-items: baseline; }
.plant .p-big { font-size: 24px; font-weight: 700; }
.plant .p-meta { font-size: 13px; color: var(--ink-2); }
.plant .spark { height: 46px; }
.bar { height: 8px; border-radius: 4px; background: #ECEEED; position: relative; overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.seg { display: inline-flex; background: #F0F1F0; border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { height: 38px; padding: 0 16px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-weight: 700; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid #CFD3D1; background: #fff; cursor: pointer; font-size: 18px; line-height: 1; }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper .when { min-width: 170px; text-align: center; font-weight: 700; }
.stepper .btn { width: auto; height: 40px; font-size: 14px; }
.stepper input[type=date] { height: 40px; border: 1px solid #CFD3D1; border-radius: 8px; padding: 0 10px; }

.chart { width: 100%; height: 360px; }
.chart.tall { height: 420px; }
.chart.small { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: #3F4342; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* flows */
.flows { position: relative; height: 270px; }
.node { position: absolute; width: 150px; padding: 12px 14px; border-radius: 10px; border: 1px solid; background: #fff; display: grid; gap: 2px; }
.node .n-l { font-size: 12px; font-weight: 700; }
.node .n-v { font-size: 22px; font-weight: 700; }
.node .n-s { font-size: 12px; color: var(--ink-2); }
.node.pv { left: 0; top: 0; border-color: #F2C27F; background: #FFF6EA; } .node.pv .n-l { color: #8A5200; }
.node.grid { right: 0; top: 0; border-color: #C9CCCA; background: #F4F5F4; } .node.grid .n-l { color: #3F4342; }
.node.load { left: 50%; bottom: 0; transform: translateX(-50%); width: 170px; border-color: #9DBBDB; background: #EEF3F9; } .node.load .n-l { color: var(--accent); }
.flows svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flow-lbl { position: absolute; font-size: 12px; font-weight: 700; background: #fff; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.dash { stroke-dasharray: 7 6; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -26; } }
@media (prefers-reduced-motion: reduce) { .dash { animation: none; } }

/* tables */
.tbl-box { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid #EEF0EF; vertical-align: middle; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); }

/* alarms */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { white-space: nowrap; flex-shrink: 0; }
.tabs button { height: 46px; padding: 0 16px; border: 0; background: transparent; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.alarm { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.alarm .sev-bar { background: var(--warn); }
.alarm .a-body { padding: 18px 22px; display: grid; gap: 8px; }
.alarm .a-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; color: var(--ink-2); }
.alarm .a-meta b { color: var(--ink); }
.alarm h3 { font-size: 17px; }
.alarm p { margin: 0; line-height: 1.5; color: #2E3230; max-width: 75ch; }
.alarm .a-act { padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; justify-content: center; border-left: 1px solid #EEF0EF; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

.foot-note { font-size: 12px; color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--side); padding: 10px 16px; position: sticky; top: 0; z-index: 10; }
  .topbar img { width: 92px; }
  .topbar button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid #2E3331; background: transparent; color: #fff; cursor: pointer; }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { padding: 32px 20px; }
  .login-art h1 { font-size: 28px; }
  .alarm { grid-template-columns: 6px minmax(0, 1fr); }
  .alarm .a-act { grid-column: 2; border-left: 0; border-top: 1px solid #EEF0EF; flex-direction: row; }
  .pod-kids .plant { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media print {
  .side, .topbar, .toolbar .no-print, .btn { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* modulo macchine e ambienti */
.side a.nav.sub { min-height: 38px; padding-left: 44px; font-weight: 500; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid #CFD3D1; background: #fff; cursor: pointer; font-weight: 600; font-size: 13px; color: #3F4342; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Allarmistica ---------- */
.al-strip { display: flex; align-items: center; gap: 14px; background: var(--bad); color: #fff; text-decoration: none; padding: 12px clamp(16px, 3vw, 40px); font-size: 15px; line-height: 1.4; position: sticky; top: 0; z-index: 9; }
.al-strip:hover { background: #9C1F18; }
.al-strip-go { margin-left: auto; font-weight: 700; border: 1px solid rgba(255,255,255,.6); border-radius: 8px; padding: 6px 14px; white-space: nowrap; }
.al-pulse { width: 12px; height: 12px; border-radius: 6px; background: #fff; flex-shrink: 0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.7); } 50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); } }
@media (prefers-reduced-motion: reduce) { .al-pulse, .al-hero.bad .al-big-dot { animation: none; } }

.al-hero { display: flex; align-items: center; gap: 20px; padding: 22px 26px; border-radius: var(--radius); border: 1px solid; }
.al-hero h2 { font-size: 24px; }
.al-hero p { margin: 4px 0 0; line-height: 1.5; color: #2E3230; }
.al-big-dot { width: 28px; height: 28px; border-radius: 14px; flex-shrink: 0; }
.al-hero.ok { background: var(--ok-bg); border-color: #C6E2BF; } .al-hero.ok .al-big-dot { background: #4E9A3F; }
.al-hero.warn { background: var(--warn-bg); border-color: #F0D3A6; } .al-hero.warn .al-big-dot { background: #D98200; }
.al-hero.bad { background: var(--bad-bg); border-color: #F1C1BC; } .al-hero.bad .al-big-dot { background: var(--bad); animation: pulseR 1.4s ease-in-out infinite; }
@keyframes pulseR { 0%, 100% { box-shadow: 0 0 0 0 rgba(179,38,30,.45); } 50% { box-shadow: 0 0 0 12px rgba(179,38,30,0); } }

.al-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 20px; align-items: start; }
.al-card { background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--sev); border-radius: var(--radius); padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.al-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 14px; }
.al-where { font-weight: 700; }
.al-since { color: var(--ink-2); margin-left: auto; }
.al-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.al-title h3 { font-size: 22px; }
.al-val { font-size: 26px; font-weight: 700; color: var(--sev); }
.al-lim { color: var(--ink-2); font-size: 14px; }
.al-note { color: #2E3230; font-style: italic; margin-left: 6px; }
.al-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; }
.al-todo { background: #F6F7F6; border-radius: 8px; padding: 14px 16px; }
.al-todo ol, .r-body ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; line-height: 1.45; }
.al-act { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.al-act .btn svg { width: 18px; height: 18px; }

.tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.tl li { display: grid; grid-template-columns: 28px 44px minmax(0, 1fr); gap: 8px; align-items: start; font-size: 14px; line-height: 1.4; padding-bottom: 10px; position: relative; }
.tl li::before { content: ""; position: absolute; left: 13px; top: 26px; bottom: 0; width: 2px; background: #E3E5E4; }
.tl li:last-child::before { display: none; }
.tl-ic { width: 28px; height: 28px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: #ECEEED; color: #3F4342; position: relative; z-index: 1; }
.tl-ic svg { width: 15px; height: 15px; }
.tl-t { font-weight: 700; padding-top: 5px; }
.tl-x { padding-top: 5px; }
.tl-es { color: var(--ink-2); }
.tl-sent .tl-ic { background: var(--info-bg); color: var(--accent); }
.tl-miss .tl-ic { background: var(--bad-bg); color: var(--bad); } .tl-miss .tl-es { color: var(--bad); font-weight: 700; }
.tl-ack .tl-ic { background: var(--ok-bg); color: var(--ok); }
.tl-next { opacity: .75; } .tl-next .tl-ic { background: #fff; border: 2px dashed #B9BEBC; }

.rep { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rep li { display: flex; align-items: center; gap: 12px; }
.rep li div { display: grid; }
.rep li span:not(.rep-n) { font-size: 13px; color: var(--ink-2); }
.rep-n { width: 32px; height: 32px; border-radius: 16px; background: var(--ink); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rep-n.saeg { background: #fff; color: var(--ink); border: 2px solid var(--ink); }
.conn { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.conn li { display: flex; align-items: center; gap: 10px; }
.conn .c-ago, .conn .link-btn { margin-left: auto; color: var(--ink-2); white-space: nowrap; font-size: 13px; }
.cdot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; }
.cdot.ok { background: #4E9A3F; } .cdot.bad { background: var(--bad); }
.link-btn { background: none; border: 0; color: var(--accent) !important; font-weight: 700; cursor: pointer; text-decoration: underline; }
.sosp { display: grid; gap: 12px; }
.field select { height: 44px; border: 1px solid #CFD3D1; border-radius: 8px; padding: 0 10px; background: #fff; }

.chip.ch { display: inline-flex; align-items: center; gap: 6px; }
.chip.ch svg { width: 15px; height: 15px; }
.chip:not(.on) { color: #8E9391; }
.chains { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.chain { border: 1px solid var(--line); border-top: 4px solid var(--sev); border-radius: 8px; padding: 14px 16px; }
.chain-h { margin-bottom: 8px; }
.chain ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.chain li { display: grid; gap: 4px; padding: 10px 0 10px 18px; border-left: 2px solid #E3E5E4; position: relative; font-size: 14px; }
.chain li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 5px; background: var(--sev); }
.chain li.ch-end { color: var(--ink-2); font-size: 13px; } .chain li.ch-end::before { background: #fff; border: 2px solid #B9BEBC; }
.ch-min { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 700; }
.ch-who { font-weight: 700; }
.ch-ch { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-ic { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; background: #F0F1F0; border-radius: 12px; padding: 3px 8px; }
.ch-ic svg { width: 13px; height: 13px; }
.tbl tr.row-on td { background: #F6F7F6; }

.prova { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.prova-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.prova-steps li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); transition: background .2s, border-color .2s; }
.prova-steps li.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.prova-steps li.done { color: var(--ink-2); }
.prova-steps li.done .ch-min::after { content: " · fatto"; color: var(--ok); }
.phone { background: #131313; border-radius: 30px; padding: 10px; height: 420px; display: flex; flex-direction: column; }
.ph-bar { display: flex; justify-content: space-between; color: #fff; font-size: 11px; padding: 4px 14px 8px; }
.ph-screen { flex: 1; background: linear-gradient(160deg, #2C3E50, #1B2631); border-radius: 22px; padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.ph-idle { color: #AEB6BD; margin: auto; font-size: 13px; text-align: center; }
.ph-push, .ph-mail { background: rgba(255,255,255,.94); border-radius: 14px; padding: 10px 12px; display: grid; gap: 3px; font-size: 12px; line-height: 1.35; animation: drop .35s ease-out; }
.ph-push b, .ph-mail b { font-size: 13px; }
.ph-push.ok { background: #E7F3E4; }
.ph-app, .ph-from { font-size: 11px; color: #5B5F5E; display: flex; align-items: center; gap: 6px; }
.ph-logo { width: 16px; height: 16px; border-radius: 4px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ph-sms { display: grid; gap: 4px; animation: drop .35s ease-out; }
.ph-sms .ph-from { color: #C9CDCB; }
.ph-bubble { background: #E9EBEA; border-radius: 14px 14px 14px 4px; padding: 9px 11px; font-size: 12px; line-height: 1.35; }
.ph-call { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; color: #fff; text-align: center; padding-top: 24px; animation: drop .35s ease-out; }
.ph-call b { font-size: 18px; }
.ph-call span { font-size: 12px; color: #C9CDCB; }
.ph-call p { font-size: 12px; line-height: 1.45; color: #E3E5E4; margin: 10px 4px; font-style: italic; }
.ph-av { width: 56px; height: 56px; border-radius: 28px; background: #4E9A3F; display: flex; align-items: center; justify-content: center; animation: ring 1s ease-in-out infinite; }
.ph-av svg { width: 26px; height: 26px; }
.ph-keys { display: flex; gap: 16px; margin-top: auto; padding-bottom: 14px; }
.ph-keys span { width: 44px; height: 44px; border-radius: 22px; background: rgba(255,255,255,.18); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@media (prefers-reduced-motion: reduce) { .ph-push, .ph-mail, .ph-sms, .ph-call, .ph-av { animation: none; } }

.rules { display: grid; gap: 8px; }
.rule { border: 1px solid var(--line); border-radius: 8px; }
.rule.off { opacity: .55; }
.rule summary { display: grid; grid-template-columns: 110px minmax(160px, 1.1fr) minmax(0, 1.4fr) 130px 110px 52px; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; font-size: 14px; }
.rule summary::-webkit-details-marker { display: none; }
.r-name { display: grid; } .r-name span { font-size: 13px; color: var(--ink-2); }
.r-cond { color: #2E3230; }
.r-when { font-size: 13px; color: var(--ink-2); }
.r-body { padding: 4px 16px 16px 136px; display: grid; gap: 8px; }
.switch { width: 46px; height: 26px; border-radius: 13px; border: 0; background: #CFD3D1; position: relative; cursor: pointer; padding: 0; }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; transition: left .15s; }
.switch.on { background: var(--ok); } .switch.on i { left: 23px; }

@media (max-width: 1100px) { .al-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .al-strip { top: 64px; font-size: 14px; }
  .prova { grid-template-columns: minmax(0, 1fr); }
  .phone { max-width: 260px; margin: 0 auto; width: 100%; }
  .rule summary { display: flex; flex-wrap: wrap; }
  .rule summary .r-name { flex: 1 1 60%; order: -1; }
  .rule summary .switch { order: -1; }
  .rule summary .r-cond { flex: 1 1 100%; }
  .r-body { padding: 4px 16px 16px; }
  .al-since { margin-left: 0; }
}

/* schema flussi */
.flow-box { width: 100%; }
.flow-svg { width: 100%; height: auto; display: block; max-height: 440px; margin: 0 auto; font-family: var(--font); }
.flow-svg .f-cap { font-weight: 700; fill: #3F4342; letter-spacing: .02em; }
.flow-svg .f-val { font-weight: 700; fill: #131313; }
.flow-svg .f-sub { fill: #5B5F5E; }
.flow-svg .f-lbl { font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }


/* legenda cliccabile */
.legend.lg { gap: 8px; }
.lg-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 4px 12px; border: 1px solid #DEE1DF; border-radius: 17px; background: #fff; font-size: 13px; font-weight: 600; color: #2E3230; cursor: pointer; transition: opacity .15s, background .15s; }
.lg-btn:hover { background: #F3F4F3; }
.lg-btn i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.lg-btn small { font-weight: 400; color: var(--ink-2); font-size: 12px; }
.lg-btn.off { opacity: .45; text-decoration: line-through; background: #F6F7F6; }
.lg-btn.off i { filter: grayscale(1); }
.lg-all { min-height: 34px; padding: 4px 12px; border: 0; background: none; color: var(--accent); font-weight: 700; text-decoration: underline; cursor: pointer; font-size: 13px; }

/* home: 4 impianti uguali + striscia del punto di connessione */
.plants4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.plants4 .plant { height: 100%; box-sizing: border-box; }
.plants4 .plant .p-text { min-height: 63px; }
.plants4 .plant > .p-meta:last-child { margin-top: auto; }
.p-pod { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); min-height: 22px; }
.pod-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; background: #E4ECF5; color: #325C8D; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.pod-tag.b { background: #EAF3E1; color: #4F7F2A; }
.pod-tag.c { background: #F0F1F0; color: #5B5F5E; }
.pod-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #325C8D; border-radius: var(--radius); padding: 18px 24px; }
.pod-strip .ps-icon { width: 44px; height: 44px; border-radius: 22px; background: #131313; color: #F2A33A; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pod-strip .ps-icon svg { width: 22px; height: 22px; }
.pod-strip .who { flex: 1 1 260px; display: grid; gap: 3px; }
.pod-strip h2 { font-size: 19px; }
.pod-strip .p-meta { font-size: 13px; color: var(--ink-2); }
.pod-strip .stat { display: grid; gap: 2px; }
.pod-strip .stat span { font-size: 12px; color: var(--ink-2); }
.pod-strip .stat b { font-size: 20px; }
@media (max-width: 1280px) { .plants4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .plants4 { grid-template-columns: minmax(0, 1fr); } }
@supports (grid-template-rows: subgrid) {
  .plants4 { grid-auto-rows: auto; }
  .plants4 .plant { display: grid; grid-row: span 8; grid-template-rows: subgrid; gap: 12px; align-content: start; }
}
.plants4 .p-top { flex-wrap: wrap; row-gap: 6px; }
.plants4 .p-bar { display: grid; gap: 8px; align-content: start; }
.ch-sico { width: 26px; height: 26px; border-radius: 13px; background: var(--ok-bg); color: var(--ok); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ch-sico svg { width: 15px; height: 15px; }
.ph-wa { display: grid; gap: 4px; animation: drop .35s ease-out; }
.ph-wa .ph-from { color: #C9CDCB; }
.ph-ok { color: #8FD18A; font-size: 10px; }
.ph-wbubble { background: #DCF8C6; color: #131313; border-radius: 4px 14px 14px 14px; padding: 8px 10px 16px; font-size: 12px; line-height: 1.4; position: relative; }
.ph-hint { color: #3F4342; font-size: 11px; }
.ph-time { position: absolute; right: 8px; bottom: 3px; font-size: 10px; color: #5B5F5E; }
.ph-wbtn { background: rgba(255,255,255,.95); color: #1F7A5A; text-align: center; font-size: 12px; font-weight: 700; border-radius: 8px; padding: 6px; }
.chain-h { display: flex; justify-content: space-between; align-items: center; }
.chain-ed { border: 1px solid var(--line); border-top: 4px solid var(--sev); border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; display: grid; gap: 14px; background: #FBFBFB; }
.ce-head { display: flex; align-items: center; gap: 12px; }
.ce-head h3 { font-size: 17px; }
.ce-opts { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; }
.ce-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; }
.ce-check input { width: 18px; height: 18px; }
.ce-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ce-steps li { display: grid; grid-template-columns: 32px 120px minmax(180px, 240px) minmax(0, 1fr) auto; gap: 12px; align-items: end; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.ce-n { width: 28px; height: 28px; border-radius: 14px; background: var(--sev); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; align-self: center; }
.ce-steps .field select { width: 100%; }
.ce-move { display: flex; gap: 4px; }
.ce-move .icon-btn { width: 40px; height: 40px; border: 1px solid #DEE1DF; border-radius: 8px; background: #fff; font-size: 16px; cursor: pointer; }
.ce-move .icon-btn:disabled { opacity: .35; cursor: default; }
.ce-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 900px) {
  .ce-steps li { grid-template-columns: 32px minmax(0, 1fr); }
  .ce-steps li > :not(.ce-n) { grid-column: 2; }
}
.plant .p-grid { margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.plant .p-grid .pod-tag.gr { background: #E3E5E4; color: #2E3230; }
