:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e2e7ef;
  --text: #1b2333;
  --muted: #667085;
  --primary: #1d4ed8;
  --primary-soft: #e8eefc;
  --danger: #c62828;
  --side: #121a2b;
  --side-text: #c6cfdf;
  --aperto: #1d4ed8; --aperto-bg: #e5edff;
  --sospeso: #a15c00; --sospeso-bg: #fff1d6;
  --chiuso: #1e7b45; --chiuso-bg: #dff4e7;
  --radius: 8px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: grid; grid-template-columns: 230px 1fr; min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- sidebar */
.sidebar { background: var(--side); color: var(--side-text); padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 0 6px; }
.brand-logo { width: 36px; height: 36px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; font-weight: 700; }
.brand small { display: block; color: var(--side-text); font-size: 12px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--side-text); padding: 9px 12px; border-radius: 6px; }
nav a:hover { background: #1f2a40; color: #fff; text-decoration: none; }
nav a.active { background: var(--primary); color: #fff; }
nav a.sub { padding: 6px 12px 6px 26px; font-size: 13px; }
nav .nav-titolo { color: var(--side-text); padding: 9px 12px 3px; cursor: default; user-select: none; }
.cl-attivo { background: var(--chiuso-bg); color: var(--chiuso); }
.cl-dismesso { background: #f2f4f7; color: #667085; }
label.spunta { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }
.sidebar-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sidebar .btn:not(.primary) { background: #1f2a40; color: #fff; border-color: #2c3a55; }

main { padding: 24px 28px 60px; min-width: 0; }

/* ---------- elementi comuni */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

.btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px;
  border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b9c3d3; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1a43bd; }
.btn.danger { color: var(--danger); }
.btn.warn { color: var(--sospeso); }
.btn.ok { color: var(--chiuso); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 18px 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
/* Tabelle e Backup: tecnici, tipi, marche e modelli in una sola scheda a linguette */
.tabelle-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); }
.tabelle-azioni { display: flex; align-items: center; gap: 8px; }
.tabelle-azioni input[type=search] { width: 220px; }
.tabelle-pannello { max-height: 440px; overflow: auto; }
.tabelle-pannello thead th { position: sticky; top: 0; z-index: 1; }
.tabelle-pannello tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) { .tabelle-azioni, .tabelle-azioni input[type=search] { width: 100%; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text);
  border-left: 4px solid var(--border); }
.kpi:hover { text-decoration: none; border-color: #b9c3d3; }
.kpi .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.aperto { border-left-color: var(--aperto); }
.kpi.sospeso { border-left-color: var(--sospeso); }
.kpi.chiuso { border-left-color: var(--chiuso); }
.kpi.alert { border-left-color: var(--danger); }

.info { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 20px; }
.info div > span { display: block; font-size: 12px; color: var(--muted); }
.info div > b { font-weight: 500; white-space: pre-wrap; }
.info .wide { grid-column: 1 / -1; }
.testo { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 4px 0 0; }

/* ---------- badge */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-aperto { background: var(--aperto-bg); color: var(--aperto); }
.st-sospeso { background: var(--sospeso-bg); color: var(--sospeso); }
.st-chiuso { background: var(--chiuso-bg); color: var(--chiuso); }
.st-lavorazione { background: #ffedd5; color: #9a3412; }
.st-annullato { background: #fee2e2; color: #991b1b; text-decoration: line-through; }
.alert-box.annullata { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.pr-urgente { background: #fde2e2; color: #b42318; }
.pr-alta { background: #ffe9d5; color: #b54708; }
.pr-normale { background: #eef2f6; color: #475467; }
.pr-bassa { background: #f2f4f7; color: #98a2b3; }
.tag { display: inline-block; background: #eef2f6; color: #475467; padding: 1px 7px; border-radius: 4px; font-size: 12px; }

/* ---------- tabelle */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: #fafbfd; white-space: nowrap; }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover { background: #f5f8ff; }
tbody tr:last-child td { border-bottom: 0; }
td .sec { display: block; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- filtri */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 280px; flex: 1; max-width: 420px; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 3px; gap: 2px; }
.tabs button { font: inherit; border: 0; background: none; padding: 5px 12px; border-radius: 5px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tabs button .c { font-size: 11px; margin-left: 4px; opacity: .8; }

/* ---------- form */
input, select, textarea { font: inherit; color: inherit; border: 1px solid #cfd6e2; border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0ff; border-color: var(--primary); }
.filters input, .filters select { width: auto; }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px 14px; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: 4px; }
.field.s3 { grid-column: span 3; } .field.s4 { grid-column: span 4; } .field.s8 { grid-column: span 8; } .field.s12 { grid-column: span 12; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field label .req { color: var(--danger); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: auto; }
.form-sep { grid-column: span 12; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cerca-disp { position: relative; }
.cerca-risultati { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16,24,40,.12); z-index: 5; max-height: 260px; overflow: auto; }
.cerca-risultati button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; font: inherit; border-bottom: 1px solid var(--border); }
.cerca-risultati button:hover { background: #f5f8ff; }
.cerca-risultati small { color: var(--muted); display: block; }

/* ---------- modale */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; }
.modal .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.form-err { background: #fde2e2; color: #912018; padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; display: none; }
.form-err.show { display: block; }

/* ---------- toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1b2333; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; }
.toast.err { background: var(--danger); }

/* ---------- timeline storico */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.timeline li.aperto::before { background: var(--aperto); }
.timeline li.sospeso::before { background: var(--sospeso); }
.timeline li.chiuso::before { background: var(--chiuso); }
.timeline .when { color: var(--muted); font-size: 12px; }
.alert-box { background: var(--sospeso-bg); color: #7a4500; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }

/* ---------- verificazioni periodiche */
.vp { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.vp-ok { background: var(--chiuso-bg); color: var(--chiuso); }
.vp-in_scadenza { background: #ffe9c2; color: #8a4b00; }
.vp-scaduta, .vp-negativa { background: #fde2e2; color: #b42318; }
.vp-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; padding: 14px 16px; border-radius: 8px;
  margin-bottom: 14px; border: 2px solid var(--border); background: #f8fafc; }
.vp-box span { display: block; font-size: 12px; color: var(--muted); }
.vp-box b { font-size: 20px; display: block; }
.vp-box small { color: var(--muted); }
.vp-box.vp-ok { border-color: #9fd8b6; background: var(--chiuso-bg); }
.vp-box.vp-in_scadenza { border-color: #f0a23c; background: #fff4e0; }
.vp-box.vp-scaduta, .vp-box.vp-negativa { border-color: #e5484d; background: #fdecec; animation: lampeggio 1.6s ease-in-out 3; }
.vp-box.vp-in_scadenza small, .vp-box.vp-scaduta small, .vp-box.vp-negativa small { color: inherit; font-weight: 600; }
@keyframes lampeggio { 50% { box-shadow: 0 0 0 5px rgba(229, 72, 77, .25); } }

.avvisi-bar { background: #fff4e0; border: 1px solid #f0a23c; color: #6b3a00; padding: 9px 14px; border-radius: 7px; margin-bottom: 16px; }
.avvisi-bar.grave { background: #fdecec; border-color: #e5484d; color: #8f1d1d; }
.avvisi-bar a { color: inherit; text-decoration: underline; }
.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #f0a23c; color: #fff; font-size: 11px;
  font-weight: 700; text-align: center; margin-left: 4px; }
.nav-badge.grave { background: #e5484d; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.sec-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.info .sec { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

/* ---------- QR Agenzia Entrate */
.qr-zona { border: 2px dashed #c4cede; border-radius: 8px; padding: 16px; text-align: center; margin-bottom: 14px; background: #fafbfd; }
.qr-zona.over { border-color: var(--primary); background: var(--primary-soft); }
.qr-azioni { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.qr-azioni label.btn { display: inline-block; }
.qr-hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.qr-zona video { width: 100%; max-width: 420px; margin-top: 12px; border-radius: 6px; background: #000; }
.qr-stato { margin-top: 8px; font-weight: 600; color: var(--primary); min-height: 1em; }
.ade-box { border: 1px solid #b8cdf3; background: #f3f7ff; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.ade-titolo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); margin-bottom: 10px; }
.ok-box { background: var(--chiuso-bg); color: #145c33; border-radius: 6px; padding: 10px 12px; }
.form-grid .form-grid { grid-column: 1 / -1; }
[hidden] { display: none !important; }

/* ---------- accesso e utenti */
body.schermata-accesso { grid-template-columns: 1fr; }
body.schermata-accesso .sidebar, body.schermata-accesso #avvisi, body.schermata-accesso #licenza-bar { display: none; }
.accesso { min-height: 80vh; display: grid; place-items: center; }
.accesso-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px 30px; width: 100%; max-width: 400px;
  box-shadow: 0 10px 30px rgba(16,24,40,.08); }
.accesso-card h1 { margin: 18px 0 14px; }
.accesso-card .field { margin-bottom: 12px; }
.accesso-brand { color: var(--text); padding: 0; }
.accesso-brand small { color: var(--muted); }
.utente-box { border-top: 1px solid #2c3a55; padding-top: 10px; margin-top: 4px; color: #fff; }
.utente-nome small { display: block; color: var(--side-text); font-size: 12px; }
.utente-azioni { display: flex; gap: 6px; margin-top: 8px; }
.sidebar .utente-azioni .btn { flex: 1; padding: 4px 6px; }
.perm-barra { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.perm-barra span { color: var(--muted); }
.perm-gruppo { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.perm-gruppo h3 { margin: 0 0 6px; }
.scelta.perm { align-items: flex-start; font-weight: 400; padding: 3px 0; }
.scelta.perm input { margin-top: 3px; }
.ruolo-amministratore { background: #fde2e2; color: #b42318; }
.ruolo-supervisor { background: #ede4ff; color: #5b2fb3; }
.ruolo-tecnico { background: var(--aperto-bg); color: var(--aperto); }
.ruolo-amministrazione { background: var(--chiuso-bg); color: var(--chiuso); }

/* ---------- chiamata chiusa con intervento generato */
.st-intervento { background: #ede4ff; color: #5b2fb3; margin-top: 3px; }
.int-box { background: #f3edff; border: 1px solid #c9b3f5; color: #3e1f86; border-radius: 7px; padding: 10px 14px; margin-bottom: 16px; }

/* ---------- modulo rapportino */
.rapp-cliente { background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.rapp-cliente .sec { display: block; color: var(--muted); font-size: 12px; }
.scelte { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.scelta { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; }
.scelta input { width: auto; }
.lavori { gap: 6px; }
.riga-ric { display: grid; grid-template-columns: 1fr 110px 90px 70px 130px 90px 32px; gap: 6px; margin-bottom: 6px; align-items: center; }
.riga-costo { flex-direction: row; display: grid; grid-template-columns: 1fr 110px 90px 70px 90px 32px; gap: 6px; align-items: center; }
.riga-costo .lbl-costo { font-weight: 600; }
.tot { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totali-rapp { flex-direction: row; display: flex; justify-content: flex-end; gap: 22px; align-items: center; flex-wrap: wrap;
  background: #f8fafc; border-radius: 6px; padding: 8px 12px; }
.totali-rapp label { display: flex; align-items: center; gap: 6px; }
@media (max-width: 860px) { .riga-ric, .riga-costo { grid-template-columns: 1fr 1fr; } }
/* pratica di installazione: dispositivi installati nel rapportino e scelta del cliente */
.riga-inst { display: grid; grid-template-columns: 170px 1fr 1fr 140px 140px 1fr 32px; gap: 6px; margin-bottom: 6px; align-items: center; }
@media (max-width: 860px) { .riga-inst { grid-template-columns: 1fr 1fr; } .riga-inst [data-togli-inst] { justify-self: end; } }
.inst-clienti { width: 100%; margin-top: 6px; }
.tag.tag-inst { background: #dcfce7; color: #166534; }

/* ---------- rapportino stampabile (modello "Rapporto di intervento polivalente") */
.rp { --rp-blu: #7b86c9; --rp-rosa: #f7dde5; --rp-testo: #3a3f8f; --rp-rosso: #e52b2b;
  background: #fff; width: 200mm; margin: 0 auto; padding: 6mm; font: 8.8pt/1.2 Arial, Helvetica, sans-serif; color: #111;
  border: 1px solid var(--border); }
.rp-intestazione { width: 100%; display: block; margin-bottom: 2mm; }
.rp-t { width: 100%; border-collapse: collapse; margin-bottom: 1.2mm; table-layout: fixed; }
.rp-t td { border: 1px solid var(--rp-blu); padding: 0.7mm 1.6mm; vertical-align: top; background: #fff; overflow-wrap: anywhere; }
.rp-l, .rp-h td, .rp-h.rp-hcell, td.rp-h { color: var(--rp-testo); font-weight: 700; }
.rp-l { margin-right: 2mm; }
.rp-h td, td.rp-h, .rp-hcell { background: var(--rp-rosa) !important; }
.rp-titolo td { vertical-align: middle; height: 7.5mm; white-space: nowrap; }
.rp-titolo .rp-rosso { background: var(--rp-rosso); color: #fff; font-weight: 700; font-size: 10.5pt; width: 44%; border-color: var(--rp-rosso); }
.rp-titolo .rp-num { width: 20%; color: var(--rp-testo); font-size: 10pt; }
.rp-titolo .rp-num b { color: var(--rp-rosso); font-size: 11pt; }
.rp-titolo .rp-data { width: 15%; }
.rp-ana td { background: linear-gradient(#fff, #fdf2f5) !important; height: 5mm; }
.rp-app tr:not(.rp-h) td { height: 5mm; }
.rp-w20 { width: 20%; } .rp-w30 { width: 30%; } .rp-w36 { width: 36%; }
.rp-c { text-align: center; width: 12%; }
.rp-box2 { height: 12mm; white-space: pre-wrap; }
.rp-lavori .rp-note { white-space: pre-wrap; }
.rp-voce { margin: 0.4mm 0; }
.rp-cb { display: inline-block; width: 3.6mm; height: 3.6mm; border: 1.2px solid var(--rp-rosso); vertical-align: -0.7mm;
  text-align: center; line-height: 3.4mm; font-size: 9pt; font-weight: 700; color: #000; margin-right: 1mm; }
.rp-ricambi td { height: 5mm; }
.rp-ricambi tr:not(.rp-h) td:first-child { width: 46%; }
.rp-ricambi .rp-h td { font-size: 8pt; }
.rp .num { text-align: right; white-space: nowrap; }
.rp-basso > tbody > tr > td { padding: 0; border: 0; }
.rp-pag { width: 38%; padding: 0 2mm 0 0 !important; }
.rp-pag > .rp-hcell { padding: 0.7mm 1.6mm; border-bottom: 1px solid var(--rp-blu); }
.rp-regime td { white-space: nowrap; vertical-align: middle; }
.rp-pag > .rp-voce { padding: 0 2mm; }
.rp-pag { border: 1px solid var(--rp-blu) !important; }
.rp-banca { padding-left: 6mm !important; }
.rp-costi { padding: 0 0 0 2mm !important; }
.rp-in { margin: 0; }
.rp-in td { height: 5mm; font-size: 8.5pt; }
.rp-in td.rp-h { width: 36%; font-size: 8pt; }
.rp-dx { text-align: right; }
.rp-ora { border: 1.5px solid var(--rp-rosso) !important; }
.rp-ora .rp-l { color: var(--rp-testo); }
.rp-totale { background: var(--rp-rosa) !important; font-weight: 700; }
.rp-esito td { vertical-align: middle; font-size: 8pt; white-space: nowrap; }
.rp-esito .rp-c { width: 13%; }
.rp-doc { height: 9mm; }
.rp-firme td { height: 18mm; width: 50%; position: relative; }
.rp-linea { position: absolute; left: 40%; right: 4mm; bottom: 3mm; border-bottom: 1px solid #333; }
.rp-firme td:has(.rp-firma) { height: 26mm; }
.rp-firma { position: absolute; left: 30%; right: 3mm; top: 1mm; bottom: 5mm; width: 68%; height: calc(100% - 6mm); object-fit: contain; }
.rp-firmato { position: absolute; left: 1.6mm; bottom: 0.8mm; font-size: 7pt; color: #666; }

@media print {
  @page { size: A4; margin: 6mm; }
  body { display: block; background: #fff; }
  .sidebar, .no-print, #toast-root, #avvisi, #modal-root { display: none !important; }
  main { padding: 0; }
  .rp { border: 0; padding: 0; width: auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.btn-menu { display: none; }

/* ---------- tablet in verticale e schermi stretti */
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  /* barra in alto compatta; il menu si apre con il pulsante */
  .sidebar { position: sticky; top: 0; z-index: 40; height: auto; padding: 8px 14px; gap: 0; }
  .brand { justify-content: space-between; }
  .brand small { display: none; }
  .btn-menu { display: inline-flex; flex-direction: column; justify-content: center; gap: 5px; width: 46px; height: 42px; margin-left: auto;
    background: #1f2a40; border: 1px solid #2c3a55; border-radius: 8px; cursor: pointer; padding: 0 11px; }
  .btn-menu span { display: block; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
  body.menu-aperto .btn-menu span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.menu-aperto .btn-menu span:nth-child(2) { opacity: 0; }
  body.menu-aperto .btn-menu span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .sidebar nav, .sidebar .sidebar-actions { display: none; }
  body.menu-aperto .sidebar { max-height: 100vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
  body.menu-aperto .sidebar nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 10px; }
  body.menu-aperto .sidebar .sidebar-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
  body.menu-aperto .utente-box { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
  nav a { padding: 12px 14px; font-size: 15px; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .field, .field.s3, .field.s4, .field.s8 { grid-column: span 12; }
  .filters input[type=search] { min-width: 0; width: 100%; max-width: none; }
  .filters > * { flex: 1 1 auto; }
  .filters input[type=search] { flex-basis: 100%; order: -1; }
  .page-head h1 { font-size: 20px; }

  /* elenchi: ogni riga diventa una scheda */
  table.a-schede thead { display: none; }
  table.a-schede, table.a-schede tbody, table.a-schede tr, table.a-schede td { display: block; width: 100%; }
  table.a-schede tr { border-bottom: 1px solid var(--border); padding: 10px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
  table.a-schede tbody tr:last-child { border-bottom: 0; }
  table.a-schede td { border: 0; padding: 2px 0; text-align: left !important; min-width: 0; }
  table.a-schede td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
  table.a-schede td:first-child { grid-column: 1 / -1; font-size: 15px; }
  table.a-schede td:first-child::before { display: none; }
  table.a-schede td.vuota { display: none; }
  table.a-schede .clip { max-width: none; }
  .table-wrap { overflow-x: visible; }
}

/* ---------- schermi touch: controlli piu' grandi */
@media (pointer: coarse) {
  input, select, textarea { min-height: 44px; font-size: 16px; }
  textarea { min-height: 80px; }
  .btn { min-height: 42px; padding: 9px 16px; }
  .btn.small { min-height: 36px; padding: 6px 12px; }
  .tabs button { padding: 9px 14px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; }
  .scelta { padding: 6px 0; min-height: 36px; }
  .modal .x { font-size: 30px; padding: 4px 10px; }
  .modal footer .btn { min-width: 110px; }
  .riga-ric input, .riga-costo input { min-height: 40px; }
}

/* ---------- check-list VP */
.griglia-scelte { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
@media (max-width: 860px) { .griglia-scelte { grid-template-columns: 1fr; } }

/* ---------- magazzino */
.qta-bassa { color: var(--danger); }
.qta-uscita { color: #b42318; font-weight: 600; }
.qta-entrata { color: var(--chiuso); font-weight: 600; }
.copia { display: inline-flex; gap: 6px; align-items: center; max-width: 100%; margin: 4px 0; }
.copia input { width: 360px; max-width: 100%; font-size: 12px; padding: 4px 6px; }
.passi { padding-left: 18px; margin: 0; }
.passi li { margin-bottom: 10px; }

/* ---------- calendario degli interventi */
.cal-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.cal-nav, .cal-schede { display: flex; gap: 4px; }
.cal-titolo { font-size: 15px; margin-right: auto; }
.cal-barra select { width: auto; max-width: 100%; font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.cal-griglia { display: grid; grid-template-columns: repeat(var(--giorni), minmax(0, 1fr)); gap: 8px; }
.cal-giorno { background: var(--bg); border-radius: var(--radius); padding: 8px; min-height: 120px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cal-giorno.oggi { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.cal-giorno.passato { opacity: .75; }
.cal-data { font-size: 13px; color: var(--muted); }
.cal-data b { color: var(--text); font-size: 16px; }
.cal-data em { font-style: normal; color: var(--primary); font-weight: 600; }
.cal-vuoto { color: var(--muted); font-size: 13px; }
.ev { display: block; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c, #98a2b3); border-radius: 6px;
  padding: 6px 8px; color: var(--text); font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
a.ev:hover { text-decoration: none; border-color: #b9c3d3; border-left-color: var(--c, #98a2b3); }
.ev-ora { font-weight: 600; font-size: 12px; color: var(--muted); }
.ev-tit { font-weight: 600; }
.ev-sub, .ev-tec { color: var(--muted); font-size: 12px; }
.ev-tec::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, #98a2b3); margin-right: 5px; }
.ev-pr { background: #fde8e8; color: var(--danger); border-radius: 4px; padding: 0 5px; margin-left: 4px; text-transform: uppercase; font-size: 10px; }
.ev.st-chiuso { opacity: .6; } .ev.st-chiuso .ev-tit { text-decoration: line-through; }
.ev.st-sospeso { background: var(--sospeso-bg); }
.ev.t0 { --c: #1d4ed8; } .ev.t1 { --c: #c2410c; } .ev.t2 { --c: #15803d; } .ev.t3 { --c: #7e22ce; }
.ev.t4 { --c: #be123c; } .ev.t5 { --c: #0e7490; } .ev.t6 { --c: #a16207; } .ev.t7 { --c: #4338ca; } .ev.tn { --c: #98a2b3; }
.cal-dp { margin-top: 14px; }
.cal-dp h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-dp h4 span { background: var(--bg); border-radius: 10px; padding: 0 8px; }
.cal-dp-elenco { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.cal-google { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
@media (max-width: 860px) {
  .cal-griglia { grid-template-columns: 1fr; }
  .cal-giorno { min-height: 0; }
  .cal-google { height: 480px; }
}
/* schermo del laboratorio: solo il calendario, a tutto schermo e leggibile da lontano */
body.schermo-lab { display: block; }
body.schermo-lab .sidebar, body.schermo-lab #avvisi, body.schermo-lab #licenza-bar { display: none; }
body.schermo-lab main { padding: 14px 18px; max-width: none; }
.lab-testa { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 18px; }
.lab-ora { font-size: 24px; font-weight: 700; }
.cal.lab .cal-giorno { min-height: calc(100vh - 210px); }
.cal.lab .ev { font-size: 15px; padding: 8px 10px; }
.cal.lab .ev-ora, .cal.lab .ev-sub, .cal.lab .ev-tec { font-size: 14px; }
.cal.lab .cal-data { font-size: 15px; } .cal.lab .cal-data b { font-size: 22px; }
.cal.lab .cal-titolo { font-size: 18px; }
/* area "Il mio account" e istruzioni passo passo */
.passi { padding-left: 20px; line-height: 1.55; }
.passi li { margin-bottom: 6px; }
.copia-riga { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; background: var(--bg); padding: 6px 10px; border-radius: 6px; }
.copia-riga .mono { overflow-wrap: anywhere; }

/* foto degli articoli (scattate con l'app del magazzino) */
.foto-articolo { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.foto-articolo img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
/* seriali dei pezzi nella scheda articolo */
.seriali-agg { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seriali-agg input { flex: 1 1 280px; min-width: 0; width: auto; }
.seriali-agg select { flex: 0 1 220px; width: auto; }
.seriali-scelta { max-height: 180px; overflow: auto; }

/* ---------- revisione per la fatturazione */
.fatt-dash { border-top: 3px solid var(--primary); }
.fatt-testa { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.fatt-testa h2 { margin: 0; }
.fatt-dash .kpis { margin-bottom: 12px; }
.kpi-euro { font-weight: 600; margin-top: 2px; }
.fatt-tab tbody tr { cursor: pointer; }
.fatt-tab .sec { display: block; }
.fatt-lavoro { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fatt-azioni { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; background: var(--primary-soft); }
.fatt-azioni span { font-weight: 600; margin-right: auto; }
body.rev-aperta { overflow: hidden; }
.rev-overlay { position: fixed; inset: 0; z-index: 90; background: #e9edf3; display: flex; flex-direction: column; }
.rev-testa { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rev-pos { font-weight: 600; min-width: 64px; text-align: center; }
.rev-titolo { margin-right: auto; min-width: 0; }
.rev-titolo .sec { margin-left: 6px; }
.rev-corpo { flex: 1; overflow: auto; padding: 18px; }
.rev-foglio { max-width: 100%; overflow-x: auto; }
.rev-foglio .rp { box-shadow: 0 2px 10px rgba(16, 24, 40, .12); }
.rev-piede { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border); }
.rev-importi { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; color: var(--muted); }
.rev-importi b { color: var(--text); }
.rev-totale { font-size: 18px; } .rev-totale b { color: var(--primary); }
.rev-nota { flex: 1; min-width: 200px; }
.rev-bottoni { display: flex; gap: 8px; margin-left: auto; }
.rev-bottoni .btn { padding: 10px 18px; font-weight: 600; }
.rev-bottoni kbd { font: 11px/1 inherit; border: 1px solid currentColor; border-radius: 3px; padding: 1px 4px; margin-left: 6px; opacity: .7; }
.rev-fine { max-width: 420px; margin: 60px auto; text-align: center; background: var(--surface); border-radius: var(--radius); padding: 30px; }
@media (max-width: 860px) {
  .rev-bottoni { width: 100%; } .rev-bottoni .btn { flex: 1; }
  .rev-bottoni kbd { display: none; }
  .fatt-lavoro { white-space: normal; max-width: none; }
}
body.rev-aperta #toast-root { bottom: 130px; z-index: 95; }

/* ---------- firma dell'operatore */
.firma-anteprima { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: #fff; text-align: center; }
.firma-anteprima img { max-width: 100%; max-height: 120px; }
.firma-prova { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.firma-scacchi { min-height: 140px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px;
  background: #fff repeating-conic-gradient(#e6e8ec 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.firma-scacchi img { max-width: 100%; max-height: 200px; }
.firma-rp { position: relative; min-height: 140px; border: 1px solid #333; background: #fff; color: #333; padding: 6px; font-size: 11px; }
.firma-rp #fp-rp { position: absolute; left: 32%; right: 8px; top: 6px; bottom: 10px; display: flex; align-items: center; justify-content: center; }
.firma-rp #fp-rp img { max-width: 100%; max-height: 100%; }
.firma-regola { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.firma-regola label { display: flex; align-items: center; gap: 8px; }
.firma-regola select { width: auto; }
@media (max-width: 700px) { .firma-prova { grid-template-columns: 1fr; } }

/* ---------- WhatsApp */
.wa-tabs { margin-bottom: 14px; }
.wa-elenco { max-height: 60vh; overflow: auto; }
.wa-elenco th { position: sticky; top: 0; z-index: 1; }
label.wa-disp { display: flex; gap: 6px; align-items: flex-start; margin: 2px 0; cursor: pointer; }
label.wa-disp input { margin-top: 3px; }
.wa-anteprima { white-space: pre-wrap; max-height: 7.5em; overflow: auto; font-size: 13px; }
tr.wa-fatto { background: var(--chiuso-bg); }
.form-grid > p.s12 { grid-column: 1 / -1; }
/* scelta del magazzino (centrale o car kit) nel titolo della pagina Magazzino */
.page-head h1 .scelta-magazzino { font-size: 15px; font-weight: 600; margin-left: 10px; vertical-align: middle; max-width: 100%; }

/* licenza */
.licenza-bar { background: #eef4ff; border: 1px solid #9db8f0; color: #1d3f8a; padding: 7px 14px; border-radius: 7px; margin-bottom: 12px; font-size: 13px; }
.licenza-bar.demo { background: #fff4e0; border-color: #f0a23c; color: #6b3a00; }
.licenza-bar a { color: inherit; text-decoration: underline; }
.stato-lic { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; vertical-align: middle; background: #eef2f6; color: #475467; }
.stato-lic.chiuso { background: #e3f6ea; color: #17663a; }
.stato-lic.sospeso { background: #fff4e0; color: #6b3a00; }
.stato-lic.alert { background: #fdecec; color: #8f1d1d; }
/* verifica in due passaggi */
.qr-due-fattori { margin: 10px 0; }
.qr-due-fattori img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.codici-recupero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin: 8px 0; font-size: 15px; }
.form-attiva { margin-top: 8px; }
/* registro delle operazioni */
.registro-apribile { cursor: pointer; }
.registro-rifiutata td { background: #fff6f5; }
.registro-dettagli td { background: #fafbfd; font-size: 13px; }
.registro-mod { margin-bottom: 8px; }
.registro-campi { margin: 4px 0 0 12px; border-collapse: collapse; }
.registro-campi td { padding: 2px 10px 2px 0; border: 0; background: none; vertical-align: top; word-break: break-word; }
.registro-dettagli .muted, #registro-righe .muted { color: var(--muted); }
