:root {
  --navy: #1F3A6B;
  --navy-2: #2b4d87;
  --navy-ink: #16294c;
  --azure: #008BCB;
  --azure-2: #0a9bde;
  --azure-soft: #e7f5fc;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --border: #e1e7ef;
  --border-2: #cbd5e1;
  --text: #1b2839;
  --muted: #677789;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --ok: #1e8e5a;
  --ok-soft: #e6f6ec;
  /* colori derivati: il tema scuro li ridefinisce sotto */
  --title: var(--navy);           /* titoli, codici, testo in evidenza */
  --topbar: var(--navy);
  --text-2: #3b4b5f;
  --faint: #a9b5c4;
  --placeholder: #9aa6b5;
  --input-bg: #fff;
  --btn-bg: #fff;
  --panel-3: #fbfcfe;
  --border-3: #aebbd0;
  --azure-line: #cfeafa;
  --azure-soft-2: #d9effa;
  --danger-line: #f3c7c2;
  --tint: rgba(31,58,107,.06);
  --tint-2: #e8edf4;
  --overlay: rgba(16,30,56,.55);
  --selection: #cfe8f7;
  --switch-off: #c6d0dc;
  --toast-bg: var(--navy-ink);
  --tabbar-bg: rgba(255,255,255,.96);
  --info-text: var(--navy-ink);
  --warn-bg: #fff8e8; --warn-line: #f1dcaa; --warn-text: #7a5200;
  --badge-bg: #eef1f4; --badge-text: #556;
  --st-aperto-bg: #e7f5fc; --st-aperto: #0a6aa0;
  --st-corso-bg: #fff3df; --st-corso: #a9640a;
  --st-annullato-bg: #fdeaea; --st-annullato: #b02525;
  color-scheme: light;
  /* angoli quasi squadrati, per un aspetto più tecnico */
  --r-sm: 2px;
  --r: 3px;
  --r-lg: 4px;
  --shadow: 0 1px 2px rgba(16,42,80,.05), 0 4px 14px rgba(16,42,80,.04);
  --shadow-lg: 0 24px 60px rgba(10,25,50,.28);
  --ease: cubic-bezier(.2,.7,.2,1);
  --t: .16s var(--ease);
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* Niente "scatto" quando compare la barra di scorrimento, senza riservarle una
   striscia vuota: (100vw - 100%) è la larghezza della barra (0 se non c'è o se è
   sovrapposta, come su telefono e Mac). Il contenuto resta centrato sulla finestra
   intera e gli elementi allineati a destra compensano quella larghezza. */
body { overflow-x: clip; }
body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
a { color: var(--azure); }
h1, h2, h3, h4 { letter-spacing: -.01em; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
::selection { background: var(--selection); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .92em; letter-spacing: 0; }
.muted { color: var(--muted); }

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: #2f3a80 url(../img/login-sfondo-pixel.webp) center / cover no-repeat;
}
.login-card {
  background: var(--panel); border-radius: 14px; box-shadow: 0 24px 64px rgba(20,45,100,.22), 0 2px 6px rgba(20,45,100,.08);
  width: 100%; max-width: 380px; padding: 0; overflow: hidden; animation: pop-in .35s var(--ease);
}
.login-head { background: var(--topbar); padding: 26px 28px 22px; display: flex; justify-content: center; }
.login-head img { height: 52px; width: auto; }
.login-body { padding: 24px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-body h1 { font-size: 18px; margin: 0; }
.login-sub { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--topbar);
  display: flex; align-items: center; gap: 14px; padding: 0 max(4px, calc(20px - (100vw - 100%))) 0 20px; height: 56px;
  padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top));
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 4px 14px rgba(16,42,80,.16);
}
.topbar .logo { height: 28px; width: auto; display: block; }
.topbar .divider { width: 1px; height: 24px; background: rgba(255,255,255,.18); }
.crumb { color: #fff; font-size: 14px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb .sep { color: rgba(255,255,255,.35); }
.crumb-app { color: rgba(255,255,255,.72); font-weight: 500; white-space: nowrap; }
.crumb-cur { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.crumb-cur strong { font-weight: 600; white-space: nowrap; }
.crumb-sub { color: #bcd3e8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.topbar .spacer { flex: 1; }
.ver { color: rgba(255,255,255,.4); font-size: 11px; }
.tbtn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18);
  padding: 6px 12px; border-radius: var(--r); cursor: pointer; font: inherit; font-weight: 600; font-size: 13px;
  transition: background var(--t), border-color var(--t);
}
.tbtn .ico { width: 16px; height: 16px; }
.tbtn-ico { width: 34px; height: 32px; padding: 0; justify-content: center; }
.tbtn.tbtn-ico .ico { width: 17px; height: 17px; }
.who { display: inline-flex; align-items: center; gap: 6px; color: #d6e4f2; font-size: 13px; max-width: 240px; min-width: 0; }
.who .ico { width: 16px; height: 16px; flex: none; opacity: .85; }
.who-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.container { max-width: 1120px; margin: 0 auto; padding: 20px 20px 72px; position: relative; left: calc((100vw - 100%) / 2); }
/* spazio per il pulsante rotondo dell'archivio sopra l'ultima riga */
.container.has-tabs { padding-bottom: 104px; }
.container.anim-in .tab-body > *, .container.anim-in > .page-head, .container.anim-in > .card { animation: fade-up .22s var(--ease) both; }
.container.anim-in .tab-body > *:nth-child(2) { animation-delay: .03s; }
.container.anim-in .tab-body > *:nth-child(n+3) { animation-delay: .06s; }
/* la riga della ricerca compare solo in dissolvenza: una trasformazione (anche nulla)
   farebbe da riferimento al pannello fisso dei filtri su telefono */
.container.anim-in .tab-body > .search-row { animation-name: fade-in; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- avvisi ---------- */
.note {
  display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.45;
  padding: 8px 12px; border-radius: var(--r); border: 1px solid; margin-bottom: 16px;
}
.note .ico { width: 16px; height: 16px; margin-top: .5px; } /* centrata sulla prima riga (13px, interlinea 1.45) */
.note-local { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.note-lock { background: var(--panel-2); border-color: var(--border); color: var(--text-2); }
.note-ro { background: var(--azure-soft); border-color: var(--azure-line); color: var(--info-text); }

/* ---------- tabs (in alto; su telefono diventano una barra in basso) ---------- */
.tabs { display: flex; gap: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 14px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px;
  border: none; background: none; margin-bottom: -1px; transition: color var(--t), background var(--t);
}
.tab .ico { width: 17px; height: 17px; opacity: .8; }
.tab::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--azure);
  transform: scaleX(0); transition: transform .2s var(--ease);
}
.tab.active { color: var(--title); }
.tab.active .ico { opacity: 1; }
.tab.active::after { transform: scaleX(1); }
.tab-end { margin-left: auto; }
.tab-short { display: none; }
/* icone centrate sul testo: l'icona è un elemento flex (non in linea, che la
   appoggerebbe sulla linea di base alzandola) e il testo ha interlinea 1.2 */
.tab-ico { display: inline-flex; }
.tab-full, .tab-short { line-height: 1.2; }

/* ---------- intestazione di pagina ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 20px; color: var(--title); font-weight: 700; }
.ph-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.ph-actions { display: flex; gap: 8px; }

/* ---------- card ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 14px;
}
.card h2 { margin: 0; font-size: 15px; color: var(--title); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head { margin-bottom: 12px; }
.card-head p { margin: 3px 0 0; font-size: 13px; }
.card-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card-actions .btn-ghost:first-child { margin-right: auto; }
.card-new h2 { margin-bottom: 12px; }
.sub-h { margin: 20px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.cards-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; align-items: start; }
.count {
  font-size: 11px; font-weight: 700; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border);
  padding: 0 6px; border-radius: var(--r-sm); line-height: 18px; letter-spacing: 0;
}
.empty { color: var(--muted); text-align: center; padding: 28px; }

/* ---------- campi ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.grow { flex: 1; min-width: 150px; }
.hint { font-size: 12px; margin: 8px 0 0; line-height: 1.45; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--input-bg); border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 8px 11px; width: 100%; min-height: 38px; outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
input:focus, select:focus, textarea:focus { border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
/* caselle di spunta quadrate, nello stile del sito (non quelle arrotondate del browser) */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; padding: 0;
  width: 18px; height: 18px; min-height: 0; border: 1.5px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--input-bg) center / 12px 12px no-repeat; cursor: pointer; vertical-align: middle;
  transition: background-color var(--t), border-color var(--t), box-shadow var(--t);
}
input[type="checkbox"]:focus { box-shadow: none; border-color: var(--border-2); }
input[type="checkbox"]:checked {
  background-color: var(--navy); border-color: var(--navy);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.9' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='square'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate {
  background-color: var(--navy); border-color: var(--navy);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6h6' stroke='%23fff' stroke-width='1.8'/%3E%3C/svg%3E");
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--azure); outline-offset: 2px; }
input[type="checkbox"]:disabled { opacity: .45; cursor: default; }
textarea { resize: vertical; min-height: 64px; }
/* sola lettura: campi leggibili, non "spenti" */
input:disabled:not([type="checkbox"]), select:disabled, textarea:disabled {
  background: var(--panel-2); color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; cursor: default;
}
.inline:disabled { background: transparent; }
input:disabled::placeholder, textarea:disabled::placeholder { color: transparent; -webkit-text-fill-color: transparent; }
.p-row input[type="checkbox"]:disabled { opacity: .75; }
.rte-view {
  border: 1px solid var(--border); border-radius: var(--r); background: var(--panel-2);
  padding: 8px 11px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; min-height: 40px;
}
.rte-view a { color: var(--azure); text-underline-offset: 2px; }
.err-field { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }
/* campo appena salvato in automatico */
.flash-ok { animation: flash-ok 1.2s var(--ease); }
@keyframes flash-ok { 0%, 40% { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); } 100% { } }
/* iOS: i campi data hanno una larghezza minima propria che sborda dal contenitore */
input[type="date"] { min-width: 0; }
@supports (-webkit-touch-callout: none) {
  input[type="date"] { -webkit-appearance: none; appearance: none; display: block; text-align: left; }
  input[type="date"]::-webkit-date-and-time-value { text-align: left; }
}

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-2); background: var(--btn-bg); border-radius: var(--r);
  padding: 8px 14px; min-height: 38px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t), transform .08s;
}
.btn .ico { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .tab:focus-visible, .rte-btn:focus-visible, .modal-x:focus-visible, .icon-btn:focus-visible, .list-row:focus-visible {
  outline: 2px solid var(--azure); outline-offset: 2px;
}
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-accent { background: var(--azure); color: #fff; border-color: var(--azure); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.btn-ghost { background: none; border-color: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; flex: none;
  border: 1px solid transparent; background: none; border-radius: var(--r); cursor: pointer; color: var(--muted);
  transition: background var(--t), color var(--t);
}
.icon-btn .ico { width: 17px; height: 17px; }
.icon-btn[disabled] { opacity: .3; cursor: not-allowed; }

/* ---------- elenchi (commesse, tematiche) ---------- */
.card-list { padding: 4px 0; }
.list-row, .list-head {
  display: grid; align-items: center; gap: 12px; padding: 11px 20px;
  grid-template-columns: 84px minmax(0, 1fr) auto 18px;
}
.list-row { cursor: pointer; border-top: 1px solid var(--border); transition: background var(--t); outline-offset: -2px; }
.list-row:first-child, .list-head + .list-row { border-top: none; }
.list-head {
  padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; white-space: nowrap;
}
.lr-code { font-weight: 700; color: var(--title); font-size: 14px; white-space: nowrap; }
.lr-main { min-width: 0; }
.lr-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-chev { color: var(--faint); display: grid; place-items: center; transition: transform var(--t), color var(--t); }
.lr-chev .ico { width: 16px; height: 16px; }
.lr-col { font-size: 14px; white-space: nowrap; }
.tem-row { grid-template-columns: 22px 60px minmax(0, 1fr) 72px 104px 72px 32px; }
.tem-row.ro { grid-template-columns: 60px minmax(0, 1fr) 72px 104px 72px; } /* sola lettura: senza caselle né campanella */
.tem-row.is-sel, .td-row.is-sel { background: var(--azure-soft); }
/* campanella "notifica via email" in fondo alle righe */
.icon-btn.bell { width: 32px; height: 32px; margin: -6px 0; color: var(--azure); }
.icon-btn.bell .ico { width: 18px; height: 18px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chk input { margin: 0; }
.chk-lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
.list-head .chk-lbl { text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }
.list-head .m-only { display: none; }
/* ricerca */
.search-row { position: relative; z-index: 16; display: flex; gap: 8px; margin: 0 0 12px; } /* finestrelle sopra l'elenco, anche durante l'animazione */
.search { position: relative; flex: 1; min-width: 0; margin: 0; }
/* pulsanti Filtri / Ordina accanto alla ricerca */
.search-tools { display: flex; gap: 8px; flex: none; }
.tool-btn { position: relative; min-height: 42px; background: var(--panel); }
.tool-btn.on { border-color: var(--azure); color: var(--title); background: var(--azure-soft); }
.tool-btn.open { border-color: var(--title); }
.tool-n {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.tool-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--azure); }
/* finestrelle dei filtri e dell'ordine */
#temPop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; }
.search-row.is-open { z-index: 45; } /* finestrella aperta: sopra pulsanti rotondi e barra in basso */
.pop {
  width: 360px; max-width: calc(100vw - 24px); max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 4px 14px 12px; animation: fade-up .14s var(--ease);
}
.pop-sm { width: 290px; }
.pop-head {
  position: sticky; top: 0; z-index: 1; background: var(--panel); display: flex; align-items: center; justify-content: space-between;
  gap: 8px; min-height: 42px; margin: 0 -14px 6px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--border);
}
.pop-head strong { color: var(--title); font-size: 14px; }
.pop-group { border: none; margin: 0 0 8px; padding: 0; min-width: 0; }
.pop-group legend { padding: 6px 0 2px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pop-opt { display: flex; align-items: center; gap: 10px; padding: 6px 6px; margin: 0 -6px; border-radius: var(--r); cursor: pointer; font-size: 14px; }
.pop-opt > span:first-of-type { display: flex; flex-direction: column; min-width: 0; }
.pop-opt small { font-size: 12px; }
.pop-n { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pop-hint { font-size: 12px; margin: 4px 0 0; }
/* scelta singola (ordine): pallino nello stile delle caselle */
input[type="radio"] {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; width: 18px; height: 18px; min-height: 0; padding: 0;
  border: 1.5px solid var(--border-2); border-radius: 50%; background: var(--input-bg); cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t);
}
input[type="radio"]:checked { border-color: var(--navy); box-shadow: inset 0 0 0 4px var(--input-bg); background: var(--navy); }
input[type="radio"]:focus { box-shadow: none; }
input[type="radio"]:checked:focus { box-shadow: inset 0 0 0 4px var(--input-bg); }
input[type="radio"]:focus-visible { outline: 2px solid var(--azure); outline-offset: 2px; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; min-height: 42px; background: var(--panel); }
/* barra delle azioni sulle tematiche selezionate */
.bulk {
  position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 5;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 4px 12px 8px; padding: 6px 6px 6px 14px;
  background: var(--navy); color: #fff; border-radius: var(--r); box-shadow: 0 6px 18px rgba(16,42,80,.2);
  animation: fade-up .16s var(--ease);
}
.bulk-n { font-weight: 600; font-size: 14px; margin-right: auto; }
.bulk .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.22); }
.bulk .icon-btn { color: #fff; }
/* pulsante rotondo dell'archivio */
.fab {
  position: fixed; right: max(8px, calc(24px - (100vw - 100%)), env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; background: var(--navy); color: #fff;
  box-shadow: 0 8px 22px rgba(16,42,80,.32), 0 2px 6px rgba(16,42,80,.2);
  transition: transform .15s var(--ease), background var(--t), box-shadow var(--t);
}
.fab .ico { width: 24px; height: 24px; }
.fab:active { transform: scale(.94); }
.fab.on { background: var(--azure); }
/* a sinistra: archivia in un colpo le tematiche chiuse */
.fab.fab-left { right: auto; left: max(24px, env(safe-area-inset-left)); }
.fab-n {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #fff; color: #1F3A6B; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.page-head h1 { display: flex; align-items: center; gap: 6px; }
.page-head h1 .ico { width: 20px; height: 20px; }
.m-only { display: none; }
.chip-code {
  display: inline-block; font-weight: 700; font-size: 12px; color: var(--title); background: var(--azure-soft);
  border: 1px solid var(--azure-line); padding: 0 6px; border-radius: var(--r-sm); line-height: 19px;
}

.badge { font-size: 12px; padding: 1px 8px; border-radius: var(--r-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; background: var(--badge-bg); color: var(--badge-text); white-space: nowrap; }
.badge .ico { width: 13px; height: 13px; }
.badge-sys { background: var(--warn-bg); color: var(--warn-text); }
.stato-Aperto { background: var(--st-aperto-bg); color: var(--st-aperto); }
.stato-Incorso { background: var(--st-corso-bg); color: var(--st-corso); }
.stato-Sospeso { background: var(--badge-bg); color: var(--badge-text); }
.stato-Annullato { background: var(--st-annullato-bg); color: var(--st-annullato); }
.stato-Chiuso { background: var(--ok-soft); color: var(--ok); }

/* ---------- righe modificabili (persone, ruoli, stati) ---------- */
.p-list { display: flex; flex-direction: column; }
.p-row {
  display: grid; align-items: center; gap: 6px; padding: 4px 0;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 34px;
  border-top: 1px solid var(--border);
}
.p-row:first-child { border-top: none; }
.p-list.solo .p-row { grid-template-columns: 28px minmax(0, 1fr) 34px; }
.p-chk { display: grid; place-items: center; }
.p-row.off .inline { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--border-2); }
.inline { border-color: transparent; background: transparent; padding-left: 8px; padding-right: 8px; }
.inline:focus { background: var(--input-bg); }
.p-add { border-top: 1px dashed var(--border-2); padding-top: 10px; margin-top: 6px; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) auto; }
.p-list.solo .p-add { grid-template-columns: 28px minmax(0, 1fr) auto; }
.p-plus { color: var(--placeholder); }
.p-plus .ico { width: 16px; height: 16px; }
.s-row { grid-template-columns: 96px minmax(0, 1fr) 34px; }
.s-row.stato-row { grid-template-columns: minmax(0, 1fr) auto 34px; }
.s-sigla { font-weight: 700; color: var(--title); }

/* ---------- amministrazione ---------- */
.u-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 150px 34px; }
.u-head { padding: 0 0 6px; border-bottom: 1px solid var(--border); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 150px 34px; gap: 6px; }
.u-head span { padding-left: 9px; }
.u-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; }
.u-pwd { display: flex; align-items: center; gap: 0; }
.pwd {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 14px; letter-spacing: .06em;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px 7px; margin-right: 2px;
  user-select: all;
}
.u-row.is-new { animation: row-new 2.4s var(--ease); }
@keyframes row-new { 0%, 50% { background: var(--ok-soft); } 100% { background: transparent; } }
.adm-list { display: flex; flex-direction: column; }
.adm-row {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer;
}
.adm-row:first-child { border-top: none; }
.adm-row .lr-title, .adm-row .lr-meta { display: block; }
.adm-list .list-row { grid-template-columns: 84px minmax(0, 1fr) 18px; padding: 10px 4px; }
.perm-badges { display: flex; gap: 4px; }
/* finestra dei permessi di una commessa */
.modal.modal-perm { max-width: 780px; }
.pm-autori {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--panel-2);
}
.pm-autori > span:first-child { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.pm-autori .muted { font-size: 12px; }
.pm-head, .pm-row { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr)); gap: 10px; align-items: center; }
.pm-head {
  padding: 0 4px 6px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
}
.pm-row { padding: 10px 4px; border-top: 1px solid var(--border); transition: background var(--t); }
.pm-list .pm-row:first-child { border-top: none; }
.pm-who { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.pm-who strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-who .muted { font-size: 12px; }
.pm-cell { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.pm-lbl { display: none; }
.pm-val { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pm-row.off .pm-who strong { color: var(--muted); font-weight: 500; }
.switch input:disabled + .switch-ui { opacity: .45; }
.adm-row.off .lr-meta { color: var(--danger); }
/* interruttore on/off */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.switch-ui {
  position: absolute; inset: 0; border-radius: 12px; background: var(--switch-off); transition: background var(--t);
  pointer-events: none;
}
.switch-ui::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s var(--ease);
}
.switch input:checked + .switch-ui { background: var(--ok); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--azure); outline-offset: 2px; }

/* ---------- elenco etichetta/valore (anteprima) ---------- */
.kv { display: grid; grid-template-columns: 190px minmax(0, 1fr); margin: 16px 0 0; border-top: 1px solid var(--border); font-size: 14px; }
.kv dt, .kv dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--muted); font-size: 13px; font-weight: 600; padding-right: 12px; }
.kv dd { overflow-wrap: anywhere; }
.card-finalize { border-left: 3px solid var(--navy); }

/* ---------- campo data e calendario nello stile del sito ---------- */
.date-field { display: block; min-width: 0; }
.date-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px;
  padding: 8px 11px; background: var(--input-bg); border: 1px solid var(--border-2); border-radius: var(--r);
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.date-btn .ico { width: 17px; height: 17px; color: var(--muted); }
.date-btn.vuoto .date-val { color: var(--placeholder); }
.date-btn.speciale .date-val { font-weight: 700; color: var(--title); letter-spacing: .04em; }
.date-btn:focus-visible, .date-btn.open { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
.date-btn:disabled { background: var(--panel-2); cursor: default; }
.date-btn:disabled .ico { opacity: .4; }
.dp {
  position: fixed; z-index: 60; width: 292px; padding: 10px; background: var(--panel);
  border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: fade-up .12s var(--ease);
}
.dp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.dp-title { flex: 1; text-align: center; color: var(--title); font-size: 14px; }
.dp-nav {
  width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--r-sm); background: none;
  color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; transition: background var(--t), color var(--t);
}
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.dp-day {
  height: 34px; border: 1px solid transparent; border-radius: var(--r-sm); background: none; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.dp-day.out { color: var(--faint); }
.dp-day.today { border-color: var(--azure); font-weight: 700; }
.dp-day.sel { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.dp-day:focus-visible, .dp-nav:focus-visible, .dp-sp:focus-visible, .dp-link:focus-visible { outline: 2px solid var(--azure); outline-offset: 1px; }
.dp-special { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.dp-sp {
  min-height: 34px; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--btn-bg); cursor: pointer;
  font: inherit; font-weight: 700; font-size: 13px; letter-spacing: .06em; color: var(--title); transition: background var(--t), border-color var(--t);
}
.dp-sp.sel { background: var(--navy); border-color: var(--navy); color: #fff; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.dp-link { border: none; background: none; padding: 6px 4px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--azure); }

/* ---------- menu di scelta nello stile del sito (js/selpick.js), al posto del <select> nativo ---------- */
.sel-field { display: block; min-width: 0; }
.sel-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px;
  padding: 6px 10px 6px 11px; background: var(--input-bg); border: 1px solid var(--border-2); border-radius: var(--r);
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.sel-btn > .ico { width: 17px; height: 17px; color: var(--muted); flex: none; transition: transform .15s var(--ease); }
.sel-btn.open > .ico { transform: rotate(180deg); }
.sel-btn:focus-visible, .sel-btn.open { outline: none; border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
.sel-btn:disabled { background: var(--panel-2); cursor: default; }
.sel-btn:disabled > .ico { opacity: .4; }
.sel-val { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; }
.sel-l { font-weight: 600; color: var(--title); white-space: nowrap; }
.sel-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-val .badge { font-size: 12px; }
.sp {
  position: fixed; z-index: 60; overflow-y: auto; overscroll-behavior: contain; padding: 4px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: fade-up .12s var(--ease);
}
.sp-head { display: none; }
.sp-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 7px 10px; border: none; border-radius: var(--r);
  background: none; font: inherit; font-size: 14px; color: var(--text); text-align: left; cursor: pointer; transition: background var(--t);
}
.sp-lbl { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
.sp-lbl .sel-sub { white-space: normal; }
.sp-check { flex: none; width: 18px; height: 18px; color: var(--azure); }
.sp-check .ico { width: 18px; height: 18px; }
.sp-opt.sel { background: var(--azure-soft); }
.sp-opt:focus-visible { outline: 2px solid var(--azure); outline-offset: -2px; }

/* ---------- sezione To-do ---------- */
.td-actions { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
/* selettore a quattro tasti */
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--panel); padding: 2px; gap: 2px; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: none; cursor: pointer;
  padding: 6px 10px; min-height: 32px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px; color: var(--muted);
  transition: background var(--t), color var(--t);
}
.seg-btn .ico { width: 16px; height: 16px; }
.seg-btn.on { background: var(--navy); color: #fff; }
.seg-btn:focus-visible { outline: 2px solid var(--azure); outline-offset: 1px; }
.td-chiusi { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.td-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.td-grid .card { margin-bottom: 0; }
.td-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 20px 8px; }
.td-card-head .muted { font-size: 12px; }
.td-row { grid-template-columns: 22px 58px minmax(0, 1fr) 56px 88px 96px 32px; }
.td-row.ro { grid-template-columns: 58px minmax(0, 1fr) 56px 88px 96px; }
.td-grid .td-row { gap: 8px; }
.td-row.is-todo .lr-code { color: var(--azure); }
.td-row .lr-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.td-row .lr-scad { font-variant-numeric: tabular-nums; }
.td-late { color: var(--danger); font-weight: 600; }

/* ---------- contatti per le notifiche ---------- */
.ct-list { border-top: 1px solid var(--border); }
.ct-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; gap: 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.ct-row:last-child { border-bottom: none; }
.ct-grp { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; min-width: 0; }
.ct-sigla { font-weight: 700; color: var(--title); font-size: 15px; }
.ct-desc { font-size: 13px; color: var(--muted); }
.ct-mails { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; min-width: 0; }
.ct-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 4px 4px 10px; min-height: 32px;
  background: var(--azure-soft); border: 1px solid var(--azure-line); border-radius: var(--r); font-size: 14px; color: var(--info-text);
}
.ct-chip > .ico { width: 15px; height: 15px; color: var(--azure); flex: none; }
.ct-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-x { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border: none; background: none; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; }
.ct-x .ico { width: 13px; height: 13px; }
.ct-x:focus-visible { outline: 2px solid var(--azure); outline-offset: 1px; }
.ct-none { font-size: 13px; padding-top: 4px; }
.ct-add { display: flex; gap: 6px; }
.ct-add input { flex: 1; min-width: 0; }
.ct-card .card-head .ico, .gs-card .card-head .ico { width: 15px; height: 15px; vertical-align: -2px; color: var(--azure); }
.ct-card .card-head h2 .ico, .gs-card .card-head h2 .ico { width: 18px; height: 18px; vertical-align: -3px; margin-right: 2px; }
.ct-card, .gs-card { margin-top: 16px; }

/* gestori della commessa: ricerca con suggerimenti (solo amministratore) */
.gs-search { position: relative; margin: 0 0 12px; }
.gs-search > .ico { position: absolute; left: 12px; top: 21px; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 17px; height: 17px; }
.gs-search input { padding-left: 38px; min-height: 42px; scroll-margin-top: calc(72px + env(safe-area-inset-top)); }
.gs-drop {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; max-height: 320px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 4px;
  animation: fade-up .12s var(--ease);
}
.gs-opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 10px; border: none; background: none;
  border-radius: var(--r); cursor: pointer; text-align: left; font: inherit; font-size: 14px; color: var(--text);
}
.gs-opt.on { background: var(--azure-soft); }
.gs-nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-nome mark { background: none; color: var(--azure); font-weight: 700; }
.gs-stato { font-size: 12px; flex: none; }
.gs-empty { padding: 9px 10px; font-size: 13px; }
.gs-list { border-top: 1px solid var(--border); }
.gs-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.gs-row:last-child { border-bottom: none; }
.gs-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .3px;
}
.gs-who { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.gs-who strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-who .muted { font-size: 12px; }
.gs-none { font-size: 13px; padding-top: 10px; margin: 0; }
.badge-gest { background: var(--azure-soft); color: var(--azure); font-size: 11px; vertical-align: 1px; }

/* finestra "Notifica via email" */
.modal.modal-notifica { max-width: 720px; }
.modal-notifica .modal-head h3 { display: flex; align-items: center; gap: 8px; }
.modal-notifica .modal-head h3 .ico { width: 20px; height: 20px; color: var(--azure); }
.nt-list li { align-items: baseline; }
.nt-list .ct-sigla { font-size: 14px; flex: none; }
.nt-to { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.nt-sub { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 14px 0 6px; }
.nt-prev-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 6px; }
.nt-prev-head .nt-sub { margin: 0; }
.nt-prev-head select { width: auto; max-width: 60%; min-height: 34px; }
.nt-subject { font-size: 13px; margin: 0 0 8px; overflow-wrap: anywhere; }
.nt-frame { display: block; width: 100%; height: 440px; border: 1px solid var(--border-2); border-radius: var(--r); background: #eef2f7; margin-bottom: 12px; }

/* numero documento modificabile a pezzi (Genera rapporto) */
.num-doc { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.num-lbl { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.num-parts { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 16px; }
.num-fix { color: var(--title); font-weight: 600; white-space: nowrap; }
.num-in { width: auto; min-height: 36px; padding: 6px 6px; text-align: center; font-size: 16px; font-weight: 600; color: var(--title); }
.num-in::placeholder { color: var(--placeholder); font-weight: 500; }
.num-sez { width: 8ch; }
.num-ver { width: 7ch; }
.num-rev { width: 5ch; }
.num-doc .hint { margin-top: 8px; }

/* ---------- modale ---------- */
body.modal-open { overflow: hidden; }
.modal-bg {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 40;
  overflow: hidden; overscroll-behavior: contain; touch-action: none;
  opacity: 0; transition: opacity .18s var(--ease);
}
.modal-bg.open { opacity: 1; }
/* scorrimento solo verticale: niente spostamenti laterali del contenuto */
.modal {
  background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 720px; max-height: 92vh; max-height: 92dvh;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 0 24px 0;
  transform: translateY(12px) scale(.985); transition: transform .22s var(--ease);
}
.modal-bg.open .modal { transform: none; }
.modal-bg.no-anim, .modal-bg.no-anim .modal { transition: none; }
.modal input, .modal select, .modal textarea, .modal table, .modal img { max-width: 100%; }
.modal .field, .modal .split > *, .modal .row > * { min-width: 0; }
.modal .field + .field, .modal .split + .field, .modal .field + .split { margin-top: 12px; }
.modal .split > .field { margin-top: 0; }
.modal-head {
  position: sticky; top: 0; z-index: 6; background: var(--panel);
  display: flex; align-items: center; gap: 10px; margin: 0 -24px 16px; padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; color: var(--title); font-size: 17px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.btn-back {
  flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; color: var(--title);
  background: var(--azure-soft); border-color: var(--azure-line); animation: fade-up .2s var(--ease);
}
.modal-x {
  flex: none; width: 34px; height: 34px; border: 1px solid transparent; background: none; border-radius: var(--r);
  cursor: pointer; color: var(--muted); font-size: 15px; transition: background var(--t), color var(--t);
}
.modal-foot {
  position: sticky; bottom: 0; z-index: 6; background: var(--panel);
  display: flex; align-items: center; gap: 8px; margin: 22px -24px 0; padding: 12px 24px;
  border-top: 1px solid var(--border);
}
.modal-foot .spacer { flex: 1; }

/* finestra piccola: archiviazione delle chiuse */
.modal.modal-sm { max-width: 480px; }
.m-intro { font-size: 14px; margin: 0 0 14px; }
.ac-preview { margin-top: 16px; }
.ac-n { font-size: 14px; margin-bottom: 8px; }
.ac-n strong { color: var(--title); }
.ac-none { margin: 0; font-size: 14px; }
.ac-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: var(--r); }
.ac-list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 14px; border-top: 1px solid var(--border); }
.ac-list li:first-child { border-top: none; }
.ac-tit { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-d { font-size: 12px; flex: none; }
.ac-preview .note { margin-bottom: 0; background: var(--azure-soft); border-color: var(--azure-line); color: var(--info-text); }
.note-err { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); margin-bottom: 0; }

/* ---------- follow-up ---------- */
.fu-box { margin-top: 20px; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; background: var(--panel-3); }
.fu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fu-head h4 { margin: 0; color: var(--title); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.fu-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.fu-list li {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 10px; font-size: 13px;
  display: flex; align-items: flex-start; gap: 8px; transition: border-color var(--t), background var(--t);
}
.fu-list li.muted { justify-content: center; background: none; border-style: dashed; }
.fu-list li .fu-body { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.fu-list li .btn { flex: none; }
.fu-list li.editing { border-color: var(--azure); background: var(--azure-soft); }
.fu-btns { display: flex; gap: 2px; flex: none; }
.fu-btns .btn { min-height: 30px; padding: 2px 7px; }
.fu-btns .btn .ico { width: 16px; height: 16px; }
.fu-new { margin-top: 6px; padding: 6px 9px; border-left: 3px solid var(--azure); background: var(--panel-2); border-radius: var(--r-sm); white-space: pre-wrap; }
.fu-new .muted { font-size: 12px; }
.fu-date { font-weight: 700; color: var(--title); }
.fu-autore { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 3px; white-space: normal; }
.fu-autore .ico { width: 14px; height: 14px; }
.fu-autore strong { color: var(--text-2); font-weight: 600; }
.fu-come { font-weight: 400; font-size: 12px; margin-left: 8px; }
.fu-form { margin-top: 12px; padding-top: 14px; border-top: 1px dashed var(--border-2); animation: fade-up .2s var(--ease); }
.fu-form-title { font-weight: 700; color: var(--title); font-size: 13px; margin-bottom: 8px; }
.fu-form .field { margin-top: 10px; }
.fu-form .split .field { margin-top: 0; }
a.tem-link, .rte-area a[data-tem] {
  color: var(--title); text-decoration: underline dotted; text-underline-offset: 2px; font-weight: 600;
}
a.tem-link::before, .rte-area a[data-tem]::before { content: '↪ '; font-weight: 400; color: var(--azure); }

/* ---------- editor di testo ---------- */
.rte {
  position: relative; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--input-bg);
  transition: border-color var(--t), box-shadow var(--t);
}
.rte:focus-within { border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
.rte-bar {
  display: flex; align-items: center; gap: 2px; padding: 3px 4px; border-bottom: 1px solid var(--border);
  background: var(--panel-2); border-radius: var(--r) var(--r) 0 0;
}
.rte-btn {
  width: 30px; height: 28px; display: inline-grid; place-items: center; padding: 0;
  border: 1px solid transparent; background: none; border-radius: var(--r-sm); cursor: pointer;
  color: var(--text-2); font-size: 14px; line-height: 1; transition: background var(--t), color var(--t), border-color var(--t);
}
.rte-btn b, .rte-btn i, .rte-btn u { font-family: Georgia, 'Times New Roman', serif; font-size: 15px; }
.rte-btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.rte-sep { width: 1px; height: 18px; background: var(--border-2); margin: 0 4px; }
.rte-area {
  padding: 8px 11px; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5;
  max-height: 340px; overflow-y: auto; cursor: text;
}
.rte-area:empty::before { content: attr(data-placeholder); color: var(--placeholder); pointer-events: none; }
.rte-area a { color: var(--azure); text-decoration: underline; text-underline-offset: 2px; }
.rte-chip, .rte-pop {
  position: absolute; z-index: 4; background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(16,42,80,.16);
}
.rte-chip { display: flex; align-items: center; gap: 2px; padding: 3px; font-size: 12px; max-width: 100%; animation: fade-up .14s var(--ease); }
.rte-chip-lbl { padding: 0 8px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.rte-chip button {
  border: none; background: none; border-radius: var(--r-sm); padding: 5px 9px; cursor: pointer; font-weight: 600; color: var(--title);
  transition: background var(--t);
}
.rte-chip button[data-chip="remove"] { color: var(--danger); }
.rte-pop {
  top: 38px; left: 4px; right: 4px; max-width: 440px; padding: 10px;
  opacity: 0; transform: translateY(-4px); transition: opacity .14s var(--ease), transform .14s var(--ease);
}
.rte-pop.in { opacity: 1; transform: none; }
.rte-pop-tabs { display: flex; gap: 2px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.rte-pop-tabs button {
  border: none; background: none; padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t), border-color var(--t);
}
.rte-pop-tabs button.on { color: var(--title); border-bottom-color: var(--azure); }
.rte-pop-body { display: flex; gap: 6px; flex-direction: column; }
.rte-pop-body[data-pb="url"] { flex-direction: row; }
.rte-tem-list { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.rte-tem-list li + li { border-top: 1px solid var(--border); }
.rte-tem-list li.muted { padding: 8px 10px; font-size: 13px; }
.rte-tem-list button {
  display: block; width: 100%; text-align: left; border: none; background: none; padding: 7px 10px; cursor: pointer; font-size: 13px;
  transition: background var(--t);
}
.rte-tem-list button.on { background: var(--azure-soft); }
.rte-tem-list strong { color: var(--title); margin-right: 4px; }
.rte-pop-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }

/* ---------- notifiche ---------- */
#toasts {
  position: fixed; z-index: 200; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - 24px);
}
.toast {
  background: var(--toast-bg); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 14px;
  box-shadow: 0 10px 30px rgba(10,25,50,.3); border-left: 3px solid #3ecf8e;
  opacity: 0; transform: translateY(10px); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast-err { border-left-color: #ff6b5b; }

/* ---------- tema scuro (pulsante sole/luna nella barra in alto) ---------- */
:root[data-theme="dark"] {
  --navy: #2f5d9e;
  --navy-2: #3a6cb3;
  --navy-ink: #0b1220;
  --azure: #2ea7e0;
  --azure-2: #4bb5e8;
  --azure-soft: rgba(46,167,224,.14);
  --bg: #0e1522;
  --panel: #162131;
  --panel-2: #1b2839;
  --border: #253347;
  --border-2: #34455c;
  --text: #e3e9f2;
  --muted: #93a2b6;
  --danger: #ff7b6b;
  --danger-soft: rgba(255,123,107,.13);
  --ok: #43c585;
  --ok-soft: rgba(67,197,133,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.2);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  --title: #9cc3f2;
  --topbar: #111a2b;
  --text-2: #b9c6d6;
  --faint: #5f6f84;
  --placeholder: #6d7d92;
  --input-bg: #111b29;
  --btn-bg: #1b2839;
  --panel-3: #131d2c;
  --border-3: #4a5d77;
  --azure-line: rgba(46,167,224,.3);
  --azure-soft-2: rgba(46,167,224,.22);
  --danger-line: rgba(255,123,107,.35);
  --tint: rgba(255,255,255,.06);
  --tint-2: rgba(255,255,255,.08);
  --overlay: rgba(3,7,14,.66);
  --selection: rgba(46,167,224,.35);
  --switch-off: #3b4b61;
  --toast-bg: #22324a;
  --tabbar-bg: rgba(20,30,45,.94);
  --info-text: #cfe3f7;
  --warn-bg: rgba(240,180,60,.1); --warn-line: rgba(240,180,60,.3); --warn-text: #f2c46b;
  --badge-bg: rgba(255,255,255,.08); --badge-text: #b3c0cf;
  --st-aperto-bg: rgba(46,167,224,.15); --st-aperto: #6cc4f0;
  --st-corso-bg: rgba(240,160,50,.14); --st-corso: #f2b35c;
  --st-annullato-bg: rgba(255,110,100,.14); --st-annullato: #ff8c80;
  color-scheme: dark;
}
:root[data-theme="dark"] .topbar { box-shadow: 0 1px 0 rgba(255,255,255,.05), 0 4px 14px rgba(0,0,0,.35); }
:root[data-theme="dark"] .login-card { box-shadow: 0 24px 64px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3); }
:root[data-theme="dark"] .bulk { box-shadow: 0 6px 18px rgba(0,0,0,.4); }
:root[data-theme="dark"] .fab { box-shadow: 0 8px 22px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3); }
:root[data-theme="dark"] .rte-chip, :root[data-theme="dark"] .rte-pop { box-shadow: 0 8px 24px rgba(0,0,0,.45); }
:root[data-theme="dark"] .tabs { box-shadow: none; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.8); }
/* passaggio morbido tra i due temi (solo al clic sul pulsante) */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), fill .25s var(--ease) !important;
}

@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- effetti al passaggio del mouse: solo dove c'è un mouse
   (su iPhone/iPad resterebbero "accesi" dopo il tocco) ---------- */
@media (hover: hover) {
  .tbtn:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.32); }
  .tab:hover { color: var(--title); background: var(--tint); }
  input:hover, select:hover, textarea:hover, .rte:hover { border-color: var(--border-3); }
  .inline:hover { border-color: var(--border-2); background: var(--input-bg); }
  .btn:hover { border-color: var(--title); color: var(--title); }
  .btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; box-shadow: 0 2px 8px rgba(31,58,107,.25); }
  .btn-accent:hover { background: var(--azure-2); border-color: var(--azure-2); color: #fff; box-shadow: 0 2px 8px rgba(0,139,203,.25); }
  .btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
  .btn-ghost:hover { background: var(--tint); border-color: transparent; }
  .btn-ghost.btn-danger:hover { background: var(--danger-soft); }
  .btn[disabled]:hover { border-color: var(--border-2); color: inherit; background: var(--btn-bg); box-shadow: none; }
  .icon-btn:hover { background: var(--tint); color: var(--title); }
  .icon-btn.bell:hover { background: var(--azure-soft); color: var(--azure); }
  .td-row.is-sel:hover { background: var(--azure-soft-2); }
  .ct-x:hover { background: var(--danger-soft); color: var(--danger); }
  .gs-opt:hover { background: var(--tint); }
  .gs-opt.on:hover { background: var(--azure-soft-2); }
  .icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
  .icon-btn[disabled]:hover { background: none; color: var(--muted); }
  .list-row:hover { background: var(--panel-2); }
  .list-row:hover .lr-chev { color: var(--title); transform: translateX(2px); }
  .tem-row.is-sel:hover { background: var(--azure-soft-2); }
  .date-btn:not(:disabled):hover { border-color: var(--border-3); }
  .dp-nav:hover, .dp-day:not(.sel):hover { background: var(--tint); color: var(--title); }
  .dp-sp:not(.sel):hover { border-color: var(--title); }
  .dp-link:hover { text-decoration: underline; }
  .seg-btn:not(.on):hover { background: var(--tint); color: var(--title); }
  .pop-opt:hover { background: var(--tint); }
  .tool-btn.on:hover { background: var(--azure-soft-2); }
  input[type="checkbox"]:hover:not(:checked):not(:indeterminate):not(:disabled) { border-color: var(--title); }
  .bulk .btn:hover { background: rgba(255,255,255,.2); color: #fff; border-color: rgba(255,255,255,.4); }
  .bulk .icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
  .fab:hover { background: var(--navy-2); box-shadow: 0 10px 26px rgba(16,42,80,.38); }
  .fab.on:hover { background: var(--azure-2); }
  .modal-x:hover { background: var(--tint); color: var(--title); }
  .btn-back:hover { background: var(--azure-soft-2); }
  .fu-list li:hover { border-color: var(--border-2); }
  a.tem-link:hover { color: var(--azure); }
  .rte-btn:hover { background: var(--tint-2); color: var(--title); }
  .rte-btn.on:hover { background: var(--navy-2); color: #fff; }
  .rte-chip button:hover { background: var(--azure-soft); }
  .rte-tem-list button:hover { background: var(--azure-soft); }
}
/* su touch lo sfioramento non esiste: il suggerimento su Ctrl/scorciatoie non serve */
@media (hover: none) { .hint-desk { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- desktop largo: sezioni affiancate ---------- */
@media (min-width: 1100px) {
  .cards-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- tablet: etichette brevi delle sezioni ---------- */
@media (max-width: 1024px) {
  .td-grid { grid-template-columns: 1fr; }
  .tab-full { display: none; }
  .tab-short { display: inline; }
}

/* ---------- tablet ---------- */
@media (max-width: 900px) {
  .container { padding: 16px 16px 60px; }
  .tabs { overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; padding: 11px 12px; }
  .crumb-app, .crumb .sep { display: none; }
  .btn, .tbtn { min-height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
  input, select, .date-btn { min-height: 42px; }
  .rte-btn { width: 36px; height: 32px; }
  .tem-row { grid-template-columns: 22px 54px minmax(0, 1fr) 60px 100px 60px 32px; gap: 10px; }
  .icon-btn.bell { width: 36px; height: 36px; }
  .tem-row.ro { grid-template-columns: 54px minmax(0, 1fr) 60px 100px 60px; }
  .list-row, .list-head { padding-left: 16px; padding-right: 16px; }
}

/* ---------- cellulare ---------- */
@media (max-width: 680px) {
  /* 16px evita lo zoom automatico di iOS sui campi */
  input, select, textarea, .rte-area { font-size: 16px; }
  .container { padding: 12px 12px 40px; }
  .container.has-tabs { padding-bottom: calc(var(--tabbar-h) + 88px + env(safe-area-inset-bottom)); }
  .card { padding: 14px; }
  .note { margin-bottom: 12px; }

  .topbar { padding-left: 12px; padding-right: 8px; gap: 10px; height: calc(52px + env(safe-area-inset-top)); }
  .topbar .logo { height: 22px; }
  .topbar .divider, .ver, .tbtn-lbl { display: none; }
  .crumb-cur { flex-direction: column; gap: 0; line-height: 1.2; }
  .crumb-cur strong { font-size: 14px; }
  .crumb-sub { font-size: 12px; max-width: 60vw; }
  .tbtn { padding: 6px 10px; }
  .tbtn-ico { width: 40px; padding: 0; }

  /* barra delle sezioni fissa in basso, come nelle app */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; overflow: visible;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--tabbar-bg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); border-bottom: none; box-shadow: 0 -4px 16px rgba(16,42,80,.06);
  }
  .tab {
    flex-direction: column; justify-content: center; gap: 3px; padding: 6px 2px; margin: 0; min-height: 0;
    font-size: 10.5px; font-weight: 600; letter-spacing: .1px;
  }
  .tab .ico { width: 22px; height: 22px; opacity: .75; }
  .tab::after { top: 0; bottom: auto; left: 28%; right: 28%; }
  .tab-full { display: none; }
  .tab-short { display: block; }
  .tab-end { margin-left: 0; }

  .page-head { margin: 2px 0 12px; align-items: center; }
  .page-head h1 { font-size: 19px; }
  .ph-actions .btn span { display: none; }
  .ph-actions .btn { width: 40px; padding: 0; }
  .ph-actions .btn .ico { width: 20px; height: 20px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: auto; }
  .split { grid-template-columns: 1fr; }
  .split.keep { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card-actions .btn { flex: 1; }
  .card-actions .btn-ghost:first-child { flex: 0 0 100%; margin-right: 0; }

  /* elenchi compatti: codice, titolo con dettagli, stato */
  .list-head { display: none; }
  .list-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 12px 14px; }
  .list-row .lr-chev { display: none; }
  .lr-code { align-self: start; margin-top: 1px; }
  .lr-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  /* campanella sotto lo stato: il titolo resta largo */
  .tem-row { grid-template-columns: 24px 46px minmax(0, 1fr) auto; grid-template-areas: "chk code main stato" "chk code main bell"; row-gap: 2px; }
  .tem-row > :last-child.bell, .tem-row > span:last-child { grid-area: bell; }
  .tem-row .bell, .td-row .bell { justify-self: end; align-self: start; margin: 0 -8px -8px 0; }
  .tem-row > .chk:first-child { grid-area: chk; align-self: start; margin-top: 2px; }
  .tem-row .lr-code { grid-area: code; }
  .tem-row .lr-main { grid-area: main; }
  .tem-row .lr-cura, .tem-row .lr-fu { display: none; }
  .tem-row .lr-stato { grid-area: stato; align-self: start; justify-self: end; }
  .tem-row.ro { grid-template-columns: 46px minmax(0, 1fr) auto; grid-template-areas: "code main stato"; row-gap: 0; }
  /* in cima all'elenco: "seleziona tutte" */
  .list-head.tem-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
  .list-head.tem-row > span { display: none; }
  .list-head .m-only { display: inline; }
  .list-head .chk-lbl { text-transform: none; letter-spacing: 0; font-size: 13px; }
  .bulk { top: calc(60px + env(safe-area-inset-top)); margin: 4px 8px 8px; }
  .tool-lbl { display: none; }
  .tool-btn { width: 44px; padding: 0; }
  .tool-btn .tool-n, .tool-btn .tool-dot { position: absolute; top: -6px; right: -6px; }
  .tool-btn .tool-dot { top: 5px; right: 5px; }
  .search-row { gap: 6px; }
  /* calendario su telefono: pannello che sale dal basso */
  .dp.dp-sheet {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); z-index: 70; box-shadow: 0 -10px 40px rgba(10,25,50,.35);
  }
  .dp-sheet .dp-day { height: 42px; font-size: 16px; }
  .dp-sheet .dp-nav { width: 40px; height: 40px; }
  .dp-sheet .dp-sp { min-height: 44px; font-size: 15px; }
  .date-btn { min-height: 42px; font-size: 16px; }
  /* menu di scelta su telefono: pannello che sale dal basso, voci grandi */
  .sel-btn { min-height: 42px; font-size: 16px; }
  .sp.sp-sheet {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 70dvh; border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); z-index: 70; box-shadow: 0 -10px 40px rgba(10,25,50,.35);
  }
  .sp-sheet .sp-head { display: block; padding: 10px 6px 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
  .sp-sheet .sp-opt { min-height: 50px; font-size: 16px; }
  /* su telefono la finestrella sale dal basso, sopra la barra delle sezioni */
  #temPop .pop {
    position: fixed; left: 10px; right: 10px; width: auto; max-width: none;
    bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - var(--tabbar-h) - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    box-shadow: 0 -8px 40px rgba(10,25,50,.35);
  }
  .bulk .btn span { display: none; }
  .bulk .btn { width: 40px; padding: 0; }
  .fab { right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); width: 52px; height: 52px; }
  .fab.fab-left { right: auto; left: 16px; }
  .modal.modal-sm { height: auto; max-height: 92dvh; }
  .tem-row .lr-meta { white-space: normal; }
  .td-row { grid-template-columns: 24px 46px minmax(0, 1fr) auto; grid-template-areas: "chk code main stato" "chk code main bell"; row-gap: 2px; }
  .td-row > .chk:first-child { grid-area: chk; align-self: start; margin-top: 2px; }
  .td-row .lr-code { grid-area: code; }
  .td-row .lr-main { grid-area: main; }
  .td-row .lr-stato { grid-area: stato; justify-self: end; }
  .td-row .bell { grid-area: bell; }
  .td-row.ro { grid-template-columns: 46px minmax(0, 1fr) auto; grid-template-areas: "code main stato"; }
  .list-head.td-row:not(.ro) { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
  .list-head.td-row > span { display: none; }
  .ct-row { grid-template-columns: 1fr; gap: 8px; }
  .ct-add .btn span { display: none; }
  .ct-add .btn { width: 44px; padding: 0; }
  .nt-frame { height: 56dvh; }
  .gs-opt { flex-direction: column; gap: 1px; }
  .gs-nome { white-space: normal; }
  .td-row .lr-cura, .td-row .lr-scad { display: none; }
  .td-row .lr-stato { align-self: start; }
  .td-row .lr-meta { white-space: normal; }
  .seg-lbl { display: none; }
  .seg-btn { padding: 0; width: 38px; justify-content: center; }
  .td-actions { width: 100%; justify-content: space-between; }
  .td-card-head { padding: 12px 14px 6px; }
  .m-only { display: inline; }
  .hint-desk { display: none; }

  /* righe persone: nome e ruolo uno sotto l'altro */
  .p-row { grid-template-columns: 28px minmax(0, 1fr) 40px; grid-template-areas: "chk nome del" ". ruolo ."; row-gap: 0; padding: 6px 0; }
  .p-row .p-chk { grid-area: chk; }
  .p-row .p-nome { grid-area: nome; font-weight: 500; }
  .p-row .p-ruolo { grid-area: ruolo; font-size: 14px; min-height: 34px; color: var(--muted); }
  .p-row .p-del { grid-area: del; }
  .p-list.solo .p-row { grid-template-areas: "chk nome del"; }
  .p-add { grid-template-columns: 28px minmax(0, 1fr); grid-template-areas: "chk nome" ". ruolo" ". btn"; row-gap: 6px; }
  .p-list.solo .p-add { grid-template-columns: 28px minmax(0, 1fr); grid-template-areas: "chk nome" ". btn"; }
  .p-add .p-ruolo { font-size: 16px; color: inherit; }
  .p-add .p-btn { grid-area: btn; }
  .s-row { grid-template-columns: 76px minmax(0, 1fr) 40px; grid-template-areas: none; }
  .s-row.stato-row { grid-template-columns: minmax(0, 1fr) auto 40px; }

  .who { display: none; }
  .u-head { display: none; }
  .u-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; grid-template-areas: "nome cognome del" "soc soc ." "pwd pwd ."; row-gap: 2px; padding: 8px 0; }
  .u-row .u-nome { grid-area: nome; font-weight: 500; }
  .u-row .u-cognome { grid-area: cognome; font-weight: 500; }
  .u-row .u-soc { grid-area: soc; }
  .u-row .u-pwd { grid-area: pwd; padding-left: 4px; }
  .u-row .u-del { grid-area: del; }
  .u-add { grid-template-columns: 1fr 1fr; grid-template-areas: "nome cognome" "soc soc" "btn btn"; row-gap: 6px; }
  .u-add .u-btn { grid-area: btn; }
  .adm-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .adm-list .list-row { grid-template-columns: auto minmax(0, 1fr); }
  .list-head.tem-row.ro { display: none; }
  .modal.modal-perm { height: 100dvh; }
  .pm-head { display: none; }
  .pm-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 6px; padding: 12px 0; }
  .pm-who { grid-column: 1 / -1; }
  .pm-cell { flex-direction: column; align-items: flex-start; gap: 4px; }
  .pm-lbl { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
  .pm-val { font-size: 11px; white-space: normal; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: none; padding-bottom: 0; font-size: 12px; }
  .kv dd { padding-top: 2px; }

  /* modale a tutto schermo tipo "sheet" che sale dal basso */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 100vh; max-height: 100dvh; height: 100dvh;
    padding: 0 14px; transform: translateY(24px);
  }
  .modal-head { margin: 0 -14px 14px; padding: 10px 10px 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .fu-box { padding: 12px; margin-left: -4px; margin-right: -4px; }
  .modal-foot { margin: 20px -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .modal-foot .spacer { display: none; }
  .modal-foot .btn { flex: 1; }
  .modal-foot .btn-danger { flex: 0 0 44px; padding: 0; }
  .lbl-desk { display: none; }
  .rte-pop { right: 4px; max-width: none; }
  .rte-pop-body[data-pb="url"] { flex-direction: column; }
  /* su telefono le notifiche stanno in alto, per non coprire i pulsanti */
  #toasts { top: calc(10px + env(safe-area-inset-top)); bottom: auto; }
  .toast { transform: translateY(-10px); }
}

/* ---------- pagina di una voce aperta dal link di una notifica (voce.html) ---------- */
a.tbtn { text-decoration: none; }
.voce-page { max-width: 820px; }
.voce-commessa { margin: 6px 0 10px; font-size: 13px; color: var(--muted); }
.voce-commessa span { font-weight: 700; color: var(--azure); text-transform: uppercase; letter-spacing: .5px; font-size: 12px; }
.voce-card { padding: 20px 22px; }
.voce-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.voce-code { font-weight: 700; color: var(--title); font-size: 15px; }
.voce-code.is-todo { color: var(--azure); }
.voce-genere { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.voce-sp { flex: 1; }
.voce-tit { margin: 8px 0 14px; font-size: 22px; line-height: 1.3; color: var(--text); }
.voce-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 18px; margin: 0 0 16px; }
.voce-info dt { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.voce-info dd { margin: 0; font-size: 15px; }
.voce-box { background: var(--azure-soft); border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.voce-lbl { font-size: 11px; font-weight: 700; color: var(--azure); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.voce-sez { margin-top: 12px; }
.voce-sez .voce-lbl { color: var(--muted); }
.voce-h2 { margin: 0 0 8px; font-size: 16px; color: var(--title); display: flex; align-items: center; gap: 8px; }
.voce-fu { padding: 12px 0; border-top: 1px solid var(--border); }
.voce-fu-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-bottom: 4px; font-size: 14px; }
.voce-fu-head .muted { font-size: 13px; }
.voce-na { margin-top: 8px; padding: 8px 12px; background: var(--panel-2); border-left: 3px solid var(--azure); border-radius: var(--r-sm); font-size: 14px; }
.voce-na .muted { font-size: 13px; margin-top: 4px; }
.voce-err h1 { margin: 0 0 6px; font-size: 20px; color: var(--title); }
.voce-err p { margin: 0; }
.voce-nota { font-size: 12px; text-align: center; margin: 4px 0 24px; }
@media (max-width: 680px) {
  .voce-card { padding: 16px; }
  .voce-tit { font-size: 19px; }
  .topbar a.tbtn .tbtn-lbl { display: inline; }
}
.voce-page .rte-view { background: none; border: none; padding: 0; min-height: 0; }
.voce-apri { text-align: center; margin: 6px 0 10px; }
.voce-apri .btn { text-decoration: none; }

/* ---------- tutorial (pagina Admin → TUTORIAL) ---------- */
.tut-hero {
  display: flex; align-items: center; gap: 18px; margin: 0 0 16px; padding: 18px 20px; border-radius: 10px; color: #fff;
  background: linear-gradient(120deg, var(--navy) 0%, #24508f 55%, var(--azure) 100%);
  box-shadow: 0 10px 28px rgba(16,42,80,.22);
}
.tut-hero-ico { flex: none; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.16); }
.tut-hero-ico .ico { width: 30px; height: 30px; }
.tut-hero-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tut-hero-txt strong { font-size: 17px; }
.tut-hero-txt span { font-size: 13px; opacity: .9; line-height: 1.45; }
.btn.btn-tutorial {
  flex: none; min-height: 54px; padding: 0 26px; gap: 10px; border: none; border-radius: 10px;
  background: #fff; color: var(--navy); font-size: 17px; font-weight: 800; letter-spacing: 1.6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.2); transition: transform var(--t), box-shadow var(--t);
}
.btn.btn-tutorial .ico { width: 24px; height: 24px; color: var(--azure); }
.btn-tutorial:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.note.note-tut { background: var(--azure-soft); border-color: var(--azure); color: var(--info-text); }
.note-tut .ico { color: var(--azure); }

.tut { position: fixed; inset: 0; z-index: 9000; pointer-events: none; }
.tut-blk { position: fixed; pointer-events: auto; background: transparent; }
.tut.tut-pieno .tut-blk[data-b="t"] { background: rgba(4,11,24,.8); }
.tut-spot {
  position: fixed; border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(4,11,24,.8);
  transition: left .28s var(--ease), top .28s var(--ease), width .28s var(--ease), height .28s var(--ease);
}
.tut-spot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 11px; border: 2px solid var(--azure-2);
  box-shadow: 0 0 0 4px rgba(10,155,222,.25); animation: tut-pulse 1.6s ease-in-out infinite;
}
@keyframes tut-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.012); } }
.tut-card {
  position: fixed; pointer-events: auto; width: 390px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto;
  background: var(--panel); color: var(--text); border-radius: 12px; padding: 14px 18px 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.06);
  transition: left .25s var(--ease), top .25s var(--ease), opacity .15s;
}
.tut.tut-attesa .tut-card { opacity: .55; }
.tut-card h3 { margin: 6px 0 6px; font-size: 18px; line-height: 1.3; color: var(--title); }
.tut-top { display: flex; align-items: center; gap: 8px; }
.tut-chip { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--azure); background: var(--azure-soft); padding: 3px 8px; border-radius: 20px; }
.tut-n { font-size: 12px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.tut-x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 15px; width: 30px; height: 30px; border-radius: var(--r); margin-right: -8px; }
.tut-chip + .tut-x { margin-left: auto; }
.tut-x:hover { background: var(--tint); color: var(--title); }
.tut-bar { height: 4px; border-radius: 4px; background: var(--tint-2); margin: 10px 0 4px; overflow: hidden; }
.tut-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--azure), var(--navy-2)); border-radius: 4px; transition: width .3s var(--ease); }
.tut-txt { font-size: 14px; line-height: 1.55; color: var(--text-2); }
.tut-txt b { color: var(--text); }
.tut-task {
  display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 10px; padding: 10px 12px; border-radius: 8px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); font-size: 14px; line-height: 1.45;
}
.tut-task-ico { font-size: 16px; line-height: 1.3; }
.tut-task:not(.ok) .tut-task-ico { animation: tut-punta 1.1s ease-in-out infinite; }
@keyframes tut-punta { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
.tut-task.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.tut-task.ok .tut-task-ico { font-weight: 800; }
.tut-note { margin-top: 10px; font-size: 13px; color: var(--muted); font-style: italic; }
.tut-sezioni { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tut-lbl { width: 100%; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tut-sez { border: 1px solid var(--border-2); background: var(--btn-bg); color: var(--title); border-radius: 20px; padding: 5px 11px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tut-sez:hover { border-color: var(--azure); background: var(--azure-soft); }
/* pulsanti sempre visibili, anche quando il riquadro è accorciato e scorre */
.tut-foot {
  position: sticky; bottom: -14px; z-index: 1; display: flex; align-items: center; gap: 8px;
  margin: 14px -18px -14px; padding: 10px 18px 14px; background: var(--panel); border-top: 1px solid var(--border);
}
.tut-sp { flex: 1; }
.tut-back { width: 38px; padding: 0; justify-content: center; }
.tut-link { border: none; background: none; padding: 4px 2px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tut-link:hover { color: var(--title); }
.tut-card.tut-shake { animation: tut-scossa .38s; }
@keyframes tut-scossa { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
body.tut-on #toasts { z-index: 9100; }
body.tut-on .dp, body.tut-on .sp { z-index: 9500; } /* calendario e menu di scelta sempre usabili durante il tour */
.tut-min { font-size: 13px; }
/* riquadro ridotto: titolo e azione da fare, per vedere cosa c'è sotto */
.tut-card.tut-mini .tut-txt, .tut-card.tut-mini .tut-bar, .tut-card.tut-mini .tut-note, .tut-card.tut-mini .tut-foot { display: none; }
.tut-card.tut-mini .tut-task { margin-bottom: 2px; }
@media (hover: hover) {
  .btn.btn-tutorial:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.28); }
}
@media (max-width: 680px) {
  .tut-hero { flex-wrap: wrap; padding: 16px; gap: 12px; }
  .tut-hero-ico { width: 44px; height: 44px; }
  .btn.btn-tutorial { width: 100%; justify-content: center; }
  .tut-card { width: calc(100vw - 16px); max-width: none; max-height: 52dvh; padding: 12px 14px; }
  .tut-card h3 { font-size: 17px; }
  .tut-foot { flex-wrap: wrap; margin: 12px -14px -12px; padding: 8px 14px 12px; bottom: -12px; }
}
@media (prefers-reduced-motion: reduce) { .tut-spot::after, .tut-task-ico { animation: none !important; } }
