/* =========================================================
   Token colore: tema chiaro (default) e scuro
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-2: #334155;
  --muted: #64748b;
  --input-bg: #ffffff;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-soft-border: #bfdbfe;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-soft-border: #fecaca;
  --warn-soft: #fffbeb;
  --warn-text: #92400e;
  --warn-border: #fde68a;
  --ok-soft: #dcfce7;
  --ok-text: #166534;
  --toast-bg: #0f172a;
  --backdrop: rgba(15, 23, 42, .45);
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  --radius: 10px;
  --topbar-h: 56px;
  --today: #f0f6ff;
  --non-business: rgba(148, 163, 184, .09);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #131c2e;
    --surface-2: #1a2438;
    --surface-3: #212c42;
    --border: #2a3650;
    --border-strong: #3a4866;
    --text: #e2e8f0;
    --text-2: #cbd5e1;
    --muted: #94a3b8;
    --input-bg: #0f172a;
    --primary: #3b82f6;
    --primary-600: #2563eb;
    --primary-soft: rgba(59, 130, 246, .16);
    --primary-soft-border: rgba(59, 130, 246, .4);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --danger-soft-border: rgba(248, 113, 113, .35);
    --warn-soft: rgba(251, 191, 36, .12);
    --warn-text: #fcd34d;
    --warn-border: rgba(251, 191, 36, .35);
    --ok-soft: rgba(34, 197, 94, .15);
    --ok-text: #86efac;
    --toast-bg: #e2e8f0;
    --backdrop: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
    --today: rgba(59, 130, 246, .10);
    --non-business: rgba(0, 0, 0, .22);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #131c2e;
  --surface-2: #1a2438;
  --surface-3: #212c42;
  --border: #2a3650;
  --border-strong: #3a4866;
  --text: #e2e8f0;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --input-bg: #0f172a;
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --primary-soft: rgba(59, 130, 246, .16);
  --primary-soft-border: rgba(59, 130, 246, .4);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --danger-soft-border: rgba(248, 113, 113, .35);
  --warn-soft: rgba(251, 191, 36, .12);
  --warn-text: #fcd34d;
  --warn-border: rgba(251, 191, 36, .35);
  --ok-soft: rgba(34, 197, 94, .15);
  --ok-text: #86efac;
  --toast-bg: #e2e8f0;
  --backdrop: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
  --today: rgba(59, 130, 246, .10);
  --non-business: rgba(0, 0, 0, .22);
}

/* Tema Nero: grigi neutri senza tinta blu, sfondo nero pieno (ottimo anche su OLED) */
:root[data-theme="black"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-2: #171717;
  --surface-3: #212121;
  --border: #262626;
  --border-strong: #3a3a3a;
  --text: #ededed;
  --text-2: #d4d4d4;
  --muted: #a3a3a3;
  --input-bg: #050505;
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --primary-soft: rgba(59, 130, 246, .16);
  --primary-soft-border: rgba(59, 130, 246, .4);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --danger-soft-border: rgba(248, 113, 113, .35);
  --warn-soft: rgba(251, 191, 36, .12);
  --warn-text: #fcd34d;
  --warn-border: rgba(251, 191, 36, .35);
  --ok-soft: rgba(34, 197, 94, .15);
  --ok-text: #86efac;
  --toast-bg: #ededed;
  --backdrop: rgba(0, 0, 0, .7);
  --shadow: none;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .8);
  --today: rgba(255, 255, 255, .05);
  --non-business: rgba(255, 255, 255, .025);
}

/* FullCalendar segue i token */
:root {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-2);
  --fc-list-event-hover-bg-color: var(--surface-2);
  --fc-today-bg-color: var(--today);
  --fc-now-indicator-color: var(--danger);
  --fc-highlight-color: rgba(59, 130, 246, .18);
  --fc-non-business-color: var(--non-business);
  --fc-button-bg-color: var(--surface);
  --fc-button-border-color: var(--border);
  --fc-button-text-color: var(--text);
  --fc-button-hover-bg-color: var(--surface-2);
  --fc-button-hover-border-color: var(--border-strong);
  --fc-button-active-bg-color: var(--primary);
  --fc-button-active-border-color: var(--primary);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
[hidden] { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.sees-all) .sees-all-only { display: none !important; }
.perm-off { display: none !important; } /* elementi con data-perm senza il permesso */

/* select con pulsante "+" per aggiungere voci al volo */
.select-add { display: flex; gap: 6px; }
.select-add select { flex: 1; min-width: 0; }
.add-btn { flex: none; width: 34px; border: 1px solid var(--border); background: var(--surface-2); color: var(--primary);
  border-radius: 8px; font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer; }
.add-btn:hover { background: var(--primary-soft); border-color: var(--primary-soft-border); }
.inline-add { display: flex; gap: 6px; margin-top: 6px; }
.inline-add input { flex: 1; min-width: 0; }
.field-add { display: flex; flex-direction: column; }
.comm-flag { padding: 8px 10px; border: 1px dashed var(--border-strong); border-radius: 8px; flex-wrap: wrap; }
.comm-flag small { font-weight: 400; }
/* flag Urgente / Festivo affiancati, con la maggiorazione del cliente accanto */
.flag-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.flag-box { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.flag-box:has(input:checked) { border-color: var(--primary); background: var(--surface-2); }
.flag-hint { color: var(--muted); font-weight: 400; margin-left: auto; }
/* promemoria del contratto sotto il flag 🤝 Contratto */
.contract-info { flex-basis: 100%; font-weight: 400; color: var(--muted); }
.contract-info:empty { display: none; }
.contract-info.contract-ok { color: var(--ok-text); }
.contract-info.contract-warn { color: var(--warn-text); }
.flag-contract:has(input:disabled) { opacity: .85; }
/* Richiedente: testo libero + tendina dei contatti */
.contact-row { display: flex; gap: 6px; align-items: stretch; }
.contact-row .combo { flex: 1; display: block; min-width: 0; }
/* tendina del Richiedente: contatti (★ principale, ruolo, di chi è) e nomi già usati */
.combo-list li.contact-item .star { color: #f59e0b; font-weight: 700; }
.combo-list li .contact-where { flex: none; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.contact-save { flex: none; white-space: nowrap; }
.contact-save[hidden] { display: none; }
/* schede della modale generica (Dati / Contatti / Contratti) */
.edit-tabs { display: flex; flex: none; gap: 2px; padding: 4px 20px 0; border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; } /* niente barra: la sottolineatura del tab attivo sporge di 1 px */
.edit-tabs::-webkit-scrollbar { display: none; }
.edit-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; margin-bottom: -1px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.edit-tabs button:hover { color: var(--text); }
.edit-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.edit-panel .panel-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.crm-table td, .crm-table th { padding: 7px 8px; }
.crm-table tr.clickable { cursor: pointer; }
.crm-table tr.clickable:hover td { background: var(--surface-2); }
.crm-table tr.inactive td { opacity: .55; }
.pill-future { background: var(--warn-soft); color: var(--warn-text); }
.sub-dialog { width: min(560px, calc(100vw - 32px)); }
.comm-row { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 12px; align-items: end; }
.comm-row input { font-family: ui-monospace, Consolas, monospace; letter-spacing: .05em; }
.comm-row .hint { padding-bottom: 8px; }
.hint.warn { color: var(--warn-text); }
.ev-comm { padding: 0 3px; }

/* interventi affiancati: tutti i dati restano visibili, il testo va a capo nella colonna */
.fc-timegrid-event-harness + .fc-timegrid-event-harness .fc-timegrid-event { box-shadow: 0 0 0 1px var(--surface); }
.fc-timegrid-event .ev { overflow-wrap: break-word; hyphens: auto; }
.fc-timegrid-event .ev-badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; margin-left: 0; }
.fc-timegrid-event .ev-time { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* prima riga: cliente - cliente finale, poi stato e 📨 sulla stessa riga se c'è spazio */
.ev-tg { font-size: 11.5px; line-height: 1.22; }
.ev-tg .ev-badge { font-size: 9.5px; line-height: 1.35; padding: 0 4px; }
.ev-tg .ev-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 4px; }
.ev-tg .ev-head .ev-client { min-width: 0; }
.ev-tg .ev-head .ev-badge { flex: none; max-width: 100%; }
/* link "+N" per gli interventi oltre il terzo affiancato */
.fc .fc-timegrid-more-link { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; font-weight: 700; font-size: 12px; padding: 2px 4px; box-shadow: none; }
.fc .fc-timegrid-more-link:hover { background: var(--primary-soft); color: var(--primary); }
.fc .fc-popover { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-lg); border-radius: 10px; overflow: hidden; z-index: 900; }
.fc .fc-popover-header { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* avviso sovrapposizione nella scheda intervento */
.overlap-msg { margin-bottom: 14px; background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--warn-border);
  padding: 8px 12px; border-radius: 8px; font-size: 13px; }

/* rimborsi e riepilogo economico nella scheda intervento */
.expenses { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; margin: 0; background: var(--surface-2); }
.expenses legend { font-size: 12.5px; font-weight: 650; color: var(--text-2); padding: 0 6px; }
.exp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
#km-amount { background: var(--surface-3); font-weight: 600; }
.exp-wide { grid-column: span 2; }
.exp-full { grid-column: 1 / -1; }
/* rimborso diverso dal valore predefinito del cliente */
.expenses input.is-changed { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); font-weight: 600; }
/* modificato ma non editabile da chi guarda: resta grigio, il rosso solo nel testo */
.expenses input.is-changed:disabled { background: var(--surface-3); border-color: var(--border); -webkit-text-fill-color: var(--danger); }
.def-hint { color: var(--danger); font-weight: 500; font-size: 11.5px; min-height: 0; }
.def-hint:empty { display: none; }
.refunds { font-size: 12.5px; white-space: nowrap; }
.refunds small { display: block; white-space: normal; max-width: 180px; }
.refund-changed { color: var(--danger); font-weight: 600; }
.refund-lock { font-size: 11px; color: var(--muted); }
.amount-cell { white-space: nowrap; }
.amount-parts { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.amount-parts .refund-changed { color: var(--danger); }
#money-sum { margin-top: 10px; }
/* congelato ma ancora correggibile (admin/supervisore): niente grigio, solo l'indicazione 🔒 sotto il campo */
.expenses input.is-frozen:not(:disabled) { border-style: dashed; }
.def-hint.frozen { color: var(--muted); }
.comm-row input[readonly] { background: var(--surface-2); }
.money-box:empty { display: none; }
.money-line { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; padding: 8px 12px; border-radius: 8px;
  background: var(--primary-soft); border: 1px solid var(--primary-soft-border); }
.money-tot { margin-left: auto; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 17px; margin: 0; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 12px; font-weight: 650; }
.mt { margin-top: 20px; }
.mt-sm { margin-top: 10px; }
.muted { color: var(--muted); }
small.code, .code { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--muted); }

/* ---------- Controlli ---------- */
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg);
  padding: 7px 10px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, .2); }
/* campi non modificabili (bloccati o in sola lettura): sempre grigi, così interfaccia e dato salvato coincidono */
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  background: var(--surface-3); color: var(--muted); border-color: var(--border); cursor: not-allowed;
  box-shadow: none; opacity: 1; -webkit-text-fill-color: var(--muted);
}
input[readonly]:focus, textarea[readonly]:focus { border-color: var(--border); box-shadow: none; }
select:disabled { appearance: none; -webkit-appearance: none; }
label:has(> input:disabled), label:has(> select:disabled), label:has(> textarea:disabled) { color: var(--muted); }
input[type=checkbox]:disabled, input[type=radio]:disabled { cursor: not-allowed; opacity: .55; }
label.check:has(input:disabled) { color: var(--muted); cursor: not-allowed; }
/* pulsanti di modalità (Presso cliente / In sede) bloccati */
.segmented:has(input:disabled) { background: var(--surface-3); }
.segmented input:disabled + span { color: var(--muted); cursor: not-allowed; }
.segmented input:checked:disabled + span { background: var(--border-strong); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 36px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; }
.lbl { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 6px; }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.lbl-row .lbl { margin: 0; }
.mini-links { font-size: 12px; color: var(--muted); }
/* Filtri calendario: gruppi richiudibili (chiusi di default) con riepilogo e salvataggio 💾 */
.filters-block .lbl-row { align-items: center; }
.filters-actions { display: inline-flex; gap: 4px; }
.filters-actions .btn { padding: 2px 10px; font-size: 12px; }
/* Salva in evidenza quando i filtri sono cambiati e non salvati */
.filters-save.dirty { background: var(--primary); border-color: var(--primary); color: #fff; }
.filt-group { border-top: 1px solid var(--border, rgba(127,127,127,.25)); }
.filt-group > summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 7px 2px; cursor: pointer; font-weight: 600; user-select: none; }
.filt-group > summary::-webkit-details-marker { display: none; }
.filt-group > summary::before { content: '▸'; color: var(--muted); font-size: 11px; width: 10px; }
.filt-group[open] > summary::before { content: '▾'; }
.filt-count { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.filt-count.filt-on { color: var(--primary); font-weight: 600; }
.filt-links { margin: 0 0 6px 16px; }
.filt-group > ul { margin: 0 0 8px 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 550; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger-soft-border); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.icon-btn:hover { color: var(--text); }
.theme-btn { font-size: 18px; width: 32px; height: 32px; border-radius: 8px; }
.theme-btn:hover { background: var(--surface-2); }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.icon-sm { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; width: 26px; height: 24px; cursor: pointer; font-size: 13px; }
.icon-sm:disabled { opacity: .35; cursor: default; }

/* ---------- Login ---------- */
.auth-screen { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 10%, var(--primary-soft), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--border); }
.auth-card .muted { margin: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; white-space: nowrap; }
/* login: logo grande e centrato (si riduce sui telefoni stretti) */
.brand-lg { font-size: min(36px, calc((100vw - 88px) / 6.6)); gap: .3em; justify-content: center; }
.brand-tagline { margin: -6px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
/* marchio TeknoCore: nuvola (colore del testo) con freccia blu */
.brand-mark { width: 36px; height: 24px; flex: none; overflow: visible; }
.brand-mark path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .bm-cloud { stroke: currentColor; stroke-width: 3.6; }
.brand-mark .bm-arrow { stroke: var(--primary); stroke-width: 3.6; }
.brand-lg .brand-mark { width: 1.65em; height: 1.1em; }
.brand-name .bn-a { font-weight: 400; }
.brand-name .bn-b { font-weight: 700; color: var(--primary); }

/* ---------- Layout ---------- */
.app { height: 100%; display: flex; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.crumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; overflow: hidden; }
.crumb-sep { color: var(--muted); }

/* menu principale a sinistra (riducibile alle icone con body.nav-mini) */
.nav { width: 214px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border);
  transition: width .15s ease; overflow: hidden; z-index: 30; }
.nav-brand { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; font-size: 28px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.nav-brand .brand-mark { width: 44px; height: 29px; }
body.nav-mini .nav-brand .brand-mark { width: 36px; height: 24px; }
.nav-items { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px; }
.nav-sec + .nav-sec { margin-top: 4px; }
.nav-title { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 10px 4px; white-space: nowrap; }
.nav-link { display: flex; align-items: center; gap: 11px; width: 100%; padding: 7px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--muted); font: inherit; font-weight: 550; font-size: 14px; text-decoration: none; white-space: nowrap; cursor: pointer; text-align: left; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link.soon { opacity: .45; cursor: default; }
.nav-link.soon:hover { background: none; color: var(--muted); }
.nav-soon { margin-left: auto; font-size: 10.5px; font-weight: 500; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-foot { flex: none; border-top: 1px solid var(--border); padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-toggle .ico { transition: transform .15s ease; }
body.nav-mini .nav { width: 62px; }
body.nav-mini .nav .nav-label { display: none; }
body.nav-mini .nav-brand { padding: 0; justify-content: center; }
body.nav-mini .nav-items { padding: 6px 8px; }
body.nav-mini .nav-title { height: 0; padding: 0; margin: 9px 6px; border-top: 1px solid var(--border); }
body.nav-mini .nav-sec:first-child .nav-title { border-top: 0; margin: 4px 6px; }
body.nav-mini .nav-link { justify-content: center; padding: 9px 0; }
body.nav-mini .nav-toggle .ico { transform: rotate(180deg); }
.nav-tip { position: fixed; z-index: 2000; transform: translateY(-50%); background: var(--text); color: var(--surface); font-size: 12.5px;
  font-weight: 550; padding: 4px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; box-shadow: var(--shadow-lg); }
.nav-backdrop { display: none; }
.bottombar { display: none; }
.home-pick { display: flex; flex-direction: column; gap: 4px; max-width: 320px; }
.tabs, .subtabs { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
.tabs { flex: 1; }
.tabs button, .subtabs button { border: 0; background: none; font: inherit; font-weight: 550; color: var(--muted); padding: 8px 12px;
  border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tabs button:hover, .subtabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active, .subtabs button.active { background: var(--primary-soft); color: var(--primary); }
.subtabs { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.user-box { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-size: 12px; font-weight: 700; background: var(--primary); overflow: hidden; flex: none; }
.avatar img { width: 78%; height: 78%; object-fit: cover; margin-top: 12%; }
.avatar.has-img img { width: 100%; height: 100%; margin: 0; }
.avatar-lg { width: 40px; height: 40px; }
.avatar-xl { width: 88px; height: 88px; }

/* menu utente */
.user-box { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid transparent; background: none; color: var(--text);
  font: inherit; font-weight: 550; padding: 3px 8px 3px 3px; border-radius: 22px; cursor: pointer; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); }
.caret { font-size: 11px; color: var(--muted); }
.user-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 1000; min-width: 240px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.user-menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu-head small { display: block; color: var(--muted); font-size: 12px; }
.user-menu-head .menu-version { font-size: 11px; margin-top: 2px; opacity: .85; }
.user-menu-head .menu-version:empty { display: none; }
.user-menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; color: var(--text);
  font: inherit; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.user-menu button:hover, .user-menu button:focus-visible { background: var(--primary-soft); outline: none; }

/* finestra profilo */
.dialog-shell { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.profile-body { display: flex; flex-direction: column; gap: 0; }
.profile-sec { padding: 4px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.profile-sec:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 4px; }
.avatar-row { display: flex; align-items: center; gap: 18px; }
.file-btn { position: relative; overflow: hidden; flex-direction: row; color: var(--text); font-size: 13px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.schedule-table th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 4px 6px; }
.schedule-table td { padding: 3px 6px; }
.schedule-table input[type=time] { width: 110px; }
.schedule-table input[type=number] { width: 80px; }
.schedule-table tr.off td:first-child { color: var(--muted); }
.schedule-table tfoot td { border-top: 1px solid var(--border); padding-top: 8px; font-weight: 650; }
.schedule-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* scheda azienda */
.company-grid { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); align-items: start; }
.addr-row { display: grid; grid-template-columns: 90px 1fr 70px 1fr; gap: 10px; }
.logo-preview { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 16px; display: grid; place-items: center;
  min-height: 120px; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.logo-preview img { max-width: 100%; max-height: 120px; }
.footer-preview { font-size: 11.5px; color: var(--muted); line-height: 1.5; border-top: 2px solid var(--border-strong); padding-top: 6px; text-align: center; }

.view { flex: 1; min-height: 0; }
#view-calendar { display: flex; }
/* filtri del calendario: pannello a destra */
.side { width: 270px; flex: none; padding: 18px; border-left: 1px solid var(--border); background: var(--surface);
  overflow-y: auto; display: flex; flex-direction: column; gap: 18px; order: 2; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.side .hint { margin-top: -6px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; }
.kpi span { display: block; font-size: 17px; font-weight: 700; }
.kpi small { color: var(--muted); font-size: 11px; line-height: 1.2; display: block; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

.user-toggles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.user-toggles li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 6px; border-radius: 6px; }
.user-toggles li:hover { background: var(--surface-2); }
.user-toggles li.off label { color: var(--muted); }
.user-toggles li.off .dot-btn { opacity: .35; }
.dot-btn { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.dot-btn:disabled { cursor: default; }

.cal-wrap { flex: 1; min-width: 0; padding: 16px 18px; background: var(--surface); }
#calendar { height: 100%; }
/* pannello sinistro chiuso col pulsante ☰ */
#view-calendar.side-closed .side { display: none; }
.fc .fc-sidebar-button { font-size: 18px; line-height: 1; padding: .3em .6em; }

.page { overflow-y: auto; padding: 22px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
/* gli elementi della pagina non si schiacciano quando il contenuto è più alto dello schermo (es. le voci di Impostazioni) */
.page > * { flex-shrink: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions input[type=search] { width: 240px; }
.actions select { width: 220px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
form.card { display: flex; flex-direction: column; gap: 12px; align-self: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.subview { display: grid; gap: 16px; }

/* ---------- Palette colori ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer; padding: 0; position: relative; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.swatch.on::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.swatch-custom { background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444); display: block; overflow: hidden; }
.swatch-custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; padding: 0; border: 0; }
.swatches-pop { padding: 10px; max-width: 220px; }
.day-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* ---------- FullCalendar ---------- */
.fc { color: var(--text); }
.fc .fc-toolbar-title { font-size: 18px; font-weight: 650; text-transform: capitalize; }
.fc .fc-button { font-weight: 550; font-size: 13px; padding: 5px 11px; box-shadow: none !important; text-transform: capitalize; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
/* «+ Nuovo intervento» a destra di Oggi: pulsante principale */
.fc .fc-newInt-button, .fc .fc-newInt-button:hover { background: var(--primary); border-color: var(--primary); color: #fff; text-transform: none; }
.fc .fc-newInt-button:hover { background: var(--primary-600); }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { text-transform: capitalize; font-weight: 600; padding: 6px 4px; color: var(--text); }
/* altezza delle righe da 15' calcolata dallo zoom (app.js); l'etichetta dell'ora non occupa
   spazio, così le righe possono diventare basse quando si vedono molte ore */
#calendar.fc .fc-timegrid-slot { height: var(--slot-h, 22px); padding: 0; line-height: 0; }
#calendar.fc .fc-timegrid-slot:empty::before { content: none; }
#calendar.fc .fc-timegrid-slot-label { vertical-align: top; }
#calendar.fc .fc-timegrid-slot-label-frame { height: 0; overflow: visible; }
#calendar.fc .fc-timegrid-slot-label-cushion { display: block; padding: 3px 6px 0; line-height: 1; font-size: 12px; }
.fc .fc-timegrid-slot-minor { border-top-style: dotted; }
.fc .fc-zoomOut-button, .fc .fc-zoomIn-button { font-size: 16px; line-height: 1; padding: 4px 10px; }
/* interventi fuori dalla fascia visibile: segnale in cima / in fondo alla colonna del giorno */
.off-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.off-badge { position: absolute; pointer-events: auto; height: 20px; padding: 0 6px; border: 0; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 650; cursor: pointer; opacity: .92;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.off-badge:hover { opacity: 1; }
.off-up { top: 3px; }
.off-down { bottom: 3px; }
#calendar.cal-no-zoom .fc-zoomOut-button, #calendar.cal-no-zoom .fc-zoomFit-button, #calendar.cal-no-zoom .fc-zoomIn-button { display: none; }
.fc .fc-timegrid-axis-cushion { font-size: 11px; color: var(--muted); max-width: 70px; white-space: normal; text-align: right; line-height: 1.15; }
.fc .fc-timegrid-slot-label-cushion { color: var(--muted); }
.fc .fc-daygrid-body-natural .fc-daygrid-day-events { margin-bottom: 4px; }
.fc-timegrid-event .fc-event-main { padding: 2px 5px; }
.fc-event { cursor: pointer; border-radius: 6px; }
.fc-event.is-locked { opacity: .8; }
.fc-h-event .fc-event-main { color: #fff; }
.ev { overflow: hidden; height: 100%; font-size: 12px; line-height: 1.3; }
.ev-time { font-size: 11px; opacity: .9; }
.ev-client { font-weight: 700; }
.ev-sub { opacity: .92; }
.ev-code { font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.ev-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: rgba(255, 255, 255, .92); margin-left: 4px; }
.fc-daygrid-event .ev, .ev-allday { display: flex; gap: 4px; white-space: nowrap; align-items: center; padding: 1px 3px; }
/* riga «Tutto il giorno» (viste orarie): alta almeno quanto un'ora della griglia, contenuto su più righe
   come gli interventi in griglia */
#calendar .fc-timegrid .fc-daygrid-body .fc-daygrid-day-frame { min-height: max(48px, calc(var(--slot-h, 22px) * 4)); height: 100%; }
/* la cella "riempibile" fa estendere a tutta la riga anche lo sfondo fuori orario (sabato, domenica) */
#calendar .fc-timegrid .fc-daygrid-body td.fc-daygrid-day { height: 1px; }
#calendar .fc-timegrid .fc-daygrid-event .ev.ev-allday { display: block; white-space: normal; overflow-wrap: break-word;
  min-height: max(42px, calc(var(--slot-h, 22px) * 4 - 6px)); padding: 2px 5px; }
.ev-allday .ev-head .ev-time { margin-left: 2px; }
.fc-list-event .ev-badge { box-shadow: 0 0 0 1px var(--border); }
.fc-list-event .ev, .fc-list-event .ev-sub { color: var(--text); }

/* ---------- Menu contestuale ---------- */
.ctx-menu { position: fixed; z-index: 1100; min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; font-size: 13.5px; }
.ctx-head { padding: 6px 10px 8px; font-weight: 650; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ctx-head small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.ctx-label { padding: 4px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ctx-menu button:not(.swatch) { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; color: var(--text);
  font: inherit; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.ctx-menu button:not(.swatch):hover:not(:disabled), .ctx-menu button:not(.swatch):focus-visible { background: var(--primary-soft); outline: none; }
.ctx-menu button:disabled { color: var(--muted); cursor: not-allowed; }
.ctx-check { margin-left: auto; color: var(--primary); font-weight: 700; }
.ctx-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.ctx-empty { padding: 8px 10px; color: var(--muted); }

/* ---------- Report ---------- */
.filters { display: flex; flex-direction: column; gap: 14px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 20px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.presets button.active { background: var(--primary-soft); border-color: var(--primary-soft-border); color: var(--primary); font-weight: 600; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi-row .kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-card .v { font-size: 24px; font-weight: 700; }
.kpi-card .l { color: var(--muted); font-size: 12.5px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1.2fr) 2fr 64px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track, .bar-fill { display: block; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.table-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.table-head h3 { margin: 0; }
.bulk { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { --c: var(--primary); border: 1px solid var(--c); color: var(--c); background: transparent; border-radius: 20px;
  padding: 3px 10px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip:hover { background: var(--c); color: #fff; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--primary-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .desc { max-width: 420px; }
.table .desc small { color: var(--muted); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table tr.inactive td { color: var(--muted); }
.table .desc small.int-notes { border-top: 1px dashed var(--border); margin-top: 3px; padding-top: 2px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill-off { background: var(--surface-3); color: var(--muted); }
.pill-on { background: var(--ok-soft); color: var(--ok-text); }
.support-pill { background: var(--primary-soft, rgba(37, 99, 235, .12)); color: var(--primary); margin-left: 4px; vertical-align: 1px; }
.pill-upd { background: rgba(59, 130, 246, .16); color: var(--primary); }
.pill-err { background: var(--danger-soft); color: var(--danger); }

/* numero di settimana accanto al titolo del calendario */
.fc .fc-toolbar-title[data-week]::after { content: attr(data-week); margin-left: 10px; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 650; vertical-align: middle; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.fc .fc-daygrid-week-number, .fc .fc-timegrid-axis-cushion.fc-timegrid-weeknumber { font-size: 11px; color: var(--muted); background: transparent; }

/* vista «Lista» del calendario: interventi del mese con titolo, richiedente e ticket modificabili sul posto */
.int-list { height: 100%; overflow: auto; }
.int-list-table { width: 100%; }
.int-list-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.int-list-table tr.day-start td { border-top: 2px solid var(--border-strong); }
.int-list-table td { vertical-align: middle; }
:is(.int-list-table, #report-table) .nowrap { white-space: nowrap; }
:is(.int-list-table, #report-table) input.inl { width: 100%; min-width: 120px; padding: 4px 6px; font-size: 13px; border-color: transparent; background: transparent; }
:is(.int-list-table, #report-table) input.inl:hover:not(:disabled) { border-color: var(--border); }
:is(.int-list-table, #report-table) input.inl:focus { border-color: var(--primary); background: var(--surface-2); }
:is(.int-list-table, #report-table) input.inl:disabled { color: var(--muted); }
:is(.int-list-table, #report-table) input.inl.saving { opacity: .6; }
:is(.int-list-table, #report-table) input.inl.saved { border-color: var(--ok-text); box-shadow: 0 0 0 2px var(--ok-soft); }
:is(.int-list-table, #report-table) input.inl.err { border-color: var(--danger); }
.int-list-table tbody tr:hover td { background: var(--surface-2); }
:is(.int-list-table, #report-table) input.inl-num { min-width: 60px; max-width: 80px; text-align: right; }
:is(.int-list-table, #report-table) input.inl-flag { width: 16px; height: 16px; min-width: 0; }
.int-list-table .center, .list-cols-table .center { text-align: center; }
:is(.int-list-table, #report-table) .inl-mark { font-size: 11px; color: var(--muted); font-weight: 400; }
.table-tools, .int-list-tools { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.int-list-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; font-size: 13px; }
.list-cols-table td { padding-top: 4px; padding-bottom: 4px; }
.list-cols-table tr.muted label { color: var(--muted); }
.list-cols-table .icon-btn { padding: 2px 6px; font-size: 11px; }
.list-cols-table .icon-btn:disabled { opacity: .3; }

/* intestazioni ordinabili (Clienti, Clienti finali) */
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--text); }
th[data-sort].sorted { color: var(--primary); }
.sort-ind { margin-left: 4px; font-size: 10px; }

/* import / export anagrafiche */
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
#import-dialog.dialog-lg { width: min(980px, calc(100vw - 32px)); }
.import-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.import-scroll { max-height: 52vh; overflow: auto; margin-top: 8px; }
.import-ok { color: var(--ok-text); font-weight: 600; }
#import-table tr.row-err td { background: var(--danger-soft); }
.form-error-line { color: var(--danger); font-size: 12.5px; }

/* ---------- Dialog ---------- */
.dialog { border: 1px solid var(--border); padding: 0; border-radius: 14px; width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface); }
.dialog-lg { width: min(720px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--backdrop); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { flex: 1; }
.duration { font-size: 13px; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 3px 10px; border-radius: 20px; }
.code-badge { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.dialog-body { padding: 18px 20px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.spacer { flex: 1; }
/* riquadri Importi / Rimborsi nelle anagrafiche e campi nella barra in fondo (flag «attivo») */
.edit-group > .form-grid { gap: 10px 14px; }
.edit-foot-fields { display: flex; align-items: center; gap: 12px; }
.edit-foot-fields:empty { display: none; }
.edit-foot-fields .check { margin: 0; font-size: 13.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.time-pair { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
/* Totale ore (sola lettura) accanto alla pausa */
/* Totale ore: riga sottile sotto Inizio / Fine / Pausa, larga quanto i tre campi */
/* stesso stile per le righe di calcolo dell'editor (tariffa urgente / festiva, rimborso km) */
.hours-total, .calc-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 10px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 550; overflow: hidden; }
.hours-total .ht-val, .calc-row .calc-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-row .calc-text { min-width: 0; }
.hours-total output, .calc-row output { display: inline-block; }
/* effetto rullo: il nuovo valore entra dal basso se aumenta, dall'alto se diminuisce */
output.roll-up { animation: hours-roll-up .3s ease-out; }
output.roll-down { animation: hours-roll-down .3s ease-out; }
@keyframes hours-roll-up { from { transform: translateY(100%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hours-roll-down { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
.date-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.date-row label.check { padding-bottom: 8px; white-space: nowrap; }
.form-error { margin-top: 12px; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-soft-border); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.locked-msg { margin-bottom: 14px; background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--warn-border); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.sub-list { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.sub-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sub-list ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.sub-list p { margin: 0; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { flex-direction: row; font-weight: 500; font-size: 13.5px; color: var(--text); cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { padding: 6px 14px; border-right: 1px solid var(--border); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--primary); color: #fff; }
.segmented input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--primary-600); }
.seg-sm span { padding: 4px 12px; font-size: 13px; }

.edit-ftab[hidden] { display: none; }
.preset-roles { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin-left: 0; margin-right: 0; }
.preset-roles legend { font-size: 12.5px; font-weight: 650; color: var(--text-2); padding: 0 6px; }
.preset-roles-list { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 0 22px; }
.preset-roles .hint { margin: 6px 0 0; }
.field-list { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; max-height: 360px; overflow-y: auto; }
.field-list li { display: flex; align-items: center; justify-content: space-between; padding: 5px 10px; border-bottom: 1px solid var(--border); }
.field-list li:last-child { border-bottom: 0; }
.field-list li.off label { color: var(--muted); }
.field-list .move { display: flex; gap: 4px; }

.combo { position: relative; }
.combo-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 240px; overflow-y: auto; }
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 13.5px; color: var(--text); }
.combo-list li.hl { background: var(--primary-soft); color: var(--primary); }
.combo-list li.create { color: var(--primary); border-top: 1px solid var(--border); margin-top: 2px; }
.combo-list li small { color: var(--muted); font-weight: 400; margin-left: 6px; }
/* storico richiedenti: nome + X per toglierlo */
.combo-list { max-height: 240px; overflow-y: auto; }
.combo-list li.contact-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 4px; }
.combo-list li.contact-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-del { flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0; }
.contact-del:hover { background: var(--danger-soft, rgba(220, 38, 38, .12)); color: var(--danger, #dc2626); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--toast-bg); color: var(--bg); padding: 10px 18px;
  border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 1200; font-size: 13.5px; max-width: calc(100vw - 32px); }
.toast.error { background: #dc2626; color: #fff; }
/* come popover il browser lo centrerebbe a tutto schermo: si riporta in basso al centro */
.toast[popover] { inset: auto auto 20px 50%; margin: 0; border: 0; overflow: visible; }

#print-area { display: none; }

/* ---------- Dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 16px; }
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.dash-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.dash-kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.dash-kpi .v { font-size: 26px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.dash-kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dash-kpi.hero .v { font-size: 34px; color: var(--text); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.dash-card h3 { margin: 0; font-size: 15px; }
.dash-card header .dash-sub { color: var(--muted); font-size: 12.5px; }
/* legenda dei parametri TV nel dialogo della dashboard */
.tv-params { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; }
.tv-params td { padding: 6px 8px; border-top: 1px solid var(--border); vertical-align: top; color: var(--muted); line-height: 1.45; }
.tv-params td:first-child { white-space: nowrap; width: 1%; }
.tv-params td:first-child code { color: var(--text); font-weight: 600; }
/* filtro a selezione multipla di ogni grafico */
.dash-filter { margin-left: auto; position: relative; font-size: 12.5px; }
.dash-filter summary { list-style: none; cursor: pointer; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); white-space: nowrap; user-select: none; }
.dash-filter summary::-webkit-details-marker { display: none; }
.dash-filter summary:hover { border-color: var(--border-strong); color: var(--text); }
.dash-filter summary b { font-weight: 600; }
.dash-filter.on summary { background: var(--primary-soft); border-color: var(--primary-soft-border); color: var(--primary); }
.dash-filter .ico { display: inline-block; transform: rotate(-45deg); }
.dash-filter-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 260px; max-width: 80vw; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; }
.dash-filter-act { display: flex; gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dash-filter-act button { flex: 1; padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 6px; cursor: pointer; }
.dash-filter-list { max-height: 260px; overflow: auto; display: flex; flex-direction: column; }
.dash-filter-list label { display: flex; flex-direction: row; justify-content: flex-start; text-align: left; font-size: 13px; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; color: var(--text); font-weight: 400; }
.dash-filter-list label:hover { background: var(--surface-2); }
.dash-filter-list input { width: auto; margin: 0; }
.dash-canvas { position: relative; height: 300px; }
.dash-empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.dash-empty.small { padding: 24px; font-size: 13px; }
.dash-table { margin-top: 10px; font-size: 12.5px; }
.dash-table summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.dash-table table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.dash-table th, .dash-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.widget-checks { display: flex; flex-direction: column; gap: 6px; }
.exp-label { flex-direction: row; align-items: center; color: var(--muted); }
#view-report .actions select { width: auto; min-width: 200px; }
.exp-formats { display: inline-flex; gap: 6px; }
#view-dashboard .actions select { width: auto; min-width: 150px; }
#view-dashboard .actions input[type=month] { width: 170px; }
#view-dashboard .actions input[type=number] { width: 100px; }
.tv-link { display: flex; gap: 6px; }
.tv-link input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---------- Modalità TV ---------- */
body.tv { overflow: hidden; }
.tv-wrap { height: 100vh; display: flex; flex-direction: column; padding: 2vh 2.2vw; gap: 2vh; }
.tv-head { display: flex; align-items: center; gap: 20px; }
.tv-head img { height: 6vh; max-width: 18vw; object-fit: contain; }
.tv-head h1 { font-size: 3.6vh; flex: 1; }
.tv-head .tv-sub { color: var(--muted); font-size: 2vh; }
.tv-clock { font-size: min(3.6vh, 2.4vw); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tv-body { flex: 1; min-height: 0; overflow: hidden; }
.tv .dash-kpi .l { font-size: 1.8vh; }
.tv .dash-kpi .v { font-size: 4.4vh; }
.tv .dash-kpi.hero .v { font-size: 5.4vh; }
.tv .dash-kpi .s { font-size: 1.6vh; }
.tv .dash-card h3 { font-size: 2.2vh; }
.tv .dash-card header .dash-sub { font-size: 1.6vh; }
/* in TV tutto in una schermata 16:9: andamento a tutta larghezza, sotto tre grafici affiancati */
.tv .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.6vh 1.2vw; }
.tv .dash-kpis { gap: 1.2vw; }
.tv .dash-kpi { padding: 1.4vh 1.2vw; }
.tv .dash-card { padding: 1.4vh 1.2vw; }
.tv .dash-card header { margin-bottom: .8vh; }
.tv .dash-canvas { height: 28vh; }
.tv .dash-card.wide .dash-canvas { height: 22vh; }
.tv .dash { gap: 1.6vh; }
.tv-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 1.6vh; }
.tv-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 4px 10px; cursor: pointer; font: inherit; }
.tv-error { margin: auto; text-align: center; color: var(--muted); font-size: 3vh; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar { gap: 10px; padding: 0 12px; }
  #me-name { display: none; }
  #view-calendar { flex-direction: column; overflow-y: auto; }
  .side { width: auto; border-left: 0; border-bottom: 1px solid var(--border); padding: 12px 16px; gap: 10px; overflow: visible; order: 0; }
  .side .hint { display: none; }
  .cal-wrap { padding: 10px; min-height: 620px; }
  .page { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .actions input[type=search], .actions select { width: 100%; }
  .company-grid { grid-template-columns: 1fr; }
  .addr-row { grid-template-columns: 1fr 1fr; }
  .schedule-table input[type=time] { width: 92px; }
  .schedule-table input[type=number] { width: 60px; }
  .schedule-table th:nth-child(6), .schedule-table td:nth-child(6) { display: none; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: 8px; }
}
/* telefono: barra in basso; il menu completo si apre da «Altro» come pannello da sinistra */
@media (max-width: 760px) {
  .nav { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg); z-index: 900; }
  body.nav-mini .nav { width: 260px; }
  body.nav-mini .nav .nav-label { display: revert; }
  body.nav-mini .nav-brand { padding: 0 16px; justify-content: flex-start; }
  body.nav-mini .nav-brand .brand-mark { width: 44px; height: 29px; }
  body.nav-mini .nav-title { height: auto; padding: 12px 10px 4px; margin: 0; border-top: 0; }
  body.nav-mini .nav-link { justify-content: flex-start; padding: 10px; }
  body.nav-open .nav { transform: none; }
  .nav-toggle { display: none !important; }
  .nav-link { padding: 10px; font-size: 15px; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 850; }
  .nav-backdrop[hidden] { display: none; }
  .app-main { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 800; background: var(--surface);
    border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottombar a, .bottombar button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 550;
    text-decoration: none; border-radius: 8px; cursor: pointer; }
  .bottombar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottombar .ico { width: 22px; height: 22px; }
  .bottombar .active { color: var(--primary); }
  .crumb .muted, .crumb-sep { display: none; }
  .toast[popover] { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ---------- Stampa ---------- */
@page {
  size: A4 landscape; margin: 12mm;
  /* margini occupati dalla pagina: così il browser non aggiunge le sue intestazioni e piè di pagina
     (data, titolo, indirizzo web) anche se nella finestra di stampa l'opzione è attiva */
  @top-center { content: ""; }
  @bottom-left { content: ""; }
  /* numero di pagina in basso a destra, nel margine: «Pagina 1 di N» */
  @bottom-right { content: "Pagina " counter(page) " di " counter(pages); font: 8pt system-ui, sans-serif; color: #555; vertical-align: middle; }
}
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .pr-layout { width: 100%; border-collapse: collapse; }
  .pr-layout > thead { display: table-header-group; } /* intestazione ripetuta su ogni pagina */
  .pr-layout > thead > tr > td, .pr-layout > tbody > tr > td, .pr-layout > tfoot > tr > td { padding: 0; }
  .pr-foot-space { height: 16mm; }
  .pr-page-foot { position: fixed; left: 0; right: 0; bottom: 0; height: 13mm; border-top: 1px solid #000; padding-top: 2mm;
    font-size: 7.5pt; line-height: 1.35; color: #333; text-align: center; background: #fff; }
  .pr-brand { display: flex; align-items: center; gap: 14px; }
  .pr-logo { max-height: 16mm; max-width: 60mm; object-fit: contain; }
  .pr-total td { border-top: 2px solid #000; font-weight: 700; padding-top: 5px; }
  .pr-printed { margin-top: 8px; font-size: 8pt; color: #555; text-align: right; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 8px; }
  .pr-head h1 { font-size: 16pt; margin: 0; }
  .pr-company { font-weight: 700; font-size: 10pt; text-transform: uppercase; letter-spacing: .04em; }
  .pr-sub { font-size: 9pt; color: #333; margin-top: 2px; }
  .pr-tot { font-size: 9.5pt; white-space: nowrap; }
  .pr-table { width: 100%; border-collapse: collapse; }
  .pr-table th { text-align: left; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid #000; padding: 4px 6px; }
  .pr-table td { padding: 4px 6px; vertical-align: top; }
  .pr-table .num { text-align: right; font-variant-numeric: tabular-nums; }
  /* intestazione di colonna ripetuta su ogni pagina; un intervento (riga + titolo + descrizione) non si spezza:
     se non ci sta, va tutto alla pagina successiva */
  .pr-table thead { display: table-header-group; }
  .pr-table tbody.pr-item { break-inside: avoid; page-break-inside: avoid; }
  .pr-table tbody.pr-item tr, .pr-table tbody.pr-item td { break-inside: avoid; page-break-inside: avoid; }
  /* riepilogo finale: riquadro tabellato staccato dall'elenco, a destra, mai spezzato tra due pagine */
  .pr-summary { margin: 8mm 0 0 auto; min-width: 75mm; border-collapse: collapse; border: 1px solid #000; break-inside: avoid; page-break-inside: avoid; }
  .pr-summary th { text-align: left; font-size: 9.5pt; padding: 5px 10px; border-bottom: 1px solid #000;
    background: #e9ecf0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-summary td { padding: 4px 10px; font-size: 10pt; border-top: 1px solid #ccc; }
  .pr-summary td.num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 24px; }
  .pr-summary tr.pr-summary-total td { border-top: 2px solid #000; font-weight: 700; font-size: 11pt; padding-top: 6px; padding-bottom: 6px;
    background: #e9ecf0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-item > tr:last-child td { border-bottom: 1px solid #bbb; }
  /* riga principale (cliente finale, data, ore…) e riga Titolo / Richiedente su sfondo grigio chiaro,
     per staccare un intervento dall'altro; stampato anche senza «Grafica di sfondo» */
  .pr-item > tr:first-child td, .pr-item > tr.pr-meta td {
    background: #e9ecf0; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .pr-item.has-desc > tr:first-child td { padding-top: 5px; }
  .pr-item > tr.pr-meta td { padding-bottom: 4px; }
  .pr-item.has-desc > tr:first-child td { padding-bottom: 1px; }
  .pr-desc td { font-size: 9pt; color: #333; white-space: pre-line; padding-top: 1px; padding-left: 18px; }
  .pr-meta td { padding-top: 0; padding-bottom: 1px; padding-left: 18px; font-size: 9pt; }
  .pr-meta-grid { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 0 10px; align-items: baseline; }
  .pr-meta-grid b { font-weight: 700; }
  .pr-notes td { padding-top: 2px; padding-left: 18px; font-size: 9pt; color: #333; }
  .pr-notes-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 10px; align-items: baseline; }
  .pr-notes-grid span { white-space: pre-line; }
  /* divisori leggeri tratteggiati tra Titolo/Richiedente, Descrizione e Note interne */
  .pr-meta + .pr-desc td, .pr-meta + .pr-notes td, .pr-desc + .pr-notes td {
    border-top: 1px dashed #c8c8c8; padding-top: 3px;
  }
  .pr-item.has-desc > tr.pr-meta td, .pr-item.has-desc > tr.pr-desc td, .pr-item.has-desc > tr.pr-notes td { padding-bottom: 3px; }
  .pr-table tfoot td { border-top: 2px solid #000; font-weight: 700; padding-top: 5px; }
  .pr-foot { margin-top: 10px; font-size: 8pt; color: #555; text-align: right; }
}

/* ---------- Prospect ---------- */
/* banner in cima alla scheda (prospect convertito, pulsanti di conversione, «Da prospect» nel cliente) */
.edit-banner { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 20px;
  background: var(--primary-soft); border-bottom: 1px solid var(--primary-soft-border); font-size: 13.5px; }
.edit-banner a { color: var(--primary); font-weight: 600; }
.checks-field { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 10px; margin: 0; }
.checks-field legend { padding: 0 4px; font-size: 13px; color: var(--text-2); }
.checks-field .day-checks { flex-wrap: wrap; gap: 6px 16px; }
.overdue { color: var(--danger); }
/* Impostazioni: riquadri uno sotto l'altro (Interventi) e griglia delle tendine (Prospect) */
.settings-stack { display: grid; gap: 16px; }
.prospect-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.prospect-lists .table td { padding-top: 7px; padding-bottom: 7px; }
.prospect-lists tr.clickable { cursor: pointer; }

/* ---------- Permessi a spunta (scheda ruolo) ---------- */
.perm-table { table-layout: fixed; }
.perm-table th:first-child, .perm-table td:first-child { width: 44%; text-align: left; }
.perm-table th, .perm-table td { text-align: center; padding-top: 6px; padding-bottom: 6px; }
.perm-table .perm-sec td { background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--text-2); text-align: left; }
.perm-table input { width: 16px; height: 16px; cursor: pointer; }
.perm-specials { display: grid; gap: 6px; margin-top: 14px; }

.pill-flag { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); font-weight: 500; }
.dup-warn { display: block; margin-top: 4px; color: var(--warn-text); font-size: 12.5px; font-weight: 500; }

/* ---------- Ricerca globale (barra in alto) ---------- */
.gsearch { position: relative; width: min(340px, 34vw); flex: none; }
.gsearch input { width: 100%; }
.gsearch-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1000; margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: min(70vh, 520px); overflow-y: auto; min-width: 300px; }
.gsearch-list .gs-group { padding: 8px 12px 4px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.gsearch-list .gs-item { padding: 6px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.gsearch-list .gs-item small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-list .gs-item.hl, .gsearch-list .gs-item:hover { background: var(--primary-soft); }
.gsearch-list .gs-empty { padding: 10px 12px; color: var(--muted); }
@media (max-width: 700px) { .gsearch { width: 40vw; } .gsearch-list { min-width: 260px; } }

/* ---------- Etichette ---------- */
.tag-pill { font-weight: 500; border: 0; }
.tag-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-check { position: relative; cursor: pointer; }
.tag-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tag-check .tag-pill { opacity: .35; transition: opacity .12s; }
.tag-check input:checked + .tag-pill { opacity: 1; }
.tag-check input:checked + .tag-pill::before { content: '✓ '; }
.tag-check input:focus-visible + .tag-pill { outline: 2px solid var(--primary); outline-offset: 2px; }
.tag-check input:disabled + .tag-pill { cursor: default; }
.tag-check:hover input:not(:disabled):not(:checked) + .tag-pill { opacity: .6; }
.int-range .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.small-hint { font-size: 12.5px; margin: 4px 0 8px; }
