/* ================= token =================
   Mai rosso/verde per gli stati: testo + icona + contrasto. Giallo = avviso, inchiostro invertito = scaduto/grave.
   Densità: sul PC controlli da 32px e righe compatte; sul telefono 42px e campi a 16px (l'iPhone non zooma).
   Il bianco solo per riquadri, tabelle e campi: il fondo della pagina resta calcestruzzo. */
:root {
  --bg: #E3E4E0;          /* calcestruzzo */
  --side: #D8D9D5;        /* menu laterale, un tono più scuro del fondo */
  --surface: #F1F1EE;     /* riquadri: grigio chiaro, mai bianco pieno */
  --surface-2: #E8E9E5;
  --ink: #23262A;
  --ink-2: #4A4E54;
  --muted: #666A70;
  --line: #D3D5D0;
  --line-2: #BFC2BD;
  --accent: #2E4A85;      /* blu tracciatore, spento */
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE1EB; /* selezione: pulsanti scelti, voce del menu */
  --warn: #E9BC3F;        /* giallo segnaletica: solo avvisi */
  --warn-ink: #23262A;
  --over-bg: #4A4E54;     /* scaduto / grave: invertito ma senza nero pieno */
  --over-ink: #F1F1EE;
  --r-lg: 8px; --r-md: 6px; --r-sm: 4px;
  --shadow: 0 1px 0 rgba(28,30,33,.06), 0 10px 28px -14px rgba(28,30,33,.28);
  --s1: #2E4A85; --s2: #8095C4;   /* grafici: manodopera / materiali (lun–ven / sabato) */
  --tabbar-h: 56px;
  --ctl: 42px;            /* altezza di tasti e campi */
  --inp-fs: 16px;
  --gutter: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18191B; --side: #131416; --surface: #202124; --surface-2: #27282C;
    --ink: #DCDDDA; --ink-2: #B4B7BB; --muted: #8F9399; --line: #303236; --line-2: #3D4045;
    --accent: #8EA2D6; --accent-ink: #15192A; --accent-soft: #2A3249;
    --warn: #D9AF3C; --warn-ink: #18191B;
    --over-bg: #B4B7BB; --over-ink: #18191B;
    --s1: #8EA2D6; --s2: #4A5F96;
    --shadow: 0 1px 0 rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18191B; --side: #131416; --surface: #202124; --surface-2: #27282C;
  --ink: #DCDDDA; --ink-2: #B4B7BB; --muted: #8F9399; --line: #303236; --line-2: #3D4045;
  --accent: #8EA2D6; --accent-ink: #15192A; --accent-soft: #2A3249;
  --warn: #D9AF3C; --warn-ink: #18191B;
  --over-bg: #B4B7BB; --over-ink: #18191B;
  --s1: #8EA2D6; --s2: #4A5F96;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
  color-scheme: dark;
}
@media (min-width: 900px) {
  :root { --ctl: 32px; --inp-fs: 14px; --gutter: 20px; }
}

/* ================= base ================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
@media (min-width: 900px) { body { font-size: 14px; line-height: 1.35; } }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* barre di scorrimento dei riquadri che scorrono da soli (elenco cantieri, tabelle lunghe): ben visibili */
* { scrollbar-color: var(--line-2) transparent; }
/* link che fanno da tasti: se il mouse si sposta di qualche pixel mentre si preme, il browser inizierebbe
   a trascinare il link e il clic andrebbe perso (succedeva nel menu a sinistra su PC). Firefox: draggable="false" nel menu */
.side a, .tabbar a, a.btn, a.icon-btn, a.chip, .seg > a, .schede > a { -webkit-user-drag: none; user-select: none; }
.val, .num, .inp.r, .calc, .kpi .v, .somma b, .tot b, .cartello .v { font-variant-numeric: tabular-nums; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.xs { width: 13px; height: 13px; stroke-width: 2.2; }
svg.i.muted { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ================= impaginazione ================= */
.main { padding: 0 var(--gutter) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); min-width: 0; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: calc(env(safe-area-inset-top) + 10px) 0 10px; }
.top-t { flex: 1; min-width: 0; }
.top h1 { font-size: 23px; font-weight: 700; font-variation-settings: "wdth" 112; letter-spacing: -.015em; line-height: 1.15; }
.top .sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.top-az { display: contents; }
.side { display: none; }

/* schede della pagina (Ore · Materiali · …, Cantieri · Preventivi · Computi): nel telefono una riga sotto il titolo */
.schede { order: 5; flex-basis: 100%; display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line-2); scrollbar-width: none; }
.schede > * {
  flex: none; display: flex; align-items: center; height: 38px; padding: 0 10px; border: 0; background: none; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent;
}
.schede > *:hover { color: var(--ink); }
.schede > .on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 2px 4px env(safe-area-inset-bottom); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 650; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
  .side {
    display: flex; flex-direction: column; gap: 1px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--side); border-right: 1px solid var(--line-2); padding: 10px 8px;
  }
  .brand-r { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 10px 8px; }
  .side .brand { font-weight: 750; font-variation-settings: "wdth" 120; font-size: 17px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
  .side .side-ins {
    display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border-radius: var(--r-sm);
    background: var(--accent); color: var(--accent-ink); font-size: 12.5px; font-weight: 650; text-decoration: none;
  }
  .side .side-ins:hover { filter: brightness(1.08); }
  .side a:not(.brand):not(.side-ins) { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-size: 13.5px; }
  .side a svg.i { width: 16px; height: 16px; }
  .side a:not(.brand):not(.side-ins):hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
  .side a[aria-current="page"]:not(.side-ins) { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: inset 0 0 0 1px var(--line-2); }
  .side a[aria-current="page"]:not(.side-ins) svg.i { color: var(--accent); }
  .side a .cnt { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 0 5px; border-radius: 3px; background: var(--warn); color: var(--warn-ink); line-height: 17px; font-variant-numeric: tabular-nums; }
  .side-g { margin-top: 4px; }
  .side-g > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: var(--r-sm);
    font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); user-select: none;
  }
  .side-g > summary::-webkit-details-marker { display: none; }
  .side-g > summary:hover { color: var(--ink); }
  .side-g > summary svg.i { transition: transform .15s; }
  .side-g[open] > summary svg.i { transform: rotate(90deg); }
  .side-fondo { margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line-2); }

  .main { padding: 0 var(--gutter) 32px; width: 100%; }
  .top { position: sticky; top: 0; z-index: 25; background: var(--bg); min-height: 54px; padding: 8px 0; margin-bottom: 10px; border-bottom: 1px solid var(--line-2); flex-wrap: nowrap; gap: 14px; }
  .top h1 { font-size: 20px; white-space: nowrap; }
  .top-t { flex: 0 1 auto; display: flex; align-items: baseline; gap: 12px; }
  .top .sub { font-size: 13px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-az { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .top .icon-btn { width: 30px; height: 30px; }
  .schede { order: 0; flex-basis: auto; align-self: stretch; margin: -8px 0 -9px; border-bottom: 0; }
  .schede > * { height: auto; }
  .tabbar, .solo-telefono { display: none !important; }
}

.avvio, .login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; color: var(--muted); gap: 12px; align-content: center; }
.login form { width: min(380px, 100%); display: grid; gap: 14px; padding: 24px; color: var(--ink); }
.login h1 { font-size: 30px; font-weight: 750; font-variation-settings: "wdth" 120; letter-spacing: -.02em; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ================= componenti ================= */
.blocco { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 12px; margin-bottom: 10px; }
.blocco h2 { font-size: 14.5px; font-weight: 700; margin-bottom: 6px; }
.blocco-t { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.blocco-t h2 { margin-bottom: 0; }
.vuoto-box { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: 14px; color: var(--ink-2); margin: 6px 0 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--ctl); padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s;
}
.btn svg.i { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.conferma { background: var(--warn); border-color: var(--warn-ink); color: var(--warn-ink); }
.btn.grave { background: var(--over-bg); border-color: var(--over-bg); color: var(--over-ink); }
.btn.largo { width: 100%; }
.rapidi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0 12px; }
.rapidi .btn { font-size: 13.5px; padding: 0 6px; }
.rapidi-pc { display: flex; gap: 6px; }
.azioni { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.link { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 4px 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: var(--ctl); height: var(--ctl); flex: none; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }
.icon-btn svg.i { width: 18px; height: 18px; }

/* scelte rapide (periodi, Oggi/Ieri): pulsanti uniti in una barra */
.chips { display: flex; }
.chips.wrap { flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: calc(var(--ctl) - 2px); padding: 0 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
}
.chips:not(.wrap) > .chip + .chip { margin-left: -1px; }
.chips:not(.wrap) > .chip:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.chips:not(.wrap) > .chip:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.chips:not(.wrap) > .chip:only-child { border-radius: var(--r-md); }
.chips.wrap > .chip { border-radius: var(--r-md); }
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)); position: relative; z-index: 1; }
.chip.grow { margin-left: auto !important; border-radius: var(--r-md) !important; }

/* interruttori (Tutti/Aperti/Chiusi, Sistema/Chiaro/Scuro…): stessi pulsanti uniti delle scelte rapide */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-2); border-radius: var(--r-md); overflow: hidden; margin-bottom: 10px; background: var(--surface); }
.seg > * { display: flex; align-items: center; justify-content: center; gap: 5px; text-align: center; min-height: calc(var(--ctl) - 2px); padding: 0 10px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); text-decoration: none; border: 0; border-left: 1px solid var(--line-2); background: none; cursor: pointer; white-space: nowrap; }
.seg > :first-child { border-left: 0; }
.seg > *:hover { color: var(--ink); background: var(--surface-2); }
.seg > .on, .seg > .on:hover { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
.seg > .on .conta-seg { color: inherit; opacity: .75; }
@media (max-width: 380px) { .seg-4 > * { font-size: 12.5px; } }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 1px 6px; border-radius: var(--r-sm); white-space: nowrap; line-height: 18px; }
.tag.warn { background: var(--warn); color: var(--warn-ink); }
.tag.over { background: var(--over-bg); color: var(--over-ink); }
.tag.off { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

.msg { display: flex; gap: 6px; align-items: center; border-radius: var(--r-sm); padding: 5px 8px; font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.3; }
.msg svg.i { width: 15px; height: 15px; }
.msg.warn { background: var(--warn); color: var(--warn-ink); }
.msg.ko { background: var(--over-bg); color: var(--over-ink); }
.msgs { margin-bottom: 8px; }

.li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.li:last-child { border-bottom: 0; }
@media (hover: hover) { a.li:hover, button.li:hover { background: var(--surface-2); } }
.li-t { min-width: 0; flex: 1; }
.li .who { font-weight: 600; overflow-wrap: anywhere; }
.li .where { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.li .val { font-weight: 650; white-space: nowrap; text-align: right; }
.elenco-link .li { gap: 10px; justify-content: flex-start; }
.elenco-link h2 { margin: 12px 0 2px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.elenco-link h2:first-child { margin-top: 0; }
@media (min-width: 900px) {
  .li { padding: 6px 4px; min-height: 34px; }
  /* sul PC nome e dettaglio stanno sulla stessa riga */
  .li-t:has(.where) { display: flex; align-items: baseline; gap: 12px; }
  .li-t .who { flex: none; min-width: 150px; }
  .li-t .where { flex: 1; min-width: 0; }
}

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { display: flex; flex-direction: column; color: inherit; text-decoration: none; min-width: 0; }
.kpi .v { font-size: 18px; font-weight: 650; font-variation-settings: "wdth" 85; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .l { font-size: 12px; color: var(--muted); }

/* il cartello: i totali della pagina in inchiostro pieno, come la tabella di cantiere */
.cartello { display: flex; flex-wrap: wrap; align-items: stretch; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 10px; }
.cartello > div { padding: 7px 14px; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); min-width: 0; }
.cartello > div:first-child { border-left: 0; }
.cartello .k { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 650; white-space: nowrap; }
.cartello .v { font-size: 17px; font-weight: 700; font-variation-settings: "wdth" 92; white-space: nowrap; }
.cartello .grow { flex: 1; align-items: flex-end; }
.cartello .link { white-space: nowrap; }
.cartello .neg { font-size: 15px; }
@media (max-width: 899px) {
  .cartello > div { padding: 6px 10px; flex: 1 1 30%; }
  .cartello > div:first-child { flex-basis: 100%; border-bottom: 1px solid var(--line); }
  .cartello > div:nth-child(2) { border-left: 0; }
  .cartello .grow:empty { display: none; }
}
/* righe di totale più semplici (altre pagine) */
.somma { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 10px; }
.somma b { font-size: 16px; }
.somma .muted { color: var(--muted); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 70px);
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: min(92vw, 520px);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); padding: 10px 14px; border-radius: var(--r-md); box-shadow: var(--shadow); font-weight: 550;
}
.toast.ko { background: var(--warn); color: var(--warn-ink); }
@media (min-width: 900px) { .toast { bottom: 80px; left: calc(50% + 100px); } }

/* ================= moduli ================= */
.field { display: block; min-width: 0; position: relative; }
.flbl { display: block; font-size: 12px; color: var(--muted); margin: 0 0 2px 2px; }
.inp {
  width: 100%; height: var(--ctl); border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--surface);
  padding: 0 10px; font-size: var(--inp-fs); appearance: none; -webkit-appearance: none;
}
select.inp { padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="date"].inp { min-width: 0; display: flex; align-items: center; }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp.r { text-align: right; font-weight: 600; }
.inp::placeholder { color: var(--muted); opacity: .7; }
.inp.ko, .scegli.ko .inp { border: 2px solid var(--ink); background: var(--warn); color: var(--warn-ink); }
.inp.ko::placeholder { color: var(--warn-ink); }
.calc { height: var(--ctl); display: flex; align-items: center; justify-content: flex-end; font-weight: 650; padding: 0 2px; white-space: nowrap; }

/* data: in testa al modulo, una riga sola */
.date-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 12px 10px; margin-bottom: 10px; }
.date-box.ko { border: 2px solid var(--ink); }
.date-box .lbl { font-size: 12px; color: var(--muted); }
.date-big { position: relative; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; margin: 0 0 8px; min-height: 32px; cursor: pointer; }
.date-big .wd { font-size: 26px; font-weight: 750; font-variation-settings: "wdth" 120; letter-spacing: -.02em; line-height: 1.1; }
.date-big .dm, .date-big .y { font-size: 17px; font-variation-settings: "wdth" 108; }
.date-big .dm { color: var(--ink-2); font-weight: 500; }
.date-big .y { color: var(--muted); }
.date-big .vuota { font-size: 22px; font-weight: 600; font-variation-settings: "wdth" 115; color: var(--muted); letter-spacing: -.02em; line-height: 1.2; }
.date-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; margin: 0; cursor: pointer; appearance: none; -webkit-appearance: none; }
.date-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.mese-nav { display: flex; align-items: center; gap: 8px; }
.mese-nav .date-big { flex: 1; justify-content: center; margin: 0 0 8px; cursor: default; }

.blocco.testata .campi, .blocco.fisse { margin: 0; }
.righe { display: grid; gap: 6px; margin-bottom: 6px; }
.fr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 10px 10px; }
.fr-head { display: flex; justify-content: space-between; align-items: center; min-height: 22px; margin-bottom: 2px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.campi { display: grid; gap: 6px 8px; }
/* ore: una scheda per persona, con uno o più cantieri */
.scheda-corpo, .cantieri { display: grid; gap: 6px; }
.sub { display: grid; grid-template-columns: 1fr 72px; gap: 6px 8px; align-items: end; }
.sub .c-note, .sub .msg { grid-column: 1 / -1; }
.sub .msg { margin-top: 0; }
.sub .c-note .flbl, .sub + .sub .flbl { display: none; }
.piu .sub { grid-template-columns: 1fr 72px var(--ctl); padding-top: 6px; border-top: 1px dashed var(--line); }
.piu .sub:first-child { border-top: 0; padding-top: 0; }
.sub .togli { grid-row: 1; grid-column: 3; height: var(--ctl); }
.add.add-sub { min-height: calc(var(--ctl) - 4px); margin: 0; font-size: 13px; }
.tot-ore { color: var(--ink); }
.t-materiali .fr .campi { grid-template-columns: 1fr 1fr 1fr; }
.t-materiali .c-descrizione { grid-column: 1 / -1; }
.testata .campi { grid-template-columns: 1fr 112px; }
.testata .c-cantiere { grid-column: 1 / -1; }
.t-carburante .campi, .t-buste .fr .campi { grid-template-columns: 1fr 120px; }
.t-carburante .c-note, .t-buste .fr .c-note { grid-column: 1 / -1; }

.fisse { padding: 2px 12px; }
.fissa { display: grid; grid-template-columns: 120px 1fr; gap: 4px 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.fissa:first-child { border-top: 0; }
.fissa .nome { grid-column: 1 / -1; font-weight: 650; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.fissa .nome small { font-weight: 500; color: var(--ink-2); font-size: 12.5px; }
.fissa .msg { grid-column: 1 / -1; margin-top: 0; }

@media (min-width: 900px) {
  /* PC: il modulo diventa un elenco di righe dentro un solo riquadro, intestazioni una volta sola */
  /* niente overflow: hidden, se no le tendine dei suggerimenti vengono tagliate al bordo del riquadro */
  .righe { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
  .righe .fr { border: 0; border-radius: 0; border-bottom: 1px solid var(--line); padding: 6px 10px; }
  .righe .fr:first-child { border-top-left-radius: calc(var(--r-lg) - 1px); border-top-right-radius: calc(var(--r-lg) - 1px); }
  .righe .fr:last-child { border-bottom: 0; border-bottom-left-radius: calc(var(--r-lg) - 1px); border-bottom-right-radius: calc(var(--r-lg) - 1px); }
  .righe .fr + .fr .flbl { display: none; }
  .fr-head { min-height: 18px; margin-bottom: 0; font-size: 12px; }
  .scheda-corpo { grid-template-columns: 1.2fr 4.8fr; align-items: start; gap: 8px; }
  .cantieri { gap: 4px; }
  .sub, .piu .sub { grid-template-columns: 1.5fr 80px 1.6fr; border-top: 0; padding-top: 0; }
  .piu .sub { grid-template-columns: 1.5fr 80px 1.6fr var(--ctl); }
  .sub .c-note { grid-column: auto; }
  .sub .c-note .flbl { display: block; }
  .sub + .sub .flbl { display: none; }
  .sub .togli { grid-column: 4; }
  .add.add-sub { justify-self: start; width: auto; padding: 0 12px; }
  .t-materiali .fr .campi { grid-template-columns: 3fr 90px 130px 130px; }
  .t-materiali .c-descrizione { grid-column: auto; }
  .testata .campi { grid-template-columns: 2fr 2fr 1fr; }
  .testata .c-cantiere { grid-column: auto; }
  .t-carburante .campi, .t-buste .fr .campi { grid-template-columns: 1.3fr 140px 2fr; }
  .t-carburante .c-note, .t-buste .fr .c-note { grid-column: auto; }
  .fissa { grid-template-columns: 1.3fr 140px 2fr; align-items: center; padding: 5px 0; }
  .fissa .nome { grid-column: auto; flex-direction: column; gap: 0; align-self: center; }
  .fissa .flbl { display: none; }
  .date-box { display: flex; flex-wrap: wrap; align-items: center; column-gap: 14px; padding: 6px 12px; }
  .date-box .lbl { order: 0; }
  .date-box .date-big, .date-box .mese-nav { margin: 0; min-height: 0; }
  .date-box .date-big .wd { font-size: 22px; }
  .date-box .date-big .dm, .date-box .date-big .y { font-size: 15px; }
  .date-box .msg { flex-basis: 100%; }
  .date-box .mese-nav .date-big { flex: none; }
}

.add {
  width: 100%; min-height: var(--ctl); border-radius: var(--r-md); border: 1.5px dashed var(--line-2); background: none;
  color: var(--ink-2); font-weight: 600; font-size: 13.5px; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; margin-bottom: 10px;
}
.add svg.i { width: 16px; height: 16px; }
.add:hover { border-color: var(--muted); color: var(--ink); }
@media (min-width: 900px) { .modulo > .add { width: auto; padding: 0 14px; } }

.savebar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 10px; margin: 6px calc(-1 * var(--gutter)) 0; padding: 8px var(--gutter);
  background: var(--surface); border-top: 1px solid var(--line-2);
}
.savebar .tot { flex: 1; font-size: 13px; color: var(--ink-2); line-height: 1.2; min-width: 0; }
.savebar .tot b { display: block; font-size: 17px; color: var(--ink); }
.savebar .btn.primary { min-width: 140px; }
@media (min-width: 900px) {
  .savebar { bottom: 0; margin: 6px 0 0; border: 1px solid var(--line-2); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow); }
  .savebar .tot { display: flex; align-items: baseline; gap: 10px; }
  .savebar .tot b { order: -1; }
}

.riepilogo { display: flex; gap: 8px; align-items: flex-start; border-radius: var(--r-md); padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.riepilogo.ko { background: var(--over-bg); color: var(--over-ink); }
.riepilogo.warn { background: var(--warn); color: var(--warn-ink); }
.esito { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: var(--accent-soft); color: var(--ink); border-radius: var(--r-md); padding: 9px 12px; margin-bottom: 10px; font-weight: 550; }
.esito span { flex: 1; min-width: 60%; }
.esito a { color: inherit; font-weight: 650; text-underline-offset: 3px; }

.gia { margin-top: 16px; }
.gia h3, .gruppo h3 { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 2px 2px; }
.gia .li { padding-left: 4px; padding-right: 4px; }

/* completamento nomi */
.scegli { position: relative; }
.ac {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow);
  max-height: 232px; overflow-y: auto; overscroll-behavior: contain;
}
.ac li { padding: 9px 12px; cursor: pointer; }
@media (min-width: 900px) { .ac li { padding: 6px 10px; } }
.ac li.hl { background: var(--accent-soft); }
.ac li:hover { background: var(--surface-2); }
.ac li b { color: var(--accent); font-weight: 750; }
.ac li small { color: var(--muted); }
.ac li.nuovo { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); }
.ac li.vuoto { color: var(--muted); cursor: default; }
.msg-ko { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--ink); }

/* ================= filtri: sul PC una riga sola sopra ciò che filtrano ================= */
.filtri { display: grid; gap: 8px; margin-bottom: 10px; }
.filtri .chips { overflow-x: auto; scrollbar-width: none; }
.filtri-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.filtri .seg { margin: 0; }
@media (min-width: 900px) {
  .filtri { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .filtri-campi { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .filtri .field { display: flex; align-items: center; gap: 6px; }
  .filtri .flbl { margin: 0; font-size: 12.5px; white-space: nowrap; }
  .filtri input[type="date"].inp { width: 136px; }
  .filtri select.inp { width: auto; min-width: 170px; max-width: 240px; }
  .filtri .seg { display: inline-grid; }
  .filtri .seg > * { padding: 0 12px; }
  .filtri .cerca-cant { width: 260px; margin: 0; }
}

/* ================= giornate a tendina (registro, scheda del cantiere) =================
   Un solo riquadro: ogni giornata ha una fascia grigia (tocca per chiudere) e sotto le sue righe. */
.giornate { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 10px; }
details.gruppo { border-top: 1px solid var(--line-2); }
details.gruppo:first-child { border-top: 0; }
details.gruppo > summary {
  display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; user-select: none; -webkit-user-select: none;
  padding: 0 10px; min-height: 34px; background: var(--surface-2);
  font-size: 13px; color: var(--ink-2); font-weight: 650; font-variant-numeric: tabular-nums;
}
details.gruppo > summary::-webkit-details-marker { display: none; }
details.gruppo > summary .t { flex: 1; min-width: 0; }
details.gruppo > summary > span:last-child { color: var(--ink); }
details.gruppo > summary svg.i { flex: none; transition: transform .15s; color: var(--muted); }
details.gruppo[open] > summary svg.i { transform: rotate(90deg); }
details.gruppo[open] > summary { border-bottom: 1px solid var(--line); }
details.gruppo > summary:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, var(--surface-2)); }
details.gruppo .li { padding-left: 32px; padding-right: 10px; }
.tendine-az { margin-left: 8px; padding: 2px 4px; font-weight: 500; }
.cartello .tendine-az { margin: 0; }

/* ================= fase 2: viste e grafici ================= */
.solo-pc { display: none; }
@media (min-width: 900px) { .solo-pc { display: block; } .solo-pc.rapidi-pc { display: flex; } .solo-telefono { display: none !important; } }
.neg { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: var(--r-sm); background: var(--warn); color: var(--warn-ink); font-weight: 650; white-space: nowrap; }
.nota-riga { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.conta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* mese */
.mese-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mese-t { flex: 1; text-align: center; font-size: 20px; font-variation-settings: "wdth" 112; color: var(--muted); }
.mese-t b { color: var(--ink); font-weight: 700; }
.mese-bar .chip { text-decoration: none; color: var(--ink); }
.filtro-attivo { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border-radius: var(--r-md); padding: 6px 10px; margin-bottom: 4px; font-size: 14px; }
.agenda { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px 12px; margin-bottom: 12px; }
.day { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.day:first-of-type { border-top: 0; }
.day .dd { line-height: 1.1; }
.day .dd b { display: block; font-size: 22px; font-variation-settings: "wdth" 80; font-weight: 700; }
.day .dd span { font-size: 12.5px; color: var(--muted); }
.day.sat .dd { background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: var(--r-sm); padding: 2px 4px; }
.day.sun .dd { opacity: .55; background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line) 5px 6px); border-radius: var(--r-sm); padding: 2px 4px; }
.filtro-persona { margin-bottom: 8px; }
.ent { display: grid; grid-template-columns: 1fr auto; font-size: 14.5px; padding: 3px 0; color: inherit; text-decoration: none; }
.ent .p { font-weight: 600; }
.ent .c { color: var(--muted); font-size: 13px; grid-column: 1; }
.ent .h { grid-row: 1 / span 2; grid-column: 2; font-weight: 650; font-variant-numeric: tabular-nums; align-self: center; padding-left: 10px; }
.ent + .ent { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 6px; }
.empty-day { font-size: 13.5px; color: var(--muted); display: block; padding-top: 3px; }

.scorri { overflow-x: auto; }
.griglia { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 13px; font-variation-settings: "wdth" 85; font-variant-numeric: tabular-nums; }
/* colonne fisse: nome, poi i giorni si dividono il resto; sul PC la tabella sta tutta nella pagina */
.griglia col.c-nome { width: 112px; }
.griglia col.c-ore { width: 42px; }
.griglia col.c-sab, .griglia col.c-gg { width: 34px; }
@media (min-width: 1200px) { .griglia col.c-nome { width: 136px; } }
/* sotto questa larghezza i numeri non ci starebbero: allora (finestra stretta, telefono) scorre, con il nome fermo a sinistra */
.griglia { min-width: 840px; }
.griglia th.nome { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.griglia th.g, .griglia td.g { padding-left: 0; padding-right: 0; }
@media (max-width: 1199px) { .griglia tfoot td.g { font-size: 11.5px; } }
@media (max-width: 899px) { .griglia col.c-nome { width: 84px; } }
.griglia th, .griglia td { padding: 4px 2px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.griglia th.nome { text-align: left; padding-right: 8px; font-weight: 600; font-variation-settings: "wdth" 95; overflow: hidden; text-overflow: ellipsis; }
.griglia thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.griglia thead th.g span { display: block; font-size: 10.5px; }
/* sabato: lavorativo, scritte come gli altri giorni, appena ombreggiato; domenica: a righe e attenuata (non conta).
   Ombre ricavate dall'inchiostro del tema attivo: valgono sia in chiaro sia in scuro. */
.griglia .sab { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.griglia .dom { background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--line) 5px 6px); color: var(--muted); }
.griglia thead th.oggi { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.griglia td.g a { color: inherit; text-decoration: none; display: block; font-weight: 600; }
.griglia td.multi a { text-decoration: underline dotted; text-underline-offset: 3px; }
.griglia .n { text-align: right; padding: 4px 6px; }
.griglia tfoot td, .griglia tfoot th { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 600; }

.sum { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin-bottom: 12px; }
.sum dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; max-width: 420px; }
.sum dt { opacity: .75; font-size: 14px; }
.sum dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.sum .big { font-size: 20px; opacity: 1; font-weight: 700; }
.sum p { margin: 10px 0 0; font-size: 12.5px; opacity: .75; max-width: 70ch; }
.pay { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 8px; }
.pay .top { display: flex; justify-content: space-between; align-items: baseline; }
.pay .top b, .pay .top .val { font-size: 17px; font-weight: 700; }
.pay dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 8px 0 0; font-size: 14px; }
.pay dt { color: var(--muted); }
.pay dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.pay .nero { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 3px; font-weight: 650; color: var(--ink); }

.tabella-box { overflow-x: auto; padding: 4px 6px; }
.tabella-box h2 { margin: 6px 6px; }
.tabella-box .blocco-t { padding: 4px 6px 2px; }
.tab { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variation-settings: "wdth" 92; font-variant-numeric: tabular-nums; }
.tab th { text-align: left; font-weight: 650; color: var(--muted); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tab td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
.tab .n { text-align: right; }
@media (hover: hover) { .tab tbody tr:hover td { background: var(--surface-2); } }
.tab tr.spento td { color: var(--muted); }
.tab tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.tab td a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); }
.tab.compatta { font-size: 13px; }
.tab.compatta td, .tab.compatta th { padding: 5px 7px; }
.tabella-box .muted.small { margin: 6px 8px; }

/* cantieri */
.cant { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 9px 12px; margin-bottom: 6px; color: inherit; text-decoration: none; }
.cant-t { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15.5px; margin-bottom: 4px; }
.cant .gb-nome { display: none; }
.cant .gb-riga { grid-template-columns: 1fr auto; }
.cant dl { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 0 12px; margin: 6px 0 0; font-size: 13px; }
.cant dt { color: var(--muted); grid-row: 1; }
.cant dd { margin: 0; grid-row: 2; font-weight: 600; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.cerca-cant { margin-bottom: 10px; }
.filtri .cerca-cant { margin: 0; }
@media (min-width: 900px) { .cerca-cant { max-width: 420px; } }
/* PC: con tanti cantieri la tabella scorre dentro il riquadro, con la sua barra; intestazione e totale restano in vista */
.tab-scorre { max-height: min(62vh, 560px); overflow: auto; scrollbar-width: auto; scrollbar-color: var(--muted) var(--surface-2); }
.tab-scorre.alta { max-height: max(320px, calc(100vh - 250px)); }
.tab-scorre::-webkit-scrollbar { width: 12px; height: 12px; }
.tab-scorre::-webkit-scrollbar-track { background: var(--surface-2); border-left: 1px solid var(--line); }
.tab-scorre::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 6px; border: 3px solid var(--surface-2); }
.tab-scorre thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 0; box-shadow: inset 0 -1px var(--line); }
.tab-scorre tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 0; box-shadow: inset 0 2px var(--ink); }
.anno-nav { display: flex; align-items: center; gap: 6px; }
.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-btn.sm svg.i { width: 16px; height: 16px; }
.scheda-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.scheda-barra .azioni { margin: 0; }
@media (min-width: 900px) { .scheda-barra .azioni { margin-left: auto; } }
.scheda-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--ink-2); font-size: 13.5px; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 7px 10px; margin: 0 0 10px; color: var(--ink-2); }
/* scheda cantiere: costi, lavori, pagamenti, margine in un riquadro largo, numeri grandi */
.riep { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 12px; }
.riep-g { padding: 12px 18px 14px; min-width: 0; border-top: 1px solid var(--line); }
.riep-g:nth-child(-n+2) { border-top: 0; }
.riep-g:nth-child(even) { border-left: 1px solid var(--line); }
@media (min-width: 1100px) {
  .riep { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.15fr); }
  .riep-g { border-top: 0; border-left: 1px solid var(--line); }
  .riep-g:first-child { border-left: 0; }
}
.riep-g h2 { font-size: 12.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
.riep-g dl { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; margin: 0; font-size: 15.5px; }
.riep-g dt { color: var(--ink-2); }
.riep-g dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.riep-g .tot { border-top: 1px solid var(--line-2); padding-top: 6px; margin-top: 3px; font-weight: 700; color: var(--ink); font-size: 16.5px; }
.riep-g p.small { margin: 8px 0 0; }
.riep-g select.inp { margin-top: 8px; }
.riep-v { font-size: 30px; font-weight: 700; font-variation-settings: "wdth" 90; font-variant-numeric: tabular-nums; line-height: 1.2; }
.riep-v .neg { font-size: 24px; padding: 2px 10px; }
.kpi .v .neg { font-size: 16px; }
.due-colonne { display: grid; gap: 4px 16px; }
@media (min-width: 900px) { .due-colonne { grid-template-columns: 1fr 1fr; align-items: start; } }
.sez { font-size: 15px; font-weight: 700; margin: 6px 2px 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sez .muted { font-size: 13px; font-weight: 500; }

/* home: presenze sopra, scadenze sotto (righe su due colonne sul PC largo) */
.home-cols > * { min-width: 0; }
@media (min-width: 1100px) {
  .scad-righe { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); column-gap: 28px; }
  .scad-righe .li:last-child { border-bottom: 1px solid var(--line); }
}
.scad-home .li-t .who { flex: 1; min-width: 0; }
.scad-home .li-t .where { flex: none; white-space: nowrap; }

/* grafici: segni sottili, 2px di stacco nel colore della superficie, estremità arrotondate 4px */
.legenda { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); margin: 2px 0 10px; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.s1 { background: var(--s1); }
.s2 { background: var(--s2); }

.gv { position: relative; height: 190px; margin: 4px 0 0 34px; }
.gv-griglia { position: absolute; inset: 0 0 22px 0; }
.gv-tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.gv-tick span { position: absolute; right: calc(100% + 6px); top: -8px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gv-colonne { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.gv-col { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; border: 0; background: none; padding: 0 0 22px; cursor: pointer; min-width: 0; border-radius: 6px; }
.gv-col:hover, .gv-col.on { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.gv-pila { display: flex; flex-direction: column-reverse; gap: 2px; width: min(24px, 62%); border-radius: 4px 4px 0 0; overflow: hidden; }
.gv-seg { display: block; min-height: 2px; flex-basis: 0; }
.gv-lbl { position: absolute; bottom: 2px; font-size: 11.5px; color: var(--muted); }
.gv-col.on .gv-lbl { color: var(--ink); font-weight: 650; }
.lettura { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 13.5px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lettura span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.lettura .lettura-tot { color: var(--ink); font-weight: 650; }

.gb { display: grid; gap: 2px; }
.gb-riga { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; padding: 6px 4px; border: 0; background: none; border-radius: 8px; color: inherit; text-decoration: none; text-align: left; width: 100%; }
button.gb-riga { cursor: pointer; }
@media (hover: hover) { button.gb-riga:hover { background: var(--surface-2); } }
.gb-riga.on { background: var(--accent-soft); }
.gb-nome { font-weight: 600; font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.gb-nome small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.gb-traccia { display: block; min-width: 0; }
.gb-pila { display: flex; gap: 2px; height: 14px; border-radius: 0 4px 4px 0; overflow: hidden; }
.gb-seg { display: block; min-width: 2px; flex-basis: 0; }
.gb-val { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; font-size: 14px; }
@media (forced-colors: active) { .gv-seg.s2, .gb-seg.s2, .sw.s2 { background: repeating-linear-gradient(45deg, CanvasText 0 2px, Canvas 2px 5px); } }

a.chip { text-decoration: none; color: var(--ink); }
a.chip[aria-pressed="true"] { color: var(--ink); }
.pay dl { column-gap: 0; }
.pay dd { padding-left: 12px; }
.gb-riga { grid-template-columns: minmax(90px, 190px) 1fr auto; }
.altri { margin: 0 0 10px; }

/* ================= fase 3: anagrafiche, parametri, esporta ================= */
.btn.piccolo { padding: 0 12px; }
.barra-az { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.barra-az .cerca { max-width: 260px; }
.spenti .li .who { color: var(--muted); }
.spenti h2 { color: var(--muted); font-size: 13.5px; }
.li svg.i.muted { margin-left: 4px; }
.modulo-ana { display: grid; gap: 10px; padding: 12px; }
@media (min-width: 900px) { .modulo-ana { grid-template-columns: 1fr 1fr; column-gap: 20px; } .campo-ana:has(.area) { grid-column: 1 / -1; } }
.campo-ana .nota { font-size: 12.5px; color: var(--muted); margin: 4px 2px 0; }
.inp.corto { max-width: 180px; }
.inp.area { height: auto; min-height: 72px; padding: 7px 10px; resize: vertical; line-height: 1.4; }
.data-riga { display: flex; align-items: center; gap: 8px; }
.data-riga .inp { max-width: 220px; }
.seg-2 { margin-bottom: 0; max-width: 320px; }
.scegli-um { margin-top: 6px; }
.li-btn { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.li-btn .li-t { display: flex; flex-direction: column; }

/* ================= contabilità: modifica ================= */
.info-pop { width: min(440px, calc(100vw - 32px)); margin: auto; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.info-pop::backdrop { background: rgba(0, 0, 0, .35); }
.info-pop h2 { font-size: 16px; font-weight: 650; }
.info-pop ul { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 8px; font-size: 14.5px; line-height: 1.45; color: var(--ink-2); }
.info-pop b { color: var(--ink); }
.modulo-ana .largo { grid-column: 1 / -1; }
.periodo { display: flex; align-items: center; gap: 8px; }
.periodo .inp { max-width: 200px; }
.link:disabled { opacity: .35; cursor: default; }
.cv-az { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 2px; }
.cv-az .link { padding: 4px 6px; }
.fr.cs { border-left: 4px solid var(--accent); }
.fr.cs .inp { font-weight: 650; }
.cv-campi { display: grid; gap: 8px 10px; grid-template-columns: 70px 1fr 1fr; }
.cv-campi .c-desc { grid-column: 1 / -1; }
.inp.area.auto { min-height: 0; field-sizing: content; }
.m-economia .cv-campi, .m-preventivo .cv-campi { grid-template-columns: 64px 1fr 1fr 1fr; }
.cv-fisso { min-height: 46px; display: flex; align-items: center; padding: 4px 2px; font-weight: 550; overflow-wrap: anywhere; }
.cs-testo { font-weight: 650; padding: 4px 2px; }
.m-misura .cv-campi .calc { font-weight: 600; }
.m-corpo .cv-campi { grid-template-columns: 1fr 150px; }
.m-misura .cv-campi .c-var { grid-column: 2 / -1; }
.cv-giorni { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.cv-giorno, .acconto { display: grid; grid-template-columns: 1fr 90px 42px; gap: 8px; align-items: center; }
/* acconto: telefono su tre righe (descrizione, data e importo, tipo), PC su una */
.acconto { grid-template-columns: 1fr 1fr 42px; grid-template-areas: "desc desc togli" "data imp imp" "tipo tipo tipo"; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px dashed var(--line); }
.acconto .a-desc { grid-area: desc; } .acconto .a-data { grid-area: data; } .acconto .a-tipo { grid-area: tipo; }
.acconto .a-imp { grid-area: imp; } .acconto .a-togli { grid-area: togli; }
.seg.a-tipo { margin: 0; }
.seg.a-tipo > * { padding: 10px 4px; }
.seg.ko { border: 2px solid var(--ink); background: var(--warn); }
.seg.ko > * { color: var(--warn-ink); }
/* contabilità: i totali del PDF in alto */
.tot-doc .kpis { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tot-doc .kpi.forte .v { font-weight: 750; }
.tot-doc p.small { margin: 8px 0 0; }
/* cestino */
.cest { align-items: center; }
.cest .who .tag { margin-right: 4px; vertical-align: 1px; }
.cest-az { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.link.in-riga { padding: 0; font-size: inherit; }
/* contanti in ingresso */
.ct { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: baseline; }
.ct:first-child { border-top: 0; padding-top: 2px; }
.ct-t { min-width: 0; display: flex; flex-direction: column; }
.ct-t a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); }
.ct-t .muted { font-size: 13.5px; }
.ct-note { grid-column: 1 / -1; }
@media (min-width: 900px) { .ct { grid-template-columns: minmax(200px, 1fr) 130px 2fr; align-items: center; } .ct-note { grid-column: auto; } }
.cv-giorno .icon-btn, .acconto .icon-btn { height: 46px; }
@media (min-width: 900px) {
  .m-economia .cv-campi, .m-preventivo .cv-campi { grid-template-columns: 1fr 90px 110px 120px 130px; }
  .m-economia .cv-campi .c-desc, .m-preventivo .cv-campi .c-desc, .m-corpo .cv-campi .c-desc { grid-column: auto; }
  .m-misura .cv-campi { grid-template-columns: 70px repeat(7, 1fr); }
  .m-misura .cv-campi .c-var { grid-column: auto; }
  .cv-giorni { grid-template-columns: repeat(3, 1fr); column-gap: 14px; }
  .cv-giorni .add-sub { grid-column: 1 / -1; }
  .acconto { grid-template-columns: 1.3fr 160px 250px 140px 42px; grid-template-areas: "desc data tipo imp togli"; padding-bottom: 0; border-bottom: 0; }
}

/* ================= contabilità: il foglio A4 =================
   Colori fissi: è carta, non segue il tema. Unità in mm/pt per avere a schermo quello che esce in stampa.
   Impostazione sobria: inchiostro e grigi, nessuna riga verticale; i gruppi di colonne si separano con lo spazio,
   le sezioni con un titolo e il loro totale. Il blu solo nel tipo di documento. */
.anteprima { overflow-x: auto; padding-bottom: 12px; }
.foglio { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 14mm 16mm; background: #fff; box-shadow: var(--shadow); border-radius: 2px; }
.doc { --blu: #2E4A85; --grigio: #5F646B; --riga: #E2E4E7; --riga-2: #B9BDC3; color: #1E2124; font-family: "Archivo", Arial, sans-serif; font-size: 10pt; line-height: 1.38; font-variant-numeric: tabular-nums; }
.doc-testa { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; padding-bottom: 4mm; border-bottom: .75pt solid #1E2124; }
.doc-logo { width: 80mm; height: auto; display: block; }
.doc-rif { text-align: right; font-size: 10pt; padding-bottom: 1mm; line-height: 1.5; }
.doc-tipo { font-size: 8pt; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--blu); margin-bottom: 1.5mm; }
.doc-lbl-in { color: var(--grigio); }
.doc-parti { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin: 5mm 0 0; }
.doc-lbl { font-size: 7.5pt; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--grigio); margin-bottom: 1mm; }
.doc-val { white-space: pre-line; font-size: 10pt; }
.doc-titolo { font-size: 14pt; font-weight: 700; line-height: 1.25; margin: 6mm 0 3mm; color: #1E2124; font-variation-settings: "wdth" 100; letter-spacing: 0; }

.doc-tab { width: 100%; border-collapse: collapse; }
.doc-tab th { font-size: 7.5pt; font-weight: 600; color: var(--grigio); text-align: left; vertical-align: bottom; padding: 1.2mm 1.5mm 1.5mm; white-space: nowrap; }
.doc-tab thead tr:last-child th, .doc-tab thead th[rowspan] { border-bottom: .75pt solid #1E2124; }
.doc-tab th.grp { text-align: center; font-weight: 700; color: #1E2124; padding-bottom: .8mm; }
.doc-tab th.grp::after { content: ""; display: block; height: 0; border-bottom: .5pt solid var(--riga-2); margin-top: .8mm; }
.doc-tab td { padding: 1.6mm 1.5mm; vertical-align: top; border-bottom: .5pt solid var(--riga); }
.doc-tab tr { break-inside: avoid; }
.doc-tab .n { width: 7mm; color: var(--grigio); }
.doc-tab .r { text-align: right; white-space: nowrap; }
.doc.m-economia .doc-tab td.r, .doc.m-economia .doc-tab th.r { width: 21mm; }
.doc.m-corpo .doc-tab td.r, .doc.m-corpo .doc-tab th.r { width: 30mm; }
.doc-desc { white-space: pre-line; }
/* a corpo: la descrizione va a capo a metà colonna, a destra resta spazio libero */
.doc.m-corpo .doc-desc { padding-right: 72mm; }
/* sezioni: titolo in neretto con una riga sotto, nessuna fascia colorata */
.doc-sez td { font-weight: 700; font-size: 8.5pt; letter-spacing: .06em; text-transform: uppercase; color: #1E2124; padding-top: 4.5mm; padding-bottom: 1.2mm; border-bottom: .75pt solid var(--riga-2); }
.doc-tab tbody tr:first-child.doc-sez td { padding-top: 2.5mm; }
.doc-subtot td { font-weight: 600; color: #1E2124; border-bottom: 0; padding-top: 1.4mm; padding-bottom: 1mm; }
.doc-subtot td:nth-child(2) { color: var(--grigio); font-weight: 500; }
.doc-parz td { font-weight: 700; font-size: 10.5pt; border-top: .75pt solid #1E2124; border-bottom: 0; padding-top: 2.4mm; }
.doc-giorni { list-style: none; margin: 1.5mm 0 0; padding: 0; columns: 32mm; column-gap: 6mm; font-size: 9pt; color: #3A3F47; white-space: nowrap; }
.doc-giorni li { display: flex; justify-content: space-between; gap: 2mm; border-bottom: .5pt dotted #C3C7CD; break-inside: avoid; }
/* a misura: dieci colonne, corpo più piccolo. Computato | eseguito | variazione divisi da una riga verticale sottile
   e continua (intestazione, sezioni, voci, totali), con lo stesso spazio ai due lati. */
.doc.m-misura { font-size: 8.6pt; }
.doc.m-misura .doc-tab td, .doc.m-misura .doc-tab th { padding-left: 1.1mm; padding-right: 1.1mm; }
.doc.m-misura .doc-tab td { padding-top: 1.3mm; padding-bottom: 1.3mm; }
.doc.m-misura .doc-tab td.r { width: 15mm; }
.doc.m-misura .doc-tab td.r, .doc.m-misura .doc-tab th.r { padding-left: 2.2mm; }
.doc.m-misura .doc-tab td.doc-var { width: 16mm; }
.doc-tab .sep { border-left: .5pt solid var(--riga-2); padding-left: 2mm !important; }
.doc-tab th.grp.sep { padding-left: 2mm; padding-right: 2mm; }
.doc-tab th.grp.sep::after { margin-left: 0; }
.doc-sez td.sep { border-bottom: .75pt solid var(--riga-2); }
.doc-var { color: #1E2124; }
.doc-zero { color: #A5AAB1; }
/* U.M. una volta per riga, accanto alla descrizione */
.doc-tab td.doc-um { white-space: nowrap; color: var(--grigio); }
.doc-tab th.doc-um { white-space: nowrap; }
.doc-fondo { margin-top: 6mm; }
.doc-totali { margin-left: auto; min-width: 92mm; border-collapse: collapse; break-inside: avoid; font-size: 10pt; }
.doc-totali td { padding: 1.3mm 1.5mm; border-bottom: .5pt solid var(--riga); }
.doc-totali .r { text-align: right; white-space: nowrap; padding-left: 10mm; }
.doc-totali tr.forte td { font-weight: 700; }
.doc-totali .fin td { border-top: .75pt solid #1E2124; border-bottom: 0; padding-top: 2.4mm; font-size: 12pt; font-weight: 700; }
.doc-nota-iva { text-align: right; font-size: 7.5pt; color: var(--grigio); margin-top: 1mm; }
.doc-note { margin-top: 6mm; break-inside: avoid; }
.doc-firma { display: flex; justify-content: flex-end; align-items: flex-end; gap: 10mm; margin-top: 10mm; break-inside: avoid; }
.doc-timbro { text-align: center; }
.doc-firma.con-accettazione { justify-content: space-between; }
.doc-accetta { width: 70mm; }
.doc-riga-firma { border-bottom: .6pt solid #1E2124; height: 22mm; }
.doc-timbro img { display: block; width: 60mm; height: auto; margin-top: 1mm; mix-blend-mode: multiply; }

@media print {
  @page {
    size: A4; margin: 12mm 12mm 14mm;
    @bottom-right { content: "Pagina " counter(page) " di " counter(pages); font: 8pt Arial, sans-serif; color: #5F646B; }
  }
  :root { color-scheme: light !important; }   /* col tema scuro i margini del PDF uscivano neri */
  html, body { background: #fff !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .side, .tabbar, .top, .toast, .savebar, .no-stampa { display: none !important; }
  .app { display: block !important; }
  .main { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .anteprima { overflow: visible; padding: 0; }
  .foglio { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; border-radius: 0; zoom: 1 !important; }
}

/* cantieri | preventivi; collegamento di un preventivo al cantiere */
.seg.schede { max-width: 420px; }
.collegato { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--ink); border-radius: var(--r-md); padding: 9px 12px; margin-bottom: 12px; font-size: 14.5px; font-weight: 550; }
.collegato a { color: inherit; font-weight: 700; text-underline-offset: 3px; }


/* preventivi: filtro, ordinamento, numero in evidenza */
.stato-prev > * { font-size: 13.5px; }
.conta-seg { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.ordina-barra { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 4px; }
.ordina-barra .field { flex: 1; max-width: 240px; }
.ordina-barra .verso { white-space: nowrap; min-height: 44px; font-size: 14px; }
.num-prev { flex: none; min-width: 40px; padding: 4px 6px; border-radius: var(--r-sm); background: var(--surface-2); font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.tab-prev .ordina { color: inherit; text-decoration: none; }
.tab-prev .ordina.on { color: var(--ink); }
.tab-prev td a { color: inherit; }
.tab-scorre:has(.tab-prev) { max-height: none; }

/* computi metrici: caricamento, controllo dei prezzi, nomi brevi */
.inp.file { height: auto; padding: 10px 12px; font-size: 15px; }
.avanza { margin-top: 10px; }
.avanza-t { font-size: 13.5px; color: var(--ink-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.avanza-b { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.avanza-b span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.lista-errori { margin: 6px 0 0; padding-left: 18px; }
.tag.mod { background: var(--accent-soft); color: var(--accent); }
.filtri-cm > * { font-size: 13.5px; }
.tab-cm td { white-space: normal; }
.tab-cm td.n { white-space: nowrap; }
.tab-cm .cm-cod { white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.tab-cm .cm-d { min-width: 260px; }
.tab-cm tr.cm-manca td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
.cm-testo { margin: 0; line-height: 1.4; }
.cm-desc summary { cursor: pointer; list-style: none; line-height: 1.4; }
.cm-desc summary::-webkit-details-marker { display: none; }
.cm-desc .link-sum { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cm-desc[open] .cm-corto { display: none; }
.cm-desc .chiudi, .cm-desc[open] .apri { display: none; }
.cm-desc[open] .chiudi { display: inline; }
.cm-tag { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cm-tag:empty { display: none; }
.cm-sez { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin-bottom: 4px; }
.cm-prezzo { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.cm-prezzo .inp { width: 112px; height: 40px; }
.cm-campi { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 6px; }
.cm-campi .cm-prezzo .inp { width: 100%; }
.cm-nome .field { margin-top: 6px; }
/* consultazione del prezzario */
.pz-cerca { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 900px) { .pz-cerca { grid-template-columns: 1fr 2fr 120px; } }
.pz-campi { align-items: center; margin-top: 10px; }
.pz-altre { margin: 10px 6px 4px; }
/* ricerca nel prezzario sotto una voce del preventivo o della contabilità */
.pz-voce { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.pz-voce .fr-head { margin: 0; }
@media (min-width: 900px) { .pz-cerca-voce { grid-template-columns: 160px 1fr; } .pz-cerca-voce:has(select) { grid-template-columns: 160px 1fr 200px; } }
.pz-risultati { max-height: 360px; overflow-y: auto; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.pz-riga { cursor: pointer; }
/* computo scritto a mano */
.cmm { display: grid; gap: 6px; margin-bottom: 6px; }
.cmm-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.cmm-desc { grid-column: 1 / -1; }
.cmm-tit .cmm-titolo { font-weight: 700; }
.cmm-tit .cmm-sotto { font-weight: 600; }
.cmm-misure { display: grid; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.cmm-misura { display: grid; grid-template-columns: repeat(4, 1fr) 64px 32px; gap: 4px; align-items: center; }
.cmm-misura .cmm-mt { grid-column: 1 / -1; }
.cmm-campi .cm-prezzo { justify-content: stretch; }
.cmm-campi .cm-prezzo .inp { width: 100%; height: auto; }
.cmm-q { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cmm-voce > .add-sub { margin-top: 6px; }
@media (min-width: 900px) {
  .cmm-campi { grid-template-columns: 170px 90px 130px 200px 1fr; }
  .cmm-misura { grid-template-columns: 1fr repeat(4, 84px) 84px 32px; }
  .cmm-misura .cmm-mt { grid-column: auto; }
}
.pz-riga:hover, .pz-riga:focus-visible { background: var(--accent-soft); outline: none; }
