/* ==========================================================================
   PCMANIA — Gestionale riparazioni (demo)
   Palette: antracite #1f2328 + accento #00a3e0, superfici chiare.
   ========================================================================== */
:root {
  --antracite: #1f2328;
  --antracite-2: #2b3138;
  --accento: #00a3e0;
  --accento-testo: #0077a6;      /* accento scurito per testo su fondo chiaro (contrasto AA) */
  --accento-tenue: #e3f5fc;
  --sfondo: #f3f5f7;
  --superficie: #ffffff;
  --superficie-2: #f8f9fb;
  --bordo: #dde2e8;
  --bordo-forte: #c6cdd6;
  --testo: #1f2328;
  --testo-2: #5a6472;
  --testo-3: #8a93a0;
  --errore: #b42318;
  --ok: #157240;
  --raggio: 8px;
  --ombra: 0 1px 2px rgba(31, 35, 40, .06), 0 1px 3px rgba(31, 35, 40, .06);
  --ombra-alta: 0 12px 32px rgba(31, 35, 40, .18);
  --topbar-h: 56px;
  --sidebar-w: 220px;
  --sidebar-w-chiusa: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45;
  color: var(--testo); background: var(--sfondo);
}
body[data-shell]:not(.pronto) #contenuto { visibility: hidden; }
a { color: var(--accento-testo); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 .75em; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tab-num { font-variant-numeric: tabular-nums; }
.muted { color: var(--testo-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.ico { width: 18px; height: 18px; flex: none; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 16px 0 8px;
  background: var(--antracite); color: #fff;
}
.topbar-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 6px;
  background: transparent; color: #cfd5dc; cursor: pointer;
}
.topbar-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.wordmark {
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .32em; padding-right: .1em;
  white-space: nowrap;
}
.wordmark:hover { text-decoration: none; color: #fff; }
.badge-demo {
  font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  color: #9fdcf4; border: 1px solid rgba(0, 163, 224, .45); border-radius: 999px; padding: 2px 9px;
}
.cerca-scheda {
  position: relative; flex: 1; max-width: 460px; margin-left: auto;
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); border-radius: 8px;
  color: #aab3bd;
}
.cerca-scheda:focus-within { background: #fff; color: var(--testo-2); border-color: var(--accento); }
.cerca-scheda input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: #fff;
  font: inherit; font-size: 14px; outline: none;
}
.cerca-scheda:focus-within input { color: var(--testo); }
.cerca-scheda input::placeholder { color: #aab3bd; }
.cerca-risultati {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--bordo); border-radius: 8px; box-shadow: var(--ombra-alta);
  padding: 4px; color: var(--testo);
}
.cerca-risultati a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--testo);
}
.cerca-risultati a:hover, .cerca-risultati a.sel { background: var(--accento-tenue); text-decoration: none; }
.cerca-risultati .num { font-weight: 700; }
.cerca-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cerca-info span, .cerca-info small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cerca-info small { color: var(--testo-2); }
.cerca-vuoto { padding: 10px; color: var(--testo-2); }
.sede-sel select {
  height: 36px; padding: 0 28px 0 10px; border-radius: 8px; font: inherit; font-size: 13px;
  color: #fff; background: var(--antracite-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23aab3bd' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid rgba(255, 255, 255, .12); appearance: none; cursor: pointer;
}
.sede-sel select option { color: var(--testo); background: #fff; }
.utente-chip { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accento); color: #fff; font-size: 12px; font-weight: 700; flex: none;
}
.utente-nome { display: flex; flex-direction: column; line-height: 1.15; }
.utente-nome strong { font-size: 13px; font-weight: 600; }
.utente-nome small { font-size: 11px; color: #aab3bd; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  width: var(--sidebar-w); height: calc(100vh - var(--topbar-h)); flex: none;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--superficie); border-right: 1px solid var(--bordo); padding: 12px 10px;
  transition: width .18s ease; overflow: hidden;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 6px;
  color: var(--testo-2); font-weight: 500; white-space: nowrap;
}
.sidebar a:hover { background: var(--superficie-2); color: var(--testo); text-decoration: none; }
.sidebar a.attiva { background: var(--accento-tenue); color: var(--accento-testo); font-weight: 600; box-shadow: inset 3px 0 0 var(--accento); }
.sidebar-esci { font-size: 13px; }
.sidebar-chiusa .sidebar { width: var(--sidebar-w-chiusa); }
.sidebar-chiusa .sidebar a span { opacity: 0; pointer-events: none; }
.velo { display: none; }
.area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.contenuto { flex: 1; padding: 22px 24px 28px; width: 100%; }
.footer { padding: 14px 24px 18px; font-size: 12px; color: var(--testo-3); }

/* ── Intestazione pagina ─────────────────────────────────────────────────── */
.pagina-testa {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.pagina-testa p { margin: 4px 0 0; color: var(--testo-2); }
.azioni { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.briciole { font-size: 13px; color: var(--testo-2); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }

/* ── Pulsanti ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 7px; border: 1px solid var(--bordo-forte); background: var(--superficie); color: var(--testo);
  font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--superficie-2); text-decoration: none; }
.btn .ico { width: 16px; height: 16px; }
.btn-primario { background: var(--accento); border-color: var(--accento); color: #fff; }
.btn-primario:hover { background: #0092c9; }
.btn-scuro { background: var(--antracite); border-color: var(--antracite); color: #fff; }
.btn-scuro:hover { background: var(--antracite-2); }
.btn-piccolo { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-icona { width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--testo-2); }
.btn-icona:hover { background: var(--accento-tenue); color: var(--accento-testo); }
.btn-pericolo { color: var(--errore); }
.btn-grande { height: 44px; padding: 0 20px; font-size: 15px; }

/* ── Card, KPI ───────────────────────────────────────────────────────────── */
.card { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); box-shadow: var(--ombra); }
.card-testa { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--bordo); }
.card-testa a { font-size: 13px; }
.card-corpo { padding: 16px; }
.griglia { display: grid; gap: 16px; }
.griglia-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.griglia-2 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.griglia-2-uguale { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.griglia-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.griglia-laterale { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }
.kpi {
  display: block; padding: 16px 18px; color: var(--testo); position: relative; overflow: hidden;
}
.kpi:hover { text-decoration: none; border-color: var(--accento); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--kpi, var(--accento)); }
.kpi-label { font-size: 13px; color: var(--testo-2); font-weight: 500; }
.kpi-valore { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-nota { font-size: 12px; color: var(--testo-3); }
.colonna { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* barre per stato */
.barre { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.barre li a { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; color: var(--testo); font-size: 13px; }
.barre li a:hover { text-decoration: none; }
.barre li a:hover .barra-label { text-decoration: underline; }
.barra { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--superficie-2); overflow: hidden; }
.barra span { display: block; height: 100%; border-radius: 4px; background: var(--c); min-width: 2px; }
.barre .conta { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ritardi */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li + li { border-top: 1px solid var(--bordo); }
.lista a.riga { display: flex; align-items: center; gap: 12px; padding: 11px 16px; color: var(--testo); }
.lista a.riga:hover { background: var(--superficie-2); text-decoration: none; }
.riga-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.riga-info small { color: var(--testo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ritardo { font-size: 12px; font-weight: 650; color: var(--errore); white-space: nowrap; text-align: right; }
.ritardo small { display: block; font-weight: 400; color: var(--testo-3); }
.vuoto { padding: 22px 16px; text-align: center; color: var(--testo-2); }

/* ── Badge stato ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--fg); font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--superficie-2); color: var(--testo-2); border: 1px solid var(--bordo); white-space: nowrap; }
.pill-ok { background: #dff5e5; color: var(--ok); border-color: #bfe8cb; }
.pill-ko { background: #fde7e7; color: var(--errore); border-color: #f6c9c6; }
.pill-garanzia { background: #f0e8fe; color: #6d28d9; border-color: #dccbfb; }

/* ── Tabelle compatte ────────────────────────────────────────────────────── */
.tabella-wrap { overflow-x: auto; }
table.tabella { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabella th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--testo-2); text-transform: none;
  background: var(--superficie-2); padding: 8px 10px; border-bottom: 1px solid var(--bordo); white-space: nowrap;
}
.tabella td { padding: 8px 10px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
.tabella tbody tr:last-child td { border-bottom: 0; }
.tabella tbody tr:hover td { background: #fafbfc; }
.tabella .destra { text-align: right; }
.tabella .nowrap { white-space: nowrap; }
.tabella .col-azioni { white-space: nowrap; text-align: right; width: 1%; }
.tabella .col-azioni .btn-icona { width: 30px; height: 30px; }
.tabella a.num { font-weight: 700; }
.tabella .sub { display: block; font-size: 12px; color: var(--testo-2); }
.tabella tr.cliccabile { cursor: pointer; }
.tabella tfoot td { font-weight: 650; background: var(--superficie-2); border-top: 1px solid var(--bordo); border-bottom: 0; }
.ritardo-cell { color: var(--errore); font-weight: 600; }
.tabella-compatta td { white-space: nowrap; }
.tabella-compatta td.a-capo { white-space: normal; min-width: 140px; }
.tabella-compatta td.troncato .cella { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }

/* ── Filtri e form ───────────────────────────────────────────────────────── */
.filtri {
  display: grid; grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(130px, 1fr)) minmax(290px, 1.6fr) auto;
  gap: 10px; align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--bordo);
}
@media (min-width: 1201px) { .filtri.filtri-3 { grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr) minmax(160px, 1fr); } }
.filtri .check { height: 36px; }
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo > span, .campo > label, .etichetta { font-size: 12px; font-weight: 600; color: var(--testo-2); }
.campo .obbl { color: var(--errore); }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--bordo-forte); border-radius: 7px;
  background: #fff; color: var(--testo); font: inherit; font-size: 14px;
}
textarea.input { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input:focus { outline: none; border-color: var(--accento); box-shadow: 0 0 0 3px rgba(0, 163, 224, .18); }
.input[readonly] { background: var(--superficie-2); }
.input.errore { border-color: var(--errore); box-shadow: 0 0 0 3px rgba(180, 35, 24, .12); }
.aggiunta-rapida { display: flex; gap: 4px; align-items: center; }
.aggiunta-rapida .input { flex: 1; min-width: 0; border-color: var(--accento); }
.aggiunta-rapida .btn-icona { width: 34px; height: 34px; flex: none; }
.aggiunta-rapida [data-ok] { color: var(--ok); }
.aiuto { font-size: 12px; color: var(--accento-testo); }
.intervallo { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; }
.intervallo span { color: var(--testo-3); font-size: 12px; }
.intervallo input { min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.check input { width: 16px; height: 16px; accent-color: var(--accento); }
.radio-gruppo { display: flex; gap: 16px; flex-wrap: wrap; min-height: 36px; align-items: center; }
.campi { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.prefisso { position: relative; }
.prefisso .input { padding-left: 26px; }
.prefisso::before { content: "€"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--testo-3); }

/* sezioni del form di accettazione (ricalcano la scheda cartacea) */
.sezione { margin-bottom: 16px; }
.sezione-testa {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: #eceff2; border-bottom: 1px solid var(--bordo); border-radius: var(--raggio) var(--raggio) 0 0;
}
.sezione-testa h2 { font-size: 14px; font-weight: 700; }
.segmento { display: inline-flex; border: 1px solid var(--bordo-forte); border-radius: 7px; overflow: hidden; background: #fff; }
.segmento button { border: 0; background: transparent; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--testo-2); cursor: pointer; }
.segmento button[aria-pressed="true"] { background: var(--antracite); color: #fff; }
.cliente-scelto {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid #bfe6f6; background: var(--accento-tenue); border-radius: 8px;
}
.cliente-scelto .avatar { width: 36px; height: 36px; }
.suggerimenti { position: relative; }
.suggerimenti-lista {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; background: #fff;
  border: 1px solid var(--bordo); border-radius: 8px; box-shadow: var(--ombra-alta); padding: 4px; max-height: 280px; overflow: auto;
}
.suggerimenti-lista button {
  display: flex; width: 100%; justify-content: space-between; gap: 10px; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; font: inherit; cursor: pointer; color: var(--testo);
}
.suggerimenti-lista button:hover { background: var(--accento-tenue); }
.suggerimenti-lista small { color: var(--testo-2); }
.barra-salva {
  position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; margin-top: 4px; background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio);
  box-shadow: 0 -4px 16px rgba(31, 35, 40, .08);
}
.numero-anteprima { display: flex; align-items: center; gap: 14px; }
.numero-anteprima small { display: block; font-size: 12px; color: var(--testo-2); }
.numero-anteprima strong { font-size: 22px; font-family: var(--mono); }
.numero-anteprima .barcode { width: 120px; height: 34px; display: block; }

/* ── Dettaglio riparazione ───────────────────────────────────────────────── */
.dett-testa { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 18px; }
.dett-id { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.dett-id h1 { font-family: var(--mono); font-size: 26px; }
.dett-id h1 small { display: block; font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--testo-2); letter-spacing: 0; margin-bottom: 2px; }
.dett-barcode { width: 160px; height: 44px; }
.dett-barcode .barcode { width: 100%; height: 100%; display: block; }
.dett-meta { display: flex; flex-direction: column; gap: 6px; }
.dett-meta .riga-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--testo-2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--bordo); overflow-x: auto; padding: 0 10px; scrollbar-width: thin; }
.tabs button {
  border: 0; background: transparent; padding: 12px 12px 11px; font: inherit; font-size: 13.5px; font-weight: 550; color: var(--testo-2);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--testo); }
.tabs button[aria-selected="true"] { color: var(--accento-testo); border-bottom-color: var(--accento); }
.tabs .conta-tab { display: inline-block; margin-left: 5px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--superficie-2); border: 1px solid var(--bordo); font-size: 11px; text-align: center; }
.pannello { padding: 18px; }
.pannello[hidden] { display: none; }
dl.dati { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 13.5px; }
dl.dati dt { color: var(--testo-2); }
dl.dati dd { margin: 0; overflow-wrap: anywhere; }
.blocco-titolo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--testo-2); margin: 0 0 12px; }
.riquadro { border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 16px; background: var(--superficie); }
.difetto { background: var(--superficie-2); border-left: 3px solid var(--accento); padding: 10px 12px; border-radius: 0 6px 6px 0; font-style: italic; }
.nascosto-codice { letter-spacing: .2em; }
.avviso-privato {
  display: flex; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 14px; border-radius: 7px;
  background: #fff8e6; border: 1px solid #f3dfa6; color: #7a5200; font-size: 13px;
}
.note-lista { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.nota { border: 1px solid var(--bordo); border-radius: 8px; padding: 10px 12px; background: var(--superficie); }
.nota-testa { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--testo-2); margin-bottom: 4px; }
.nota-testa .avatar { width: 22px; height: 22px; font-size: 9.5px; }
.nota-testa strong { color: var(--testo); }
.allegati { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.allegato { border: 1px solid var(--bordo); border-radius: 8px; overflow: hidden; background: var(--superficie); }
.thumb {
  height: 110px; display: grid; place-items: center; color: var(--testo-3);
  background: repeating-linear-gradient(135deg, #eef1f4 0 10px, #e7ebef 10px 20px);
}
.thumb .ico { width: 34px; height: 34px; }
.thumb.pdf { background: #f6f0ef; color: #b04a3f; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.allegato-info { padding: 8px 10px; font-size: 12px; }
.allegato-info strong { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.allegato-info span { color: var(--testo-2); }
.carica {
  display: grid; place-items: center; text-align: center; gap: 4px; min-height: 160px; border: 2px dashed var(--bordo-forte); border-radius: 8px;
  color: var(--testo-2); cursor: pointer; font-size: 13px; padding: 10px;
}
.carica:hover { border-color: var(--accento); color: var(--accento-testo); }
.carica input { display: none; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline li { position: relative; padding: 0 0 20px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: -2px; width: 2px; background: var(--bordo); }
.timeline li:last-child::before { display: none; }
.timeline .punto { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--superficie), 0 0 0 4px var(--bordo); }
.timeline .quando { font-size: 12px; color: var(--testo-2); margin: 4px 0 2px; }
.timeline .quando strong { color: var(--testo); font-weight: 600; }
.timeline p { margin: 0; font-size: 13.5px; }
.timeline li.corrente .punto { box-shadow: 0 0 0 3px var(--superficie), 0 0 0 5px var(--c); }

/* ricambi utilizzati */
.tabella .input { height: 32px; font-size: 13px; }
.tabella .input-qta { width: 70px; text-align: right; }
.tabella .input-prezzo { width: 110px; text-align: right; }
.totale-riga { display: flex; justify-content: flex-end; gap: 24px; padding: 12px 10px 0; font-size: 15px; }
.totale-riga strong { font-size: 18px; font-variant-numeric: tabular-nums; }

/* riconsegna */
.saldo { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.firma-box { position: relative; border: 1px dashed var(--bordo-forte); border-radius: 8px; background: #fff; height: 170px; touch-action: none; }
.firma-box canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.firma-box .firma-linea { position: absolute; left: 20px; right: 20px; bottom: 36px; border-bottom: 1px solid var(--bordo-forte); pointer-events: none; }
.firma-box .firma-hint { position: absolute; left: 20px; bottom: 12px; font-size: 12px; color: var(--testo-3); pointer-events: none; }

/* modale */
dialog.modale { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--ombra-alta); color: var(--testo); }
dialog.modale::backdrop { background: rgba(20, 24, 28, .45); }
.modale-testa { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--bordo); }
.modale-corpo { padding: 18px; max-height: calc(100vh - 200px); overflow: auto; }
.modale-piede { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--bordo); background: var(--superficie-2); }
.scelta-stati { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.scelta-stati label { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--bordo); border-radius: 7px; cursor: pointer; }
.scelta-stati label:has(input:checked) { border-color: var(--accento); background: var(--accento-tenue); }
.scelta-stati input { accent-color: var(--accento); }

/* permessi */
.matrice th, .matrice td { text-align: center; }
.matrice th:first-child, .matrice td:first-child { text-align: left; }
.matrice input { width: 17px; height: 17px; accent-color: var(--accento); cursor: pointer; }

/* configurazione dispositivi */
.lista-config { list-style: none; margin: 0; padding: 0; }
.lista-config li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 16px; border-bottom: 1px solid var(--bordo); font-size: 13.5px; }
.lista-config li:last-child { border-bottom: 0; }
.lista-config li.sel { background: var(--accento-tenue); }
.lista-config button.voce { flex: 1; text-align: left; border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; padding: 0; }
.lista-config small { color: var(--testo-3); }
.aggiungi { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--bordo); background: var(--superficie-2); border-radius: 0 0 var(--raggio) var(--raggio); }

/* paginazione */
.paginazione { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--bordo); font-size: 13px; color: var(--testo-2); flex-wrap: wrap; }
.paginazione .pagine { display: flex; gap: 4px; }
.paginazione button { min-width: 32px; height: 32px; border: 1px solid var(--bordo); background: #fff; border-radius: 6px; font: inherit; cursor: pointer; color: var(--testo); }
.paginazione button[aria-current="page"] { background: var(--antracite); color: #fff; border-color: var(--antracite); }
.paginazione button:disabled { opacity: .45; cursor: default; }

.piede-card { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--bordo); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 16px); opacity: 0;
  background: var(--antracite); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--ombra-alta);
  font-size: 13.5px; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.visibile { opacity: 1; transform: translate(-50%, 0); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-pagina {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(160deg, #1f2328 0%, #1f2328 46%, #f3f5f7 46%);
}
.login-card { width: 100%; max-width: 400px; padding: 32px 30px 26px; }
.login-card .wordmark { color: var(--antracite); font-size: 26px; display: block; text-align: center; }
.login-card .sottotitolo { text-align: center; color: var(--testo-2); margin: 6px 0 22px; font-size: 13.5px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .btn { width: 100%; }
.login-card .badge-demo { color: var(--accento-testo); border-color: #9fdcf4; background: var(--accento-tenue); }
.login-piede { text-align: center; margin-top: 18px; font-size: 12px; color: var(--testo-3); display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* ── Anteprime di stampa (schermo) ───────────────────────────────────────── */
.stampa-barra { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.anteprima { overflow: auto; padding: 24px; background: #d9dde2; border-radius: var(--raggio); }
.foglio { background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .18); margin: 0 auto; color: #000; }

/* ── Elementi che esistono solo su smartphone ────────────────────────────── */
.testo-corto, .sidebar-mobile, .nav-basso, .filtri-toggle { display: none; }
a, button, .btn, select, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.conta-filtri { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accento); color: #fff; font-size: 11.5px; font-weight: 700; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .filtri { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filtri .campo-testo { grid-column: span 3; }
  .griglia-2, .griglia-laterale { grid-template-columns: 1fr; }
  .utente-nome { display: none; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 25; width: 260px; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--ombra-alta);
  }
  .sidebar-chiusa .sidebar { width: 260px; }
  .sidebar-chiusa .sidebar a span { opacity: 1; }
  .menu-aperto .sidebar { transform: none; }
  .menu-aperto .velo { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 24; background: rgba(20, 24, 28, .4); }
  .griglia-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .griglia-3, .griglia-2-uguale { grid-template-columns: 1fr; }
  .badge-demo { font-size: 10px; }
}

/* ── Smartphone ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --topbar-h: 100px; --nav-h: 62px; --sicuro: env(safe-area-inset-bottom, 0px); }
  body { font-size: 15px; }
  .testo-lungo, .nascondi-mobile { display: none !important; }
  .testo-corto { display: inline; }

  /* Topbar: riga 1 marchio + utente, riga 2 ricerca. La sede passa nel menu laterale. */
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding: 6px 14px 8px 6px; gap: 4px 8px; align-content: center; }
  body:not(.senza-nav) .topbar-btn { display: none; }
  body:not(.senza-nav) .wordmark { margin-left: 10px; }
  .wordmark { font-size: 15px; letter-spacing: .26em; }
  .badge-demo { padding: 1px 8px; }
  .sede-sel { display: none; }
  .utente-chip { display: flex; margin-left: auto; }
  .utente-chip .avatar { width: 32px; height: 32px; }
  .cerca-scheda { order: 10; flex: 1 0 100%; max-width: none; margin: 2px 0 0 8px; height: 42px; }
  .cerca-scheda input { font-size: 16px; }
  .cerca-risultati { max-height: 60vh; overflow: auto; }
  .cerca-risultati a { padding: 11px 10px; }

  /* Menu laterale a tutta altezza, con utente e sede */
  .sidebar { top: 0; height: 100vh; height: 100dvh; width: 280px; z-index: 50; overflow-y: auto; padding: 14px 12px calc(14px + var(--sicuro)); justify-content: flex-start; gap: 14px; }
  .sidebar-chiusa .sidebar { width: 280px; }
  .sidebar-esci { margin-top: auto; }
  .menu-aperto .velo { inset: 0; z-index: 45; }
  .sidebar a { height: 46px; font-size: 15px; }
  .sidebar-mobile { display: flex; flex-direction: column; gap: 12px; padding: 4px 4px 14px; border-bottom: 1px solid var(--bordo); }
  .utente-mobile { display: flex; gap: 10px; align-items: center; }
  .utente-mobile strong { display: block; font-size: 15px; }
  .utente-mobile small { display: block; font-size: 12px; color: var(--testo-2); overflow-wrap: anywhere; }

  /* Barra di navigazione in basso */
  .nav-basso {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--nav-h) + var(--sicuro)); padding: 0 4px var(--sicuro);
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--bordo); box-shadow: 0 -2px 12px rgba(31, 35, 40, .06);
  }
  .nav-basso a, .nav-basso button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--nav-h);
    border: 0; background: transparent; font: inherit; font-size: 11px; font-weight: 600; color: var(--testo-2); cursor: pointer;
  }
  .nav-basso a:hover { text-decoration: none; }
  .nav-basso .ico { width: 23px; height: 23px; }
  .nav-basso .attiva { color: var(--accento-testo); }
  .nav-basso .nav-piu {
    display: grid; place-items: center; width: 46px; height: 46px; margin-top: -18px; border-radius: 50%;
    background: var(--accento); color: #fff; box-shadow: 0 4px 12px rgba(0, 163, 224, .45);
  }
  .nav-basso .nav-piu .ico { width: 24px; height: 24px; stroke-width: 2.4; }
  .nav-basso .nav-nuova { color: var(--accento-testo); justify-content: flex-end; padding-bottom: 7px; }
  body:not(.senza-nav) .area { padding-bottom: calc(var(--nav-h) + var(--sicuro)); }

  /* Azioni della pagina agganciate in basso (sopra la navigazione, se c'è) */
  .azioni-basso {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 39; flex-wrap: nowrap; gap: 8px;
    padding: 10px 14px calc(10px + var(--sicuro));
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--bordo); box-shadow: 0 -4px 14px rgba(31, 35, 40, .08);
  }
  body:not(.senza-nav) .azioni-basso { bottom: calc(var(--nav-h) + var(--sicuro)); padding-bottom: 10px; box-shadow: none; }
  .azioni-basso > .btn { flex: 1 1 0; min-width: 0; height: 46px; padding: 0 8px; }
  body:has(.azioni-basso) .area { padding-bottom: calc(68px + var(--sicuro)); }
  body:not(.senza-nav):has(.azioni-basso) .area { padding-bottom: calc(68px + var(--nav-h) + var(--sicuro)); }
  body:has(.azioni-basso) .toast, body:has(.barra-salva) .toast { bottom: calc(84px + var(--sicuro)); }
  body:not(.senza-nav) .toast { bottom: calc(var(--nav-h) + 16px + var(--sicuro)); }
  body:not(.senza-nav):has(.azioni-basso) .toast { bottom: calc(var(--nav-h) + 84px + var(--sicuro)); }

  /* Spaziature e tipografia */
  .contenuto { padding: 14px 14px 20px; }
  .footer { padding: 8px 14px 16px; }
  h1 { font-size: 20px; }
  .pagina-testa { margin-bottom: 14px; align-items: flex-start; }
  .card-testa { padding: 12px 14px; }
  .card-corpo { padding: 14px; }
  .kpi { padding: 12px 14px; }
  .kpi-valore { font-size: 28px; }

  /* Controlli comodi al tocco; 16px evitano lo zoom automatico di iPhone sui campi */
  .input, select.input, textarea.input { height: 44px; font-size: 16px; }
  textarea.input { height: auto; }
  .tabella .input { height: 42px; font-size: 16px; }
  .btn { min-height: 44px; }
  .btn-piccolo { min-height: 38px; height: 38px; font-size: 13.5px; }
  .btn-icona, .tabella .col-azioni .btn-icona { width: 44px; height: 44px; min-height: 44px; }
  .check { min-height: 44px; font-size: 15px; }
  .check input, .scelta-stati input { width: 20px; height: 20px; }
  .matrice input { width: 22px; height: 22px; }
  .paginazione button { min-width: 42px; height: 42px; }
  .lista-config li { padding: 4px 6px 4px 14px; min-height: 48px; }
  .lista-config button.voce { align-self: stretch; min-height: 44px; }
  .segmento button { padding: 10px 12px; font-size: 13.5px; }
  .tabs button { padding: 14px 12px 13px; font-size: 14px; }
  .aggiunta-rapida .btn-icona { width: 44px; height: 44px; }

  /* Filtri: ricerca sempre visibile, il resto dietro il pulsante "Filtri" */
  .filtri { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px 14px; }
  .filtri > * { grid-column: 1 / -1; }
  .filtri > .campo-testo { grid-column: 1; }
  .filtri > .filtri-toggle { display: inline-flex; grid-column: 2; align-self: end; height: 44px; }
  .filtri:not(.filtri-aperti) > :not(.campo-testo):not(.filtri-toggle) { display: none; }
  .filtri-aperti .filtri-toggle { background: var(--accento-tenue); border-color: var(--accento); }

  /* Moduli: una colonna, due per i campi brevi (.m-mezzo) */
  .campi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .campi > * { grid-column: 1 / -1 !important; }
  .campi > .m-mezzo { grid-column: span 1 !important; }
  dl.dati { grid-template-columns: minmax(104px, 38%) minmax(0, 1fr); gap: 7px 12px; }
  dl.dati dt { font-size: 13px; }
  .riquadro { padding: 14px; }
  .pannello { padding: 14px; }
  .aggiungi { flex-wrap: wrap; }
  .aggiungi .input { flex: 1 1 100%; }
  .aggiungi .btn { flex: 1; }

  /* Nuova accettazione: barra di salvataggio compatta in basso */
  .barra-salva {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; border-width: 1px 0 0;
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 8px 14px calc(10px + var(--sicuro));
  }
  .barra-salva .numero-anteprima { grid-column: 1 / -1; gap: 8px; }
  .barra-salva .numero-anteprima > div { display: flex; align-items: baseline; gap: 6px; }
  .barra-salva .numero-anteprima strong { font-size: 15px; }
  .barra-salva #barcode-anteprima, .barra-salva .btn-annulla { display: none; }
  .barra-salva .azioni { display: contents; }
  .barra-salva .btn { height: 46px; width: 100%; }
  body:has(.barra-salva) .area { padding-bottom: calc(110px + var(--sicuro)); }

  /* Dettaglio scheda */
  .dett-testa { padding: 14px; gap: 12px; }
  .dett-id { gap: 10px 14px; }
  .dett-id h1 { font-size: 24px; }
  .dett-barcode { width: 130px; height: 38px; }
  .firma-box { height: 200px; }

  /* Finestre modali come pannelli dal basso */
  dialog.modale { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; }
  .modale-corpo { max-height: calc(92dvh - 140px); }
  .modale-piede { padding: 10px 14px calc(10px + var(--sicuro)); }
  .modale-piede .btn { flex: 1; height: 46px; }
  .scelta-stati { grid-template-columns: 1fr; }
  .scelta-stati label { min-height: 46px; }

  .anteprima { padding: 10px; }

  /* Tabelle → card compatte su due colonne */
  table.tabella.responsive thead { display: none; }
  table.tabella.responsive, table.tabella.responsive tbody { display: block; width: 100%; }
  table.tabella.responsive tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 14px; align-items: start; grid-auto-flow: row dense;
    padding: 13px 14px; border-bottom: 1px solid var(--bordo);
  }
  table.tabella.responsive tbody tr:hover td { background: transparent; }
  table.tabella.responsive td { display: block; width: auto; min-width: 0; border: 0; padding: 0; text-align: left; font-size: 14px; }
  table.tabella.responsive td::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--testo-2); font-weight: 500; margin-bottom: 1px; }
  table.tabella.responsive td[data-label=""]::before { content: none; }
  table.tabella.responsive td.card-titolo { grid-column: 1 / -1; font-size: 16px; }
  table.tabella.responsive tr:has(.m-accanto) td.card-titolo { grid-column: 1; }
  table.tabella.responsive td.m-accanto { grid-row: 1; grid-column: 2; justify-self: end; text-align: right; }
  table.tabella.responsive td.m-accanto::before { content: none; }
  table.tabella.responsive td.m-largo { grid-column: 1 / -1; }
  table.tabella.responsive td.col-azioni { grid-column: 2; justify-self: end; align-self: end; display: flex; gap: 2px; margin: 0 -8px -6px 0; }
  table.tabella.responsive td.col-azioni::before { content: none; }
  table.tabella.responsive td .badge { white-space: normal; }
  table.tabella.responsive td.vuoto { grid-column: 1 / -1; }
  .tabella .input-qta, .tabella .input-prezzo { width: 100%; }
  .tabella-compatta td, .tabella-compatta td.troncato .cella { white-space: normal; max-width: none; }
}
@media (max-width: 380px) {
  .topbar .badge-demo { display: none; }
  .griglia-kpi { gap: 10px; }
  .kpi-label { font-size: 12px; }
}

/* ── Stampa: si nasconde tutta l'interfaccia, resta solo il foglio ───────── */
@media print {
  .topbar, .sidebar, .velo, .footer, .no-print, .toast, .nav-basso { display: none !important; }
  body { background: #fff; }
  .layout, .area, .contenuto { display: block; padding: 0 !important; margin: 0; max-width: none; min-height: 0; }
  .anteprima { padding: 0; background: none; border-radius: 0; overflow: visible; }
  .foglio { box-shadow: none; margin: 0; zoom: 1 !important; }
}
