/* ============================================================================
   Serramenti Demo — demo gestionale · DESIGN SYSTEM "CANTIERE BLU"
   Registro denso e funzionale da ERP moderno. Palette dal mockup approvato:
   grigio freddo di fondo, navy strutturale, giallo segnale, badge netti.
   ========================================================================== */

:root {
  --bg-app: #EDF0F4;
  --surface: #FFFFFF;
  --navy-900: #0B2239;
  --navy-800: #102C4C;
  --navy-700: #16395F;
  --navy-line: #1E4470;
  --blue-600: #1B5FB8;
  --blue-700: #164E99;
  --yellow: #FFC400;
  --yellow-deep: #8A5B00;
  --yellow-soft: #FFF4D6;
  --yellow-line: #F2DCA0;
  --ink: #1A2733;
  --ink-2: #46586A;
  --ink-3: #5E7082;
  --line: #D7DEE6;
  --line-soft: #E4E9EF;
  --green-ink: #14683A;
  --green-soft: #E1F4E7;
  --green-line: #B8E2C6;
  --blue-soft: #E3EDFB;
  --blue-line: #BBD4F3;
  --gray-soft: #E8EDF2;
  --gray-line: #CBD6E0;
  --red-ink: #A62B2B;
  --red-soft: #FBE7E7;
  --red-line: #EFC4C4;
  --viola-ink: #5B3FA8;
  --viola-soft: #EEE9FA;
  --viola-line: #D8CCF0;
  --shadow: 0 1px 2px rgba(11, 34, 57, .06), 0 8px 24px rgba(11, 34, 57, .09);
  --font-titoli: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;
  --font-testo: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-testo);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: 224px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "side head" "side main";
  height: 100vh;
  min-width: 1180px;
  overflow: hidden;
  overflow-x: auto;
}

.num { font-variant-numeric: tabular-nums lining-nums; }

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================ SIDEBAR ============================ */

.side {
  grid-area: side;
  background: linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 100%);
  color: #B9C7D6;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.side .brandmini {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px 14px;
  border-bottom: 1px solid var(--navy-line);
}
.side .brandmini .bi {
  width: 30px; height: 30px; border-radius: 4px;
  background: var(--yellow); color: var(--navy-900);
  font-family: var(--font-titoli);
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center;
}
.side .brandmini .t1 { color: #FFF; font-weight: 700; font-size: 12px; letter-spacing: .10em; }
.side .brandmini .t2 { font-size: 10px; color: #7E93A9; letter-spacing: .14em; margin-top: 1px; }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav .sect { font-size: 9.5px; letter-spacing: .16em; color: #6C8299; padding: 6px 10px 5px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: #B9C7D6; text-decoration: none;
  font-size: 12.5px; font-weight: 500;
  padding: 8px 10px; border-radius: 6px;
  border-left: 3px solid transparent;
}
/* la guardia di ruolo (app.js § aggiornaNavRuolo) spegne le voci con
   l'attributo hidden: senza questa riga il display:flex qui sopra vince sul
   [hidden] del browser e il menu resta intero anche a chi non deve vederlo. */
.nav a[hidden] { display: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a svg { flex: 0 0 auto; opacity: .85; }
.nav a .cnt {
  margin-left: auto; background: var(--navy-700); color: #DAE4EE;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 9px;
}
.nav a.active {
  background: rgba(255, 255, 255, .10);
  color: #FFF; border-left-color: var(--yellow);
  font-weight: 600;
}
.nav a.active svg { opacity: 1; }
.nav a.newq { color: #FFD84D; }
.nav a.newq svg { opacity: 1; }

.side .spacer { flex: 1; }

.sede {
  border-top: 1px solid var(--navy-line);
  padding: 12px 12px 14px;
}
.sede .lbl { font-size: 9.5px; letter-spacing: .16em; color: #6C8299; font-weight: 600; padding: 0 2px 7px; }
.sede select {
  width: 100%;
  background: var(--navy-700);
  color: #FFF;
  border: 1px solid var(--navy-line);
  border-radius: 6px;
  font-family: var(--font-testo);
  font-size: 12px; font-weight: 600;
  padding: 7px 8px;
  cursor: pointer;
}
.sede select:focus { outline: 2px solid var(--yellow); outline-offset: 1px; }

.btn-reset {
  margin-top: 10px;
  width: 100%;
  background: none;
  border: 1px dashed #3D5A78;
  color: #7E93A9;
  border-radius: 6px;
  font-family: var(--font-testo);
  font-size: 11px; font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}
.btn-reset:hover { color: #DAE4EE; border-color: #56718C; }

.sede .ver { margin-top: 10px; padding: 0 2px; font-size: 10px; color: #56718C; letter-spacing: .04em; }

/* ============================ HEADER ============================ */

.head {
  grid-area: head;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
  min-width: 0;
}
.wordmark { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.wordmark .wm {
  font-family: var(--font-titoli);
  font-weight: 700; font-size: 21px; letter-spacing: .10em; color: var(--navy-900);
}
.wordmark .wm .accent { color: var(--blue-600); }
.wordmark .sep { width: 1px; height: 18px; background: var(--line); align-self: center; }
.wordmark .app-name {
  font-size: 11px; font-weight: 600; letter-spacing: .14em; color: var(--ink-3);
  text-transform: uppercase;
}

.head .search {
  margin-left: 12px;
  flex: 0 1 320px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-app); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 11px; color: var(--ink-3);
}
.head .search svg { flex: 0 0 auto; }
.head .search input {
  border: none; background: none; outline: none;
  font-family: var(--font-testo); font-size: 12px; color: var(--ink);
  width: 100%;
}
.head .search input::placeholder { color: var(--ink-3); }

.head .right { margin-left: auto; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.head .date { font-size: 11.5px; color: var(--ink-3); }

.badge-demo {
  background: var(--yellow); color: var(--navy-900);
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  padding: 3px 9px; border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.head .user { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--line); }
.head .user .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy-800); color: #FFF;
  font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.head .user .un { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.head .user .ur { font-size: 10.5px; color: var(--ink-3); }

/* ============================ MAIN ============================ */

.main {
  grid-area: main;
  padding: 18px 20px 28px;
  min-width: 0;
  overflow-y: auto;
}

.page-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title h2 { font-size: 16px; font-weight: 700; color: var(--navy-900); letter-spacing: -.01em; }
.page-title .ctx { font-size: 11.5px; color: var(--ink-3); }
.page-title .spazio { margin-left: auto; }

/* ============================ BOTTONI ============================ */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--blue-600); color: #FFF;
  font-family: var(--font-testo);
  font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--blue-600);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--blue-700); border-color: var(--blue-700); text-decoration: none; }

.btn.secondario {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--gray-line);
}
.btn.secondario:hover { background: var(--gray-soft); color: var(--ink); }

.btn.giallo {
  background: var(--yellow); color: var(--navy-900);
  border-color: var(--yellow);
}
.btn.giallo:hover { background: #EDB600; border-color: #EDB600; }

.btn.pericolo {
  background: var(--surface); color: var(--red-ink);
  border: 1px solid var(--red-line);
}
.btn.pericolo:hover { background: var(--red-soft); }

.btn.mini { font-size: 11px; padding: 4px 10px; border-radius: 5px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================ CARD & KPI ============================ */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
  margin-bottom: 14px;
}
.card .chd {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; border-bottom: 1px solid var(--line-soft);
}
.card .chd h3 { font-size: 12.5px; font-weight: 700; color: var(--navy-900); letter-spacing: .02em; }
.card .chd .sub { font-size: 11px; color: var(--ink-3); }
.card .chd .lnk { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--blue-600); cursor: pointer; white-space: nowrap; }
.card .cbody { padding: 13px 15px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 13px 15px 12px;
  border-top: 3px solid var(--navy-800);
  min-width: 0;
}
.kpi.k2 { border-top-color: var(--blue-600); }
.kpi.k3 { border-top-color: var(--yellow); }
.kpi.k4 { border-top-color: #2E9E5B; }
.kpi .kl { font-size: 10.5px; font-weight: 600; letter-spacing: .10em; color: var(--ink-3); text-transform: uppercase; }
.kpi .kv {
  font-family: var(--font-titoli);
  font-size: 31px; font-weight: 700; color: var(--navy-900);
  line-height: 1.1; margin-top: 5px; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .kv small { font-size: 19px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.kpi .ks { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.kpi .ks b { color: var(--green-ink); font-weight: 700; }
.kpi .ks .warn { color: var(--yellow-deep); font-weight: 700; }

/* ============================ KANBAN / PIPELINE ============================ */

.pipe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--line-soft); }
.pipe.col5 { grid-template-columns: repeat(5, 1fr); }
.pcol { background: #F7F9FB; padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pcol + .pcol { border-left: 1px solid var(--line-soft); }
.pcol .ph { padding: 1px 3px 4px; }
.pcol .ph .r1 { display: flex; align-items: center; gap: 7px; }
.pcol .ph .pd { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.pcol .ph .pn { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--ink-2); text-transform: uppercase; white-space: nowrap; }
.pcol .ph .pc { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--ink-2); }
.pcol .ph .psum { display: block; font-size: 10.5px; color: var(--ink-3); margin: 1px 0 0 15px; }

/* pallini colonna: s1 bozza/ordinato · s2 inviato/arrivato · s3 trattativa/posato · s4 accettato/collaudato */
.pd.s1 { background: #94A6B8; }
.pd.s2 { background: var(--blue-600); }
.pd.s3 { background: var(--yellow); }
.pd.s4 { background: #2E9E5B; }

.pcard {
  background: #FFF; border: 1px solid var(--line);
  border-left-width: 3px; border-radius: 6px;
  padding: 8px 10px 8px;
  min-width: 0;
}
.pcard.cliccabile { cursor: pointer; }
.pcard.cliccabile:hover { border-color: var(--blue-line); box-shadow: 0 1px 4px rgba(11, 34, 57, .10); }
.pcard.s1 { border-left-color: #94A6B8; }
.pcard.s2 { border-left-color: var(--blue-600); }
.pcard.s3 { border-left-color: var(--yellow); }
.pcard.s4 { border-left-color: #2E9E5B; }
.pcard .pcl { font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pco { font-size: 11px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pcf { display: flex; align-items: center; margin-top: 6px; gap: 6px; }
.pcard .pcf .imp { font-size: 12.5px; font-weight: 800; color: var(--navy-900); }
.pcard .pcf .gg {
  margin-left: auto; font-size: 10px; font-weight: 700;
  background: var(--gray-soft); color: var(--ink-2);
  border: 1px solid var(--gray-line);
  padding: 1px 6px; border-radius: 8px; white-space: nowrap;
}
.pcard .pcf .gg.late { background: var(--yellow-soft); color: var(--yellow-deep); border-color: var(--yellow-line); }
.pcard .pcf .gg.ok { background: var(--green-soft); color: var(--green-ink); border-color: var(--green-line); }
.pcol .more { font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-align: center; padding: 2px 0 0; }

/* ============================ TABELLE ============================ */

.tabella-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
table.fissa { table-layout: fixed; }

thead th {
  font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); text-align: left;
  padding: 8px 8px; background: #F7F9FB;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; vertical-align: middle;
}
thead th.wrap { white-space: normal; line-height: 1.25; }
thead th:first-child, tbody td:first-child { padding-left: 15px; }
thead th:last-child, tbody td:last-child { padding-right: 15px; }
thead th.r, tbody td.r { text-align: right; }

tbody td {
  padding: 7px 8px; border-bottom: 1px solid var(--line-soft);
  font-size: 12px; color: var(--ink); vertical-align: middle; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F4F7FA; }
tbody tr.cliccabile { cursor: pointer; }

td .cliente { display: block; font-weight: 600; font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
td .comune { display: block; font-size: 10.5px; color: var(--ink-3); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
td.numref { font-weight: 600; color: var(--blue-700); font-size: 11px; letter-spacing: .01em; }
td .muted, td.muted { color: var(--ink-3); font-size: 11.5px; }
td.imp { font-weight: 800; color: var(--navy-900); font-size: 12.5px; }
td .late-txt, .late-txt { color: var(--yellow-deep); font-weight: 700; }

/* ============================ BADGE DI STATO ============================ */

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .01em;
  padding: 2px 8px; border-radius: 9px; border: 1px solid;
  white-space: nowrap;
}
/* preventivi */
.badge.bozza      { background: var(--gray-soft);   color: #46586A;          border-color: var(--gray-line); }
.badge.inviato    { background: var(--blue-soft);   color: #1655A8;          border-color: var(--blue-line); }
.badge.tratt      { background: var(--yellow-soft); color: var(--yellow-deep); border-color: var(--yellow-line); }
.badge.accettato  { background: var(--green-soft);  color: var(--green-ink); border-color: var(--green-line); }
.badge.rifiutato  { background: var(--red-soft);    color: var(--red-ink);   border-color: var(--red-line); }
/* commesse */
.badge.ordinato   { background: var(--gray-soft);   color: #46586A;          border-color: var(--gray-line); }
.badge.arrivato   { background: var(--blue-soft);   color: #1655A8;          border-color: var(--blue-line); }
.badge.posato     { background: var(--viola-soft);  color: var(--viola-ink); border-color: var(--viola-line); }
.badge.collaudato { background: var(--green-soft);  color: var(--green-ink); border-color: var(--green-line); }

/* badge squadre */
.sq {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 8px; border: 1px solid;
  white-space: nowrap;
}
.sq.sq1 { background: var(--blue-soft); color: #1655A8; border-color: var(--blue-line); }
.sq.sq2 { background: var(--viola-soft); color: var(--viola-ink); border-color: var(--viola-line); }

/* ============================ AVVISI ============================ */

.alert {
  background: var(--yellow-soft);
  border: 1px solid #F0D488; border-left: 4px solid var(--yellow);
  border-radius: 8px; padding: 12px 14px 13px;
  margin-bottom: 14px;
}
.alert .at { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 800; color: #6B4A00; }
.alert p { font-size: 11.5px; color: #7A5A10; margin-top: 5px; line-height: 1.5; }
.alert .al { display: inline-block; margin-top: 7px; font-size: 11.5px; font-weight: 700; color: var(--navy-900); border-bottom: 1.5px solid var(--yellow); cursor: pointer; }
.alert .al:hover { text-decoration: none; }

/* ============================ POSE (colonnina) ============================ */

.pose-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.pose-row:last-of-type { border-bottom: none; }
.pose-row.today { background: #F2F7FE; }
.pose-row .day {
  flex: 0 0 44px; text-align: center;
  background: var(--navy-800); color: #FFF; border-radius: 5px;
  padding: 3px 0 4px; line-height: 1.1;
}
.pose-row.today .day { background: var(--blue-600); }
.pose-row .day .dw { font-size: 8.5px; font-weight: 700; letter-spacing: .12em; color: #BFD1E3; text-transform: uppercase; display: block; }
.pose-row .day .dn { font-family: var(--font-titoli); font-size: 16px; font-weight: 700; }
.pose-row .pi { min-width: 0; flex: 1; }
.pose-row .pi .pn2 { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pose-row .pi .pl2 { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pose-foot {
  display: flex; gap: 12px; padding: 9px 14px;
  background: #F7F9FB; border-top: 1px solid var(--line-soft);
  font-size: 10.5px; color: var(--ink-3);
}
.pose-foot span { white-space: nowrap; }
.pose-foot b { color: var(--ink-2); }

/* ============================ FORM ============================ */

.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  color: var(--ink-3); text-transform: uppercase;
}
.campo input, .campo select, .campo textarea {
  font-family: var(--font-testo);
  font-size: 12.5px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--gray-line);
  border-radius: 6px;
  padding: 7px 10px;
  width: 100%;
}
.campo textarea { resize: vertical; min-height: 64px; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none; border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(27, 95, 184, .15);
}
.campo .hint { font-size: 10.5px; color: var(--ink-3); }
.campo.errore input, .campo.errore select { border-color: var(--red-ink); }
.campo .msg-errore { font-size: 10.5px; color: var(--red-ink); font-weight: 600; }

.form-griglia { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 12px; }
.form-griglia .largo2 { grid-column: span 2; }
.form-griglia .largo4 { grid-column: span 4; }

.check-inline { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.check-inline input { width: auto; }

/* ============================ TOOLBAR / FILTRI ============================ */

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.chip {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--gray-line); border-radius: 14px;
  font-family: var(--font-testo);
  font-size: 11.5px; font-weight: 600;
  padding: 4px 12px; cursor: pointer;
}
.chip:hover { background: var(--gray-soft); }
.chip.attivo { background: var(--navy-800); color: #FFF; border-color: var(--navy-800); }
.chip .n { opacity: .7; font-weight: 700; margin-left: 3px; }

/* ============================ MODALE ============================ */

.modale-sfondo {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(11, 34, 57, .45);
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 48px 20px;
}
.modale-sfondo.aperta { display: flex; }
.modale {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 760px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.modale .mhd {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modale .mhd h3 { font-size: 14px; font-weight: 700; color: var(--navy-900); }
.modale .mhd .sub { font-size: 11px; color: var(--ink-3); }
.modale .mx {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--ink-3);
  padding: 4px 6px; border-radius: 5px;
  font-family: var(--font-testo);
}
.modale .mx:hover { background: var(--gray-soft); color: var(--ink); }
.modale .mbody { padding: 15px 18px 18px; }
.modale .mfoot {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  background: #F7F9FB;
}

/* ============================ RIEPILOGO TOTALI ============================ */

.totali { margin-top: 10px; margin-left: auto; max-width: 320px; font-size: 12px; }
.totali .tr { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.totali .tr.sconto { color: var(--red-ink); }
.totali .tr.finale {
  border-top: 2px solid var(--navy-800); margin-top: 5px; padding-top: 7px;
  font-size: 14px; font-weight: 800; color: var(--navy-900);
}

/* ============================ VARIE ============================ */

.vuoto {
  padding: 34px 20px; text-align: center;
  color: var(--ink-3); font-size: 12.5px;
}

.griglia-2 { display: grid; grid-template-columns: 1fr 290px; gap: 14px; align-items: start; }
.colonna { display: flex; flex-direction: column; min-width: 0; }

.brands { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 13px; }
.brands .bt { font-size: 9.5px; letter-spacing: .1em; font-weight: 700; color: var(--ink-3); text-transform: uppercase; }
.brands .bp {
  font-size: 10px; font-weight: 700; color: var(--ink-2);
  background: var(--gray-soft); border: 1px solid var(--gray-line);
  padding: 2px 8px; border-radius: 9px; letter-spacing: .03em; white-space: nowrap;
}

.nota-demo { font-size: 10.5px; color: var(--ink-3); font-style: italic; }

/* ============================ STAMPA ============================ */

#area-stampa { display: none; }

@media print {
  body { display: block; height: auto; min-width: 0; overflow: visible; background: #FFF; }
  body.modo-stampa .side,
  body.modo-stampa .head,
  body.modo-stampa .main,
  body.modo-stampa .modale-sfondo { display: none !important; }
  body.modo-stampa #area-stampa { display: block; padding: 0; color: #000; }
}

/* ============================================================================
   SEZIONE V2 — estensione del design system per il gestionale totale
   (rilievi → preventivo/portale → commessa → ordine → bonus → fattura →
   assistenza). Resta dentro palette e font "Cantiere Blu" già definiti sopra.
   Vedi CONTRATTO-V2.md § Classi CSS per il contratto di ogni classe.
   ========================================================================== */

/* ---- sidebar più densa: 12 voci / 5 sezioni nello stesso spazio ---- */
/* override mirato, non tocca il resto delle regole .nav già in vigore */
.nav a { padding: 6px 10px; }
.nav .sect { padding: 4px 10px 3px; }

/* ============================ BADGE — alias colore v2 ============================ */
/* il nucleo mappa gli stati nuovi (rilievi, ordini, pratiche, fatture, ticket)
   su questi cinque alias, coerenti con i colori badge già in uso in v1 */
.badge.neutro { background: var(--gray-soft);   color: #46586A;            border-color: var(--gray-line); }
.badge.blu    { background: var(--blue-soft);   color: #1655A8;            border-color: var(--blue-line); }
.badge.giallo { background: var(--yellow-soft); color: var(--yellow-deep); border-color: var(--yellow-line); }
.badge.verde  { background: var(--green-soft);  color: var(--green-ink);   border-color: var(--green-line); }
.badge.rosso  { background: var(--red-soft);    color: var(--red-ink);     border-color: var(--red-line); }

/* ============================ HEADER — campanella notifiche ============================ */

.bell-wrap { position: relative; }

.bell {
  position: relative;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink-2); cursor: pointer;
}
.bell:hover { background: var(--gray-soft); color: var(--ink); }
.bell .bdot {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--red-ink); color: #FFF;
  font-size: 9.5px; font-weight: 800; line-height: 1;
  border-radius: 8px; border: 2px solid var(--surface);
}

.notif-drop {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 40;
  width: 328px; max-height: 380px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px; display: none;
}
.notif-drop.aperta { display: block; }
.nitem {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px; cursor: pointer;
}
.nitem:hover { background: var(--gray-soft); }
.nitem.warn { background: var(--yellow-soft); }
.nitem.warn:hover { background: #FBECBE; }
.nitem .nt { flex: 1; font-size: 11.5px; line-height: 1.4; color: var(--ink-2); }
.nitem.warn .nt { color: #6B4A00; font-weight: 600; }
.nitem .nx { flex: 0 0 auto; font-size: 12px; color: var(--ink-3); }

/* ============================ HEADER — ricerca globale ============================ */

.head .search { position: relative; }

.search-drop {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px; display: none;
}
.search-drop.aperta { display: block; }
.sgrp {
  padding: 8px 10px 4px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
}
.srow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
}
.srow:hover, .srow.attiva { background: var(--blue-soft); }
.srow .sr1 { font-size: 12px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .sr2 { flex: 0 0 auto; max-width: 42%; font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================ HEADER — selettore ruolo ============================ */

.role-sel select {
  font-family: var(--font-testo);
  font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  background: var(--bg-app); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; max-width: 176px; cursor: pointer;
}
.role-sel select:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; }

/* ============================ TIMELINE ============================ */

.timeline { display: flex; flex-direction: column; margin-top: 4px; }
.tl-item { position: relative; display: flex; gap: 11px; padding: 7px 2px; }
.tl-item::before {
  content: ''; position: absolute; left: 4px; top: 20px; bottom: -7px; width: 1px;
  background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  flex: 0 0 auto; width: 9px; height: 9px; margin-top: 4px;
  background: var(--blue-600); border-radius: 50%;
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.tl-txt { font-size: 12px; font-weight: 500; color: var(--ink); }
.tl-meta { margin-top: 2px; font-size: 10.5px; color: var(--ink-3); }

/* ============================ CHECKLIST PRATICHE ============================ */

.checklist { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.ck-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px; border: 1px solid transparent;
  font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.ck-row:hover { background: var(--gray-soft); }
.ck-row input[type="checkbox"] { flex: 0 0 auto; width: 15px; height: 15px; accent-color: var(--blue-600); cursor: pointer; }
.ck-row.fatto { background: var(--green-soft); border-color: var(--green-line); color: var(--green-ink); text-decoration: line-through; text-decoration-color: var(--green-line); }

.prog { width: 100%; height: 7px; margin-top: 8px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.prog-in { display: block; height: 100%; background: var(--blue-600); border-radius: 4px; }

/* ============================ GRAFICI REPORT (solo CSS, zero librerie) ============================ */

.chart-bars { display: flex; flex-direction: column; gap: 8px; }
.cb-row { display: flex; align-items: center; gap: 10px; }
.cb-lbl { flex: 0 0 110px; font-size: 11px; font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-bar { flex: 1; height: 16px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.cb-in { display: block; height: 100%; min-width: 2px; background: var(--blue-600); border-radius: 4px; }
.cb-val { flex: 0 0 auto; min-width: 54px; text-align: right; font-size: 11.5px; font-weight: 700; color: var(--navy-900); }

.chart-cols {
  display: flex; align-items: flex-end; gap: 14px;
  height: 150px; padding: 6px 4px 0;
  border-bottom: 1px solid var(--line);
}
.cc-col { flex: 1; height: 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.cc-in { width: 100%; max-width: 34px; min-height: 3px; background: var(--blue-600); border-radius: 4px 4px 0 0; }
.cc-lbl { margin-top: 6px; font-size: 10px; font-weight: 600; color: var(--ink-3); text-align: center; white-space: nowrap; }

.chart-leg { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
.chart-leg > * { display: inline-flex; align-items: center; gap: 6px; }
.chart-leg > *::before { content: ''; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 2px; background: var(--blue-600); }
.chart-leg > *:nth-child(2)::before { background: var(--yellow); }
.chart-leg > *:nth-child(3)::before { background: #2E9E5B; }
.chart-leg > *:nth-child(4)::before { background: var(--viola-ink); }

/* ============================ CONFIGURATORE VISIVO (infisso.js) ============================ */

.cfg-box {
  display: flex; align-items: center; justify-content: center;
  min-height: 190px; padding: 14px;
  background: var(--bg-app); border: 1px solid var(--line); border-radius: 8px;
}
.cfg-box svg { max-width: 100%; height: auto; }
.cfg-quote { display: flex; justify-content: center; gap: 14px; margin-top: 8px; font-size: 11px; color: var(--ink-3); }

.mini-svg { display: flex; align-items: center; justify-content: center; width: 46px; height: 42px; }
.mini-svg svg { max-width: 100%; max-height: 100%; }

/* ============================ CHROME PORTALE CLIENTE ============================ */

body.modo-portale {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "main";
}
body.modo-portale .side,
body.modo-portale .head { display: none; }
body.modo-portale .main { padding: 0; }

.p-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 9px 16px;
  background: var(--yellow); color: var(--navy-900);
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.p-bar a { color: var(--navy-900); text-decoration: underline; font-weight: 700; }

.portale-wrap {
  min-height: 100vh;
  display: flex; justify-content: center;
  padding: 32px 20px 56px;
  background: var(--bg-app);
}

.p-doc {
  width: 100%; max-width: 760px; height: fit-content;
  padding: 34px 40px 40px;
  background: var(--surface);
  border-radius: 4px;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.p-firma-canvas {
  display: block; width: 100%; height: 160px;
  background: var(--surface);
  border: 1.5px dashed var(--gray-line); border-radius: 8px;
  cursor: crosshair; touch-action: none;
}

.p-confronto { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.p-confronto > div { padding: 13px 15px; background: #F7F9FB; border: 1px solid var(--line); border-radius: 8px; }
.p-confronto > div:last-child { background: var(--blue-soft); border-color: var(--blue-line); }
.p-confronto h4 { margin-bottom: 8px; font-family: var(--font-titoli); font-size: 13px; font-weight: 700; letter-spacing: .01em; color: var(--navy-900); }

/* ============================================================================
   SEZIONE V6 — IL GESTIONALE DAL TELEFONO (CONTRATTO-V6-MOBILE.md, 10/09/26)
   Tre fasce: ≥ 1024 px invariato · 768–1023 tablet (sidebar resta, griglie a 2
   colonne) · ≤ 767 px telefono, «modo cantiere»: menu a cassetto, barra in
   basso, modali a foglio intero, misure tattili. Le regole sono scritte su
   `body.app` (index.html): prova.html e le pagine di collaudo non le ereditano.
   ========================================================================== */

/* ---- elementi nuovi del chrome: sullo schermo dell'ufficio non esistono ---- */
.btn-menu, .btn-cerca, .drawer-sfondo, .drawer-chiudi, .utente-mobile, .tabbar { display: none; }
.badge-demo .bd-corto { display: none; }

/* ---- sotto i 1180 px: via il min-width, che faceva scorrere la pagina di lato ---- */
/* Le regole tablet servono anche tra 1024 e 1179 px per contenere il layout. */
@media (max-width: 1179px) {
  body.app { min-width: 0; --head-h: 56px; }
  /* Sotto i 1024 px l'header non ha posto per il campo di ricerca accanto a
     marchio, chip DEMO, campanella e «Entra come…» (misurato: 945 px su 768).
     Il campo diventa a comparsa dietro la lente, come sul telefono. */
  body.app .btn-cerca {
    display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 38px; height: 38px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink-2); cursor: pointer;
  }
  body.app .head .search {
    position: fixed; top: var(--head-h); left: 8px; right: 8px; z-index: 41;
    margin: 0; flex: none; display: none;
    padding: 9px 12px; box-shadow: var(--shadow);
  }
  body.app.cerca-aperta .head .search { display: flex; }
  body.app .head .search input { font-size: 16px; }
  body.app .search-drop { max-height: 60vh; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .pipe, .pipe.col5 { grid-template-columns: repeat(2, 1fr); }
  .pcol:nth-child(2n+1) { border-left: none; }
  .pcol:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .griglia-2 { grid-template-columns: 1fr; }
  /* 768-1023 c'e' meno di 550 px per l'header (224 se ne prende la sidebar):
     il marchio perde separatore e sottotitolo, la ricerca si stringe. */
  .wordmark .sep, .wordmark .app-name { display: none; }
  .wordmark .wm { font-size: 18px; letter-spacing: .07em; }
  .head { gap: 10px; padding: 0 14px; }
  .head .date { display: none; }
  /* 768-1023: l'header non ha posto per data + chip lungo + utente + «Entra come…»
     (misurato: .head .right arrivava a 1185 px su 768). Restano marchio, ricerca,
     chip corto, campanella e selettore: l'identità di chi lavora sta nel selettore. */
  .head .right { gap: 10px; min-width: 0; }
  .head .user { display: none; }
  .badge-demo .bd-lungo { display: none; }
  .badge-demo .bd-corto { display: inline; }
  .role-sel select { max-width: 150px; }
  .tabella-scroll { -webkit-overflow-scrolling: touch; }
}

/* ============================ TELEFONO (≤ 767) ============================ */
@media (max-width: 767px) {
  :root { --head-h: 52px; --tabbar-h: 58px; }

  body.app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: var(--head-h) 1fr auto;
    grid-template-areas: "head" "main" "tabbar";
    height: 100vh; height: 100dvh;
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
  }

  /* ---- il cassetto: la sidebar di sempre, fuori schermo finché non la si chiama ---- */
  body.app .side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
    width: min(84vw, 320px);
    transform: translateX(-102%);
    transition: transform .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.app.nav-aperta .side { transform: none; box-shadow: 0 0 40px rgba(11, 34, 57, .45); }
  body.app .drawer-sfondo {
    display: block; position: fixed; inset: 0; z-index: 99;
    background: rgba(11, 34, 57, .5);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.app.nav-aperta .drawer-sfondo { opacity: 1; pointer-events: auto; }
  body.app .drawer-chiudi {
    display: flex; align-items: center; justify-content: center;
    margin-left: auto; width: 40px; height: 40px;
    background: none; border: 1px solid var(--navy-line); border-radius: 6px;
    color: #B9C7D6; font-size: 17px; cursor: pointer; font-family: var(--font-testo);
  }
  body.app .nav a { padding: 11px 10px; font-size: 14px; min-height: 44px; }
  body.app .nav .sect { padding: 10px 10px 4px; }
  body.app .nav a .cnt { font-size: 11px; padding: 2px 8px; }
  body.app .sede select { font-size: 16px; padding: 10px; min-height: 44px; }
  body.app .btn-reset { min-height: 40px; font-size: 12.5px; }
  body.app .utente-mobile { display: block; border-top: 1px solid var(--navy-line); padding: 12px 12px 0; }
  body.app .utente-mobile .lbl { font-size: 9.5px; letter-spacing: .16em; color: #6C8299; font-weight: 600; padding: 0 2px 7px; }
  body.app .utente-mobile select {
    width: 100%; max-width: none; min-height: 44px;
    background: var(--navy-700); color: #FFF;
    border: 1px solid var(--navy-line); border-radius: 6px;
    font-family: var(--font-testo); font-size: 16px; font-weight: 600; padding: 10px;
  }

  /* ---- header compatto: ☰ · marchio · DEMO · 🔍 · 🔔 ---- */
  body.app .head { padding: 0 10px; gap: 8px; }
  body.app .btn-menu, body.app .btn-cerca {
    display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 40px; height: 40px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink-2); cursor: pointer;
  }
  body.app { --head-h: 52px; }
  body.app .wordmark { gap: 0; min-width: 0; }
  body.app .wordmark .sep, body.app .wordmark .app-name { display: none; }
  body.app .wordmark .wm { font-size: 17px; letter-spacing: .06em; }
  body.app .head .search {
    position: fixed; top: var(--head-h); left: 8px; right: 8px; z-index: 41;
    margin: 0; flex: none; display: none;
    padding: 9px 12px; box-shadow: var(--shadow);
  }
  body.app.cerca-aperta .head .search { display: flex; }
  body.app .head .search input { font-size: 16px; min-height: 40px; }
  body.app .search-drop { max-height: 60vh; }
  body.app .srow { min-height: 44px; font-size: 13px; }
  body.app .srow .sr1, body.app .srow .sr2 { font-size: 13px; }
  body.app .head .right { gap: 8px; }
  body.app .badge-demo { padding: 3px 7px; font-size: 9.5px; }
  body.app .badge-demo .bd-lungo { display: none; }
  body.app .badge-demo .bd-corto { display: inline; }
  body.app .bell { width: 40px; height: 40px; }
  body.app .head .user, body.app .head .role-sel { display: none; }
  body.app .notif-drop {
    position: fixed; top: calc(var(--head-h) + 6px); left: 8px; right: 8px;
    width: auto; max-height: 65vh;
  }
  body.app .nitem { padding: 12px 10px; min-height: 46px; }

  /* ---- contenuto e barra in basso ---- */
  body.app .main { padding: 12px 12px 22px; }
  body.app .tabbar {
    grid-area: tabbar; z-index: 80;
    display: flex; align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--navy-900); border-top: 1px solid var(--navy-line);
  }
  body.app .tabbar a, body.app .tabbar button {
    position: relative; flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: #B9C7D6; text-decoration: none; cursor: pointer;
    font-family: var(--font-testo); font-size: 10.5px; font-weight: 600;
    background: none; border: none; border-top: 3px solid transparent;
    padding: 4px 2px 6px;
  }
  body.app .tabbar a:hover { text-decoration: none; }
  body.app .tabbar a.active { color: #FFF; border-top-color: var(--yellow); }
  body.app .tabbar svg { width: 20px; height: 20px; opacity: .9; }
  body.app .tabbar .tb-l { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.app .tabbar .tb-c {
    position: absolute; top: 4px; left: calc(50% + 6px);
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--yellow); color: var(--navy-900);
    font-size: 9.5px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  }
  body.app .tabbar .tb-c[hidden] { display: none; }
  body.app.modo-portale .tabbar, body.app.modo-portale .btn-menu { display: none; }
  body.app.modo-portale { grid-template-rows: 1fr; grid-template-areas: "main"; }
  body.app.modo-portale .main { padding: 0; }

  .page-title { gap: 6px 10px; margin-bottom: 12px; }
  .page-title h2 { font-size: 18px; }
  .page-title .spazio { flex-basis: 100%; margin: 0; height: 0; }

  /* ---- si tocca col dito ---- */
  .btn { min-height: 42px; padding: 9px 14px; font-size: 13.5px; }
  .btn.mini { min-height: 36px; padding: 6px 11px; font-size: 12.5px; }
  .chip { min-height: 38px; padding: 7px 13px; font-size: 13px; }
  .campo label { font-size: 10.5px; }
  .campo input, .campo select, .campo textarea { font-size: 16px; padding: 10px 12px; min-height: 44px; }
  .campo textarea { min-height: 88px; }
  .campo .hint { font-size: 11.5px; }
  .ck-row { padding: 12px 10px; min-height: 46px; font-size: 14px; }
  .ck-row input[type="checkbox"] { width: 22px; height: 22px; }
  .check-inline { min-height: 44px; font-size: 14px; }
  .check-inline input { width: 22px; height: 22px; }
  .form-griglia { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-griglia .largo2, .form-griglia .largo4 { grid-column: span 2; }
  .card .chd .lnk, .lnk { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; margin: 0 -6px; }
  .pose-row { padding: 10px 12px; min-height: 52px; }
  .pose-row .pi .pn2 { font-size: 13px; }
  .pose-row .pi .pl2 { font-size: 11.5px; }

  /* ---- griglie a una colonna ---- */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
  .kpi { padding: 10px 12px; }
  .kpi .kv { font-size: 26px; }
  .pipe, .pipe.col5 { grid-template-columns: 1fr; }
  .pcol + .pcol { border-left: none; border-top: 1px solid var(--line-soft); }
  .griglia-2 { grid-template-columns: 1fr; }
  .card .chd { flex-wrap: wrap; padding: 11px 12px; gap: 6px 10px; }
  .card .cbody { padding: 12px; }
  .totali { max-width: none; }
  .cb-lbl { flex-basis: 84px; }
  .chart-cols { gap: 6px; }

  /* ---- tabelle: chi resta tabella scorre nel suo contenitore e lo dice ---- */
  thead th:first-child, tbody td:first-child { padding-left: 12px; }
  thead th:last-child, tbody td:last-child { padding-right: 12px; }
  tbody tr.cliccabile td { padding-top: 11px; padding-bottom: 11px; }
  .tabella-scroll.m-scorri::after {
    content: 'scorri →'; display: block; position: sticky; left: 0;
    padding: 5px 12px; text-align: right;
    font-size: 10.5px; font-weight: 600; color: var(--ink-3);
    background: #F7F9FB; border-top: 1px solid var(--line-soft);
  }

  /* ---- modali: fogli a schermo intero, testata e piede fissi ---- */
  body.app .modale-sfondo { padding: 0; align-items: stretch; }
  body.app .modale {
    max-width: none; max-height: 100%; height: 100%;
    border-radius: 0; overflow: hidden;
    display: flex; flex-direction: column;
  }
  body.app .modale .mhd {
    flex: 0 0 auto; position: static;
    flex-wrap: wrap; gap: 6px 10px;
    padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top));
  }
  body.app .modale .mhd h3 { font-size: 16px; }
  body.app .modale .mx { width: 40px; height: 40px; font-size: 20px; margin-left: auto; }
  body.app .modale .mbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 22px; }
  body.app .modale .mfoot {
    flex: 0 0 auto; flex-wrap: wrap-reverse; gap: 8px;
    padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  body.app .modale .mfoot .btn { flex: 1 1 100%; justify-content: center; min-height: 46px; font-size: 14px; }

  /* ---- portale cliente dal suo telefono ---- */
  body.app.modo-portale .portale-wrap { padding: 12px 8px 40px; }
  .p-doc { padding: 20px 14px 26px; }
  .p-bar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 10px; font-size: 10px; }
  .p-confronto { grid-template-columns: 1fr; }
  .p-firma-canvas { height: 170px; }
}

/* ============================ TELEFONO STRETTO (≤ 600): tabelle in card ============================ */
@media (max-width: 600px) {
  table.m-card { display: block; width: 100%; padding: 8px 0 2px; table-layout: auto; }
  table.m-card thead, table.m-card colgroup { display: none; }
  table.m-card tbody { display: block; }
  table.m-card tr {
    display: block; width: auto; margin: 0 10px 8px;
    padding: 8px 10px 9px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  }
  table.m-card tbody tr:hover { background: var(--surface); }
  table.m-card tr.cliccabile:active { background: #F4F7FA; }
  table.m-card td {
    display: flex; gap: 8px; align-items: baseline;
    padding: 3px 0 !important; border: none;
    white-space: normal; overflow: visible; text-overflow: clip;
    text-align: left !important; font-size: 13px;
  }
  table.m-card td > * { min-width: 0; }
  table.m-card td[data-l]::before {
    content: attr(data-l); flex: 0 0 34%;
    font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  }
  table.m-card td.m-primario { display: block; font-size: 14px; font-weight: 700; padding-bottom: 5px !important; }
  table.m-card td.m-nascosto { display: none; }
  table.m-card td .cliente { font-size: 14px; }
  .tabella-scroll.m-scorri.m-card-dentro::after { display: none; }
}

/* ============================================================================
   V6 · LA STAMPA NON È UNO SCHERMO PICCOLO (10/09/26)
   Le media query qui sopra sono scritte DOPO @media print e non dicono `screen`:
   valgono anche in stampa, dove la carta è larga ~794 px CSS (A4 a 96 dpi) e con
   margini scende sotto i 767. Misurato: su carta da 6,5 pollici il corpo tornava
   `display:grid; overflow:hidden; height:900px`, cioè il documento del cliente
   usciva impaginato come un telefono. Questo blocco chiude la porta, e sta in
   fondo di proposito: a parità di specificità vince l'ultimo.
   ========================================================================== */

@media print {
  body.app {
    display: block !important;
    height: auto !important;
    min-width: 0 !important;
    overflow: visible !important;
    font-size: 13px;
  }
  body.app .tabbar,
  body.app .btn-menu,
  body.app .btn-cerca,
  body.app .drawer-sfondo { display: none !important; }
  body.app .side {
    position: static !important;
    transform: none !important;
    width: auto;
  }
  body.app .head .search,
  body.app .notif-drop { position: static !important; }
  body.app .modale {
    height: auto !important;
    max-height: none !important;
    border-radius: 10px;
  }
  body.app .modale .mbody { overflow: visible !important; }
}
