/* Components: panels, KPI strip, state badges, tables, buttons, forms. Flat, square corners (mockup look). */

/* panel = mockup ".panel": white, square, navy header with white uppercase title */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 9px 14px; background: var(--brand); color: var(--on-brand); }
.card-h h2, .card-h h3 { flex: 1; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--on-brand); }
.card-h .muted, .card-h a { color: rgba(255,255,255,.8); }
.card-h .badge-ok, .card-h .badge-offline { color: #fff; border-color: rgba(255,255,255,.5); }
.card-b { padding: 14px; }
.card.accent { border-top: 3px solid var(--accent); }

/* KPI strip: 4-6 numbers with units */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; border-left: 3px solid var(--line-strong); }
.kpi .label { color: var(--text-2); font-size: var(--fs-sm); }
.kpi .value { font-size: var(--fs-2xl); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .unit { font-size: var(--fs-base); font-weight: 400; color: var(--text-2); margin-left: 3px; }
.kpi.is-warning { border-left-color: var(--warn); }
.kpi.is-alarm { border-left-color: var(--alarm); }
.kpi.is-alarm .value { color: var(--alarm); }

/* State badges: always icon + word + colour. Normal is neutral. */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.badge .ic { font-size: var(--fs-md); }
.badge-ok { color: var(--ok-ink); background: transparent; border-color: var(--line); }
.badge-info { color: var(--info-ink); background: var(--info-bg); border-color: var(--info-line); }
.badge-warning { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-line); }
.badge-alarm { color: #fff; background: var(--alarm); border-color: var(--alarm); }
.badge-offline { color: var(--text-2); background: transparent; border: 1px dashed var(--offline); }
.badge-ack { color: var(--alarm); background: transparent; border-color: var(--alarm); }

/* Tables: compact, numbers right-aligned */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 700; font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-2);
  background: var(--surface); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--cell-y) var(--cell-x); border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--row-hover); }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.is-alarm td:first-child { box-shadow: inset 3px 0 0 var(--alarm); }
.table tr.is-warning td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.empty-cell { text-align: center; color: var(--text-2); padding: 24px 12px !important; }
.table-tools { display: flex; align-items: center; gap: 8px; padding: 8px 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 13px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font: 600 var(--fs-sm) var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--link); color: var(--link); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--sel); outline-offset: 1px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); color: #fff; }
.btn-danger { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.btn-danger:hover { background: var(--alarm); filter: brightness(1.1); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 26px; padding: 0 10px; font-size: var(--fs-sm); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 500; font-size: var(--fs-base); }
.field .hint { color: var(--text-2); font-size: var(--fs-sm); }
.field .error { color: var(--alarm); font-size: var(--fs-sm); }
.input, select.input, textarea.input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: inherit; }
textarea.input { height: auto; padding: 8px 10px; }
.input:hover { border-color: var(--input-hover); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }
.input[aria-invalid="true"] { border-color: var(--alarm); }
.check { display: flex; align-items: center; gap: 8px; }

/* Tabs of an asset page (Panoramica, Dati, Allarmi, Storico, Sensori, Note) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); margin-bottom: var(--gap); overflow-x: auto; }
.tabs a { padding: 9px 16px; color: var(--text-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.tabs a.is-active { color: var(--text); border-bottom-color: var(--sel); }

/* Tabs of a menu item (pages under the same menu voice), mockup ".tab-bar" */
.tab-bar { display: flex; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; margin-bottom: var(--gap); }
.tab-bar a, .tab-bar span { padding: 9px 16px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab-bar a:hover { color: var(--link); background: var(--sel-hover); text-decoration: none; }
.tab-bar a.is-active { color: var(--text); border-bottom-color: var(--sel); background: var(--sel-hover); }
.tab-bar .is-disabled { color: var(--text-3); font-weight: 500; cursor: default; }

/* Messages and empty states */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-line); }
.alert-error { background: var(--alarm-bg); border-color: var(--alarm-line); }
.alert-success { background: var(--surface); border-left: 3px solid var(--ok-ink); }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty .ic { font-size: var(--fs-hero); color: var(--line-strong); display: block; margin: 0 auto 8px; }

/* Style guide helpers */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.swatch i { display: block; height: 44px; }
.swatch span { display: block; padding: 5px 8px; font-size: var(--fs-sm); }
.swatch code { color: var(--text-2); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.icon-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); font-size: var(--fs-xs); color: var(--text-2); text-align: center; }
.icon-cell .ic { font-size: var(--fs-2xl); color: var(--text); }
.check-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.pill-list { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { display: inline-block; padding: 1px 7px; border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-sm); color: var(--text-2); background: var(--surface-2); }

/* Machines (step C2): photo next to the name in tables, and the machine page "hero" (photo + data list) */
.mono { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-sm); }
.mcell { display: flex; align-items: center; gap: 10px; }
.mthumb { flex: 0 0 auto; width: 44px; height: 33px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-3); overflow: hidden; }
.mthumb img { width: 100%; height: 100%; object-fit: cover; }
.mthumb .ic { width: 20px; height: 20px; }
.hero { display: grid; grid-template-columns: minmax(220px, 360px) 1fr; }
.hero-img { position: relative; background: var(--surface-2); min-height: 220px; display: flex; align-items: center; justify-content: center; }
.hero-img img { width: 100%; height: 100%; max-height: 320px; object-fit: cover; display: block; }
.hero-std { color: var(--text-3); }
.hero-std .ic { width: 96px; height: 96px; }
.hero-tag { position: absolute; left: 8px; bottom: 8px; font-size: var(--fs-xs); color: var(--text-2); background: var(--surface); border: 1px solid var(--line); padding: 2px 6px; }
.hero-info { padding: 14px 18px; }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 24px; margin: 0; }
.dl dt { font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.dl dd { margin: 2px 0 0; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } }
.mthumb-lg { width: 64px; height: 48px; }
.mthumb-lg .ic { width: 28px; height: 28px; }
.freebox { border-top: 1px solid var(--line); padding: 10px 14px; }
.freebox summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); }
.freerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--surface-2); }
.note-line { padding: 8px 14px; color: var(--text-2); font-size: var(--fs-sm); border-top: 1px solid var(--line); }

/* Panoramica (C4): titolo di sezione e una casella per macchina, colore + parola dello stato */
.section-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 0 0 6px; }
.tiles-group + .tiles-group { margin-top: 12px; }
.tiles-group h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tile { display: flex; flex-direction: column; min-width: 0; width: 170px; max-width: 100%; padding: 6px 10px;
        border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--r);
        background: var(--surface); color: var(--text); text-decoration: none; font-size: var(--fs-sm); }
.tile:hover { border-color: var(--text-3); }
.tile-name { font-weight: 600; overflow-wrap: anywhere; }
.tile-state { color: var(--text-2); font-size: var(--fs-xs); }
.tile.is-alarm { border-left-color: var(--alarm); background: var(--alarm-bg); }
.tile.is-warning { border-left-color: var(--warn); background: var(--warn-bg); }
.tile.is-offline { border-left: 4px dashed var(--offline); }
.tile.is-unknown { border-left-color: var(--info); }
.tile.is-ok { border-left-color: var(--ok); }
#watchTable td { white-space: normal; }
#watchTable td.nowrap { white-space: nowrap; }
@media (max-width: 760px) { .tile { width: calc(50% - 3px); } }

/* White label (WL1): logo del cliente accanto al marchio del partner, "Powered by", testo della pagina di accesso */
.sidebar-brand .client-logo { max-height: 28px; max-width: 140px; }
.powered-by { font-size: var(--fs-xs); color: var(--text-3); text-align: center; padding: 6px 0 2px; letter-spacing: .02em; }
.bare-intro { margin: 0 0 12px; text-align: center; }
.bare-intro p { margin: 4px 0 0; }

/* Ricerca veloce (C9, Ctrl+K) */
.qs-open kbd { font: 600 var(--fs-2xs) var(--font); color: var(--text-3); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 4px; }
@media (max-width: 900px) { .qs-open kbd, .qs-open .qs-label { display: none; } }
.qs { position: fixed; inset: 0; z-index: 1000; background: var(--overlay); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.qs[hidden] { display: none; }
.qs-box { width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.qs-form { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.qs-form input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: 15px var(--font); height: 30px; }
.qs-results { max-height: 55vh; overflow-y: auto; }
.qs-group { padding: 8px 14px 2px; font: 600 var(--fs-xs) var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.qs-item { display: flex; justify-content: space-between; gap: 12px; padding: 7px 14px; color: var(--text); text-decoration: none; cursor: pointer; }
.qs-item .sub { color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.qs-item:hover, .qs-item.is-active { background: var(--surface-2); text-decoration: none; }
.qs-msg { padding: 12px 14px; color: var(--text-3); }
.qs-foot { padding: 6px 14px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; font: inherit; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* M1: liste come il mockup: pallini di stato, barra della salute, quadrati per macchina, schede con conteggi, tabelle a gruppi */
:root { --learn: #2b3a7a; --ok-sq: #c9d1e6; }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; background: var(--line-strong); vertical-align: 0; flex: none; }
.s-alarm.dot, .sq.s-alarm, .hbar .s-alarm, .legend .s-alarm { background: var(--alarm); }
.s-warning.dot, .sq.s-warning, .hbar .s-warning, .legend .s-warning { background: var(--warn); }
.s-offline.dot, .sq.s-offline, .hbar .s-offline, .legend .s-offline { background: var(--offline); }
.s-unknown.dot, .sq.s-unknown, .hbar .s-unknown, .legend .s-unknown { background: var(--learn); }
.s-ok.dot, .s-online.dot { background: var(--ok); }
.sq.s-ok, .hbar .s-ok, .legend .s-ok { background: var(--ok-sq); }
.t-alarm { color: var(--alarm); font-weight: 600; }
.t-warning { color: var(--warn-ink); font-weight: 600; }
.hbar { display: flex; width: 110px; height: 7px; background: var(--ok-sq); margin: 4px 0 2px; }
.hbar span { display: block; height: 100%; }
.hcell .muted { font-size: var(--fs-sm); }
.banner { background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.banner strong { font-size: var(--fs-xl); }
.banner .hot { color: var(--alarm); }
.sq-groups { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.sq-group h3 { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; margin: 0 0 5px; }
.sqs { display: flex; gap: 4px; flex-wrap: wrap; }
.sq { display: block; width: 18px; height: 18px; background: var(--ok-sq); }
.sq:hover { outline: 2px solid var(--text-2); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-2); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
.count-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.count-tabs a { padding: 8px 12px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.count-tabs a:hover { color: var(--link); text-decoration: none; }
.count-tabs a.is-active { color: var(--link); border-bottom-color: var(--brand); }
.count-tabs .n { font-weight: 500; color: var(--text-3); margin-left: 6px; font-variant-numeric: tabular-nums; }
.tools-end { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; font-weight: 600; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.gtable { background: var(--surface); border: 1px solid var(--line); }
.gtable .grow-h, .gtable summary { display: grid; grid-template-columns: var(--gcols); align-items: center; gap: 8px 18px; padding: 8px 12px; }
.gtable .grow-h { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; border-bottom: 1px solid var(--line); }
.gtable details { border-bottom: 1px solid var(--line); }
.gtable details:last-child { border-bottom: 0; }
.gtable summary { list-style: none; cursor: pointer; }
.gtable summary::-webkit-details-marker { display: none; }
.gtable summary:hover { background: var(--sel-hover); }
.gtable summary .chev { display: inline-block; width: 14px; color: var(--text-3); transition: transform .15s; }
.gtable details[open] summary .chev { transform: rotate(90deg); }
.gtable details[open] summary { background: var(--sel-hover); }
.gtable .gin { padding: 0 12px 10px 34px; }
.gtable .gin .table { border: 1px solid var(--line); }
.gtable .r { text-align: right; }
.star { background: none; border: 0; padding: 0 4px 0 0; font-size: var(--fs-md); line-height: 1; color: var(--text-3); cursor: pointer; }
.star.is-on { color: var(--star); }
.edge-alarm { box-shadow: inset 3px 0 0 var(--alarm); }
.edge-warning { box-shadow: inset 3px 0 0 var(--warn); }
.edge-offline { box-shadow: inset 3px 0 0 var(--offline); }
.edge-unknown { box-shadow: inset 3px 0 0 var(--learn); }

/* M2: barra Indietro, testata macchina, parti */
.backbar { margin: 0 0 10px; }
.backbar .btn svg { width: 14px; height: 14px; }
.mhead { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--line); padding: 14px 16px; }
.mhead.edge-alarm { border-top-color: var(--alarm); } .mhead.edge-warning { border-top-color: var(--warn); }
.mhead.edge-offline { border-top-color: var(--offline); } .mhead.edge-unknown { border-top-color: var(--learn); }
.mhead h1 { margin: 0; font-size: var(--fs-xl); }
.mhead .mhead-r { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.mhead .since { font-size: var(--fs-sm); color: var(--text-3); text-align: right; margin-top: 2px; }
.parts { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: var(--fs-sm); }
.parts .part { display: inline-flex; align-items: center; gap: 2px; }
.todo-bar { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); padding: 8px 12px; margin-top: 10px; }
.todo-bar.s-alarm { border-left-color: var(--alarm); } .todo-bar.s-offline { border-left-color: var(--offline); } .todo-bar.s-unknown { border-left-color: var(--learn); }
@media (max-width: 720px) { .mhead { flex-wrap: wrap; } .mhead .mhead-r { width: 100%; justify-content: flex-start; } }

/* S1-S4 (13/11): stile del mockup rifinito. Titolo con icona, riquadri KPI con quadrato colorato, testate dei pannelli,
   tabelle con intestazione fissa, stati come pillole, fuoco visibile, telefono e tablet. */
.page-h h1 { display: flex; align-items: center; gap: 8px; }
.page-h h1 .ic { color: var(--brand); font-size: var(--fs-lg); }
.card-h .muted, .card-h > span, .card-h > a { font-size: var(--fs-xs); }
.card-h h2 .ic, .card-h h3 .ic { vertical-align: -0.2em; margin-right: 4px; }
.banner strong { font-weight: 700; }

.kpi.st-tile { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.st-tile .st-i { width: 36px; height: 36px; display: grid; place-items: center; flex: none; background: var(--brand-bg); color: var(--brand); }
.st-tile .st-i .ic { font-size: var(--fs-lg); }
.st-tile.s-alarm .st-i { background: var(--alarm-bg); color: var(--alarm); }
.st-tile.s-warning .st-i { background: var(--warn-bg); color: var(--warn); }
.st-tile.s-offline .st-i { background: var(--offline-bg); color: var(--offline); }
.st-tile.s-ok .st-i { background: var(--ok-bg); color: var(--ok); }
.st-tile .st-t { display: flex; flex-direction: column; min-width: 0; }
.st-tile .label { font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.st-tile .value { font-size: var(--fs-2xl); font-weight: 900; line-height: 1.15; }
.st-tile .st-s { font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); }
.st-tile.is-alarm .value { color: var(--alarm); }

/* tabelle: intestazione che resta in vista, righe cliccabili, numeri allineati */
.table-wrap { max-width: 100%; }
.table-wrap.is-tall { max-height: min(62vh, 560px); overflow: auto; }
.table thead th { position: sticky; top: 0; z-index: 1; box-shadow: inset 0 -1px 0 var(--line); }
.table td { font-size: var(--fs-sm); }
.table td.mono, .mono { font-family: var(--mono); }

/* badge di stato come le pillole del mockup (icona + parola + colore restano) */
.badge { height: 20px; padding: 0 8px; border-radius: 20px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge .ic { font-size: var(--fs-sm); }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge-warning { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge-alarm { color: var(--alarm); background: var(--alarm-bg); border-color: transparent; }
.badge-info { color: var(--brand); background: var(--brand-bg); border-color: transparent; }
.badge-offline { color: var(--offline); background: var(--offline-bg); border: 0; }
.card-h .badge { background: rgba(255,255,255,.15); color: #fff; }

/* pulsanti e campi: stessa altezza, fuoco arancione visibile, contrasto AA */
.btn { transition: background .15s, border-color .15s, color .15s; }
.btn-primary:focus-visible { outline-offset: 2px; }
button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }
.input:focus-visible { outline: 2px solid var(--sel); outline-offset: 0; }

/* skeleton di caricamento e messaggio breve (toast) */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--skel-hi) 37%, var(--surface-2) 63%); background-size: 400% 100%; min-height: 12px; }
@media (prefers-reduced-motion: no-preference) { .skel { animation: skel 1.3s ease infinite; } }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.toast-zone { position: fixed; right: 16px; bottom: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast-zone .alert { box-shadow: var(--pop-shadow); }

/* tablet */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tab-bar, .count-tabs, .tabs { scrollbar-width: thin; }
  .table .hide-md { display: none; }
}
/* telefono: tocchi da 40px, riquadri KPI a due colonne, testate che vanno a capo */
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi.st-tile { padding: 9px 10px; gap: 8px; }
  .st-tile .st-i { width: 30px; height: 30px; }
  .st-tile .value { font-size: var(--fs-xl); }
  .btn { height: 38px; padding: 0 14px; }
  .btn-sm { height: 34px; }
  .input, select.input { height: 40px; font-size: var(--fs-lg); }
  .nav-item { padding: 11px 16px; }
  .tab-bar a, .tab-bar span, .count-tabs a { padding: 11px 12px; }
  .page-h { padding: 9px 12px; }
  .page-h .grow { min-width: 0; flex-basis: 100%; }
  .card-h { padding: 9px 12px; }
  .card-b { padding: 12px; }
  .table .hide-sm { display: none; }
  .table th, .table td { padding: 8px; }
  .banner strong { font-size: var(--fs-lg); }
  .hero-info { padding: 12px; }
  .mhead { padding: 12px; }
  .mhead h1 { font-size: var(--fs-xl); }
  .gtable .grow-h { display: none; }
  .gtable summary { grid-template-columns: 14px minmax(0, 1fr); }
  .table-tools { flex-wrap: wrap; }
  .table-tools > .input, .table-tools > select.input { flex: 1 1 100%; max-width: none !important; }
  .table-tools .tools-end { margin-left: 0; flex-wrap: wrap; width: 100%; }
  .gtable summary > :nth-child(n+3) { display: none; }
  .gtable .gin { padding: 0 8px 8px; }
  .gtable .gin .table-wrap, .gtable .gin { overflow-x: auto; }
}

/* D8a/D9a: barra "Leggi dal router" / "Avvia scansione", aggiungi un dispositivo nella riga */
.net-run { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.input.input-sm { height: 26px; width: 150px; font-size: var(--fs-sm); }
@media (max-width: 640px) { .inline-form { flex-wrap: wrap; } .input.input-sm { height: 36px; width: 100%; } }

/* D10a: visore VNC in sola visione */
.vnc-card { background: #111827; }
.vnc-screen { width: 100%; height: min(72vh, 820px); overflow: hidden; }
.vnc-screen canvas { cursor: default !important; }
/* B3 (16/11): terminale SSH */
.term-card { background: #0b0f17; }
.term-box { height: min(72vh, 820px); overflow-y: auto; padding: 8px; outline: none; }
.term-box:focus { box-shadow: inset 0 0 0 2px var(--brand, #3b82f6); }
.term-view { margin: 0; color: #e5e5e5; font: 14px/1.25 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre; }
.term-view [data-b] { font-weight: 700; }
.term-cur { background: #e5e5e5 !important; color: #0b0f17 !important; }
.term-probe { position: absolute; visibility: hidden; font: 14px/1.25 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre; }

/* D4 (13/11): anteprima delle modifiche al router */
.cmd-preview { margin: 0 0 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  font-size: var(--fs-sm); line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.steps-list { margin: 0 0 14px; padding-left: 20px; color: var(--text-2); font-size: var(--fs-base); }
.switch-card .card-b { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Scheda Dispositivi della macchina, come il mockup (secCards): Sensore, Router, PLC · OPC-UA */
.sec-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.sec-card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand); box-shadow: var(--shadow);
  padding: 11px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sec-card.off { border-left-color: var(--line); }
.sec-h { display: flex; align-items: center; gap: 7px; font-size: var(--fs-md); }
.sec-h .ic { color: var(--text-2); }
.sec-h .sp, .sec-a .grow { flex: 1; }
.sec-a { display: flex; align-items: center; gap: 10px; font-size: var(--fs-base); }
.st-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.st-pill .pd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pill.ok { color: var(--text-2); border: 1px solid var(--line); }
.st-pill.ok .pd { background: var(--ok); }
.st-pill.bad { color: var(--alarm); background: var(--alarm-bg, #fdecec); }
.tag { display: inline-block; font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--line); padding: 1px 6px; color: var(--text-2);
  background: var(--surface); white-space: nowrap; }
.nowrap { white-space: nowrap; }
/* pulsante dentro la testata blu di un pannello (es. "+ Nuovo sensore") */
.card-h .btn-onbrand { margin-left: auto; background: transparent; border-color: transparent; color: #fff; }
.card-h .btn-onbrand:hover { background: rgba(255,255,255,.12); }

/* sedi: aggiungi chiuso finché non si preme Nuova sede (come il mockup) */
.addbox > summary { cursor: pointer; list-style: none; }
.addbox > summary::-webkit-details-marker { display: none; }
.addbox:not([open]) > summary { border-bottom: 0; }

/* tabella Campo / Valore (router, come il mockup) */
.table.kv td:first-child { color: var(--text-2); width: 38%; white-space: nowrap; }

/* ---- UI1 (16/11): tema, densità, numeri, vivo, pannello laterale, grafici ---- */
.dd-group { padding: 6px 12px; border-top: 1px solid var(--line); }
.dd-label { display: block; font-size: var(--fs-xs); color: var(--text-2); margin-bottom: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); }
.seg button { border: 0; background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); padding: 3px 8px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.dd-check { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); cursor: pointer; }
/* numeri allineati in tutte le tabelle; unità in grigio */
.table td, .kpi .value, .num { font-variant-numeric: tabular-nums; }
.unit { color: var(--text-3); font-size: .9em; margin-left: 2px; }
:root.dense .table th { padding-top: 5px; padding-bottom: 5px; }
/* segno "vivo": verde che pulsa piano; grigio se la pagina non riesce più ad aggiornarsi */
.live-mark { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--text-2); }
.live-mark::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: live-pulse 2s ease-in-out infinite; }
.live-mark.is-stale::before { background: var(--offline); animation: none; }
[data-ago].is-stale { color: var(--warn-ink); }
@keyframes live-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-mark::before, .skel { animation: none !important; } }
/* pannello laterale */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); z-index: 900; background: var(--bg);
  border-left: 1px solid var(--line-strong); box-shadow: var(--pop-shadow); display: flex; flex-direction: column; }
.drawer[hidden] { display: none; }
.drawer-h { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-open { margin-right: auto; font-weight: 600; font-size: var(--fs-sm); }
.drawer-b { overflow-y: auto; padding: 12px; flex: 1; }
.drawer-b .content { padding: 0; }
@media (max-width: 700px) { .drawer { width: 100vw; } }
/* grafici SVG (sparkline, banda di stato): colori dai token, quindi giusti anche nel tema scuro */
.spark { display: inline-block; vertical-align: middle; overflow: visible; }
.spark .ln { fill: none; stroke: var(--ch-line); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .ar { fill: var(--ch-line); opacity: .1; }
.spark .last { fill: var(--ch-line); }
.sband { display: block; width: 100%; height: 14px; }
.sband rect { shape-rendering: crispEdges; }
.sband .run { fill: var(--ch-run); } .sband .stop { fill: var(--ch-stop); } .sband .off { fill: var(--ch-off); }
.sband .unk { fill: var(--ch-unk); } .sband .warn { fill: var(--warn); } .sband .alarm { fill: var(--ch-alarm); } .sband .bg { fill: var(--surface-2); }
.sband-axis { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.sband-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--text-2); margin-top: 6px; }
.sband-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px; }
.sband-legend .run { background: var(--ch-run); } .sband-legend .stop { background: var(--ch-stop); } .sband-legend .off { background: var(--ch-off); }
.sband-legend .unk { background: var(--ch-unk); } .sband-legend .warn { background: var(--warn); } .sband-legend .alarm { background: var(--ch-alarm); }
/* terminale e VNC restano scuri in tutti e due i temi */
:root[data-theme="dark"] .term-card, :root[data-theme="dark"] .vnc-card { border-color: var(--line); }
@media print { .drawer, .toast-zone, .live-mark { display: none !important; } }


/* ---- UI2 (16/11): aiuto, telefono ---- */
.help h2 { font-size: var(--fs-md); margin: 4px 0 8px; }
.help h2 + p, .help p { margin: 0 0 10px; line-height: 1.55; }
.help ul { margin: 0 0 12px; padding-left: 18px; line-height: 1.55; }
.phonebar { display: none; }
@media (max-width: 700px) {
  .phonebar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface);
    border-top: 1px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom); }
  .phonebar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; font-size: var(--fs-xs);
    color: var(--text-2); text-decoration: none; min-width: 0; }
  .phonebar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .phonebar a .ic { font-size: var(--fs-xl); }
  .phonebar a.is-active { color: var(--link); box-shadow: inset 0 2px 0 var(--link); }
  .content { padding-bottom: 80px !important; }
  /* dita, non mouse: bottoni e link delle tabelle più grandi */
  .btn, .btn-sm { min-height: 40px; }
  .table td a, .table td .linkbtn { display: inline-block; padding: 6px 0; }
  .input, select.input { min-height: 40px; font-size: var(--fs-lg); }   /* 16px: iPhone non ingrandisce la pagina */
  .page-h { flex-wrap: wrap; gap: 8px; }
  .page-h h1 { font-size: var(--fs-xl); }
  .qs-open kbd, .qs-open .qs-label { display: none; }
  .drawer { top: 0; bottom: 0; }
  .toast-zone { bottom: 72px; }
}
@media (max-width: 700px) and (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); } }
@media print { .phonebar { display: none !important; } }
/* ---- UI2: pagina di accesso con il marchio del partner ---- */
.bare-card > .card { border-top: 3px solid var(--brand); }
.bare-logo { max-height: 44px; max-width: 220px; display: block; }
.bare-brand { justify-content: center; }

/* ---- UI3 (16/11): striscia allarme -> intervento ---- */
.flow { display: flex; list-style: none; margin: 0; padding: 0; gap: 0; flex-wrap: wrap; }
.flow-s { flex: 1 1 110px; min-width: 0; padding: 6px 10px 6px 12px; border-top: 3px solid var(--line); position: relative; display: flex; flex-direction: column; gap: 1px; }
.flow-s::before { content: ""; position: absolute; top: -6.5px; left: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.flow-s.is-done { border-top-color: var(--ok); } .flow-s.is-done::before { background: var(--ok); border-color: var(--ok); }
.flow-s.is-now { border-top-color: var(--warn); } .flow-s.is-now::before { background: var(--warn); border-color: var(--warn); }
.flow-s.is-skip { border-top-style: dashed; } .flow-s.is-skip .flow-t { color: var(--text-3); font-style: italic; }
.flow-l { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-top: 4px; }
.flow-t { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-d { font-size: var(--fs-xs); color: var(--text-3); }
.flow-s.is-todo .flow-t { color: var(--text-3); }

/* ---- UI4 (16/11): ritocchi visti in Chrome ---- */
:root { --learn-ink: var(--learn); --danger-bg: var(--alarm); }
.btn-danger { background: var(--danger-bg); border-color: var(--danger-bg); color: #fff; }
.btn-danger:hover { background: var(--danger-bg); }
.st-tile.s-unknown .st-i { background: var(--info-bg); color: var(--learn-ink); }
.qs-open kbd { white-space: nowrap; }
@media (max-width: 1360px) { .qs-open kbd { display: none; } }
@media (min-width: 1100px) { .kpis.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.setup-line details > summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; cursor: pointer; list-style: none; }
.setup-line details > summary::-webkit-details-marker { display: none; }
.setup-line .setup-n { font-variant-numeric: tabular-nums; color: var(--text-2); }
.setup-line .setup-bar { width: 90px; height: 6px; background: var(--surface-2); display: inline-block; }
.setup-line .setup-bar i { display: block; height: 100%; background: var(--ok); }
.setup-line .setup-next { flex: 1; min-width: 180px; }
.setup-line .setup-more { font-size: var(--fs-sm); text-decoration: underline; }
.setup-line details[open] .setup-more { display: none; }
.setup-line details[open] > summary { border-bottom: 1px solid var(--line); }
.list-meta { margin-left: auto; display: inline-flex; align-items: center; gap: 16px; }
.drawer-title { margin-right: auto; font-size: var(--fs-md); }
.drawer-open[hidden], .drawer-title[hidden] { display: none; }
/* ==== UI5 (16/11): look «moderno ma calmo»: angoli morbidi, ombre leggere, accento di stato, focus chiaro ==== */
.ic.ic-line { fill: none; stroke: currentColor; }

/* pannelli */
.card { border-radius: var(--r-card); border-color: var(--line); box-shadow: var(--shadow); }
.card > .card-h:first-child { border-radius: calc(var(--r-card) - 1px) calc(var(--r-card) - 1px) 0 0; }
.card > .card-h:first-child { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff) 0%, var(--brand) 100%); }
.card > .card-h h2 .ic, .card > .card-h h3 .ic { width: 15px; height: 15px; opacity: .9; }
.card > :last-child:not(.card-h) { border-bottom-left-radius: calc(var(--r-card) - 1px); border-bottom-right-radius: calc(var(--r-card) - 1px); }
.card-h :focus-visible { outline-color: #fff; }

/* testata della pagina: striscia con sfumatura del marchio */
.page-h { border-radius: var(--r-card); background: linear-gradient(100deg, var(--brand-bg) 0%, var(--surface) 60%); border-color: var(--line); }
.page-h h1 .ic { width: 28px; height: 28px; padding: 6px; border-radius: 8px; background: var(--brand); color: var(--on-brand); box-sizing: border-box; }

/* menu a sinistra: voce attiva a pillola */
.nav-item { margin: 1px 8px; border-radius: 8px; border-left: 0; padding-left: 10px; transition: background .15s, color .15s; }
.nav-item.is-active { box-shadow: inset 3px 0 0 var(--sel); }
.side-collapsed .nav-item { margin: 1px 6px; }
.nav-item .ic { width: 18px; height: 18px; }

/* controlli */
.btn { border-radius: var(--r); }
.btn-primary { box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.input, select.input, textarea.input { border-radius: var(--r); border-color: var(--input-line); }
.badge { border-radius: 999px; }
.tabs a, .tab-bar a { border-radius: 6px 6px 0 0; }
.table tbody tr { transition: background .12s; }
.mthumb, .mthumb-lg { border-radius: 8px; }

/* focus da tastiera: un solo anello, ben visibile in chiaro e in scuro */
a:focus-visible, button:focus-visible, summary:focus-visible, select:focus-visible, textarea:focus-visible,
input:focus-visible, [tabindex]:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .sq:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: none; }
.input:focus-visible { outline-offset: 1px; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 2000; background: var(--surface); color: var(--link); padding: 8px 14px;
  border: 2px solid var(--focus); border-radius: var(--r); font-weight: 600; }
.skip-link:focus { top: 8px; }

/* grafico Allarmi per giorno */
.daybars { position: relative; }
.db-svg { display: block; width: 100%; height: auto; max-height: 230px; overflow: visible; }
.db-grid { stroke: var(--ch-grid); stroke-width: 1; }
.db-base { stroke: var(--line-strong); stroke-width: 1; }
.db-ax { fill: var(--text-2); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.db-hit { fill: transparent; }
.db-bar { outline: none; }
.db-bar.is-on .db-hit, .db-bar:focus-visible .db-hit { fill: var(--row-hover); }
.db-bar:focus-visible .db-hit { stroke: var(--focus); stroke-width: 2; }
.db-high { fill: var(--ch-alarm); } .db-medium { fill: var(--warn); } .db-low { fill: var(--info); }
.legend i.db-high { background: var(--ch-alarm); } .legend i.db-medium { background: var(--warn); } .legend i.db-low { background: var(--info); }
.legend i { border-radius: 3px; }
.db-tip { position: absolute; transform: translate(-50%, calc(-100% - 8px)); background: var(--text); color: var(--bg); font-size: var(--fs-xs);
  font-weight: 500; padding: 5px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none; box-shadow: var(--pop-shadow); z-index: 5; }
.db-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 16px; flex-wrap: wrap; margin-top: 4px; }
.db-foot .legend { margin-top: 6px; }
.db-table > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--link); padding: 4px 0; }
.db-table[open] { flex-basis: 100%; }
.db-table .table { margin-top: 6px; }
.chart-empty { margin: 6px 0 2px; }
.band-title { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 3px; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.note-sm { font-size: var(--fs-xs); margin: 0; }

/* le mie viste + colonne */
.views-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 10px; }
.views-label { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); }
.view-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 2px 0 10px; border: 1px solid var(--line-strong);
  border-radius: 999px; background: var(--surface); font-size: var(--fs-sm); }
.view-chip a { color: var(--text); }
.view-chip.is-on { border-color: var(--brand); background: var(--brand-bg); }
.view-chip form { display: inline; }
.chip-x { border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: var(--fs-md); line-height: 1; padding: 2px 6px; border-radius: 999px; }
.chip-x:hover { background: var(--surface-2); color: var(--alarm); }
.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-b { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 250px; display: flex; flex-direction: column; gap: 7px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--pop-shadow); padding: 12px; }
.cols-slot { margin-left: auto; }
.cols-pop .pop-b { left: auto; right: 0; }
.check { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .nav-item, .table tbody tr { transition: none; }
}
/* ==== 16/11: angoli a 90 gradi su tutto (pannelli, tabelle, bottoni, campi, badge, schede, riquadri, grafici).
   Restano tondi solo i pallini di stato (puntino «in diretta», pallini dei passi e delle pillole). ==== */
*, *::before, *::after { border-radius: 0 !important; }
.live-mark::before, .flow-s::before, .st-pill .pd { border-radius: 50% !important; }
.daybars rect { rx: 0; ry: 0; }
/* ==== D2 (16/11): stato della macchina dal sensore (banda di oggi, Gantt 7 giorni, durate) ==== */
.vstate.is-next { border-top: 1px solid var(--line); }
.vstate-h { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.vnow { font-size: var(--fs-md); }
.vhint { margin: -4px 0 10px; }
.vgap { margin-top: 14px; }
.vband { display: block; width: 100%; height: 16px; }
.vband.is-small { height: 12px; }
.vband rect { shape-rendering: crispEdges; }
.vband .bg { fill: var(--surface-2); }
.vband .now { stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.vband .st-1, .vlegend .st-1, .vkey.st-1 { fill: var(--st-1); background: var(--st-1); }
.vband .st-2, .vlegend .st-2, .vkey.st-2 { fill: var(--st-2); background: var(--st-2); }
.vband .st-3, .vlegend .st-3, .vkey.st-3 { fill: var(--st-3); background: var(--st-3); }
.vband .st-4, .vlegend .st-4, .vkey.st-4 { fill: var(--st-4); background: var(--st-4); }
.vband .st-5, .vlegend .st-5, .vkey.st-5 { fill: var(--st-5); background: var(--st-5); }
.vband .st-6, .vlegend .st-6, .vkey.st-6 { fill: var(--st-6); background: var(--st-6); }
.vband .nt, .vlegend .nt, .vkey.nt { fill: var(--ch-unk); background: var(--ch-unk); }
.vband .off, .vlegend .off, .vkey.off { fill: var(--ch-off); background: var(--ch-off); }
.vlegend .none, .vkey.none { background: var(--surface-2); outline: 1px solid var(--line); outline-offset: -1px; }
.vgantt { display: flex; flex-direction: column; gap: 4px; }
.vg-row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; }
.vg-day { font-size: var(--fs-xs); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vlegend { margin: 8px 0 10px; }
.vkey { display: inline-block; width: 10px; height: 10px; margin-right: 7px; vertical-align: -1px; }
.vdur { border: 0; margin-bottom: 6px; }
/* ==== D3 (16/11): anomalie e apprendimento ==== */
.vband .ok, .vlegend .ok { fill: var(--ok); background: var(--ok); }
.vband .warn, .vlegend .warn { fill: var(--warn); background: var(--warn); }
.vband .alarm, .vlegend .alarm { fill: var(--ch-alarm); background: var(--ch-alarm); }
.vband .learn, .vlegend .learn { fill: var(--ch-unk); background: var(--ch-unk); }
.anow { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; }
.alarm-reason { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--text-2); max-width: 90ch; }
.vprog { height: 8px; background: var(--surface-2); border: 1px solid var(--line); margin: 2px 0 4px; max-width: 320px; }
.vprog > i { display: block; height: 100%; background: var(--brand); }
.vprog.is-small { height: 6px; width: 140px; margin: 0; }
.vstat { display: grid; grid-template-columns: minmax(90px, auto) 140px auto; align-items: center; gap: 4px 10px; margin: 2px 0; }
/* ==== D4 (16/11): colpi al minuto ==== */
.vline { display: grid; grid-template-columns: 34px 1fr; gap: 6px; }
.vline-y { display: flex; flex-direction: column; justify-content: space-between; text-align: right; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; line-height: 1; }
.vline svg { display: block; width: 100%; height: 180px; }
.vline .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.vline path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.vline .s-bpm { stroke: var(--st-1); }
.vline .s-plc { stroke: var(--st-4); }
.vline .now { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.vline .hit { fill: transparent; }
.vline .hit:hover { fill: var(--text); fill-opacity: .06; }
.vline-x { margin-left: 40px; }
.vline-x.is-days span { flex: 1; text-align: center; }
.vlegend .k-bpm { background: var(--st-1); height: 3px; }
.vlegend .k-plc { background: var(--st-4); height: 3px; }
/* ==== Moduli a sezioni (16/11): la griglia riempie la pagina ==== */
.fsec { margin-bottom: var(--gap); }
.fsec-err { margin-bottom: var(--gap); }
.fsec-note { margin: 0 0 10px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 18px; align-items: start; }
.fgrid .field { margin-bottom: 8px; min-width: 0; }
.fgrid .field.wide { grid-column: 1 / -1; }
.fgrid .field .input { width: 100%; }
.fgrid .field label .req, .fgrid .field-label .req { color: var(--alarm); margin-left: 3px; }
.fgrid .field-label { font-weight: 500; font-size: var(--fs-base); }
.fgrid .field.has-error .input { border-color: var(--alarm); }
.fgrid .fcheck { margin-top: 26px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.form-actions { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 8px; align-items: center; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line); margin-top: var(--gap); }
.form-actions .muted { margin-left: auto; }
.form-page { max-width: 1280px; }
.page-h .page-back { margin-left: auto; align-self: center; }

/* 16/11: logo del cliente nella lista Clienti e nella scheda cliente (stessa larghezza, righe allineate) */
.client-name { display: inline-flex; align-items: center; gap: 8px; }

/* 16/11: tabelle della scheda cliente con colonne fisse (niente colonne larghissime e vuote) */
.table-fixed { table-layout: fixed; width: 100%; }
.table-fixed td, .table-fixed th { overflow-wrap: anywhere; }
.sites-table .c-site { width: 28%; }
.sites-table .c-plant { width: 22%; }
.sites-table .c-zone { width: auto; }
.sites-table .c-num { width: 110px; }
.sites-table .c-router { width: 22%; }
.cell-line { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cell-line form { display: inline; }
.table.kv-narrow td:first-child { width: 220px; }
@media (max-width: 640px) { .table-fixed { table-layout: auto; } }
.logo-history { display: flex; flex-wrap: wrap; gap: 12px; }
.logo-history .lh { border: 1px solid var(--line); padding: 8px; width: 170px; display: flex; flex-direction: column; gap: 6px; }
.logo-history .lh img { height: 40px; width: 100%; object-fit: contain; background: var(--logo-bg); }
.logo-history .lh.is-current { border-color: var(--brand); }

/* 16/11: tabella macchine con larghezze stabili, come le altre tabelle formali (Sedi, Panoramica) */
.mtable th.c-star { width: 36px; }
.mtable th.c-name { width: 28%; }
.mtable th.c-where { width: 20%; }
.mtable th.c-state { width: 14%; }
.mtable th.c-24h { width: 10%; }
.mtable th.c-last { width: 110px; }
.mtable .mcell { min-height: 33px; }
.tools-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.tools-row > .table-tools { flex: 1 1 520px; margin: 0; }
.tools-row > .views-bar { margin: 0; }

/* 16/11: finestra "+ Nuova sede / stabilimento / zona": una card come nelle pagine, sopra la pagina */
dialog.qdlg { padding: 0; border: 0; width: min(480px, calc(100vw - 32px)); background: transparent; color: var(--text); }
dialog.qdlg::backdrop { background: rgba(0, 0, 0, .45); }
dialog.qdlg .card { margin: 0; }
dialog.qdlg .card-b { display: flex; flex-direction: column; gap: 10px; }
.qdlg-x { background: none; border: 0; color: var(--on-brand); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.qdlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
select option.opt-new { font-weight: 700; }
dialog.qdlg [hidden] { display: none !important; }

/* 16/11: ogni tabella dentro una card ha un'altezza massima e scorre dentro, con l'intestazione ferma in alto e una
   barra di scorrimento sottile dello stesso blu della barra della card. Panoramica (.no-cap) resta com'era. */
.card .table-wrap { max-height: min(68vh, 640px); overflow: auto; }
.no-cap .card .table-wrap, .card .table-wrap.no-cap { max-height: none; }
.table-wrap { scrollbar-width: thin; scrollbar-color: var(--brand) transparent; }
.table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--brand); }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-corner { background: transparent; }
@media print { .card .table-wrap { max-height: none; overflow: visible; } }

/* 17/11: Allenamento stati (come la pagina del sensore su iot.box4ai) */
.tr-grid { align-items: flex-start; }
.tr-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tr-top h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-lg, 18px); }
.tr-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tr-selected { line-height: 1.6; }
.tr-selected .ic { width: 14px; height: 14px; vertical-align: -2px; }
tr.is-selected td { background: var(--brand-bg); }
.tr-box { display: grid; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.tr-title, .tr-lbl { font-weight: 600; }
.tr-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tr-scard { display: grid; gap: 4px; text-align: left; padding: 10px; border: 1px solid var(--line); background: var(--surface, transparent); color: inherit; cursor: pointer; font: inherit; }
.tr-scard:hover { border-color: var(--ink-2, var(--line)); }
.tr-scard.is-active { border-color: var(--brand, var(--ok)); box-shadow: inset 3px 0 0 var(--brand, var(--ok)); }
.tr-sname { font-weight: 700; }
.tr-sstate { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.tr-smin { font-size: var(--fs-xs, 11px); }
.tr-led { width: 9px; height: 9px; background: var(--alarm); display: inline-block; flex: none; }
.tr-led.is-ok { background: var(--ok); }
.tr-help { font-size: var(--fs-sm); }
.tr-inrow { display: flex; gap: 8px; align-items: center; }
.tr-inrow .input { flex: 1; min-width: 0; }
.tr-inrow[hidden] { display: none; }
.tr-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.tr-btns .btn { justify-content: center; }
.tr-op { display: grid; gap: 4px; font-size: var(--fs-sm); }
.tr-op .ic, .tr-align .ic { width: 14px; height: 14px; vertical-align: -2px; }
.tr-run { padding: 8px 10px; border-left: 3px solid var(--ok); background: var(--ok-bg); }
.tr-ok { color: var(--ok); }
.tr-err { color: var(--alarm); }
.tr-note { display: flex; gap: 6px; align-items: flex-start; font-size: var(--fs-sm); color: var(--warn-ink); }
.tr-note .ic { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.tr-custom { padding: 14px 0; border-bottom: 1px solid var(--line); }
.tr-custom h3, .tr-loghdr h3 { margin: 0 0 8px; font-size: var(--fs-md, 14px); }
.tr-custom ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tr-custom li { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; border: 1px solid var(--line); }
.tr-custom li.muted { border: 0; padding: 0; }
.tr-loghdr { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 14px; flex-wrap: wrap; }
.tr-rbtns { display: flex; gap: 6px; align-items: center; }
.tr-align { color: var(--ok); font-size: var(--fs-sm); }
.tr-log { margin-top: 8px; max-height: 320px; overflow: auto; }
.trc { position: relative; }
.trc-svg { width: 100%; height: auto; display: block; }
.trc-grid { stroke: var(--line); stroke-width: 1; }
.trc-axis { stroke: var(--line-strong, var(--line)); stroke-width: 1; }
.trc-yt { font-size: 10px; text-anchor: end; fill: currentColor; opacity: .7; }
.trc-xt { font-size: 10px; text-anchor: end; fill: currentColor; opacity: .7; }
.trc-title { font-size: 11px; fill: currentColor; opacity: .75; text-anchor: middle; }
.trc-bar { cursor: default; }
.trc-bar .st-1 { fill: var(--st-1); }
.trc-bar .st-2 { fill: var(--st-2); }
.trc-bar .st-3 { fill: var(--st-3); }
.trc-bar .st-4 { fill: var(--st-4); }
.trc-bar .st-5 { fill: var(--st-5); }
.trc-bar .st-6 { fill: var(--st-6); }
.trc-bar .nt { fill: var(--ch-unk); } .trc-bar .off { fill: var(--ch-off); } .trc-bar .none { fill: var(--surface-2); }
.trc-bar rect { stroke: var(--surface); stroke-width: 1; }
.trc-bar:hover rect, .trc-bar.is-hover rect { opacity: .82; }
.trc-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--line-strong, var(--line)); padding: 6px 8px; font-size: var(--fs-sm); white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.trc-tip div:first-child { font-weight: 700; margin-bottom: 2px; }
.trc-empty { padding: 40px 0; text-align: center; }
.tr-sens { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.tr-sen { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); color: inherit; text-decoration: none; }
.tr-sen:hover { border-color: var(--brand); background: var(--brand-bg); }
.tr-sen.is-active { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); background: var(--brand-bg); }
.tr-sen-h { display: flex; align-items: center; gap: 6px; }
.tr-sen-sel { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs, 11px); color: var(--brand); font-weight: 600; }
.tr-sen-sel .ic { width: 12px; height: 12px; }
.tr-sen-l { font-size: var(--fs-sm); }
.trb-legend { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
@media (max-width: 720px) { .tr-cards { grid-template-columns: 1fr; } .tr-stats { grid-template-columns: 1fr; } }

/* 17/11 comandi dell'apprendimento e tipo BPM */
.lc-block { border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.lc-row { gap: 8px; flex-wrap: wrap; align-items: center; }
.lc-row select.input { width: auto; min-width: 220px; }
.lc-lbl { font-weight: 600; }
.lc-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.lc-grid label { display: grid; gap: 4px; font-weight: 600; }
.lc-confirm { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px; border: 1px solid var(--warn-line); background: var(--warn-bg); }
@media (max-width: 720px) { .lc-grid { grid-template-columns: 1fr; } }
.tr-pick { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin-bottom: 10px; }
.tr-pick select { grid-column: 1 / -1; }
.tr-sen-one { padding: 6px 10px; border: 1px solid var(--brand); box-shadow: inset 3px 0 0 var(--brand); background: var(--brand-bg); font-size: var(--fs-sm); line-height: 1.5; }
.tr-pick-sum { margin-top: 8px; font-size: var(--fs-sm); }
@media (max-width: 720px) { .tr-pick { grid-template-columns: 1fr; } }
.tr-pickrow { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 10px; align-items: start; }
.tr-pickrow > :only-child { grid-column: 1 / -1; }
.tr-pickcli, .tr-picksen { display: grid; gap: 4px; }
.tr-sentbl { max-height: 200px; overflow: auto; }
.tr-sentbl td { padding-top: 6px; padding-bottom: 6px; }
.tr-sentbl a { color: inherit; text-decoration: none; }
.tr-sen-one { margin-top: 10px; }
.tr-sen-one .ic { width: 14px; height: 14px; vertical-align: -2px; }
@media (max-width: 720px) { .tr-pickrow { grid-template-columns: 1fr; } }
.mon-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.mon-per { display: flex; gap: 6px; flex-wrap: wrap; margin-right: auto; }
.mon-lbl { font-size: var(--fs-sm); font-weight: 600; }
.mon-bar .mon-sel { width: auto; flex: 0 1 320px; min-width: 240px; }
.mon-tbl td:nth-child(2) { white-space: nowrap; }
.mon-tbl { border: 0; max-height: 360px; overflow: auto; }
.mon-fold > summary { list-style: none; cursor: pointer; flex-wrap: wrap; gap: 4px 12px; }
.mon-fold > summary::-webkit-details-marker { display: none; }
.mon-fold > summary .chev { display: inline-block; width: 14px; transition: transform .15s; }
.mon-fold[open] > summary .chev { transform: rotate(90deg); }
.mon-fold:not([open]) > summary { border-bottom: 0; }
.mon-link { padding-top: 6px; padding-bottom: 0; text-align: right; }
@media (max-width: 720px) { .mon-bar .mon-sel { min-width: 0; flex: 1 1 100%; } }
.mon-per { align-items: center; }
.mon-dates { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mon-dates[hidden] { display: none; }
.mon-dates .input { width: auto; padding-top: 4px; padding-bottom: 4px; }
/* 17/11 Anomalie: schede interne, semaforo, configurazione guidata */
.an-sub { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.an-sub a { padding: 8px 14px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); border-bottom: 2px solid transparent; white-space: nowrap; }
.an-sub a:hover { color: var(--text); }
.an-sub a.is-active { color: var(--text); border-bottom-color: var(--brand); }
.an-count { display: inline-block; min-width: 18px; padding: 0 5px; background: var(--brand); color: var(--on-brand); font-size: var(--fs-2xs); text-align: center; }
.an-light { border: 1px solid var(--line); border-left: 6px solid var(--text-3); padding: 12px 14px; display: grid; gap: 6px; }
.an-light p { margin: 0; }
.an-light.is-ok { border-left-color: var(--ok); }
.an-light.is-warn { border-left-color: var(--warn); }
.an-light.is-alarm { border-left-color: var(--alarm); }
.an-light.is-learn { border-left-color: var(--brand); }
.an-big { font-size: 1.15rem; font-weight: 700; }
.an-bar { height: 8px; background: var(--sel-hover); max-width: 420px; }
.an-bar i { display: block; height: 100%; background: var(--brand); }
.an-changes { margin: 0; padding-left: 18px; }
.an-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: var(--fs-sm); align-items: center; }
.an-who { margin-top: 6px; color: var(--text-2); }
.an-ans { display: grid; gap: 4px; min-width: 220px; }
.an-ans .input { padding-top: 3px; padding-bottom: 3px; }
.an-ev td { vertical-align: top; }
.wz { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
@media (max-width: 960px) { .wz { grid-template-columns: 1fr; } }
.wz-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); background: var(--surface); }
.wz-steps li { padding: 8px 10px; font-size: var(--fs-sm); color: var(--text-3); border-right: 1px solid var(--line); }
.wz-steps li:last-child { border-right: 0; }
.wz-steps li a { color: inherit; text-decoration: none; }
.wz-steps li span { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border: 1px solid currentColor; margin-right: 6px; font-weight: 700; }
.wz-steps li.is-done { color: var(--text-2); }
.wz-steps li.is-now { color: var(--text); font-weight: 700; box-shadow: inset 0 -3px 0 var(--brand); }
@media (max-width: 720px) { .wz-steps { grid-template-columns: 1fr; } .wz-steps li { border-right: 0; border-bottom: 1px solid var(--line); } }
.wz-choices { display: grid; gap: 8px; }
.wz-choices p { margin: 0; }
.wz-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); cursor: pointer; }
.wz-opt:hover { background: var(--sel-hover); }
.wz-opt:has(input:checked) { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); background: var(--brand-bg); }
.wz-opt.is-off { opacity: .75; cursor: default; }
.wz-opt input { margin-top: 3px; }
.wz-opt > span { display: grid; gap: 2px; }
.wz-hint { color: var(--text-2); font-size: var(--fs-sm); }
.wz-nav { display: flex; justify-content: space-between; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.an-light > .btn, .an-light > form { justify-self: start; }
.wz-opt input[type="radio"] { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; flex: none; margin: 2px 0 0; border: 1px solid var(--line-strong); background: var(--surface); }
.wz-opt input[type="radio"]:checked { border-color: var(--brand); box-shadow: inset 0 0 0 3px var(--surface); background: var(--brand); }
.wz-opt input[type="radio"]:disabled { background: var(--surface-2); }
/* 17/11 Anomalie: Impostazioni, Rispondi, sensore spento */
.an-reply > summary { list-style: none; cursor: pointer; display: inline-flex; }
.an-reply > summary::-webkit-details-marker { display: none; }
.an-reply[open] > summary { background: var(--sel-hover); }
.an-reply .an-ans { margin-top: 6px; padding: 8px; border: 1px solid var(--line); background: var(--surface); min-width: 260px; max-width: 340px; }
.an-reply .wz-opt { padding: 6px 8px; gap: 8px; }
.an-reply .wz-hint { display: block; font-size: var(--fs-2xs); color: var(--text-2); font-weight: 400; }
.an-act { white-space: nowrap; }
.an-inline { display: inline-flex; gap: 4px; align-items: center; margin: 0 4px 0 0; }
.an-inline select.input { width: auto; min-width: 130px; height: 28px; padding: 0 6px; font-size: var(--fs-sm); }
.an-logrow td { padding-top: 0; border-top: 0; }
.an-offline { margin: 0 0 8px; padding: 6px 10px; background: var(--sel-hover); }
/* 17/11 Misurazioni come il vecchio OEM + calendario del periodo */
.mchip { display: inline-flex; align-items: center; padding: 1px 8px 1px 6px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
.mchip .vkey { margin-right: 6px; }
tr.is-live td { background: var(--sel-hover); }
.mlive { display: inline-flex; vertical-align: -2px; color: var(--brand); }
.mlive .ic { width: 13px; height: 13px; animation: mspin 1.6s linear infinite; }
@keyframes mspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mlive .ic { animation: none; } }
.mon-bar { position: relative; }
.mon-range { display: inline-flex; align-items: center; gap: 6px; }
.mon-range .ic { width: 14px; height: 14px; }
.mcal { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); padding: 10px; display: grid; gap: 8px; }
.mcal-months { display: flex; gap: 16px; flex-wrap: wrap; }
.mcal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: var(--fs-sm); margin-bottom: 4px; text-transform: capitalize; }
.mcal-nav { border: 1px solid var(--line); background: var(--surface); width: 26px; height: 26px; cursor: pointer; color: var(--text); }
.mcal-nav:hover { background: var(--sel-hover); }
.mcal-nav[hidden] { visibility: hidden; display: inline-block; }
.mcal table { border-collapse: collapse; }
.mcal th { font-size: var(--fs-2xs); color: var(--text-3); font-weight: 600; width: 32px; text-align: center; padding: 2px 0; text-transform: capitalize; }
.mcal td { padding: 1px; }
.mcal td button { width: 32px; height: 28px; border: 0; background: transparent; cursor: pointer; font-size: var(--fs-sm); color: var(--text); font-variant-numeric: tabular-nums; }
.mcal td button:hover:not(:disabled) { background: var(--sel-hover); }
.mcal td button:disabled { color: var(--text-3); cursor: default; opacity: .45; }
.mcal td button.is-in { background: var(--brand-bg); }
.mcal td button.is-end { background: var(--brand); color: var(--on-brand); font-weight: 700; }
.mcal td button.is-today { outline: 1px solid var(--brand); outline-offset: -1px; }
.mcal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 8px; font-size: var(--fs-sm); }
.mcal-foot .btns { display: flex; gap: 6px; }
@media (max-width: 640px) { .mcal { left: 0; right: 0; } .mcal-months > div + div { display: none; } }
.mcal[hidden], .mon-dates [hidden] { display: none !important; }

/* 17/11: lettura / scansione del router in corso: icona che gira, passi, tempo passato, barra che scorre */
.nwork { display: grid; gap: 8px; min-width: min(420px, 100%); }
.nwork-t { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nwork-s { margin-left: auto; font-variant-numeric: tabular-nums; }
.nwork-steps { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-3); }
.nwork-steps li::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border: 1px solid var(--line-strong); vertical-align: 0; }
.nwork-steps li.is-done { color: var(--text-2); }
.nwork-steps li.is-done::before { background: var(--brand); border-color: var(--brand); }
.nwork-steps li.is-now { color: var(--text); font-weight: 600; }
.nwork-steps li.is-now::before { border-color: var(--brand); background: var(--brand-bg); }
.nwork-bar { position: relative; height: 3px; background: var(--brand-bg); overflow: hidden; }
.nwork-bar i { position: absolute; top: 0; bottom: 0; left: 0; width: 35%; background: var(--brand); animation: nbar 1.4s ease-in-out infinite; }
@keyframes nbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .nwork-bar i { animation: none; width: 100%; opacity: .5; } }

/* 17/11: Scansione su telefono: ogni dispositivo è un blocco (IP e stato, poi tipo / costruttore / porte, poi i comandi
   a tutta larghezza), così non serve scorrere la tabella di lato per arrivare ai pulsanti */
@media (max-width: 640px) {
  #scanTable thead { display: none; }
  #scanTable, #scanTable tbody { display: block; width: 100%; }
  #scanTable tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "ip st" "type type" "ven ports" "act act";
                  gap: 4px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  #scanTable td { display: block; padding: 0; border: 0; white-space: normal; }
  #scanTable td.hide-sm { display: none; }
  #scanTable .sc-ip { grid-area: ip; } #scanTable .sc-st { grid-area: st; text-align: right; }
  #scanTable .sc-type { grid-area: type; font-weight: 600; }
  #scanTable .sc-ven { grid-area: ven; } #scanTable .sc-ports { grid-area: ports; text-align: right; }
  #scanTable .sc-ven::before, #scanTable .sc-ports::before { content: attr(data-l) ": "; color: var(--text-3); font-family: var(--font, inherit); }
  #scanTable .sc-act { grid-area: act; margin-top: 4px; }
  #scanTable .sc-act form { display: flex; flex-wrap: wrap; gap: 6px; }
  #scanTable .sc-act .input { flex: 1 1 150px; min-width: 0; }
  #scanTable .sc-act .btn { flex: 1 1 auto; justify-content: center; }
  #scanTable td.empty-cell { grid-column: 1 / -1; }
}

/* 17/11: .table-cards = su telefono ogni riga diventa una scheda, ogni valore con la sua etichetta (td data-l) */
@media (max-width: 640px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr { display: block; width: 100%; }
  .table-cards tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td { display: flex; gap: 10px; width: 100%; padding: 3px 12px !important; border: 0 !important; white-space: normal !important; }
  .table-cards td[data-l]::before { content: attr(data-l); flex: 0 0 38%; color: var(--text-3); font-size: 11px; font-weight: 600;
                                    text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; font-family: var(--font, inherit); }
  .table-cards td.empty-cell { display: block; text-align: center; padding: 14px 12px !important; }
}
