/* OnlyFatt 1.0 — interfaccia ispirata a Danea Easyfatt
   Palette: blu navigazione, griglie chiare con intestazioni a gradiente,
   pannello laterale azzurro, barra comandi inferiore con icone grandi. */

:root {
  --nav-bg: #1d3557;
  --nav-bg2: #16293f;
  --nav-fg: #c9d6e6;
  --nav-active: #2f6db5;
  --accent: #1d6fc2;
  --accent-dark: #155394;
  --accent-soft: #e3effb;
  --sel: #3279c9;
  --bg: #e9eef3;
  --panel: #f6f9fc;
  --side: #eaf2fa;
  --border: #c3cdd8;
  --border-soft: #dbe2ea;
  --grid-head1: #fbfcfd;
  --grid-head2: #e4e9ef;
  --zebra: #f5f8fb;
  --hover: #e4effa;
  --text: #1f2a37;
  --muted: #66768a;
  --ok: #2e8b4e;
  --warn: #c98a12;
  --err: #c0392b;
  --font: "Segoe UI", "Segoe UI Variable", Tahoma, Arial, sans-serif;
  --row-h: 24px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 12.5px/1.4 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.ti { font-size: 16px; vertical-align: -2px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "Courier New", monospace; }
.hidden { display: none !important; }

/* ── Struttura ─────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* ── Navigazione sinistra ──────────────────────────────────────────────── */
.nav { width: 208px; flex-shrink: 0; background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg2)); color: var(--nav-fg); display: flex; flex-direction: column; }
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.nav-logo { width: 36px; height: 36px; flex-shrink: 0; display: block; }
.nav-brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.nav-brand-txt b { font-size: 18px; }
.nav-brand-row { display: flex; align-items: center; gap: 7px; }
/* indicatore IA nella testata: grigio se spenta/non collegata, celeste se pronta */
.ia-ind { display: inline-flex; align-items: center; gap: 2px; height: 17px; padding: 0 6px 0 4px; border-radius: 9px; font: 700 10px/17px system-ui, sans-serif; letter-spacing: .03em;
  background: rgba(255,255,255,.1); color: #7f93ab; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); flex-shrink: 0; }
.ia-ind .ti { font-size: 11px; }
.ia-ind.on { background: linear-gradient(135deg, #6d4bd8, #2b7fd4); color: #fff; box-shadow: 0 0 0 1px rgba(140,200,255,.45), 0 0 8px rgba(80,170,255,.55); }
/* Info e assistenza */
.info-prod { display: flex; gap: 14px; align-items: center; }
.info-wm { font-size: 26px; color: #0d2b5c; line-height: 1.1; }
.wordmark.info-wm span { color: #16b07a; }
.info-slogan { font-weight: 700; font-size: 13px; color: #1b3a5c; margin: 2px 0 1px; }
.licenza-txt { max-height: 420px; overflow-y: auto; padding: 4px 16px 10px; border: 1px solid var(--border-soft); border-radius: 6px; background: #fbfcfd; font-size: 12.5px; line-height: 1.5; }
.licenza-txt h3.lic-h { font-size: 13px; margin: 14px 0 4px; color: #1b3a5c; }
.licenza-txt ul { margin: 4px 0; padding-left: 20px; }
.licenza-ok { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; align-items: flex-start; }
.wordmark { font-weight: 800; letter-spacing: -.02em; }
.wordmark span { color: #3fd79a; }
.login-title.wordmark { color: #0d2b5c; font-size: 22px; }
.login-title.wordmark span { color: #16b07a; }
.nav-brand-txt small { font-size: 10.5px; color: var(--nav-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-menu { flex: 1; overflow-y: auto; padding: 6px 0; }
/* barra di scorrimento del menu: scura, nel colore della barra laterale, angoli tondi */
.nav-menu::-webkit-scrollbar { width: 10px; }
.nav-menu::-webkit-scrollbar-track { background: rgba(0, 0, 0, .18); border-radius: 10px; margin: 4px 0; }
.nav-menu::-webkit-scrollbar-thumb { background: #3d5a80; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; min-height: 40px; }
.nav-menu::-webkit-scrollbar-thumb:hover { background-color: #5577a3; }
.nav-menu::-webkit-scrollbar-button { display: none; height: 0; }
.nav-menu::-webkit-scrollbar-corner { background: transparent; }
@supports (-moz-appearance: none) { .nav-menu { scrollbar-width: thin; scrollbar-color: #3d5a80 rgba(0, 0, 0, .18); } }
.nav-group { display: flex; align-items: center; width: 100%; border: 0; background: none; cursor: pointer; text-align: left; font: 700 10px/1.2 var(--font); text-transform: uppercase; letter-spacing: .08em; color: #8fa6c1; padding: 10px 14px 4px; }
.nav-group span { flex: 1; }
.nav-group .ti { font-size: 13px; opacity: .8; }
.nav-ready .nav-group .ti { transition: transform .15s ease; }
.nav-group:hover { color: #c9d6e6; }
.nav-sec.closed .nav-group .ti { transform: rotate(-90deg); }
.nav-sec.closed .nav-sec-items { display: none; }
.nav-sec.closed.has-active .nav-group { color: #c9d6e6; }
.nav-pinned { border-top: 1px solid rgba(255,255,255,.08); padding-top: 8px; padding-bottom: 8px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 6px 14px; color: var(--nav-fg); text-decoration: none; border-left: 3px solid transparent; }
.nav-item .ti { font-size: 18px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--nav-active); color: #fff; border-left-color: #8cc4ff; }
.nav-badge { margin-left: auto; min-width: 18px; padding: 1px 5px; border-radius: 9px; background: #c0392b; color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; }
.nav-badge[hidden] { display: none; }
.nav-user { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.nav-user .ti { font-size: 20px; }
.nav-user-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user a { color: var(--nav-fg); }
.nav-user a:hover { color: #fff; }

/* ── Barra titolo pagina ───────────────────────────────────────────────── */
.pagebar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: linear-gradient(180deg, #ffffff, #eef2f6); border-bottom: 1px solid var(--border); min-height: 46px; flex-shrink: 0; }
.pagebar h1 { font-size: 17px; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.pagebar h1 .ti { font-size: 22px; color: var(--accent); }
.pagebar .count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.pagebar .spacer { flex: 1; }
.searchbox { position: relative; width: 300px; max-width: 40vw; }
.searchbox input, .searchbox input[type=search] { width: 100%; padding: 6px 28px 6px 30px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.searchbox input:focus { outline: 2px solid #9cc6f2; border-color: var(--accent); }
.searchbox .ti-search { position: absolute; left: 9px; top: 7px; color: var(--muted); }
.searchbox .clear { position: absolute; right: 6px; top: 5px; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 3px; }

/* ── Area di lavoro: griglia + pannello laterale ───────────────────────── */
.workarea { flex: 1; display: flex; min-height: 0; }
.listarea { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #fff; }
.sidepanel { width: 330px; flex-shrink: 0; background: var(--side); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sidepanel-body { flex: 1; overflow-y: auto; }
.sp-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.sp-empty .ti { font-size: 40px; display: block; margin-bottom: 8px; color: #9fb4ca; }
.sp-head { padding: 10px 12px; background: linear-gradient(180deg, #f8fbfe, #dfeaf6); border-bottom: 1px solid var(--border); }
.sp-head .sp-title { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.sp-head .sp-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.sp-sec { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); }
.sp-sec h4 { margin: 0 0 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #4a6585; }
.sp-kv { display: grid; grid-template-columns: 92px 1fr; gap: 2px 8px; font-size: 12px; }
.sp-kv dt { color: var(--muted); }
.sp-kv dd { margin: 0; word-break: break-word; }
.sp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sp-stat { background: #fff; border: 1px solid var(--border-soft); border-radius: 4px; padding: 5px 7px; }
.sp-stat b { display: block; font-size: 14px; }
.sp-stat span { font-size: 10.5px; color: var(--muted); }
.sp-docs { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.sp-docs td { padding: 3px 2px; border-bottom: 1px solid var(--border-soft); }
.sp-docs a { text-decoration: none; }
.sp-actions { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px; }
.sp-filters { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); }
.sp-filters label { display: block; font-size: 11px; color: var(--muted); margin: 6px 0 2px; }
.sp-filters select, .sp-filters input { width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; background: #fff; }

/* ── Griglia (virtual scrolling) ───────────────────────────────────────── */
.grid { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; outline: none; overflow: hidden; }
.grid-head { display: flex; background: linear-gradient(180deg, var(--grid-head1), var(--grid-head2)); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow: hidden; user-select: none; }
.grid-head .gc { font-weight: 600; font-size: 12px; color: #2c3e55; cursor: pointer; border-right: 1px solid var(--border-soft); }
.grid-head .gc:hover { background: #dfe8f2; }
.grid-head .gc.sorted::after { content: "▲"; font-size: 8px; margin-left: 4px; color: var(--accent); }
.grid-head .gc.sorted.desc::after { content: "▼"; }
.grid-body { flex: 1; overflow: auto; position: relative; }
.grid-spacer { position: relative; }
.grid-row { position: absolute; left: 0; min-width: 100%; height: var(--row-h); display: flex; cursor: default; }
.grid-row.odd { background: var(--zebra); }
.grid-row:hover { background: var(--hover); }
.grid-row.sel { background: var(--sel); color: #fff; }
.grid-row.sel .muted { color: #e6f0fb; }
.grid-row.sel .badge { box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
.grid-row.checked { box-shadow: inset 3px 0 0 #f0a020; }
.gc { padding: 0 7px; line-height: var(--row-h); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.gc.num { text-align: right; font-variant-numeric: tabular-nums; }
.gc.flex { flex: 1 0 auto; }
.grid-empty { padding: 30px; text-align: center; color: var(--muted); }
.grid.focused .grid-row.sel { background: var(--accent-dark); }
/* selezione multipla (caselline) e colonne ridimensionabili */
.gc.ck { padding: 0; text-align: center; text-overflow: clip; }
.g-ck { width: 14px; height: 14px; min-height: 0; margin: 0; vertical-align: middle; cursor: pointer; accent-color: var(--accent); }
.grid-head .gc.ck { cursor: default; }
.grid-head .gc.ck:hover { background: transparent; }
.grid-row.checked { background: #fff4dc; box-shadow: inset 3px 0 0 #f0a020; }
.grid-row.checked.odd { background: #fbefd2; }
.grid-row.checked:hover { background: #ffedc4; }
.grid-row.checked.sel { background: var(--sel); }
.grid.focused .grid-row.checked.sel { background: var(--accent-dark); }
.grid-head .gc { position: relative; }
.grid-head .g-rs { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
.grid-head .g-rs:hover, .grid-head .g-rs.on { background: rgba(43, 93, 148, .28); }
.grid.g-resizing, .grid.g-resizing * { cursor: col-resize !important; user-select: none; }
.g-selinfo { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 10px; background: #fff1d1; color: #7a4a00; border: 1px solid #f0c674; }
.g-selinfo .ti { font-size: 13px; }
.g-selinfo button { border: 0; background: none; color: #1d5a9b; text-decoration: underline; cursor: pointer; padding: 0 0 0 2px; font: inherit; }
.tb[data-multi] { position: relative; }
.tb[data-n]:not([data-n=""])::after { content: attr(data-n); position: absolute; top: 1px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #f0a020; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.badge { display: inline-block; padding: 0 6px; line-height: 17px; border-radius: 9px; font-size: 10.5px; font-weight: 600; background: #e5eaf0; color: #3c4b5c; }
.badge.ok { background: #d8f0df; color: #1e6b38; }
.badge.warn { background: #fdecc8; color: #8a5a00; }
.badge.err { background: #f8d7d3; color: #9b2a1e; }
.badge.info { background: #dbeafb; color: #1d5a9b; }

/* Barra A–Z */
.azbar { display: flex; flex-direction: column; width: 22px; flex-shrink: 0; background: #f1f4f8; border-left: 1px solid var(--border-soft); }
.azbar button { flex: 1; border: 0; background: none; font-size: 10px; font-weight: 700; color: #4a6585; cursor: pointer; padding: 0; min-height: 12px; }
.azbar button:hover { background: var(--accent); color: #fff; }
.grid-wrap { flex: 1; display: flex; min-height: 0; }

/* Barra di stato sotto la griglia */
.statusbar { display: flex; gap: 16px; align-items: center; padding: 3px 10px; font-size: 11.5px; color: #3c4b5c; background: #eef2f6; border-top: 1px solid var(--border); flex-shrink: 0; min-height: 24px; }
.statusbar b { color: var(--text); }

/* ── Barra comandi inferiore (stile Danea) ─────────────────────────────── */
.toolbar { display: flex; align-items: stretch; gap: 1px; padding: 4px 6px; background: linear-gradient(180deg, #f7f8fa, #dde2e8); border-top: 1px solid #b9c3ce; flex-shrink: 0; overflow-x: auto; }
.tb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 64px; padding: 4px 8px; border: 1px solid transparent; border-radius: 4px; background: none; cursor: pointer; text-decoration: none; color: var(--text); font-size: 11.5px; white-space: nowrap; }
.tb .ti { font-size: 23px; color: #2b5d94; }
.tb:hover { background: #fff; border-color: #b9c9db; }
.tb:active { background: #dbe8f6; }
.tb.primary .ti { color: #1f8a46; }
.tb.danger .ti { color: var(--err); }
.tb[disabled], .tb.disabled { opacity: .4; pointer-events: none; }
.tb-sep { width: 1px; background: #b9c3ce; margin: 4px 5px; }
.tb-spacer { flex: 1; }

/* ── Pulsanti ──────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border: 1px solid #aebbc9; border-radius: 4px; background: linear-gradient(180deg, #fff, #e9edf2); cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; line-height: 1.3; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: linear-gradient(180deg, #2b80d4, #1b64b0); border-color: #17589c; color: #fff; }
.btn-primary:hover { background: linear-gradient(180deg, #3489dc, #1d6cbd); }
.btn-success { background: linear-gradient(180deg, #34a35a, #23803f); border-color: #1d6d35; color: #fff; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 2px 7px; font-size: 11.5px; }
.btn-block { width: 100%; justify-content: center; padding: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-icon { padding: 3px 6px; }

/* ── Form ──────────────────────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
  border: 1px solid var(--border); border-radius: 3px; padding: 4px 6px; background: #fff; min-height: 27px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px #cfe3f8; }
input[readonly] { background: #f3f5f8; }
textarea { resize: vertical; }
.fl { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: #44546a; margin-bottom: 8px; }
.fl input, .fl select, .fl textarea { font-size: 12.5px; color: var(--text); }
.fl.req > span::after, .fl.req::first-line { }
.frow { display: flex; gap: 10px; flex-wrap: wrap; }
.frow > .fl { flex: 1 1 140px; min-width: 0; }
.frow > .fl.w-xs { flex: 0 0 70px; }
.frow > .fl.w-s { flex: 0 0 110px; }
.frow > .fl.w-m { flex: 0 0 170px; }
.frow > .fl.w-l { flex: 2 1 260px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 4px 14px 4px 0; font-size: 12.5px; color: var(--text); }
.fieldset { border: 1px solid var(--border-soft); border-radius: 5px; padding: 10px 12px 4px; margin-bottom: 12px; background: #fff; }
.fieldset > legend, .fs-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #4a6585; padding: 0 4px; }
.fs-title { padding: 0; margin: 0 0 8px; }
.help { font-size: 11px; color: var(--muted); margin: -4px 0 8px; }
.alert { padding: 8px 12px; border-radius: 4px; margin-bottom: 10px; border: 1px solid; }
.alert-error { background: #fbe9e7; border-color: #f0b8b0; color: #8f2318; }
.alert-ok { background: #e6f5ea; border-color: #a9dbb7; color: #1d6b37; }
.alert-warn { background: #fff5dd; border-color: #f1d28c; color: #7a5300; }
.alert-info { background: #e6f0fb; border-color: #b4d0ef; color: #1d4f86; }
.alert ul { margin: 4px 0 0 18px; padding: 0; }
.frow[hidden], .fieldset[hidden] { display: none; }
/* riquadri di spiegazione comprimibili */
.guida { position: relative; padding-right: 36px; }
.guida .guida-x { position: absolute; right: 6px; top: 4px; width: 26px; height: 24px; border: 0; background: none; color: inherit; opacity: .65; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.guida .guida-x:hover { opacity: 1; background: rgba(0,0,0,.07); }
.guida .guida-x .ti, .guida .guida-t .ti { font-size: 16px; color: inherit; transition: transform .15s; }
.guida .guida-t { display: none; font-weight: 600; cursor: pointer; }
.guida.chiusa { padding-top: 3px; padding-bottom: 3px; }
.guida.chiusa .guida-t { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.guida.chiusa .guida-b { display: none; }
.guida.chiusa .guida-x { top: 1px; }
.guida.chiusa .guida-x .ti { transform: rotate(-90deg); }
.drop-hint .guida-b { display: flex; align-items: center; gap: 10px; flex: 1; }

/* ── Schede (form a pagina intera) ─────────────────────────────────────── */
.formpage { flex: 1; overflow: auto; padding: 12px 14px 20px; }
.formcard { background: #fff; border: 1px solid var(--border); border-radius: 6px; max-width: 1100px; }
.formcard-body { padding: 14px 16px; }
.tabs { display: flex; gap: 2px; padding: 0 10px; background: linear-gradient(180deg, #f6f8fb, #e6ebf1); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; overflow-y: hidden; }
.tab { padding: 7px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 5px 5px 0 0; background: none; cursor: pointer; color: #3c4b5c; margin-top: 4px; white-space: nowrap; }
.tab:hover { background: #fff8; }
.tab.active { background: #fff; border-color: var(--border); color: var(--text); font-weight: 600; margin-bottom: -1px; }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ── Modali ────────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(20,35,55,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: #fff; border-radius: 6px; box-shadow: 0 18px 60px rgba(0,0,0,.35); width: 560px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; }
.modal.lg { width: 900px; }
.modal.et-modal { width: 640px; }
.modal.et-modal .frow > .fl input { width: 100%; box-sizing: border-box; }
.modal.xl { width: 1150px; height: 90vh; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: linear-gradient(180deg, #fafcfe, #e3eaf2); border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0; font-weight: 600; font-size: 13.5px; }
.modal-head .x { margin-left: auto; border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--muted); }
.modal-body { padding: 14px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--border-soft); background: #f6f8fa; border-radius: 0 0 6px 6px; }
.modal-body.flush { padding: 0; display: flex; flex-direction: column; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toasts { position: fixed; right: 16px; bottom: 76px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { min-width: 260px; max-width: 420px; padding: 10px 14px; border-radius: 5px; color: #fff; background: #34495e; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: tin .2s ease-out; }
.toast-success { background: #2e8b4e; }
.toast-error { background: #c0392b; }
.toast-warning { background: #c98a12; }
.toast-info { background: #2f6db5; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* ── Autocomplete ──────────────────────────────────────────────────────── */
.ac-list { position: fixed; z-index: 1500; background: #fff; border: 1px solid var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,.18); max-height: 320px; overflow-y: auto; min-width: 320px; border-radius: 0 0 4px 4px; }
.ac-item { padding: 5px 9px; cursor: pointer; border-bottom: 1px solid #eef1f4; display: flex; gap: 10px; align-items: baseline; }
.ac-item .ac-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .ac-side { color: var(--muted); font-size: 11px; white-space: nowrap; }
.ac-item.active, .ac-item:hover { background: var(--sel); color: #fff; }
.ac-item.active .ac-side, .ac-item:hover .ac-side { color: #e6f0fb; }
.ac-new { color: var(--accent); font-style: italic; }

/* ── Editor documento ──────────────────────────────────────────────────── */
.doc-editor { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.doc-head { display: grid; grid-template-columns: minmax(320px, 1.4fr) minmax(300px, 1fr); gap: 12px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.doc-cli { position: relative; }
.doc-cli .cli-line { display: flex; gap: 6px; }
.doc-cli .cli-line input { flex: 1; font-size: 14px; font-weight: 600; padding: 5px 8px; }
.doc-cli .cli-info { margin-top: 5px; font-size: 11.5px; color: var(--muted); min-height: 32px; line-height: 1.45; }
.doc-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; align-content: start; }
.doc-meta .fl { margin-bottom: 5px; }
.doc-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.doc-pane { flex: 1; overflow: auto; padding: 0; }
.doc-pane.padded { padding: 12px 14px; }

.righe { width: 100%; border-collapse: collapse; background: #fff; table-layout: fixed; }
.righe thead th { position: sticky; top: 0; z-index: 2; background: linear-gradient(180deg, var(--grid-head1), var(--grid-head2)); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border-soft); font-weight: 600; font-size: 11.5px; padding: 4px 5px; text-align: left; color: #2c3e55; }
.righe td { border-bottom: 1px solid #e3e8ee; border-right: 1px solid #eef1f4; padding: 0; vertical-align: top; }
.righe tr:hover td { background: #fafcff; }
.righe tr.focus td { background: #eef5fd; }
.righe input, .righe textarea, .righe select { width: 100%; border: 0; border-radius: 0; background: transparent; padding: 4px 5px; min-height: 26px; box-shadow: none; }
.righe input:focus, .righe textarea:focus, .righe select:focus { background: #fffbe6; box-shadow: inset 0 0 0 1px #e8c35c; }
.righe textarea { resize: none; overflow: hidden; line-height: 1.35; display: block; }
.righe .n input { text-align: right; font-variant-numeric: tabular-nums; }
.righe td.imp { text-align: right; padding: 5px 6px; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.righe td.act { text-align: center; white-space: nowrap; }
.righe td.act button { border: 0; background: none; cursor: pointer; color: #8a9bb0; padding: 4px 2px; }
.righe td.act button:hover { color: var(--err); }
.righe td.handle { color: #a9b6c5; text-align: center; cursor: grab; padding-top: 5px; font-size: 11px; }
.righe tr.descr td.imp { color: transparent; }
.righe tr.descr select[data-f=iva_codice], .righe tr.descr td.col-rit input { visibility: hidden; }
.righe-add { display: flex; gap: 6px; padding: 8px; flex-wrap: wrap; align-items: center; }
.righe-add .hint { color: var(--muted); font-size: 11px; margin-left: auto; }

.doc-totals { display: flex; gap: 0; align-items: stretch; background: linear-gradient(180deg, #f9fbfd, #e7ecf2); border-top: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.dt-cell { padding: 5px 14px; border-right: 1px solid var(--border-soft); min-width: 100px; }
.dt-cell span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dt-cell b { font-size: 14px; font-variant-numeric: tabular-nums; }
.dt-cell.total { background: #fff; }
.dt-cell.total b { font-size: 17px; color: var(--accent-dark); }
.dt-cell.netto b { color: #1f7a3f; }

.doc-titlebar { display: flex; align-items: center; gap: 8px; }
.doc-titlebar .state { margin-left: 4px; }
.lock-banner { padding: 6px 12px; background: #fff5dd; border-bottom: 1px solid #f1d28c; color: #7a5300; font-size: 12px; }

/* ── Scrivania ─────────────────────────────────────────────────────────── */
.home { flex: 1; overflow: auto; padding: 16px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { display: flex; gap: 12px; align-items: center; padding: 14px; background: #fff; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); box-shadow: 0 3px 10px rgba(29,111,194,.15); }
.tile .ti { font-size: 30px; color: var(--accent); }
.tile b { display: block; font-size: 14.5px; }
.tile small { color: #4d5c6e; font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
.kpi span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi b { display: block; font-size: 20px; margin-top: 3px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 14px; }
.panel-head { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); font-weight: 600; background: linear-gradient(180deg, #fbfcfd, #eef2f6); border-radius: 6px 6px 0 0; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 10px 12px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Tabelle semplici */
.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th { text-align: left; background: linear-gradient(180deg, var(--grid-head1), var(--grid-head2)); border-bottom: 1px solid var(--border); padding: 5px 7px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tbl td { padding: 4px 7px; border-bottom: 1px solid #e8ecf1; vertical-align: middle; }
.tbl tr:nth-child(even) td { background: var(--zebra); }
.tbl tr:hover td { background: var(--hover); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl input, .tbl select { width: 100%; }
.tbl-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 4px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #142740, #1d4f86 70%, #2f7fcf); padding: 20px; }
.login-box { width: 360px; max-width: 100%; background: #fff; border-radius: 8px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-head { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.login-logo { width: 52px; height: 52px; display: block; }
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 12px; }
.login-box .fl input { padding: 7px 9px; font-size: 14px; }
.login-foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 12px; }
.login-remember { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; margin: 4px 0 2px; }
.login-hint { color: var(--muted); font-size: 11px; margin: 0 0 12px 20px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .sidepanel { width: 280px; }
  .doc-head { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .nav { width: 54px; }
  .nav-brand-txt, .nav-item span, .nav-group, .nav-user-name { display: none; }
  .nav-sec.closed .nav-sec-items { display: block; } /* menu a sole icone: tutte le voci visibili */
  .nav-sec + .nav-sec { border-top: 1px solid rgba(255,255,255,.08); }
  .nav-item { justify-content: center; padding: 9px 0; }
  .sidepanel { display: none; }
  .searchbox { width: 160px; }
  .cols2 { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: 1fr 1fr; }
}

/* fatture ricevute: area di caricamento */
.drop-hint { display: flex; align-items: center; gap: 10px; margin: 8px 10px 6px; padding: 8px 12px; border: 2px dashed #b7c9dd; border-radius: 6px; background: #f6f9fc; font-size: 12.5px; color: #3c4b5c; }
.drop-hint .ti { font-size: 26px; color: #6d8fb4; }
.drop-hint .muted { display: block; font-size: 11.5px; margin-top: 2px; }
.drop-hint.over { border-color: #2f7bd0; background: #e6f0fb; }
.small-list { margin: 4px 0 10px 18px; padding: 0; font-size: 12px; max-height: 360px; overflow: auto; }
.small-list li { margin: 1px 0; }
.formcard-head { padding: 9px 14px; font-weight: 700; background: linear-gradient(180deg, #f8fbfe, #dfeaf6); border-bottom: 1px solid var(--border); }
.progress { height: 10px; background: #e5eaf0; border-radius: 5px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #2f7bd0, #4fa0ea); transition: width .25s; }
.upl-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.formcard.drop-over { outline: 2px dashed #2f7bd0; outline-offset: 2px; }

/* ── Assistente IA ─────────────────────────────────────────────────────── */
.ia-btn { position: absolute; z-index: 900; display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 7px 0 5px; border: 0; border-radius: 10px;
  background: linear-gradient(135deg, #6d4bd8, #2b7fd4); color: #fff; font: 700 10.5px/20px system-ui, sans-serif; letter-spacing: .03em; cursor: pointer;
  box-shadow: 0 2px 6px rgba(30,40,90,.35); opacity: .92; }
.ia-btn:hover { opacity: 1; }
.ia-btn .ti { font-size: 12px; }
.ia-badge-demo { display: inline-block; padding: 0 6px; border-radius: 8px; background: linear-gradient(135deg, #6d4bd8, #2b7fd4); color: #fff; font-size: 10.5px; font-weight: 700; }
.ia-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ia-act { display: flex; align-items: center; gap: 7px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; background: #fff; cursor: pointer; font-size: 13px; text-align: left; }
.ia-act:hover:not(:disabled) { border-color: #6d4bd8; background: #f4f1fd; }
.ia-act:disabled { opacity: .45; cursor: default; }
.ia-act .ti { font-size: 17px; color: #6d4bd8; }
.ia-istr { margin-top: 10px; }
.ia-wait { display: flex; align-items: center; gap: 10px; padding: 18px 6px; font-size: 14px; }
.spin { width: 18px; height: 18px; border: 3px solid #d6def0; border-top-color: #6d4bd8; border-radius: 50%; animation: pgspin .8s linear infinite; display: inline-block; }
@keyframes pgspin { to { transform: rotate(360deg); } }
.ti.spin-ic { display: inline-block; animation: pgspin .8s linear infinite; }
.btn-ia { background: linear-gradient(135deg, #6d4bd8, #2b7fd4) !important; color: #fff !important; border-color: #5a45c0 !important; }
.btn-ia:disabled { opacity: .55; }

/* ── Procedura guidata (contratti, relazioni) ──────────────────────────── */
.wiz { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.wiz-steps { width: 220px; flex-shrink: 0; background: #f3f6fa; border-right: 1px solid var(--border); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.wiz-step { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13px; color: #34495e; }
.wiz-step b { width: 24px; height: 24px; border-radius: 50%; background: #dfe7f1; color: #4a6585; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.wiz-step:hover { background: #e6edf6; }
.wiz-step.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); color: #1d4f86; font-weight: 600; }
.wiz-step.on b { background: #1d4f86; color: #fff; }
.wiz-step.done b { background: #22a05a; color: #fff; }
.wiz-body { flex: 1; overflow-y: auto; padding: 16px 22px 0; position: relative; background: #fff; }
.wiz-pane h2 { font-size: 17px; margin: 0 0 12px; color: #1d3557; }
.wiz-pane { max-width: 1050px; }
.wiz-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px 16px; margin: 6px 0 12px; }
.wiz-checks .chk { font-size: 13px; }
.wiz-nav { position: sticky; bottom: 0; display: flex; gap: 8px; max-width: 1050px; padding: 14px 0; margin-top: 16px; border-top: 1px solid var(--border-soft); background: #fff; z-index: 2; }
.wiz-gen { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.wiz-rate input { width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; }
.wiz-rate td { vertical-align: middle; }
.cli-info { font-size: 12px; margin: -6px 0 10px; min-height: 16px; }
.mono-text { font-family: Consolas, "DejaVu Sans Mono", monospace; font-size: 12.5px; line-height: 1.5; }
/* testo di contratti e altri documenti: area di scrittura a tutta larghezza, anteprima come un foglio */
/* testo di contratti e altri documenti: Modifica e Anteprima nello stesso riquadro, stessa larghezza e altezza */
textarea.testo-doc, .ct-preview { display: block; width: 100%; height: max(380px, calc(100vh - 330px)); box-sizing: border-box; }
textarea.testo-doc { padding: 18px 26px; font: 13.5px/1.6 var(--font); color: var(--text); resize: none; max-height: max(380px, calc(100vh - 330px)); overflow-y: auto; }
.ct-preview { border: 1px solid var(--border); background: #fff; padding: 18px 26px; overflow: auto; font: 13px/1.55 Georgia, "Times New Roman", serif; }
.ct-preview h3 { font: 700 13.5px/1.3 system-ui, sans-serif; color: #1d4f86; margin: 16px 0 6px; }
.ct-preview ul { margin: 4px 0 8px 20px; padding: 0; }
.btn-group { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.kbd { font-size: 10px; opacity: .7; margin-left: 4px; }
.rel-foto { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0; }
.rel-foto figure { margin: 0; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; background: #fff; position: relative; }
.rel-foto img { width: 100%; height: 120px; object-fit: cover; display: block; }
.rel-foto figcaption { padding: 4px; }
.rel-foto figcaption input { width: 100%; border: 1px solid var(--border-soft); padding: 3px 5px; font-size: 12px; }
.rel-foto .x { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }

/* ── Strumenti: finestre flottanti, calcolatrice, codice fiscale ───────── */
.fwin { position: fixed; z-index: 1200; background: #f4f6f9; border: 1px solid #8fa3ba; border-radius: 7px; box-shadow: 0 14px 40px rgba(10,25,50,.35); overflow: hidden; outline: none; }
.fwin-head { display: flex; align-items: center; gap: 7px; padding: 6px 8px 6px 10px; background: linear-gradient(180deg, #2b5c95, #1d3f6b); color: #fff; font-weight: 600; cursor: move; user-select: none; }
.fwin-head span { flex: 1; }
.fwin-x { border: 0; background: transparent; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
.fwin-body { padding: 0; }
.dc-tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: #e3e9f1; border-bottom: 1px solid #b9c7d8; flex-wrap: wrap; }
.dc-tab { display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 5px 9px; border-radius: 5px 5px 0 0; cursor: pointer; font-size: 12px; color: #2c3e50; }
.dc-tab.on { background: #f4f6f9; border-color: #b9c7d8; font-weight: 600; margin-bottom: -1px; }
.dc-tab .ti { font-size: 15px; color: #2b6cb0; }
.dc-pane { padding: 10px; }
.dc-calc { display: flex; gap: 10px; }
.dc-roll { flex: 1; display: flex; border: 1px solid #a9b8ca; background: #fff; min-width: 0; height: 196px; }
.dc-roll-tools { display: flex; flex-direction: column; gap: 4px; padding: 4px; background: #eef2f7; border-right: 1px solid #d6dee8; }
.dc-roll-tools button { border: 0; background: transparent; cursor: pointer; padding: 3px; border-radius: 3px; color: #8a6d1d; font-size: 15px; }
.dc-roll-tools button:hover { background: #fff3cf; }
.dc-roll-paper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dc-lines { flex: 1; overflow-y: auto; padding: 4px 8px; font: 12px/1.45 Consolas, "DejaVu Sans Mono", monospace; color: #333; }
.dc-line { display: flex; justify-content: flex-end; gap: 8px; }
.dc-line b { width: 28px; text-align: left; color: #555; }
.dc-line.tot span { font-weight: 700; color: #000; }
.dc-line.tot { border-top: 1px dashed #bbb; }
.dc-line.iva span { color: #1d6fc2; }
.dc-line.sep { border-top: 1px solid #ddd; height: 4px; }
.dc-display { text-align: right; font: 700 22px/1.2 Consolas, "DejaVu Sans Mono", monospace; padding: 4px 8px; border-top: 1px solid #d6dee8; background: #fbfcfe; overflow: hidden; white-space: nowrap; }
.dc-keys { display: grid; grid-template-columns: repeat(5, 40px); gap: 4px; align-content: start; }
.dc-keys button { height: 32px; border: 1px solid #a9b8ca; border-radius: 4px; background: linear-gradient(180deg, #fff, #e8edf3); cursor: pointer; font: 600 13px system-ui, sans-serif; color: #1b2a3c; padding: 0; }
.dc-keys button:hover { border-color: #2b6cb0; }
.dc-keys button.hit, .dc-keys button:active { background: #cfe0f5; }
.dc-keys .fn { font-size: 11px; color: #4a5a6c; }
.dc-keys .op { color: #1d4f86; font-size: 15px; }
.dc-keys .iva { color: #1d6fc2; font-size: 12px; }
.dc-keys .w2 { grid-column: span 2; }
.dc-keys .eq { background: linear-gradient(180deg, #3c86d6, #1d5fae); color: #fff; font-size: 16px; }
.dc-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.dc-row label { display: flex; flex-direction: column; font-size: 11.5px; color: #4a5a6c; flex: 1; min-width: 110px; }
.dc-row input, .dc-row select { padding: 5px 6px; border: 1px solid #a9b8ca; border-radius: 3px; font-size: 13px; }
.dc-row .dc-chk { flex-direction: row; align-items: center; gap: 5px; align-self: flex-end; min-width: 0; }
.dc-fs { border: 1px solid #c9d4e1; border-radius: 5px; padding: 6px 10px 8px; margin: 0 0 8px; }
.dc-fs legend { font-size: 11.5px; font-weight: 600; color: #1d4f86; padding: 0 4px; }
.dc-out { font-size: 13px; min-height: 20px; color: #1b2a3c; }
.dc-help { font-size: 11px; color: #6b7a8c; margin-top: 6px; }
.dc-prop { display: flex; align-items: center; gap: 6px; }
.dc-prop input { width: 80px; padding: 6px; border: 1px solid #a9b8ca; border-radius: 3px; text-align: right; font-size: 14px; }
.dc-prop output { min-width: 80px; padding: 6px; border: 1px solid #2b6cb0; border-radius: 3px; background: #eaf2fc; font-weight: 700; text-align: right; }
.cf-card { border: 2px solid #1f7a3d; border-radius: 12px; overflow: hidden; }
.cf-head { display: flex; gap: 10px; align-items: center; background: #1f7a3d; color: #fff; padding: 10px 14px; }
.cf-head .ti { font-size: 30px; }
.cf-head small { display: block; font-size: 11px; opacity: .85; font-weight: 400; }
.cf-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 90px; gap: 8px 10px; padding: 12px 14px 4px; }
.cf-grid label { min-width: 0; display: flex; flex-direction: column; font-size: 11px; font-weight: 700; color: #1f7a3d; text-transform: uppercase; letter-spacing: .03em; position: relative; }
.cf-grid input, .cf-grid select { width: 100%; min-width: 0; margin-top: 2px; padding: 6px 7px; border: 1px solid #b5c7bb; border-radius: 3px; font-size: 13.5px; text-transform: none; font-weight: 400; color: #111; }
.cf-grid .cf-luogo { grid-column: span 2; }
.cf-ac { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: #fff; border: 1px solid #b5c7bb; box-shadow: 0 6px 16px rgba(0,0,0,.15); max-height: 220px; overflow-y: auto; text-transform: none; font-weight: 400; letter-spacing: 0; }
.cf-ac div { padding: 5px 8px; cursor: pointer; color: #111; font-size: 13px; }
.cf-ac div.on, .cf-ac div:hover { background: #e3f3e8; }
.cf-ac small { color: #6b7a8c; }
.cf-res { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 14px 2px; padding: 10px; background: #f1f8f3; border: 1px dashed #1f7a3d; border-radius: 6px; }
.cf-res span { font: 700 22px/1 Consolas, "DejaVu Sans Mono", monospace; letter-spacing: .12em; color: #12502a; }
.cf-msg { text-align: center; font-size: 12px; min-height: 18px; padding: 0 14px; }
.cf-dec { margin: 6px 14px; font-size: 12.5px; }
.cf-dec summary { cursor: pointer; color: #1d4f86; }
.cf-note { font-size: 10.5px; color: #6b7a8c; padding: 6px 14px 10px; }
.inp-btn { display: flex; gap: 4px; }
.inp-btn input { flex: 1; min-width: 0; }

/* ══ Smartphone e tablet stretti (< 768 px). La versione desktop non cambia. ══ */
.nav-toggle, .nav-veil, .sheet-close { display: none; }
@media (max-width: 767px) {
  html, body { height: 100%; }
  body { font-size: 14px; }
  .app { height: 100dvh; }
  /* menu a scomparsa */
  .nav { position: fixed; left: 0; top: 0; bottom: 0; width: 270px !important; z-index: 1100; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 24px rgba(0,0,0,.35); }
  body.nav-open .nav { transform: none; }
  .nav .nav-brand-txt, .nav .nav-item span, .nav .nav-user-name { display: revert; }
  .nav .nav-group { display: flex; font-size: 11px; padding: 12px 16px 6px; }
  .nav .nav-sec.closed .nav-sec-items { display: none; }
  .nav .nav-sec + .nav-sec { border-top: 0; }
  .nav .nav-brand-txt { display: flex; }
  .nav .nav-item { justify-content: flex-start; padding: 11px 16px; font-size: 15px; }
  .nav-veil { position: fixed; inset: 0; background: rgba(10,20,35,.45); z-index: 1090; }
  body.nav-open .nav-veil { display: block; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 10px; background: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .nav-toggle img { width: 36px; height: 36px; border-radius: 9px; display: block; box-shadow: 0 2px 6px rgba(20,50,90,.25); transition: transform .15s; }
  .nav-toggle:active img { transform: scale(.92); }
  /* barra del titolo */
  .pagebar { flex-wrap: wrap; gap: 6px 8px; padding: 6px 10px; }
  .pagebar h1 { font-size: 16px; flex: 1 1 calc(100% - 60px); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pagebar h1 .ti { font-size: 20px; }
  .pagebar .count, .pagebar .spacer, .pagebar .kbd { display: none; }
  .pagebar select { flex: 1 1 40%; min-width: 0; height: 38px; font-size: 14px; }
  .pagebar .searchbox { order: 10; width: 100% !important; max-width: none; flex: 1 1 100%; }
  .pagebar .searchbox input { height: 40px; font-size: 16px; }
  .pagebar .btn { height: 38px; padding: 0 12px; }
  .pagebar .badge { display: none; }
  /* elenchi a schede */
  .grid-m .grid-head { display: none; }
  .grid-m .grid-row { width: 100% !important; height: 62px; display: block; padding: 7px 12px; border-bottom: 1px solid #e6ebf1; }
  .grid-m .gm-top { display: flex; gap: 8px; align-items: baseline; }
  .grid-m .gm-main { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid-m .gm-side { font-weight: 700; font-size: 15px; white-space: nowrap; }
  .grid-m .gm-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
  .grid-m .gm-sub .badge { font-size: 11px; }
  .grid-m .gm-dot { font-style: normal; margin: 0 5px; color: #b5c0cc; }
  /* selezione su mobile: sfondo chiaro + testo scuro (anche con l'elenco a fuoco, che su desktop usa il blu scuro) */
  .grid-m .grid-row.sel, .grid-m.focused .grid-row.sel { background: #dbe9f8; color: var(--text, #1d2733); box-shadow: inset 4px 0 0 var(--accent-dark); }
  .grid-m .grid-row.sel .gm-sub, .grid-m .grid-row.sel .muted { color: #44566a; }
  .grid-m .grid-row.sel .badge { box-shadow: none; }
  .az-bar, .azbar, .grid-az { display: none !important; }
  .statusbar { font-size: 12px; flex-wrap: wrap; }
  /* scheda laterale come pannello dal basso */
  .workarea { position: relative; }
  .sidepanel { display: flex !important; position: fixed; left: 0; right: 0; bottom: 0; width: auto !important; height: 78dvh; z-index: 1050; border-left: 0; border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.25); transform: translateY(105%); transition: transform .22s ease; }
  .workarea.sheet-open .sidepanel { transform: none; }
  .sheet-close { display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: #eef2f7; padding: 10px; font-size: 14px; color: #34495e; border-radius: 14px 14px 0 0; cursor: pointer; flex-shrink: 0; }
  .sp-kv { grid-template-columns: 110px 1fr; font-size: 14px; }
  .sp-head .sp-title { font-size: 17px; }
  /* barra comandi in basso: scorrevole, pulsanti più grandi */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px; gap: 2px; }
  .toolbar .tb { min-width: 66px; padding: 6px 6px; font-size: 11.5px; }
  .toolbar .tb .ti { font-size: 22px; }
  .toolbar .tb-sep { display: none; }
  /* moduli */
  .formpage { padding: 8px; }
  .formcard { max-width: none !important; }
  .formcard-body { padding: 10px; }
  .cols2 { grid-template-columns: minmax(0, 1fr) !important; }
  fieldset, .fieldset { min-width: 0; }
  .cols2 > *, .formcard-body > * { min-width: 0; }
  .frow { flex-wrap: wrap; }
  .frow > .fl, .frow > label.fl { flex: 1 1 140px !important; min-width: 140px; }
  .fl input, .fl select, .fl textarea { font-size: 16px; min-height: 40px; }
  .btn { min-height: 38px; }
  .modal { width: calc(100vw - 16px) !important; max-width: none !important; max-height: calc(100dvh - 16px); }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs .tab { white-space: nowrap; padding: 9px 12px; }
  /* editor dei documenti: testata in colonna e righe a schede */
  .doc-head { grid-template-columns: minmax(0, 1fr) !important; padding: 8px; }
  .doc-head > * { min-width: 0; }
  .doc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .doc-cli .cli-line input { font-size: 16px; min-height: 42px; }
  .righe, .righe tbody, .righe tr, .righe td { display: block; width: 100%; }
  .righe thead { display: none; }
  .righe { table-layout: auto; background: transparent; }
  .righe tbody tr { width: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 6px; padding: 8px 34px 8px 8px; margin: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; position: relative; }
  .righe td { border: 0 !important; }
  .righe td.handle, .righe td.col-rit { display: none; }
  .righe td:nth-child(2) { order: 1; }
  .righe td:nth-child(3) { grid-column: 1 / -1; order: 0; }
  .righe td:nth-child(4) { order: 2; } .righe td:nth-child(5) { order: 3; } .righe td:nth-child(6) { order: 4; }
  .righe td:nth-child(7) { order: 5; } .righe td:nth-child(8) { order: 6; } .righe td.imp { order: 7; grid-column: span 2; text-align: right; font-size: 15px; padding-top: 10px; }
  .righe td:nth-child(4)::before { content: 'Quantità'; } .righe td:nth-child(5)::before { content: 'U.m.'; } .righe td:nth-child(6)::before { content: 'Prezzo'; }
  .righe td:nth-child(7)::before { content: 'Sconto %'; } .righe td:nth-child(8)::before { content: 'IVA'; } .righe td:nth-child(2)::before { content: 'Codice'; }
  .righe td::before { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .righe input, .righe textarea, .righe select { border: 1px solid var(--border) !important; border-radius: 5px; min-height: 40px; font-size: 16px; background: #fff; }
  .righe td:last-child { position: absolute; top: 6px; right: 4px; width: auto; }
  .righe td:last-child button { font-size: 20px; }
  .doc-totals { font-size: 13px; flex-wrap: wrap; position: sticky; bottom: 0; z-index: 5; }
  .main:has(.doc-editor) { overflow-y: auto; }
  .doc-editor, .doc-body { flex: none; min-height: auto; }
  .doc-pane { flex: none; overflow: visible; }
  .righe td.imp { grid-column: 1 / -1; }
  /* procedure guidate */
  .wiz { flex-direction: column; }
  .wiz-steps { width: auto; flex-direction: row; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--border); }
  .wiz-step { flex-shrink: 0; padding: 6px 8px; }
  .wiz-step span { display: none; }
  .wiz-step.on span { display: inline; }
  .wiz-body { padding: 10px 10px 0; }
  .wiz-checks { grid-template-columns: 1fr; }
  .wiz-rate, .wiz-rate tbody, .wiz-rate tr, .wiz-rate td { display: block; width: 100%; }
  .wiz-rate thead { display: none; }
  .wiz-rate tbody tr { display: grid; grid-template-columns: 30px 1fr 1fr; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; }
  .wiz-rate tbody td:nth-child(4) { grid-column: 1 / -1; }
  .wiz-rate tfoot, .wiz-rate tfoot tr { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  /* strumenti */
  .fwin { left: 4px !important; right: 4px; top: 50px !important; width: auto !important; }
  .dc-calc { flex-direction: column; }
  .dc-roll { height: 150px; }
  .dc-keys { grid-template-columns: repeat(5, 1fr); }
  .dc-keys button { height: 48px; font-size: 17px; }
  .cf-grid { grid-template-columns: 1fr 1fr; }
  .cf-grid .cf-luogo { grid-column: 1 / -1; }
  .ia-btn { height: 26px; font-size: 12px; padding: 0 9px 0 7px; }
  .ia-menu { grid-template-columns: 1fr; }
  /* scrivania */
  .kpis { grid-template-columns: 1fr 1fr !important; }
  .home-grid, .home-cols { grid-template-columns: 1fr !important; }
}

/* ── E-mail ────────────────────────────────────────────────────────────── */
.mail-wrap { display: flex; gap: 14px; align-items: flex-start; max-width: 1280px; }
.mail-main { flex: 1; min-width: 0; max-width: none !important; }
.mail-ia { width: 320px; flex-shrink: 0; position: sticky; top: 0; }
.mail-firma { margin: -4px 0 10px; font-size: 12px; }
.mail-firma pre { margin: 2px 0 0; font: 12px/1.4 var(--font); color: #555; white-space: pre-wrap; border-left: 3px solid #dfe7f1; padding-left: 8px; }
.att { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; margin: 0 6px 6px 0; border: 1px solid var(--border); border-radius: 5px; background: #f6f9fc; font-size: 12.5px; }
.att .ti-file-type-pdf { color: #c0392b; font-size: 16px; }
.att button { border: 0; background: none; cursor: pointer; color: #8a9bb0; padding: 0 2px; }
@media (max-width: 767px) { .mail-wrap { flex-direction: column; } .mail-ia { width: 100%; position: static; } }
.altro-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; max-width: 1500px; align-items: start; }
.altro-wrap .formcard { max-width: none; }
@media (max-width: 1100px) { .altro-wrap { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 767px) {
  textarea.testo-doc, .ct-preview { height: 60vh; max-height: 60vh; }
  textarea.testo-doc { padding: 10px 12px; font-size: 16px; }
  .ct-preview { padding: 14px 14px; }
}

/* ── 1.5.0: moduli centrati, schede impostazioni su più righe, barre scorrevoli su smartphone ── */
.formcard.formcard-c { margin-left: auto; margin-right: auto; }
.tabs[data-tabs="imp"] { flex-wrap: wrap; overflow: visible; row-gap: 0; }
@media (max-width: 767px) {
  .tabs[data-tabs="imp"] { flex-wrap: nowrap; overflow-x: auto; }
  .toolbar { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .toolbar.at-end { -webkit-mask-image: none; mask-image: none; }
}

/* ── 1.5.0: magazzino e lettura codici a barre ── */
.scan-wrap { display: flex; gap: 4px; }
.scan-wrap input { flex: 1; min-width: 0; }
.scan-btn { padding: 0 9px; }
.modal.modal-scan { width: 520px; max-width: calc(100vw - 20px); }
.scan-box { position: relative; background: #0d1622; border-radius: 6px; overflow: hidden; }
.scan-box video { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 2px solid rgba(63,215,154,.9); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.scan-last { margin-top: 8px; padding: 7px 10px; border-radius: 6px; background: #eef2f6; color: var(--text) !important; font-size: 13px; }
.scan-last:empty { display: none; }
.scan-last.scan-err { background: #fdeeec; color: #8e2a1f !important; }
.scan-foto { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 10px 6px 4px; }
.scan-foto[hidden] { display: none; }
.scan-foto-t { margin: 0; color: var(--text); }
.scan-foto-btn { font-size: 15px; padding: 10px 18px; height: auto; cursor: pointer; }
.mag-fs.mag-off { opacity: .55; }
.mag-giac { padding-top: 6px; }
.lbl { font-size: 11.5px; color: var(--muted); }
.neg { color: var(--err); }
.mag-banco { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; max-width: 1400px; }
.mag-scan { display: flex; gap: 6px; align-items: stretch; }
.mag-scan input { flex: 1; min-width: 0; font-size: 18px !important; padding: 8px 12px !important; min-height: 44px; }
.mag-scan .btn { font-size: 15px; }
.mag-tot { font-size: 30px; font-weight: 800; color: #0d2b5c; }
.qty-in { width: 80px; text-align: right; }
.tbl .num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
@media (max-width: 767px) {
  .mag-banco { grid-template-columns: minmax(0, 1fr); }
  .mag-scan input { font-size: 18px !important; }
  .mag-scan .scan-lbl { display: none; }            /* sul telefono solo l'icona: il campo resta largo */
  .mag-scan .btn { flex-shrink: 0; padding: 0 14px; }
  .mag-scan .btn .ti { font-size: 22px; }
}
/* nel programma OnlyFatt Desktop (postazione fissa) la fotocamera non serve: si usa la pistola */
html.pg-desk [data-scan-for], html.pg-desk [data-camera] { display: none !important; }
.inline-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.tbl tr.muted-row td { color: #8796a8; }
@media (max-width: 767px) { .toolbar .tb { flex-shrink: 0; } }

/* scheda cliente: il riquadro Note riempie l'altezza della colonna */
.cols2.cols-stretch { align-items: stretch; }
.col-fill { display: flex; flex-direction: column; }
.col-fill .fs-fill { flex: 1; display: flex; flex-direction: column; }
.col-fill .fs-fill .fl { flex: 1; display: flex; flex-direction: column; }
.col-fill .fs-fill textarea { flex: 1; min-height: 140px; resize: vertical; }
/* ── 1.6.0: sezioni attivabili, fattura rapida ── */
.sez-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px; }
.sez-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 8px; cursor: pointer; background: #fff; }
.sez-item:hover { border-color: #9cc2ea; background: #f7fbff; }
.sez-item > .ti { font-size: 22px; color: #1d4f86; margin-top: 1px; }
.sez-item span { display: flex; flex-direction: column; }
.sez-item small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sez-item input { margin-top: 4px; }
.tile.tile-main { background: linear-gradient(135deg, #16b07a, #0f8f62); color: #fff; border-color: #0f8f62; }
.tile.tile-main small, .tile.tile-main .ti { color: #eafff5 !important; }
.ctl { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; margin: 6px 0; font-size: 12.5px; line-height: 1.45; }
.ctl > .ti { font-size: 18px; flex-shrink: 0; margin-top: -1px; }
.ctl span { flex: 1; }
.ctl .btn { display: inline-flex; margin: 3px 0 0 8px; vertical-align: middle; }
.ctl-errore { background: #fdecea; color: #7d241b; } .ctl-errore > .ti { color: #c0392b; }
.ctl-avviso { background: #fff6e0; color: #6b4a00; } .ctl-avviso > .ti { color: #c98a12; }
.ctl-ok { background: #e7f6ec; color: #1e6b38; } .ctl-ok > .ti { color: #2e8b4e; }
.ctl-head { font-weight: 700; margin: 10px 0 2px; }
.ctl-bar { margin: 8px 12px 0; padding: 8px 12px; border: 1px solid #f1d9a6; background: #fffbf0; border-radius: 8px; }
.ctl-bar > b { display: block; font-size: 13px; color: #6b4a00; margin-bottom: 2px; }
.ctl-bar .ctl { margin: 4px 0; }
.fr { max-width: 900px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px 24px 16px; }
.fr h2 { font-size: 19px; margin: 6px 0 14px; color: #0d2b5c; }
.fr h3 { font-size: 15px; margin: 0 0 8px; color: #0d2b5c; }
.fr .fl input, .fr .fl select, .fr .fl textarea { font-size: 14px; min-height: 34px; }
.fr-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; }
.fr-steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; background: #f1f4f8; color: #66768a; font-weight: 600; cursor: default; }
.fr-steps li b { width: 26px; height: 26px; border-radius: 50%; background: #dfe7f1; display: inline-flex; align-items: center; justify-content: center; }
.fr-steps li.on { background: #e3effb; color: #0d2b5c; } .fr-steps li.on b { background: #1d6fc2; color: #fff; }
.fr-steps li.done { color: #1e6b38; cursor: pointer; } .fr-steps li.done b { background: #16b07a; color: #fff; }
.fr-big input { font-size: 16px !important; min-height: 42px !important; }
.fr-or { text-align: center; color: var(--muted); margin: 14px 0 10px; position: relative; font-size: 12.5px; }
.fr-or span { background: #fff; padding: 0 10px; position: relative; } .fr-or::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--border-soft); }
.fr-tipo { display: flex; gap: 10px; margin-bottom: 10px; }
.fr-tipo label { flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 600; }
.fr-tipo label:has(input:checked) { border-color: #1d6fc2; background: #f2f8ff; }
.fr-tipo .ti { font-size: 18px; color: #1d4f86; }
.fr-sel { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: #e7f6ec; color: #1e6b38; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.fr-sel > .ti { font-size: 20px; } .fr-sel span { flex: 1; }
.fr-righe { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.fr-righe th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px; font-weight: 600; } .fr-righe th.num { text-align: right; }
.fr-righe td { padding: 3px 4px; } .fr-righe input, .fr-righe select { width: 100%; font-size: 14px; min-height: 34px; }
.fr-righe input.num, .fr-righe td.num { text-align: right; }
.fr-ivainc { display: block; margin: 10px 0 4px; }
.fr-tot { display: flex; gap: 18px; justify-content: flex-end; align-items: baseline; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); font-size: 14px; }
.fr-tot b { font-size: 22px; color: #0d2b5c; } .fr-tot small { flex-basis: 100%; text-align: right; color: var(--muted); }
.fr-riep { margin-bottom: 12px; }
.fr-riep-cli { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 8px; margin-bottom: 8px; }
.fr-riep-cli > .ti { font-size: 24px; color: #1d4f86; } .fr-riep-cli > div { flex: 1; }
.fr-riep-tot td { font-weight: 800; font-size: 16px; color: #0d2b5c; border-top: 2px solid var(--border); }
.fr-nav { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.fr-nav .btn { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.btn-ok { background: linear-gradient(180deg, #19b77f, #0f8f62); border-color: #0d7f57; color: #fff; }
.fr-err { margin-bottom: 10px; } .fr-err ul { margin: 4px 0 0 18px; padding: 0; }
.fr-ok { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: #e7f6ec; border-radius: 10px; color: #1e6b38; margin-bottom: 12px; }
.fr-ok > .ti { font-size: 42px; color: #16b07a; } .fr-ok h2 { margin: 0 0 2px; color: #155a33; }
.fr-box { border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.fr-invio { margin: 0; padding-left: 22px; } .fr-invio li { margin: 8px 0; } .fr-invio small { display: block; color: var(--muted); margin-top: 3px; }
.fr-azioni { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 767px) {
  .fr { padding: 12px; border-radius: 0; border-left: 0; border-right: 0; }
  .fr-steps li span { display: none; } .fr-steps li { justify-content: center; }
  .fr-tipo { flex-direction: column; }
  .fr-righe thead { display: none; } .fr-righe tr { display: grid; grid-template-columns: 1fr 1fr 1fr 36px; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
  .fr-righe td:first-child { grid-column: 1 / -1; } .fr-righe td.iva-col { grid-column: 1 / 3; }
}
.fr [hidden], .fr-nav[hidden] { display: none !important; }

/* ── OnlyFatt sul telefono (1.7) ───────────────────────────────────────── */
.nav-user .nav-tel .ti { font-size: 18px; }
@media (min-width: 768px) and (max-width: 860px) { .nav-user .nav-tel, .nav-user > .ti-user-circle { display: none; } }

/* riquadro QR code */
.tq { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.tq-qr { width: 230px; flex-shrink: 0; }
.tq-img { position: relative; width: 230px; height: 230px; border: 1px solid var(--border-soft); border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tq-img svg { width: 100%; height: 100%; display: block; transition: filter .25s, opacity .25s; }
.tq-logo { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 9px; box-shadow: 0 0 0 4px #fff; }
.tq-wait .ti { font-size: 34px; color: var(--accent); animation: tq-spin 1s linear infinite; }
@keyframes tq-spin { to { transform: rotate(360deg); } }
.tq-bar { height: 4px; border-radius: 2px; background: #e4ebf3; margin-top: 8px; overflow: hidden; }
.tq-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #16b07a, #1d6fc2); transition: width 1s linear; }
.tq.scaduto .tq-img svg, .tq.scaduto .tq-logo, .tq.fatto .tq-img svg, .tq.fatto .tq-logo { filter: blur(5px) grayscale(1); opacity: .35; }
.tq.scaduto .tq-codice, .tq.fatto .tq-codice { opacity: .35; text-decoration: line-through; }
.tq-info { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.tq-stato { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: #1d4f86; line-height: 1.45; }
.tq-stato .ti { font-size: 18px; vertical-align: -3px; }
.tq-stato.ok { background: #e6f5ea; color: #1d6b37; font-size: 14.5px; }
.tq-stato.warn { background: #fff5dd; color: #7a5300; }
.tq-alt { color: var(--muted); line-height: 1.45; }
.tq-codice { margin-top: 6px; font: 700 28px/1.1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 3px; color: var(--text); user-select: all; }
.tq-warn { margin: 0; font-size: 12.5px; }
.tq-nuovo { align-self: flex-start; }
.tel-wrap { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; max-width: 1200px; }
.tel-passi { margin: 0; padding-left: 20px; line-height: 1.55; }
.tel-passi li { margin-bottom: 8px; }
.tel-link { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.tel-link .inp-btn { display: flex; }
.tel-link input { flex: 1; min-width: 0; font-size: 12.5px; }
.tel-disp { max-width: 1200px; margin-top: 14px; }
@media (max-width: 1000px) { .tel-wrap { grid-template-columns: minmax(0, 1fr); } }

/* pagine pubbliche sul telefono (installa, conferma accesso) */
.ph-body { min-height: 100vh; min-height: 100dvh; margin: 0; background: linear-gradient(165deg, #142740, #1d4f86 65%, #2f7fcf); font-family: var(--font); color: var(--text);
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); box-sizing: border-box; }
.ph { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.ph-head { display: flex; gap: 12px; align-items: center; color: #fff; padding: 4px 4px 2px; }
.ph-head img { border-radius: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.ph-wm { font-size: 26px; color: #fff; }
.ph-wm span { color: #3fe0a5; }
.ph-sub { color: #c4d6ec; font-size: 13px; }
.ph-card { background: #fff; border-radius: 18px; padding: 22px 20px; box-shadow: 0 18px 50px rgba(0,0,0,.35); position: relative; }
.ph-card h1 { font-size: 21px; margin: 0 0 8px; line-height: 1.25; }
.ph-card p { font-size: 15px; line-height: 1.5; margin: 0 0 14px; color: #3a4a5c; }
.ph-ico { width: 58px; height: 58px; border-radius: 50%; background: #e6f5ea; color: #1d8a4e; display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 10px; }
.ph-ico.warn { background: #fff1d6; color: #b57400; }
.ph-btn { display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border: 0; border-radius: 13px; background: linear-gradient(135deg, #16b07a, #0f8f62); color: #fff;
  font: 600 16.5px var(--font); text-decoration: none; cursor: pointer; box-shadow: 0 6px 16px rgba(15,143,98,.35); -webkit-tap-highlight-color: transparent; }
.ph-btn:active { transform: scale(.98); }
.ph-btn.big { min-height: 60px; font-size: 18px; margin-bottom: 14px; }
.ph-btn.ghost { background: #eef3f9; color: #1d4f86; box-shadow: none; }
.ph-btn .ti { font-size: 22px; }
.ph-note { font-size: 13px !important; color: var(--muted) !important; margin: 14px 0 0 !important; }
.ph-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ph-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.ph-steps li > span { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: #1d6fc2; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.ph-steps small { color: var(--muted); font-size: 12.5px; }
.ph-dim { opacity: .55; font-size: 13px; }
.ph-key { display: inline-block; min-width: 22px; padding: 0 5px; border: 1px solid #c9d4e0; border-radius: 6px; background: #f4f7fb; text-align: center; }
.ph-ios-ico { width: 22px; height: 22px; vertical-align: -5px; color: #1d6fc2; font-size: 22px; }
.ph-mini { width: 22px; height: 22px; border-radius: 5px; vertical-align: -5px; }
.ph-ios-other { background: #fff5dd; color: #7a5300 !important; padding: 9px 11px; border-radius: 10px; font-size: 13.5px !important; }
.ph-riserva { margin-top: 16px; padding: 12px; border-radius: 12px; background: #eef5fd; font-size: 13.5px; line-height: 1.45; color: #1d4f86; }
.ph-codice { font: 700 30px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 4px; color: var(--text); margin: 6px 0 2px; user-select: all; }
.ph-arrow { display: none; }
@supports (-webkit-touch-callout: none) {
  /* Safari su iPhone: freccia che indica la barra in basso dove si trova Condividi */
  #s-ios .ph-arrow { display: block; text-align: center; font-size: 30px; color: #fff; position: absolute; left: 0; right: 0; bottom: -46px; animation: ph-bounce 1.4s ease-in-out infinite; }
  #s-ios { margin-bottom: 40px; }
}
@keyframes ph-bounce { 50% { transform: translateY(8px); } }
.ph-qr { width: 220px; height: 220px; margin: 4px auto 6px; }
.ph-qr svg { width: 100%; height: 100%; }
.ph-ok, .ph-warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.ph-ok { background: #e3f7ec; color: #145c34; }
.ph-warn { background: #fff5dd; color: #7a5300; }
.ph-ok .ti, .ph-warn .ti { font-size: 24px; flex-shrink: 0; }
.ph-link { color: #dbe8f7; text-align: center; font-size: 14px; padding: 8px; text-decoration: none; }
.ph-link[hidden] { display: none; }
.ph-foot { color: #9fb6d3; text-align: center; font-size: 11.5px; padding-top: 4px; }
.ph [hidden] { display: none !important; }

/* accesso con codice */
.login-body { flex-direction: column; }
.login-box[hidden] { display: none; }
.lc-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; color: #0d2b5c; }
.lc-title .ti { font-size: 24px; color: var(--accent); }
.lc-input { width: 100%; box-sizing: border-box; height: 54px; text-align: center; font: 700 26px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 4px; text-transform: uppercase; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }
.lc-open, .lc-back { margin-top: 8px; background: #f2f6fb; }

/* invito a installare (solo telefono, browser) */
.app-banner { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1080; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(10,30,60,.3); font-size: 13px; }
.app-banner[hidden] { display: none; }
.app-banner img { border-radius: 9px; flex-shrink: 0; }
.app-banner div { flex: 1; min-width: 0; }
.app-banner b { display: block; }
.app-banner small { color: var(--muted); }
.app-banner-x { border: 0; background: none; font-size: 18px; color: #8a9bb0; padding: 6px; cursor: pointer; }

/* azioni rapide nella scheda cliente */
.sp-azioni { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px; padding: 8px 10px 2px; }
.sp-azioni a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border: 1px solid var(--border-soft); border-radius: 8px; background: #fff; color: var(--accent-dark); text-decoration: none; font-size: 11.5px; }
.sp-azioni a:hover { border-color: var(--accent); background: var(--accent-soft); }
.sp-azioni .ti { font-size: 21px; }
.sp-azioni .ti-brand-whatsapp { color: #1fa855; }

/* Scrivania del telefono */
.m-home { display: none; }
@media (max-width: 767px) {
  .m-home { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .m-home ~ .home-grid { display: none; }
  .m-tile { display: flex; flex-direction: column; gap: 3px; min-height: 104px; padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--border-soft); color: var(--text); text-decoration: none;
    box-shadow: 0 2px 8px rgba(20,50,90,.08); -webkit-tap-highlight-color: transparent; }
  .m-tile:active { transform: scale(.97); background: var(--accent-soft); }
  .m-tile .ti { font-size: 30px; color: var(--accent); margin-bottom: auto; }
  .m-tile b { font-size: 15.5px; }
  .m-tile small { color: var(--muted); font-size: 12px; }
  .m-tile.m-main { grid-column: 1 / -1; min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 12px; background: linear-gradient(135deg, #16b07a, #0f8f62); border-color: #0f8f62; color: #fff; }
  .m-tile.m-main .ti { color: #fff; margin: 0; font-size: 34px; }
  .m-tile.m-main b { font-size: 18px; }
  .m-tile.m-main small { color: #e3fff2; flex-basis: 100%; padding-left: 46px; margin-top: -4px; }
  .m-alert { color: var(--err); font-weight: 600; }
  .m-home .m-tile:last-child:nth-child(even) { grid-column: 1 / -1; min-height: 0; }
  body.has-banner .main { padding-bottom: 84px; }
  .home { padding: 12px 10px; }
  .sp-azioni a { padding: 10px 4px; font-size: 12.5px; }
  .sp-azioni .ti { font-size: 24px; }
}

/* app installata: niente barre del browser → spazio per notch e barra Home, pulsante Indietro */
html.standalone body { background: var(--nav-bg); }
html.standalone .app { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); box-sizing: border-box; background: var(--bg); }
html.standalone .nav { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
html.standalone .main { padding-bottom: env(safe-area-inset-bottom); }
html.standalone #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
.nav-back { display: none; }
@media (max-width: 767px) {
  html.standalone .nav-back { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 22px; color: #1d3557; cursor: pointer; }
  html.standalone .app-banner { display: none; }
  .pagebar:has(.nav-back) h1 { flex-basis: calc(100% - 110px); }
}

/* ── Archivio documenti (1.8) ─────────────────────────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; flex-shrink: 0; }
.seg button { border: 0; background: none; padding: 5px 9px; cursor: pointer; color: #45576b; font: inherit; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.seg button + button { border-left: 1px solid var(--border-soft); }
.seg button.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.seg button .ti { font-size: 16px; }
.seg-full { display: flex; width: 100%; }
.seg-full button { flex: 1; justify-content: center; padding: 7px 4px; }
.btn-xs { padding: 1px 6px; font-size: 12px; height: auto; line-height: 1.5; }
.pulse { animation: pg-pulse 1.4s ease-in-out infinite; }
@keyframes pg-pulse { 50% { box-shadow: 0 0 0 4px rgba(29,111,194,.25); } }
.arc-foto { display: none; }

.arc { flex: 1; display: grid; grid-template-columns: 236px minmax(0, 1fr) 0; min-height: 0; position: relative; }
.arc.prev-open { grid-template-columns: 236px minmax(0, 1fr) minmax(360px, 34%); }
.arc-side { background: var(--side); border-right: 1px solid var(--border); overflow-y: auto; padding: 6px 0 14px; font-size: 13px; }
.arc-viste-l a, .arc-node { display: flex; align-items: center; gap: 7px; padding: 6px 12px; color: var(--text); text-decoration: none; cursor: pointer; border-left: 3px solid transparent; }
.arc-viste-l a .ti { font-size: 17px; color: #5b7898; }
.arc-viste-l a:hover, .arc-node:hover { background: #dde9f6; }
.arc-viste-l a.on, .arc-node.on { background: #cfe1f5; border-left-color: var(--accent); font-weight: 600; }
.arc-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.arc-node { padding: 4px 6px 4px calc(4px + var(--liv) * 16px); position: relative; }
.arc-node.drop { background: #bfe6d3 !important; outline: 2px dashed #16b07a; outline-offset: -2px; }
.arc-tw { width: 18px; height: 18px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.arc-tw.vuoto { cursor: default; }
.arc-ic { font-size: 17px; color: #d79b21; }
.arc-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arc-node small { color: var(--muted); font-weight: 400; font-size: 11px; }
.arc-more { border: 0; background: none; padding: 0 3px; cursor: pointer; color: var(--muted); visibility: hidden; }
.arc-node:hover .arc-more, .arc-node.on .arc-more { visibility: visible; }
.arc-menu { position: fixed; z-index: 3000; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; width: 220px; }
.arc-menu button { display: flex; width: 100%; gap: 8px; align-items: center; border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer; font: inherit; font-size: 13px; text-align: left; color: var(--text); }
.arc-menu button:hover { background: var(--hover); }
.arc-menu .btn-danger { color: var(--err); }
.arc-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 12px; }
.arc-chip { --c: #5b7a99; display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; line-height: 18px; background: color-mix(in srgb, var(--c) 14%, #fff); color: color-mix(in srgb, var(--c) 80%, #000); border: 1px solid color-mix(in srgb, var(--c) 35%, #fff); text-decoration: none; cursor: default; white-space: nowrap; }
a.arc-chip { cursor: pointer; }
a.arc-chip.on { background: var(--c); color: #fff; }
.arc-chip small { opacity: .7; }
.arc-chip button { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; }

.arc-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: #fff; }
.arc-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
.arc-bar .spacer { flex: 1; }
.arc-bar select { height: 28px; }
.arc-tit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arc-cartelle-btn { display: none; }
.arc-flt { --c: var(--accent); display: inline-flex; align-items: center; gap: 4px; padding: 1px 4px 1px 8px; border-radius: 12px; background: color-mix(in srgb, var(--c) 12%, #fff); border: 1px solid color-mix(in srgb, var(--c) 30%, #fff); font-size: 12px; }
.arc-flt button { border: 0; background: none; cursor: pointer; font-size: 15px; line-height: 1; color: var(--muted); }
.arc-sel { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 12px; background: #fff7e0; border-bottom: 1px solid #f1d28c; font-size: 13px; }
.arc-sel b { margin-right: 6px; }
.arc-list { flex: 1; overflow-y: auto; outline: none; }
.arc-hd, .arc-row { display: grid; grid-template-columns: 30px 40px minmax(0, 1fr) minmax(120px, 190px) 90px 110px 70px; gap: 8px; align-items: center; padding: 0 12px; }
.arc-hd { position: sticky; top: 0; z-index: 1; background: linear-gradient(180deg, var(--grid-head1), var(--grid-head2)); border-bottom: 1px solid var(--border); font-size: 11.5px; color: #4a5b6e; font-weight: 600; height: 28px; }
.arc-row { min-height: 52px; border-bottom: 1px solid #edf1f5; cursor: pointer; font-size: 13px; }
.arc-row:hover { background: var(--hover); }
.arc-row.sel { background: #fff5d9; }
.arc-row.cur { background: #dbe9f8; box-shadow: inset 3px 0 0 var(--accent); }
.arc-ck { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.arc-ico { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.arc-ico img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border-soft); }
.arc-ti { display: flex; flex-direction: column; min-width: 0; padding: 5px 0; }
.arc-ti b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.arc-ti .arc-tg:empty { display: none; }
.arc-tg { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0; }
.arc-sub { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arc-msub { display: none; }
.arc-col { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #34495e; font-size: 12.5px; }
.arc-col .ti { color: var(--muted); }
.arc-dt { white-space: nowrap; }
.arc-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 12px; align-content: start; }
.arc-card { position: relative; border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; background: #fff; cursor: pointer; display: flex; flex-direction: column; transition: box-shadow .15s; }
.arc-card:hover { box-shadow: 0 4px 14px rgba(20,50,90,.14); }
.arc-card.cur { outline: 2px solid var(--accent); }
.arc-card.sel { outline: 2px solid #e5a50a; }
.arc-card .arc-ck { position: absolute; left: 6px; top: 6px; z-index: 1; background: rgba(255,255,255,.9); border-radius: 4px; padding: 2px; opacity: 0; }
.arc-card:hover .arc-ck, .arc-card.sel .arc-ck { opacity: 1; }
.arc-th { height: 130px; background: #f2f5f9; display: flex; align-items: center; justify-content: center; position: relative; border-bottom: 1px solid var(--border-soft); }
.arc-th img { width: 100%; height: 100%; object-fit: cover; }
.arc-big { font-size: 58px; }
.arc-ext { position: absolute; right: 6px; bottom: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; background: rgba(255,255,255,.9); padding: 0 5px; border-radius: 4px; color: #4a5b6e; }
.arc-ct { padding: 7px 9px 9px; font-size: 12.5px; min-width: 0; }
.arc-ct b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.arc-ct small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arc-vuoto { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 60px 20px; text-align: center; color: var(--muted); }
.arc-vuoto .ti { font-size: 56px; color: #9bb3cc; }
.arc-vuoto b { font-size: 16px; color: var(--text); }
.arc-vuoto span { max-width: 420px; line-height: 1.5; }
.arc-drop { position: absolute; inset: 8px; border: 3px dashed #16b07a; border-radius: 14px; background: rgba(230,250,240,.92); display: none; align-items: center; justify-content: center; z-index: 5; pointer-events: none; }
.arc-drop.on { display: flex; }
.arc-drop div { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #0f6b49; }
.arc-drop .ti { font-size: 54px; }
.arc-drop b { font-size: 18px; }
body.arc-dragging .arc-node { transition: background .1s; }

.arc-prev { background: var(--side); border-left: 1px solid var(--border); overflow-y: auto; min-width: 0; display: none; }
.arc.prev-open .arc-prev { display: block; }
.arc-prev-empty { display: none; }
.arc-p-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border-soft); background: #fff; position: relative; }
.arc-p-x { position: absolute; right: 8px; top: 8px; }
.arc-p-nome { display: flex; gap: 6px; align-items: center; font-weight: 600; padding-right: 40px; font-size: 13.5px; min-width: 0; }
.arc-p-nome span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arc-p-nome .ti { font-size: 20px; flex-shrink: 0; }
.arc-p-meta { font-size: 12px; margin-top: 2px; }
.arc-v { background: #e6ebf1; display: flex; align-items: center; justify-content: center; }
.arc-v-pdf { width: 100%; height: max(380px, calc(100vh - 560px)); border: 0; display: block; background: #fff; }
.arc-v-txt { height: 300px; }
.arc-v-img { display: block; width: 100%; text-align: center; padding: 8px; box-sizing: border-box; cursor: zoom-in; }
.arc-v-img img { max-width: 100%; max-height: 420px; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.arc-v-ico { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.arc-huge { font-size: 76px; }
.arc-p-btns { display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-soft); background: #fff; flex-wrap: wrap; }
.arc-p-btns .spacer { flex: 1; }
.arc-form { padding: 10px 12px 18px; display: flex; flex-direction: column; gap: 2px; }
.arc-form .frow { gap: 8px; }
.arc-form .frow .fl { flex: 1; min-width: 130px; }
.arc-form #a-cont { margin-top: 6px; }
.arc-tagin { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 32px; padding: 3px 5px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: text; }
.arc-tagin input { border: 0 !important; outline: none; flex: 1; min-width: 80px; padding: 3px !important; background: none; }
.arc-quick { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 12px; margin: -2px 0 8px; }
.arc-quick button { border: 1px solid var(--border-soft); background: #fff; border-radius: 10px; padding: 1px 8px; cursor: pointer; font-size: 11.5px; }
.arc-quick button:hover { border-color: var(--accent); }
.arc-up { position: fixed; right: 16px; bottom: 16px; z-index: 2100; width: 300px; background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(10,30,60,.3); padding: 12px 14px; font-size: 13px; }
.arc-up[hidden] { display: none; }
.arc-up-t { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.arc-up-n { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 3px 0 7px; }
.arc-up-b { height: 6px; background: #e4ebf3; border-radius: 3px; overflow: hidden; }
.arc-up-b span { display: block; height: 100%; background: linear-gradient(90deg, #16b07a, #1d6fc2); transition: width .2s; }
@media (max-width: 1250px) { .arc.prev-open { grid-template-columns: 210px minmax(0, 1fr) 360px; } }
/* colonne dell'elenco in base allo spazio realmente disponibile (anteprima aperta o chiusa) */
.arc-main { container-type: inline-size; container-name: arc; }
@container arc (max-width: 820px) {
  .arc-hd, .arc-row { grid-template-columns: 30px 40px minmax(0, 1fr) 90px 110px; }
  .arc-hd > :nth-child(4), .arc-row > .arc-col, .arc-hd > :nth-child(7), .arc-row > :nth-child(7) { display: none; }
}
@container arc (max-width: 560px) {
  .arc-hd, .arc-row { grid-template-columns: 30px 40px minmax(0, 1fr) 100px; }
  .arc-hd > :nth-child(5), .arc-row > .arc-dt { display: none; }
}
@media (max-width: 1000px) and (min-width: 768px) {
  .arc, .arc.prev-open { grid-template-columns: 190px minmax(0, 1fr); }
  .arc-prev { position: fixed; right: 0; top: 0; bottom: 0; width: 400px; z-index: 1050; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
}
@media (max-width: 767px) {
  .arc-foto { display: inline-flex; }
  .pagebar .arc-viste, .pagebar #a-ord { display: none; }
  .pagebar .btn span { display: none; }
  .pagebar:has(#a-carica) h1 { flex: 1 1 0; }
  .arc, .arc.prev-open { grid-template-columns: minmax(0, 1fr); }
  .arc-cartelle-btn { display: inline-flex; }
  .arc-side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 1100; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 24px rgba(0,0,0,.3); padding-top: calc(10px + env(safe-area-inset-top)); }
  .arc.side-open .arc-side { transform: none; }
  .arc-viste-l a, .arc-node { padding-top: 10px; padding-bottom: 10px; font-size: 15px; }
  .arc-more { visibility: visible; font-size: 18px; }
  .arc-bar { padding: 6px 10px; }
  .arc-bar .btn span { display: none; }
  .arc-hd { display: none; }
  .arc-row { grid-template-columns: 46px minmax(0, 1fr); padding: 6px 12px; min-height: 64px; }
  .arc-row > .arc-ck, .arc-row > .arc-col, .arc-row > .arc-dt, .arc-row > :nth-child(6), .arc-row > :nth-child(7) { display: none; }
  .arc-ico, .arc-ico img { width: 46px; height: 46px; font-size: 32px; }
  .arc-ti b { font-size: 15px; }
  .arc-sub { display: none; }
  .arc-msub { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .arc-griglia { grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }
  .arc-th { height: 110px; }
  .arc-prev { display: block; position: fixed; inset: 0; z-index: 1150; transform: translateY(100%); transition: transform .22s ease; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .arc.prev-open .arc-prev { transform: none; }
  .arc-p-x { right: 10px; top: 10px; height: 36px; width: 36px; font-size: 18px; }
  .arc-v-img img { max-height: 55vh; }
  .arc-form input, .arc-form select, .arc-form textarea { font-size: 16px; }
  .arc-up { left: 10px; right: 10px; width: auto; bottom: calc(10px + env(safe-area-inset-bottom)); }
}

.sp-arc { display: flex; gap: 6px; flex-wrap: wrap; }
.home-scad { display: flex; gap: 8px; align-items: flex-start; max-width: 1200px; line-height: 1.5; }
.home-scad > .ti { font-size: 20px; }
.arc-sel[hidden], .arc-prev-body[hidden] { display: none !important; }
.arc-ico .ti { font-size: 28px; }
@media (max-width: 767px) { .arc-ico .ti { font-size: 34px; } }
.scan-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.scan-tool { border: 0; border-radius: 16px; padding: 6px 11px; background: rgba(0,0,0,.55); color: #fff; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.scan-tool.on { background: #f5c518; color: #222; }
@media (max-width: 767px) {
  .modal.modal-scan { width: calc(100vw - 12px); }
  .scan-box video { max-height: 62vh; min-height: 300px; }
}

/* Posta SDI: riquadro di avanzamento non modale (lavoro in background) */
.psdi-box { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 1900; display: flex; align-items: center; gap: 12px;
  max-width: min(520px, calc(100vw - 24px)); padding: 10px 12px 10px 14px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(20, 40, 80, .18); font-size: 13px; }
.psdi-box.done { border-left-color: #2e8b4e; }
.psdi-box.err { border-left-color: #c98a12; }
.psdi-box.psdi-storico { bottom: 86px; }
.psdi-box[hidden] { display: none; }
.psdi-box .psdi-ic { flex: none; width: 22px; text-align: center; }
.psdi-box .psdi-ic .spin { width: 18px; height: 18px; border-width: 3px; }
.psdi-box .psdi-ic .ti { font-size: 20px; color: #2e8b4e; }
.psdi-box.err .psdi-ic .ti { color: #c98a12; }
.psdi-box .psdi-txt { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
.psdi-box .psdi-txt small { color: var(--muted); }
.psdi-box .psdi-x { flex: none; border: 0; background: none; font-size: 20px; line-height: 1; color: #8a93a6; cursor: pointer; padding: 2px 4px; }
@media (max-width: 767px) { .psdi-box { bottom: 84px; } }

/* ── Scrivania (2.3): indicatori con contesto, grafico, Da fare, ricerca veloce ─────────────────────── */
.dk-head { flex-wrap: wrap; row-gap: 6px; }
.dk-cerca { position: relative; margin-left: auto; flex: 0 1 380px; min-width: 200px; display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; height: 32px; }
.dk-cerca:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,111,194,.15); }
.dk-cerca > .ti { color: var(--muted); font-size: 15px; }
.dk-cerca input { border: 0; outline: 0; font: inherit; font-size: 13px; flex: 1; min-width: 0; background: transparent; height: 100%; }
.dk-ris { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(20,40,70,.18); z-index: 900; max-height: 60vh; overflow: auto; padding: 4px; }
.dk-ris a { display: flex; gap: 9px; align-items: center; padding: 7px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.dk-ris a .ti { color: var(--accent); font-size: 17px; }
.dk-ris a span { display: flex; flex-direction: column; min-width: 0; }
.dk-ris a small { color: var(--muted); }
.dk-ris a.on, .dk-ris a:hover { background: var(--hover); }
.dk-ris .vuoto { padding: 10px; color: var(--muted); }
.dk-pers { flex: 0 0 auto; }
.dk-card { background: #fff; border: 1px solid var(--border-soft); border-radius: 12px; padding: 13px 15px; min-width: 0; box-shadow: 0 1px 2px rgba(20,40,70,.04); }
a.dk-card { color: var(--text); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.dk-card:hover { border-color: var(--accent); box-shadow: 0 3px 12px rgba(29,111,194,.14); }
.dk-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 1250px) { .dk-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dk-kpi { display: flex; flex-direction: column; gap: 3px; }
.dk-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dk-v { font-size: 24px; font-weight: 650; letter-spacing: -.2px; line-height: 1.2; }
.dk-v.dk-warn { color: #9a6400; } .dk-v.dk-err { color: var(--err); }
.dk-s { font-size: 12px; color: var(--muted); }
.dk-up { color: #23703f; } .dk-down { color: var(--err); }
.dk-spark { width: 100%; height: 30px; margin-top: auto; }
.dk-spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.dk-pill-row { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; background: #fbf4e6; border-radius: 7px; padding: 6px 8px; font-size: 12px; }
.dk-pill-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-bar { display: block; height: 8px; background: #e6ecf2; border-radius: 4px; overflow: hidden; margin: 5px 0 3px; }
.dk-bar > span { display: block; height: 100%; background: #179b6a; border-radius: 4px; }
.dk-bar > span.warn { background: var(--warn); } .dk-bar > span.err { background: var(--err); }
.dk-row { display: grid; gap: 12px; margin-bottom: 14px; }
.dk-row-a { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
.dk-row-a > :only-child { grid-column: 1 / -1; }
.dk-row-b { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.dk-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.dk-h h2 { margin: 0; font-size: 14px; font-weight: 600; }
.dk-c { color: var(--muted); }
.dk-n { background: var(--err); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.dk-leg { margin-left: auto; display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.dk-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.dk-leg i.c { background: var(--accent); } .dk-leg i.p { background: #c5d1de; } .dk-leg i.a { height: 0; border-top: 2px dashed #b07a10; border-radius: 0; }
.dk-chart { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 140px; padding-top: 16px; }
.dk-max { position: absolute; top: 0; left: 0; font-size: 10.5px; color: var(--muted); }
.dk-plot { flex: 1; min-height: 90px; position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); border-bottom: 1px solid #dfe6ee;
  background: linear-gradient(#edf1f5, #edf1f5) 0 0 / 100% 1px no-repeat, linear-gradient(#edf1f5, #edf1f5) 0 50% / 100% 1px no-repeat; }
.dk-col { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.dk-col i { display: block; width: 30%; max-width: 22px; border-radius: 3px 3px 0 0; }
.dk-col i.p { background: #c5d1de; } .dk-col i.c { background: var(--accent); } .dk-col i.c.now { background: #179b6a; }
.dk-avg { position: absolute; left: 0; right: 0; border-top: 1.5px dashed #b07a10; pointer-events: auto; z-index: 1; }
.dk-mesi { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); text-align: center; font-size: 11px; color: var(--muted); padding-top: 5px; }
.dk-mesi .now { color: var(--text); font-weight: 700; }
.dk-graf { display: flex; flex-direction: column; }
.dk-fare-l { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.dk-todo { display: flex; flex-direction: column; padding: 7px 10px 7px 12px; border-radius: 8px; border-left: 4px solid; color: var(--text); text-decoration: none; }
.dk-todo small { color: var(--muted); }
.dk-todo.err { background: #fdeeec; border-color: var(--err); } .dk-todo.warn { background: #fbf4e6; border-color: var(--warn); } .dk-todo.info { background: #edf4fb; border-color: var(--accent); }
.dk-todo:hover { filter: brightness(.97); }
.dk-vuoto { color: var(--muted); padding: 6px 0; }
.dk-vuoto .ti { color: var(--ok); }
.dk-list { display: flex; flex-direction: column; }
.dk-doc, .dk-lab { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid #edf1f5; color: var(--text); text-decoration: none; }
.dk-doc:last-child, .dk-lab:last-child { border-bottom: 0; }
.dk-doc:hover, .dk-lab:hover { background: var(--hover); }
.dk-grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dk-grow small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-imp { min-width: 72px; text-align: right; }
.dk-lab > .ti { font-size: 22px; color: #a36a06; }
.dk-pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.dk-pill.ok { background: #e5f3ea; color: #23703f; } .dk-pill.warn { background: #fbf1df; color: #8a5a00; } .dk-pill.info { background: var(--accent-soft); color: var(--accent-dark); }
.dk-cli { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 5px 0; }
.dk-cli .dk-bar { grid-column: 1 / -1; height: 6px; margin: 4px 0 0; }
.dk-cli .dk-bar > span { background: var(--accent); }
.dk-altri { padding: 7px 2px 0; font-size: 12px; }
@media (max-width: 1100px) { .dk-row-a { grid-template-columns: minmax(0, 1fr); } }
/* telefono: pulsanti grandi (m-home), poi indicatori 2×2, Da fare, ultimi 5, laboratorio. Scorrimento verticale. */
@media (max-width: 767px) {
  .dk-cerca { order: 5; flex: 1 1 100%; margin-left: 0; height: 42px; }
  .dk-cerca input { font-size: 16px; } /* 16px: iOS non ingrandisce la pagina al tocco */
  .dk-pers, .dk-solo-desk, .dk-graf { display: none !important; }
  .dk-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dk-v { font-size: 19px; }
  .dk-kpi .dk-spark, .dk-kpi .dk-pill-row, .dk-kpi .dk-s + .dk-s { display: none; }
  .dk-row-a, .dk-row-b { grid-template-columns: minmax(0, 1fr); }
  .dk-fare-l { max-height: none; }
  .dk-todo, .dk-doc, .dk-lab { min-height: 48px; }
  .home { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}

/* desktop: la Scrivania occupa l'altezza dello schermo, niente riquadri tagliati in fondo; i contenuti lunghi scorrono dentro il riquadro.
   Se lo schermo è basso i riquadri tengono un'altezza minima e la pagina scorre come prima. */
@media (min-width: 1100px) and (min-height: 680px) {
  .home.dk-fit { display: flex; flex-direction: column; }
  .home.dk-fit > * { flex-shrink: 0; }
  .home.dk-fit > .dk-row { grid-template-rows: minmax(0, 1fr); }
  .home.dk-fit > .dk-row-a { flex: 1.2 1 0; min-height: 200px; }
  .home.dk-fit > .dk-row-b { flex: 1 1 0; min-height: 150px; margin-bottom: 0; }
  .home.dk-fit .dk-row > .dk-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  .home.dk-fit .dk-row .dk-list, .home.dk-fit .dk-row .dk-fare-l { flex: 1; min-height: 0; max-height: none; overflow-y: auto; scrollbar-width: thin; padding-right: 2px; }
  .home.dk-fit .dk-kpis { margin-bottom: 12px; }
}

/* Foglio di lavoro: barra della scheda di riparazione (versione semplificata) */
.scheda-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 8px 12px; margin-bottom: 12px; background: #f3f7fc; border: 1px solid #cfe0f3; border-radius: 5px; }
.scheda-bar .chk { margin: 0; }
.scheda-bar .btn { margin-left: auto; }
.sc-card { max-width: 900px; }
.sc-card textarea { min-height: 110px; }
.sc-chk { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 8px 0 2px; }
.sc-chk .chk { margin: 0; font-size: 13.5px; }
.badge.storico, .grid-row.sel .badge.storico { background: #e9edf2; color: #5b6573; }

/* Impostazioni → Sistema e backup */
.bk-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.bk-state { font-size: 13px; }
.bk-tbl { margin-top: 10px; }
.bk-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.bk-form { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 4px; }
.bk-form h4, .panel-body > h4 { margin: 12px 0 6px; font-size: 13.5px; }
.bk-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Versione dimostrativa (config 'demo') */
.demo-login { background: #fff7e6; border: 1px solid #f0c36d; color: #6b4a00; border-radius: 6px; padding: 10px 12px; margin: 0 0 14px; font-size: 12.5px; line-height: 1.45; }
.demo-login b:first-child { display: block; margin-bottom: 3px; font-size: 13px; }
.demo-banner { display: flex; gap: 10px; align-items: center; background: #fff7e6; border-bottom: 1px solid #f0c36d; color: #6b4a00; padding: 7px 16px; font-size: 12.5px; line-height: 1.35; }
.demo-banner .ti { font-size: 18px; flex: 0 0 auto; }
.demo-banner span { flex: 1 1 auto; }
.demo-banner a { flex: 0 0 auto; font-weight: 600; color: #8a5a00; white-space: nowrap; }
@media (max-width: 767px) { .demo-banner { font-size: 11.5px; padding: 6px 10px; } }
