/* ================= token =================
   Mai rosso/verde per gli stati: testo + icona + contrasto. Giallo = avviso, inchiostro invertito = scaduto/grave. */
:root {
  --bg: #E7E8E5;          /* calcestruzzo */
  --surface: #F7F7F5;
  --surface-2: #EEEFEC;
  --ink: #1C1E21;
  --ink-2: #4B4F55;
  --muted: #6A6E74;
  --line: #D2D4D0;
  --accent: #2248C4;      /* blu tracciatore */
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE3F8;
  --warn: #F2C230;        /* giallo segnaletica: solo avvisi */
  --warn-ink: #1C1E21;
  --over-bg: #1C1E21;     /* scaduto / grave: massimo contrasto */
  --over-ink: #FFFFFF;
  --r-lg: 14px; --r-md: 10px; --r-sm: 6px;
  --shadow: 0 1px 0 rgba(28,30,33,.06), 0 10px 28px -14px rgba(28,30,33,.28);
  --s1: #2248C4; --s2: #6F8BF0;   /* grafici: manodopera / materiali (lun–ven / sabato) */
  --tabbar-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517; --surface: #1C1D20; --surface-2: #25262A;
    --ink: #ECEDEA; --ink-2: #BFC2C6; --muted: #92969B; --line: #33353A;
    --accent: #8FA5FF; --accent-ink: #10131C; --accent-soft: #252D4A;
    --warn: #F2C230; --warn-ink: #141517;
    --over-bg: #F4F4F2; --over-ink: #141517;
    --s1: #768CF0; --s2: #3050D8;
    --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"] {
  --s1: #768CF0; --s2: #3050D8;
  --bg: #141517; --surface: #1C1D20; --surface-2: #25262A;
  --ink: #ECEDEA; --ink-2: #BFC2C6; --muted: #92969B; --line: #33353A;
  --accent: #8FA5FF; --accent-ink: #10131C; --accent-soft: #252D4A;
  --warn: #F2C230; --warn-ink: #141517;
  --over-bg: #F4F4F2; --over-ink: #141517;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ================= 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: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.val, .num, .inp.r, .calc, .kpi .v, .somma b, .tot b { font-variant-numeric: tabular-nums; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.xs { width: 14px; height: 14px; stroke-width: 2.2; }
svg.i.muted { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ================= impaginazione ================= */
.main { padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); max-width: 1100px; margin: 0 auto; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 14px) 0 14px; }
.top-t { flex: 1; min-width: 0; }
.top h1 { font-size: 28px; font-weight: 700; font-variation-settings: "wdth" 112; letter-spacing: -.015em; line-height: 1.1; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.side { display: none; }

.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: 4px 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: 11.5px; 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: 236px 1fr; min-height: 100vh; }
  .side {
    display: flex; flex-direction: column; gap: 1px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px;
  }
  .side .brand { font-weight: 750; font-variation-settings: "wdth" 120; font-size: 19px; padding: 0 10px 16px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
  .side a:not(.brand) { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-size: 14.5px; }
  .side a svg.i { width: 19px; height: 19px; }
  .side a:not(.brand):hover { background: var(--surface-2); }
  .side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side .grp { font-size: 12.5px; color: var(--muted); padding: 14px 10px 4px; }
  .main { padding: 8px 32px 48px; width: 100%; }
  .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: 14px; margin-bottom: 12px; }
.blocco h2 { font-size: 15.5px; font-weight: 650; margin-bottom: 8px; }
.blocco-t { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.vuoto-box { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-lg); padding: 18px 16px; color: var(--ink-2); margin: 8px 0 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s;
}
.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.06); }
.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: 8px; margin: 8px 0 14px; }
.rapidi .btn { min-height: 44px; font-size: 14px; padding: 0 6px; }
.azioni { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.link { border: 0; background: none; color: var(--muted); font-size: 13.5px; padding: 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 42px; height: 42px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }

.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.grow { margin-left: auto; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg > * { text-align: center; padding: 8px 2px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer; white-space: nowrap; }
.seg > .on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
@media (max-width: 380px) { .seg-4 > * { font-size: 13px; } }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 650; padding: 3px 8px; border-radius: var(--r-sm); white-space: nowrap; }
.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); }

.msg { display: flex; gap: 8px; align-items: flex-start; border-radius: var(--r-md); padding: 7px 10px; font-size: 13.5px; font-weight: 550; margin-top: 8px; line-height: 1.35; }
.msg svg.i { margin-top: 0; }
.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: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.li:last-child { border-bottom: 0; }
@media (hover: hover) { a.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: 13.5px; overflow-wrap: anywhere; }
.li .val { font-weight: 650; white-space: nowrap; text-align: right; }
.elenco-link .li { gap: 12px; justify-content: flex-start; }
.elenco-link h2 { margin: 14px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.elenco-link h2:first-child { margin-top: 0; }

.scad { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.scad:first-of-type { border-top: 0; padding-top: 2px; }
.scad .t { font-weight: 600; }
.scad .d { grid-column: 1; font-size: 13.5px; color: var(--muted); }
.scad .tag { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

.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: 19px; font-weight: 650; font-variation-settings: "wdth" 85; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .l { font-size: 12.5px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 76px);
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: min(92vw, 520px);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 550;
}
.toast.ko { background: var(--warn); color: var(--warn-ink); }
@media (min-width: 900px) { .toast { bottom: 96px; left: calc(50% + 118px); } }

/* ================= moduli ================= */
.field { display: block; min-width: 0; position: relative; }
.flbl { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 3px 2px; }
.inp {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg);
  padding: 0 12px; font-size: 16px; /* 16px: iPhone non zooma */ appearance: none; -webkit-appearance: none;
}
select.inp { padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; 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); background: var(--surface); }
.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: 46px; display: flex; align-items: center; justify-content: flex-end; font-weight: 650; padding: 0 2px; white-space: nowrap; }

/* data: l'elemento più grande del modulo */
.date-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px 14px; margin-bottom: 12px; }
.date-box.ko { border: 2px solid var(--ink); }
.date-box .lbl { font-size: 13px; color: var(--muted); }
.date-big { position: relative; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 12px; min-height: 42px; cursor: pointer; }
.date-big .wd { font-size: 36px; font-weight: 750; font-variation-settings: "wdth" 125; letter-spacing: -.025em; line-height: 1.05; }
.date-big .dm, .date-big .y { font-size: 21px; font-variation-settings: "wdth" 110; }
.date-big .dm { color: var(--ink-2); font-weight: 500; }
.date-big .y { color: var(--muted); }
.date-big .vuota { font-size: 30px; font-weight: 600; font-variation-settings: "wdth" 115; color: var(--muted); letter-spacing: -.02em; line-height: 1.1; }
.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: 10px; }
.mese-nav .date-big { flex: 1; justify-content: center; margin: 2px 0 12px; cursor: default; }

.blocco.testata .campi, .blocco.fisse { margin: 0; }
.righe { display: grid; gap: 8px; margin-bottom: 8px; }
.fr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 12px 12px; }
.fr-head { display: flex; justify-content: space-between; align-items: center; min-height: 28px; margin-bottom: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.campi { display: grid; gap: 8px 10px; }
.t-ore .campi { grid-template-columns: 1fr 92px; }
.t-ore .c-persona, .t-ore .c-note { grid-column: 1 / -1; }
.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 132px; }
.t-carburante .c-note, .t-buste .fr .c-note { grid-column: 1 / -1; }

.fisse { padding: 4px 14px; }
.fissa { display: grid; grid-template-columns: 132px 1fr; gap: 6px 10px; padding: 12px 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: 13px; }
.fissa .msg { grid-column: 1 / -1; margin-top: 0; }

@media (min-width: 900px) {
  .t-ore .campi { grid-template-columns: 1.3fr 1.5fr 92px 1.6fr; }
  .t-ore .c-persona, .t-ore .c-note { grid-column: auto; }
  .t-materiali .fr .campi { grid-template-columns: 3fr 96px 140px 140px; }
  .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 150px 2fr; }
  .t-carburante .c-note, .t-buste .fr .c-note { grid-column: auto; }
  .fissa { grid-template-columns: 1.3fr 150px 2fr; align-items: end; }
  .fissa .nome { grid-column: auto; flex-direction: column; gap: 0; align-self: center; }
  .fissa .flbl { display: none; }
  .fr { padding: 8px 12px 10px; }
  .date-box { display: grid; grid-template-columns: 1fr auto; align-items: end; column-gap: 16px; }
  .date-box .lbl { grid-column: 1 / -1; }
  .date-box .date-big, .date-box .mese-nav { margin-bottom: 0; }
  .date-box .chips { margin-bottom: 4px; }
  .date-box .chip.grow { margin-left: 0; }
  .date-box .msg { grid-column: 1 / -1; }
}

.add {
  width: 100%; min-height: 46px; border-radius: var(--r-md); border: 1.5px dashed var(--line); background: none;
  color: var(--ink-2); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; margin-bottom: 12px;
}
.add:hover { border-color: var(--muted); }

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

.riepilogo { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px; font-size: 14.5px; }
.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: 8px 10px; background: var(--ink); color: var(--bg); border-radius: var(--r-md); padding: 11px 14px; margin-bottom: 12px; font-weight: 550; }
.esito span { flex: 1; min-width: 60%; }
.esito a { color: inherit; font-weight: 650; text-underline-offset: 3px; }

.gia { margin-top: 22px; }
.gia h3, .gruppo h3 { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); font-weight: 600; margin: 0 2px 2px; }
.gia .li, .gruppo .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); border-radius: var(--r-md); box-shadow: var(--shadow);
  max-height: 232px; overflow-y: auto; overscroll-behavior: contain;
}
.ac li { padding: 11px 12px; cursor: pointer; }
.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); }

/* ================= registro ================= */
.filtri { margin-bottom: 12px; }
.filtri .chips { margin-bottom: 10px; }
.filtri-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
@media (min-width: 900px) { .filtri-campi { grid-template-columns: 170px 170px repeat(2, minmax(0, 240px)); } }
.somma { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 2px; border-bottom: 2px solid var(--ink); margin-bottom: 8px; }
.somma b { font-size: 18px; }
.gruppo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 10px 2px; margin-bottom: 10px; }

/* ================= fase 2: viste e grafici ================= */
.solo-pc { display: none; }
@media (min-width: 900px) { .solo-pc { display: block; } .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; }
a.scad { color: inherit; text-decoration: none; }

/* 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 span { color: var(--ink); font-weight: 650; }
.day.sun .dd { opacity: .5; }
.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%; font-size: 13px; font-variation-settings: "wdth" 85; font-variant-numeric: tabular-nums; }
.griglia th, .griglia td { padding: 5px 2px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.griglia th.nome { text-align: left; padding-right: 10px; font-weight: 600; font-variation-settings: "wdth" 95; max-width: 170px; 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; }
.griglia thead th.sab { color: var(--ink); }
.griglia .dom { background: var(--surface-2); color: var(--muted); }
.griglia td.g { min-width: 26px; }
.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: 5px 6px; }
.griglia tfoot td, .griglia tfoot th { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 600; }

.sum { background: var(--ink); color: var(--bg); 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: 6px 8px; }
.tabella-box h2 { margin: 8px 6px; }
.tab { width: 100%; border-collapse: collapse; font-size: 14px; font-variation-settings: "wdth" 92; font-variant-numeric: tabular-nums; }
.tab th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tab td { padding: 9px 10px; 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: 6px 7px; }
.tabella-box .muted.small { margin: 6px 10px; }

/* cantieri */
.cant { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 8px; color: inherit; text-decoration: none; }
.cant-t { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 16.5px; margin-bottom: 6px; }
.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; }
.anno-nav { display: flex; align-items: center; gap: 8px; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.scheda-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--ink-2); font-size: 14px; margin-bottom: 12px; }
.note { background: var(--surface); border-left: 3px solid var(--line); padding: 8px 12px; margin: 0 0 12px; color: var(--ink-2); }
.kpis-6 { grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
@media (min-width: 600px) { .kpis-6 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .kpis-6 { grid-template-columns: repeat(6, 1fr); } }
.kpi .v .neg { font-size: 16px; }
.due-colonne { display: grid; gap: 8px 20px; }
@media (min-width: 900px) { .due-colonne { grid-template-columns: 1fr 1fr; align-items: start; } }
.sez { font-size: 17px; font-weight: 700; margin: 12px 2px 8px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sez .muted { font-size: 14px; font-weight: 500; }

/* 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(--bg); }
.pay dl { column-gap: 0; }
.pay dd { padding-left: 12px; }
.gb-riga { grid-template-columns: minmax(90px, 190px) 1fr auto; }
.altri { margin: 4px 0 12px; }

/* ================= fase 3: anagrafiche, parametri, esporta ================= */
.btn.piccolo { min-height: 40px; padding: 0 14px; font-size: 14px; }
.barra-az { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.barra-az .cerca { max-width: 260px; height: 44px; }
.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: 16px; padding: 16px; }
@media (min-width: 900px) { .modulo-ana { grid-template-columns: 1fr 1fr; column-gap: 24px; } .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: 84px; padding: 10px 12px; 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; }
.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; }
