:root {
  --bg: #eef1f4;
  --card: #ffffff;
  --text: #1d2730;
  --muted: #66727e;
  --line: #d6dce2;
  --accent: #c8102e;        /* rosso cantiere */
  --accent-dark: #9c0c23;
  --ok: #1d8a4e;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin-bottom: 12px; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 7px 14px;
  border: 1px solid var(--line); background: var(--btn-bg, #f7f8fa); color: var(--btn-fg, var(--text)); display: inline-block;
}
/* icona a sinistra dell'etichetta */
button > svg.ico, .button > svg.ico { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin-right: .45em; flex-shrink: 0; }
button:hover, .button:hover { border-color: #aab4be; }
/* colori dei pulsanti: predefiniti oppure quelli scelti nelle Preferenze della ditta */
button.primary { background: var(--btn1-bg, var(--accent)); border-color: var(--btn1-bg, var(--accent)); color: var(--btn1-fg, #fff); }
button.primary:hover { background: var(--btn1-bg, var(--accent-dark)); filter: brightness(.92); }
button.danger { background: #fff; border-color: var(--accent); color: var(--accent); }
button.ghost, .button.ghost { background: var(--btn-bg, transparent); }
button.small { padding: 4px 9px; font-size: 12px; }

input, select {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(200, 16, 46, .25); border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.err { color: var(--accent); min-height: 1em; margin: 6px 0; }
.spacer { flex: 1; }

/* login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box {
  background: var(--card); padding: 32px; border-radius: 12px; width: 100%; max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 14px;
}
.login-box h1, .brand { font-weight: 700; letter-spacing: .5px; }
.login-box h1 span, .brand span { color: var(--accent); }
.login-ditta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--bar-bg, #1d2730); color: var(--bar-fg, #fff);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-size: 18px; cursor: pointer; }
/* colori della barra: predefiniti oppure quelli scelti nelle Preferenze della ditta */
.ditta-corrente { display: flex; align-items: center; gap: 8px; padding-left: 16px;
  border-left: 1px solid color-mix(in srgb, var(--bar-fg, #fff) 22%, var(--bar-bg, #1d2730)); }
.ditta-corrente select { width: auto; padding: 4px 8px; color: var(--bar-fg, #fff);
  background: color-mix(in srgb, var(--bar-fg, #fff) 8%, var(--bar-bg, #1d2730));
  border-color: color-mix(in srgb, var(--bar-fg, #fff) 22%, var(--bar-bg, #1d2730)); }
.row-npa { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
.lista tbody tr.clic { cursor: pointer; }
.lista tbody tr.clic:hover td { background: #f6f8fa; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who small { display: block; color: color-mix(in srgb, var(--bar-fg, #fff) 65%, var(--bar-bg, #1d2730)); font-size: 11px; }
.who button, .who button.ghost { color: var(--bar-fg, #fff); background: transparent;
  border-color: color-mix(in srgb, var(--bar-fg, #fff) 22%, var(--bar-bg, #1d2730)); }
.who button:hover { border-color: color-mix(in srgb, var(--bar-fg, #fff) 50%, var(--bar-bg, #1d2730)); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

.screen { padding: 20px; max-width: 1200px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; border: 1px solid var(--line); }

/* menu */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.menu-grid button {
  padding: 22px 14px; background: var(--btn-bg, var(--card)); color: var(--btn-fg, var(--text)); text-align: left; font-weight: 600; font-size: 15px;
  display: flex; align-items: center;
  border-left: 4px solid var(--accent);
}
.menu-grid button > svg.ico { width: 22px; height: 22px; margin-right: 10px; color: var(--accent); }
.menu-grid button:disabled { opacity: .4; cursor: not-allowed; border-left-color: var(--line); }

/* lista utenti */
.table-wrap { overflow-x: auto; }
table.lista { width: 100%; border-collapse: collapse; }
.lista th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.lista td { padding: 5px 8px; border-bottom: 1px solid #edf0f3; vertical-align: middle; }
.lista tr.sel td { background: #fff3f5; }
.lista tr.disattivo td { color: var(--muted); }
.lista td input { padding: 5px 7px; min-width: 110px; }
.lista td.acc { font-weight: 600; white-space: nowrap; }
.lista td.azioni { white-space: nowrap; text-align: right; }
.lista code { color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--ok); }

/* scheda */
.scheda-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.2fr); gap: 24px; }
.campi { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw-row { display: flex; align-items: center; gap: 12px; }
.media { display: flex; flex-direction: column; gap: 14px; }
.media-box { display: flex; flex-direction: column; gap: 6px; }
.media-label { font-size: 12px; color: var(--muted); }
.media-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.foto-frame {
  width: 140px; height: 170px; border: 1px dashed var(--line); border-radius: 6px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; background: #fafbfc; color: var(--muted); font-size: 12px;
}
.foto-frame img { width: 100%; height: 100%; object-fit: cover; }
#firma-canvas {
  width: 100%; max-width: 480px; aspect-ratio: 3 / 1; border: 1px dashed var(--line); border-radius: 6px;
  background: #fff; touch-action: none; cursor: crosshair;
}
fieldset.privilegi { border: 1px solid var(--line); border-radius: 6px; margin: 18px 0 0; padding: 12px 14px; }
legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
.priv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

/* dialog */
dialog { border: none; border-radius: 10px; padding: 24px; width: min(380px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 28, 36, .45); }
#form-pw { display: flex; flex-direction: column; gap: 12px; }

.dlg-avviso { width: min(420px, 92vw); }
.dlg-avviso p { white-space: pre-line; line-height: 1.45; margin: 10px 0 6px; }
button.danger-pieno { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger-pieno:hover { background: var(--accent-dark); }
.frame-stampa { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; }

.rap-campi { display: flex; flex-wrap: wrap; gap: 10px; }
.rap-campi label.num { width: 90px; }
.rap-campi label.num input { text-align: right; }
.rap-campi label.corto { width: 110px; }
.rap-campi label.data { width: 160px; }
.rap-campi input.salvato, .lista.rapporti td input.salvato { background: #e9f7ef; transition: background .6s; }
/* ore degli operai nel rapporto: campi con bordo, numeri allineati a destra sotto le etichette */
.ore-operai td { padding: 4px 8px; }
.ore-operai th.num, .ore-operai td.ore, .ore-operai td.num { text-align: right; }
.ore-operai th.num, .ore-operai td.num { padding-right: 17px; }  /* 8 cella + 1 bordo + 8 campo */
.ore-operai td.ore input { width: 100px; min-width: 0; text-align: right; padding: 5px 8px;
  font-variant-numeric: tabular-nums; border: 1px solid var(--line); background: #fff; }
.ore-operai td.ore input:focus { border-color: var(--accent); }
.ore-operai td.ore input.salvato { background: #e9f7ef; transition: background .6s; }
.ore-operai tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }
.azioni .icona + .icona { margin-left: 2px; }
.nota { font-size: 12px; margin: 10px 0 0; }
#rap-cantiere { display: block; }

/* manodopera e macchinari: colonne strette con il titolo in verticale */
.griglia-bar { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-bottom: 10px; }
.griglia-bar .assegna-bar { margin: 0; }
.griglia-bar .aggiungi { min-width: 220px; }
.g-tit { font-size: 13px; }
table.griglia { width: auto; }
.griglia th, .griglia td { border-bottom: 1px solid #edf0f3; }
.griglia th.gruppo { text-align: center; font-size: 12px; letter-spacing: .5px; color: var(--text);
  border-bottom: 2px solid var(--line); padding: 4px 6px; }
.griglia th.g-macchinari, .griglia .inizio-macchinari { border-left: 2px solid var(--line); }
.griglia th.vert { vertical-align: bottom; text-align: center; padding: 4px 0; width: 30px; min-width: 30px; max-width: 30px; }
.griglia th.vert .vt {
  writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block;
  max-height: 200px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--text);
  font-size: 11.5px; line-height: 1.15;
}
.griglia th.vert .icona { display: block; margin: 4px auto 0; padding: 2px; }
.griglia th.vert .icona svg { width: 12px; height: 12px; }
.griglia th.vuota { color: var(--muted); font-weight: 400; font-size: 12px; vertical-align: bottom; padding: 4px 10px; }
.griglia th.operaio { vertical-align: bottom; }
.griglia td.cella { padding: 2px 0; text-align: center; }
.griglia td.cella input { width: 30px; padding: 3px 1px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums;
  border: 1px solid transparent; border-radius: 3px; background: transparent; min-width: 0; }
.griglia td.cella input:hover { border-color: var(--line); }
.griglia td.cella input:focus { background: #fff; border-color: var(--accent); outline: none; }
/* righe separate in grigio chiaro, sfondo alternato bianco / grigio molto chiaro */
.griglia tbody td { border-bottom: 1px solid #dde2e7; background: #fff; }
.griglia tbody tr:nth-child(even) td { background: #f5f7f9; }
.griglia tbody tr:hover td { background: #edf0f4; }
/* separatori verticali tra le colonne (la linea doppia di inizio macchinari resta) */
.griglia tbody td + td, .griglia tfoot td + td, .griglia th.vert + th.vert { border-left: 1px solid #dde2e7; }
.griglia th.fisso { vertical-align: bottom; white-space: nowrap; }
.griglia .centro { text-align: center; }
.griglia td.pos input, .griglia td.descr input { padding: 4px 6px; border: 1px solid var(--line); background: #fff; min-width: 0; }
.griglia td.pos input { width: 80px; }
.griglia td.descr input { width: 260px; }
.griglia td.pos input:focus, .griglia td.descr input:focus { border-color: var(--accent); outline: none; }
.griglia td.pos input.salvato, .griglia td.descr input.salvato { background: #e9f7ef; transition: background .6s; }
.griglia td { padding: 3px 4px; }
.btn-lr { padding: 3px 9px; font-size: 12px; font-weight: 700; border-radius: 5px; background: #fff; color: var(--muted); }
.btn-lr.attivo { background: var(--accent); border-color: var(--accent); color: #fff; }
.griglia-bar { align-items: center; }
.griglia tfoot td { font-size: 12px; text-align: center; padding: 4px 0; }
.griglia tfoot td:first-child { text-align: left; }
.voci-lista { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.voci-lista li { display: flex; align-items: center; gap: 6px; }
#form-voce input { flex: 1; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1d2730; color: #fff; padding: 10px 18px; border-radius: 6px; transition: transform .25s;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* cantieri */
.cerca { width: 220px; }
.filtro { width: auto; }
.cantiere-grid { display: grid; grid-template-columns: 140px 1fr 160px 150px; gap: 12px; }
.stato { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.stato-in-corso { background: #e3f4ea; color: var(--ok); }
.stato-chiuso { background: #eceff2; color: var(--muted); }
.stato-fatturato { background: #e6eefb; color: #2556a8; }
/* scelta del cantiere */
.scegli-wrap { position: relative; }
.popup-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 380px; max-width: 90vw;
  max-height: 70vh; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 4px; }
.popup-menu .voce-menu { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none;
  background: transparent; color: var(--text); padding: 7px 10px; border-radius: 5px; white-space: nowrap; }
.popup-menu .voce-menu:hover, .popup-menu .voce-menu:focus { background: #f1f3f6; outline: none; }
.popup-menu .voce-menu.sel { background: #fff3f5; }
.popup-menu .voce-menu .vm-num { font-weight: 700; min-width: 72px; }
.popup-menu .voce-menu .vm-nome { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.popup-menu .vuoto { padding: 8px 10px; color: var(--muted); }
.scelta-cantieri { max-height: 60vh; overflow-y: auto; }
#dlg-cantieri .assegna-bar .cerca { width: 260px; }

.assegna-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.aggiungi { width: auto; min-width: 280px; max-width: 100%; }

/* cantieri eliminati: vista alternativa alla lista e alla scheda */
#cantieri:not(.vista-lista) #sez-lista-cantieri,
#cantieri.vista-lista > section:not(#sez-lista-cantieri),
#cantieri.vista-lista .solo-attivi,
#cantieri:not(.vista-eliminati) #sez-cantieri-eliminati,
#cantieri.vista-eliminati > section:not(#sez-cantieri-eliminati),
#cantieri.vista-eliminati .solo-attivi { display: none; }
#sez-cantieri-eliminati .nota { margin: 0 0 10px; font-size: 12px; }
/* lista cantieri: una riga per cantiere con numero, nome, data e stato, conteggi RG / RGM / LR / NM */
#sez-lista-cantieri .sez-azioni select { width: auto; }
#sez-lista-cantieri .sez-azioni input[type=search] { width: 220px; }
.lc-riga { display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; gap: 14px; align-items: end;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lc-riga:hover { background: #f5f7f9; }
.lc-riga.tot { cursor: default; background: #eef1f4; font-weight: 600; }
.lc-lab { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.lc-lab .lc-stato { color: var(--text); white-space: nowrap; }
.lc-val { border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 6px 10px; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-conti { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; }
.lc-conti .lc-n { font-size: 13px; min-height: 18px; color: var(--text); }
.lc-conti button { width: 100%; padding: 6px 0; border-radius: 14px; }
.lc-riga.tot .lc-conti .lc-n { font-size: 14px; }
.lc-riga.tot .lc-conti .lc-sigla { font-size: 12px; color: var(--muted); font-weight: 400; }
@media (max-width: 860px) { .lc-riga { grid-template-columns: 1fr; } }
#sez-lista-cantieri:not(.con-documenti) #doc-cantiere,
#sez-lista-cantieri.con-documenti #lista-cantieri,
#sez-lista-cantieri.con-documenti > .sez-head { display: none; }
.doc-cant-testa { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.doc-cant-testa h4 { margin: 0; font-size: 16px; }
.doc-cant-tab tbody tr { cursor: pointer; }
.doc-cant-tab td:first-child { white-space: nowrap; }  /* tipo del documento */
.doc-cant-tab tbody tr:hover td { background: #f5f7f9; }
.doc-cant-tab td.testo { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sez-azioni { display: flex; align-items: center; gap: 8px; }
.eliminati-box { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.eliminati-box h4 { margin: 0 0 8px; font-size: 13px; }
.eliminati-box td { color: var(--muted); }

/* rapporti e documenti */
.muted { color: var(--muted); font-weight: 400; }
.sez-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sez-head h3 { margin: 0; }
.lista.rapporti td { padding: 3px 4px; }
.lista.rapporti td input { min-width: 0; padding: 4px 6px; border-color: transparent; background: transparent; }
.lista.rapporti td input:hover { border-color: var(--line); }
.lista.rapporti td input:focus { background: #fff; }
.lista.rapporti td.num input { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.lista.rapporti td.nro input { width: 64px; }
.lista.rapporti td.data input { width: 140px; }
.lista.rapporti tr.salvato td { transition: background .6s; background: #e9f7ef; }
.lista.rapporti tfoot td.num { padding-right: 11px; }
.icona { border: none; background: transparent; padding: 5px; color: var(--muted); line-height: 0; border-radius: 5px; }
.icona:hover { color: var(--accent); background: #fdecef; }
.icona svg { width: 17px; height: 17px; }
.dlg-largo { width: min(640px, 94vw); }
#form-documento { display: flex; flex-direction: column; gap: 12px; }
.doc-grid { display: grid; grid-template-columns: 110px 1fr 130px; gap: 12px; }
textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; color: var(--text); }
.file-box { display: flex; flex-direction: column; gap: 6px; }
.file-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.file-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-lista li { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.file-lista li.nuovo { border-style: dashed; }
.file-lista li.da-togliere { opacity: .45; text-decoration: line-through; }
.file-lista img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.file-lista .ico-pdf { width: 40px; height: 40px; border-radius: 4px; background: #fde7ea; color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.file-lista .fn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-lista small { color: var(--muted); }
.drop { border: 1px dashed var(--line); border-radius: 6px; padding: 12px; text-align: center; color: var(--muted); font-size: 12px; }
.drop.sopra { border-color: var(--accent); background: #fff3f5; color: var(--accent); }
.file-links a { display: inline-block; margin-right: 8px; }
.lista th.num, .lista td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lista tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }
.prio { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.prio-Alta { background: #fde7ea; color: var(--accent); }
.prio-Media { background: #fff4dc; color: #8a5a00; }
.prio-Bassa { background: #eceff2; color: var(--muted); }

/* macchinari */
.span-2 { grid-column: span 2; }
.nuovo-macc .m-gruppo { width: 170px; }
.lista.macchinari td select { min-width: 0; width: 150px; padding: 4px 4px; border-color: transparent; background: transparent; }
.lista.macchinari td select:hover { border-color: var(--line); }
.lista.macchinari td select.salvato { background: #e9f7ef; transition: background .6s; }

/* preferenze */
.pref-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.pref-grid .card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.pref-grid .nota { margin: 0; font-size: 12px; }
.pref-grid h3 { margin: 0; }
.gruppi-pref td { padding: 3px 6px; }
.gruppi-pref td input { min-width: 0; padding: 4px 6px; border-color: transparent; background: transparent; }
.gruppi-pref td input:hover { border-color: var(--line); }
.gruppi-pref td input:focus { background: #fff; border-color: var(--accent); }
.gruppi-pref td input.salvato { background: #e9f7ef; transition: background .6s; }
.gruppi-pref td.g-num input, #form-gruppo-pref .g-num { width: 70px; text-align: right; }
.gruppi-pref td.g-nome input { width: 100%; }
.gruppi-pref th:first-child, .gruppi-pref td.g-num { width: 82px; }
.gruppi-pref tbody tr:nth-child(even) td { background: #f7f8fa; }
/* gruppi macchinari e voci: schede alte quanto la riga della griglia; gli elenchi scorrono al loro interno */
.pref-grid .card.gruppi-card, .pref-grid .card[data-voci] { align-self: stretch; }
.gruppi-wrap { flex: 1 1 0; height: 0; min-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.gruppi-wrap thead th { position: sticky; top: 0; z-index: 1; background: #fff; }
#form-gruppo-pref { margin: 0; flex-wrap: nowrap; }
#form-gruppo-pref .g-nome { flex: 1; }
.icona:disabled { opacity: .3; cursor: not-allowed; background: transparent; color: var(--muted); }
#form-colori { display: flex; flex-direction: column; gap: 12px; }
.colori-grid { display: grid; grid-template-columns: 1fr 90px 90px; gap: 8px 12px; align-items: center; }
.colori-grid input[type=color] { height: 36px; padding: 2px; cursor: pointer; }
.anteprima-colori { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px;
  border: 1px dashed var(--line); border-radius: 6px; }
.anteprima-colori .muted { font-size: 12px; margin-right: 4px; }
.anteprima-barra { flex-basis: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 6px;
  background: var(--bar-bg, #1d2730); color: var(--bar-fg, #fff); margin-bottom: 4px; }
.anteprima-barra .brand { font-size: 15px; cursor: default; }
.anteprima-barra .ab-nome { font-size: 12px; font-weight: 700; line-height: 1.1; }
.anteprima-barra .ab-nome small { display: block; font-weight: 400; font-size: 10px;
  color: color-mix(in srgb, var(--bar-fg, #fff) 65%, var(--bar-bg, #1d2730)); }
.anteprima-barra .ab-btn { font-size: 12px; padding: 3px 10px; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--bar-fg, #fff) 22%, var(--bar-bg, #1d2730)); }
#form-colori .err { margin: 0; }
.nuovo-macc .m-codice { width: 120px; }
.nuovo-macc .m-descr { width: 320px; }
.lista.macchinari { font-size: 13px; }
.lista.macchinari th, .lista.macchinari td { padding: 3px 5px; white-space: nowrap; }
.lista.macchinari td.azioni button.small { padding: 3px 7px; }
.lista.macchinari td input { min-width: 0; padding: 4px 6px; border-color: transparent; background: transparent; }
.lista.macchinari td input:hover { border-color: var(--line); }
.lista.macchinari td input:focus { background: #fff; border-color: var(--accent); }
.lista.macchinari td input.salvato { background: #e9f7ef; transition: background .6s; }
#macchinari.screen { max-width: none; }
.lista.macchinari td.m-gruppo input { width: 110px; }
.lista.macchinari td.m-codice input { width: 80px; font-weight: 600; }
.lista.macchinari td.m-descr input { width: 200px; }
.lista.macchinari td.m-cant, .lista.macchinari td.m-dest { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.lista.macchinari td.m-dest { max-width: 130px; }
.lista.macchinari td.dt { line-height: 1.15; font-variant-numeric: tabular-nums; }
.lista.macchinari td.dt small { display: block; color: var(--muted); }
/* i pulsanti restano visibili anche quando la tabella scorre in orizzontale */
.lista.macchinari th:last-child, .lista.macchinari td.azioni { position: sticky; right: 0; background: #fff;
  box-shadow: -6px 0 6px -6px rgba(0,0,0,.18); }
.lista.macchinari tbody tr:nth-child(even) td, .lista.storico tbody tr:nth-child(even) td { background: #f7f8fa; }
.stato-cantiere { background: #e6eefb; color: #2556a8; }
.stato-magazzino { background: #eceff2; color: var(--muted); }
.stato-officina { background: #fff4dc; color: #8a5a00; }
.lista.macchinari td select.stato-sel { width: auto; border: none; padding: 2px 6px 2px 9px; cursor: pointer; font-size: 12px; }
.lista.macchinari td select.stato-sel.stato-magazzino { background: #eceff2; }
.lista.macchinari td select.stato-sel.stato-officina { background: #fff4dc; }
.dlg-storico { width: min(1100px, 96vw); }
.lista.storico { font-size: 13px; }
.lista.storico th, .lista.storico td { white-space: nowrap; padding: 5px 6px; }
.lista.storico td.m-cant { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.lista.storico tr.aperto td { background: #f0f6ff; }
#form-spost { display: flex; flex-direction: column; gap: 12px; }
.spost-grid { display: grid; grid-template-columns: 1fr 1fr 140px; gap: 12px; }
.calc { background: #f7f8fa; font-weight: 600; }
#spost-luogo { margin: -6px 0 0; font-size: 12px; min-height: 1em; }

@media (max-width: 760px) {
  .cantiere-grid { grid-template-columns: 1fr 1fr; }
  .spost-grid { grid-template-columns: 1fr 1fr; }
  .cerca { width: 100%; }
  .scheda-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .who { margin-left: 0; flex-wrap: wrap; }
  .screen { padding: 16px; }
}
.griglia td.centro input[type=checkbox] { min-width: 0; padding: 0; width: 16px; height: 16px; }
/* posizione e descrizione: maiuscolo mostrato con il CSS mentre si scrive, salvato in maiuscolo dal server */
.griglia td.pos input, .griglia td.descr input { text-transform: uppercase; }

/* rapporto lavori a regia */
.regia { max-width: 1060px; }
.regia-top { display: grid; grid-template-columns: 1fr 300px; gap: 24px; margin-bottom: 16px; }
.regia-titolo { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; flex-wrap: wrap; }
.regia-titolo h2 { font-size: 18px; font-weight: 500; letter-spacing: .3px; }
.regia-titolo label { font-size: 16px; color: var(--text); }
.regia-no { width: 110px; }
.regia-campi { display: grid; grid-template-columns: auto minmax(0, 360px); gap: 6px 8px; align-items: center; }
.regia-campi > span { text-align: right; font-size: 12px; color: var(--muted); }
.regia-campi input[readonly] { background: #f3f5f7; color: var(--text); }
.regia-data { width: 170px; }
.regia-radio { display: flex; gap: 18px; }
.regia-radio input { width: auto; accent-color: var(--accent); }
.regia-comm { display: flex; flex-direction: column; gap: 6px; }
.regia-comm > span { font-size: 15px; }
.regia textarea { width: 100%; }
.regia-tab { width: 100%; border-collapse: collapse; table-layout: fixed; }
.regia-tab th { background: #e2e5e9; font-size: 11px; font-weight: 600; text-align: left; padding: 5px 6px;
  border-right: 1px solid #fff; line-height: 1.1; vertical-align: bottom; }
.regia-tab th small { font-weight: 400; }
.regia-tab th.w-n { width: 62px; text-align: center; }
.regia-tab th.w-cat { width: 22%; }
.regia-tab .sep { border-left: 2px solid #c9ced4; }
.regia-tab td { border-bottom: 1px solid #e3e6ea; border-right: 1px solid #eef0f2; padding: 0; }
.regia-tab td input, .regia-tab td select { width: 100%; border: none; border-radius: 0; padding: 5px 6px; background: transparent;
  min-width: 0; font-size: 13px; }
.regia-tab td input:focus, .regia-tab td select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.regia-tab td.n input { text-align: right; font-variant-numeric: tabular-nums; }
.regia-altre { margin: 6px 0 14px; }
.regia-blocco { color: var(--text); font-size: 12px; margin-bottom: 14px; }
.regia-firme { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.regia-firme-tit { display: flex; align-items: center; gap: 22px; font-size: 12px; margin-bottom: 4px; min-height: 22px; }
.regia-firme-tit label { font-size: 12px; }
@media (max-width: 760px) {
  .regia-top, .regia-firme { grid-template-columns: 1fr; }
  .regia-tab { min-width: 860px; }
}
.regia-tab th.w-x { width: 34px; }
.regia-tab td.azioni { text-align: center; border-right: none; }

/* indirizzi */
.lista-alta { max-height: 320px; overflow-y: auto; }
.contatto { max-width: 1000px; }
.contatto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.c-col { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 7px 10px; align-items: center; align-content: start; }
.c-col + .c-col { border-left: 1px solid var(--line); padding-left: 24px; }
.c-lab { text-align: right; font-size: 13px; color: var(--muted); }
.c-riga { display: flex; align-items: center; gap: 6px; }
.c-riga > select, .c-riga > input:not([type=checkbox]) { flex: 1; min-width: 0; }
.c-cap input[name=npa] { flex: 0 0 80px; }
.c-naz select { flex: 1; }
.c-data { width: 170px; }
.c-radio { display: flex; gap: 20px; }
.c-radio.verticale { flex-direction: column; gap: 4px; }
.c-radio input, .c-flag input { width: auto; accent-color: var(--accent); }
.c-flag { display: flex; align-items: center; gap: 8px; }
.c-foto { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: stretch; }
.c-logo { width: 130px; height: 110px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center;
  justify-content: center; overflow: hidden; cursor: pointer; color: var(--muted); font-size: 12px; background: #fff; }
.c-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.c-busta { margin: 0; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 12px;
  white-space: pre-wrap; min-height: 110px; background: #fafbfc; }
#contatto-foto-togli { grid-column: 1; justify-self: start; }
.icona.penna svg { width: 16px; height: 16px; }
#form-lista textarea { width: 100%; font: inherit; }
.regia-comm .c-riga select { flex: 1; }
@media (max-width: 860px) {
  .contatto-grid { grid-template-columns: 1fr; }
  .c-col + .c-col { border-left: none; padding-left: 0; margin-top: 7px; }
}

/* materiale ricevuto / prestazioni / materiale uscito / controlli */
.mov-tab { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 900px; }
.mov-tab th { background: #e2e5e9; font-size: 11px; font-weight: 600; text-align: left; padding: 5px 6px;
  border-right: 1px solid #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-tab th.c { text-align: center; }
.mov-tab td { border-bottom: 1px solid #e3e6ea; border-right: 1px solid #eef0f2; padding: 0; height: 40px; }
.mov-tab td input:not([type=checkbox]):not([type=radio]) { width: 100%; height: 100%; border: none; border-radius: 0;
  padding: 4px 6px; background: transparent; font-size: 12px; text-transform: uppercase; min-width: 0; }
.mov-tab td input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.mov-tab td input.salvato { background: #e9f7ef; transition: background .6s; }
.mov-tab td.c { text-align: center; }
.mov-tab td.c input[type=checkbox], .mov-tab td.c input[type=radio] { width: 17px; height: 17px; accent-color: var(--accent); }
.mov-tab td.n input { text-align: right !important; font-variant-numeric: tabular-nums; }
.mov-tab .w-pos { width: 56px; } .mov-tab .w-flag { width: 38px; } .mov-tab .w-liq { width: 74px; }
.mov-tab .w-boll { width: 80px; } .mov-tab .w-un { width: 64px; } .mov-tab .w-qt { width: 80px; }
.mov-tab .w-c { width: 130px; } .mov-tab .w-ico { width: 132px; } .mov-tab .w-x { width: 34px; }
.mov-tab .w-esito { width: 44px; text-align: center; } .mov-tab .w-visto { width: 90px; }
.mov-ico { display: flex; align-items: center; justify-content: space-around; height: 100%; background: #c8eefb; padding: 0 4px; }
.mov-ico.con-foto { background: #fff6cf; }
.mov-ico .icona { color: #111; padding: 3px; }
.mov-ico .icona svg { width: 22px; height: 22px; }
.mov-ico .miniatura { width: 30px; height: 30px; border: 1px solid #d0d5da; border-radius: 4px; background: #fff;
  overflow: hidden; display: flex; padding: 0; cursor: pointer; }
.mov-ico .miniatura img { width: 100%; height: 100%; object-fit: cover; }
.mov-ico .miniatura:disabled { cursor: default; opacity: .5; }
.esito-lab { float: right; font-weight: 600; }
.controlli-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 14px; align-items: start; }
.ctrl-tab { min-width: 560px; }
.ctrl-tab td { height: 32px; }
.firme-ctrl { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #e3e6ea; }
.firme-col + .firme-col { border-left: 1px solid #e3e6ea; }
.firme-tit { background: #e2e5e9; font-size: 11px; font-weight: 600; padding: 5px 6px; }
.firma-box { padding: 6px; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid #e3e6ea; }
.firma-box label { font-size: 12px; justify-content: space-between; }
.firma-box canvas { width: 100%; aspect-ratio: 360 / 150; background: #fff; border: 1px dashed var(--line);
  border-radius: 4px; touch-action: none; cursor: crosshair; }
.firma-box.alta canvas { aspect-ratio: 360 / 330; }
.firma-box button { align-self: flex-end; }
.dlg-foto { width: min(900px, 94vw); }
.dlg-foto img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto 12px; }
@media (max-width: 1100px) { .controlli-grid { grid-template-columns: 1fr; } }
.popup-menu .voce-menu.disattivo { color: var(--muted); }
#cerca-utente { min-width: 340px; }
/* campi calcolati del rapporto (NM, MR, PE, MU) */
.rap-campi input[readonly], .lista.rapporti td.num input[readonly] { background: #f3f5f7; color: var(--text); cursor: default; }
/* documenti provvisori */
#provvisori-cantiere.screen { max-width: 1640px; }
.prov-tab { min-width: 1440px; }
.prov-tab .w-nr { width: 40px; } .prov-tab .w-data { width: 128px; } .prov-tab .w-team { width: 124px; }
.prov-tab .w-tip { width: 162px; } .prov-tab .w-lav { width: 70px; } .prov-tab .w-nota { width: 168px; }
.prov-tab td select { width: 100%; height: 100%; border: none; border-radius: 0; padding: 0 6px; background: transparent; font: inherit; }
.prov-tab td select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.prov-tab td input[type=date] { padding: 0 6px; }
.btn-nota { white-space: nowrap; background: #fff; color: var(--muted); }
.btn-nota.attivo { background: var(--accent); border-color: var(--accent); color: #fff; }

/* nota di movimento (modulo M-MAG.001) */
.dlg-nota { width: min(1180px, 97vw); }
.nota-top { display: grid; grid-template-columns: 250px 1fr; gap: 22px; margin-bottom: 14px; }
.nota-ditta { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.5; min-height: 96px; }
.nota-riga1 { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; flex-wrap: wrap; }
.nota-riga1 h3 { font-size: 18px; font-weight: 500; letter-spacing: .3px; margin: 0; flex: 1; }
.nota-riga1 label { font-size: 16px; color: var(--text); }
.nota-no { width: 130px; }
.nota-cod { font-size: 16px; }
.nota-campi { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 110px auto 160px; gap: 6px 8px; align-items: center; }
.nota-campi > span, .nota-piede > span { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.nota-tab { min-width: 860px; }
.nota-tab td input { height: 30px; }
.nota-banda { background: #e2e5e9; padding: 6px 8px; margin: 6px 0 14px; }
.nota-piede { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto auto; gap: 8px 10px; align-items: center; }
.nota-piede .regia-radio { gap: 14px; }
@media (max-width: 860px) {
  .nota-top { grid-template-columns: 1fr; }
  .nota-campi, .nota-piede { grid-template-columns: auto minmax(0, 1fr); }
}

/* impiegati */
.impiegato { max-width: 1100px; }
.imp-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.imp-campi { border: none; padding: 0; margin: 0; min-width: 0; }
.imp-blocco { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.c-col .c-lab small { font-size: 11px; }
.imp-utente { align-items: flex-end; }
.imp-sopra { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
.imp-sopra.imp-id { flex: 0 0 80px; }
.imp-sopra input[readonly] { background: #f3f5f7; color: var(--text); }
.imp-corto { max-width: 160px; }
.imp-num { max-width: 200px; text-align: right; font-variant-numeric: tabular-nums; }
.c-loc input[name=npa] { flex: 0 0 90px; }
.lucchetto svg { width: 20px; height: 20px; }
.lucchetto.chiuso { color: var(--accent); }
.imp-firma-box { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.imp-firma { width: 100%; height: 110px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; color: var(--muted); font-size: 12px; overflow: hidden; background: #fff; }
.imp-firma img { max-width: 100%; max-height: 100%; object-fit: contain; }
.imp-campi input:disabled:not([type=checkbox]):not([type=radio]), .imp-campi select:disabled { background: #f3f5f7; color: var(--text); }
.imp-campi input:disabled:not([type=checkbox]):not([type=radio]) ~ .c-logo, .impiegato.bloccato .c-logo, .impiegato.bloccato .imp-firma { cursor: default; }

/* preferenze: elenchi voci manodopera e macchinari */
.voci-wrap { flex: 1 0 360px; height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.voci-pref td.azioni { width: 40px; }
.form-voce-pref .g-nome { flex: 1; }

/* documenti provvisori nella scheda del cantiere */
.provv-cant td { font-size: 12px; }
.provv-cant input.n-rap { width: 70px; padding: 3px 6px; text-align: right; min-width: 0; }
.provv-cant tr.inserito td { color: var(--muted); }
.stato-inserito { background: #e3f4ea; color: var(--ok); }
.stato-attesa { background: #fff4dc; color: #8a5a00; }

/* rapporto macchine */
.rm-top { display: grid; grid-template-columns: 250px 1fr; gap: 22px; margin-bottom: 14px; }
.rm-sx { display: flex; flex-direction: column; gap: 10px; }
.rm-titolo { font-size: 18px; font-weight: 500; letter-spacing: .3px; margin: 0; }
.rm-campi { display: flex; flex-direction: column; gap: 10px; }
.rm-riga { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rm-riga > span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rm-riga input { width: auto; }
.rm-riga .rm-data { width: 170px; }
.rm-riga .rm-largo { flex: 1; min-width: 200px; }
.rm-riga .rm-n { width: 120px; }
.rm-riga .rm-no { font-size: 15px; color: var(--text); }
.rm-riga .rm-cod { font-size: 18px; margin-left: auto; }
.rm-riga .rm-cont { margin-left: auto; }
.rm-riga .rm-num { width: 160px; text-align: right; }
.rm-campi input[readonly] { background: #f3f5f7; color: var(--text); }
.rm-tab th.w-rm { width: 96px; text-align: center; }
.rm-tab tfoot td { background: #e2e5e9; font-weight: 600; font-size: 12px; padding: 6px; text-align: right; }
.rm-tab tfoot td:first-child { text-align: left; }
.rm-firme { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rm-firme .firma-box { border: none; padding: 0; }
.rm-firme .firma-box > span { font-size: 12px; }
.rm-firme canvas { aspect-ratio: 480 / 170; }
@media (max-width: 900px) {
  .rm-top, .rm-firme { grid-template-columns: 1fr; }
}

/* schede delle Preferenze */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs .tab { border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent;
  color: var(--muted); padding: 8px 16px; margin-bottom: -1px; }
.tabs .tab.attivo { background: var(--card); border-color: var(--line); color: var(--text); font-weight: 600; }

/* calendario della registrazione ore */
/* preferenze più larghe delle altre schermate: tipologie orarie e giorni periodo leggibili per intero */
#preferenze.screen { max-width: 1640px; }
.cal-grid { display: grid; grid-template-columns: minmax(540px, 1fr) minmax(780px, 1.5fr); gap: 28px; align-items: start; }
.cal-col { display: flex; flex-direction: column; gap: 18px; }
.cal-anno { display: flex; align-items: center; gap: 10px; margin-left: 150px; }
.cal-anno select { width: 120px; }
.cal-blocco { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; align-items: start; }
.cal-lab { text-align: right; color: var(--muted); font-size: 13px; padding-top: 10px; }
/* tipologie orarie e giorni periodo: etichetta sopra, il riquadro usa tutta la larghezza */
.cal-col-larga .cal-blocco { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.cal-col-larga .cal-lab { text-align: left; padding-top: 0; }
.cal-lista { border: 1px solid var(--line); border-radius: 8px; max-height: 360px; overflow-y: auto; }
.cal-lista.giallo { background: #fdeccc; } .cal-lista.verde { background: #dfe8cf; } .cal-lista.viola { background: #d6cdf6; }
.cal-riga { display: grid; grid-template-columns: 160px minmax(0, 1fr) 36px; align-items: center; gap: 6px;
  padding: 3px 8px; border-bottom: 1px solid rgba(0,0,0,.07); }
.cal-riga input { background: transparent; border-color: transparent; padding: 5px 6px; min-width: 0; }
.cal-riga input:hover { border-color: rgba(0,0,0,.15); }
.cal-riga input:focus { background: #fff; border-color: var(--accent); }
.cal-riga input.salvato { background: #e9f7ef; transition: background .6s; }
.cal-riga.nuova { background: rgba(255,255,255,.45); }
.cal-riga.nuova input { border-color: rgba(0,0,0,.15); background: #fff; }
.cal-tip { padding: 0; margin: 0; max-height: 640px; overflow-y: auto; }
.tip-tab th { font-size: 11px; font-weight: 500; vertical-align: bottom; line-height: 1.2; }
.tip-tab th.t-flag { width: 86px; text-align: center; }
.tip-tab th.t-lock, .tip-tab td.t-lock { width: 38px; text-align: center; }
.tip-tab th.t-id, .tip-tab td.t-id { width: 42px; text-align: center; }
.tip-tab th.t-x, .tip-tab td.t-x { width: 40px; }
.tip-tab td { padding: 4px 6px; }
.tip-tab tbody tr:nth-child(even) td { background: #f7f8fa; }
.tip-tab td.c { text-align: center; }
.tip-tab td.c input { width: 17px; height: 17px; accent-color: var(--accent); }
.tip-tab td input.t-txt { border-color: transparent; background: transparent; padding: 4px 6px; width: 100%; min-width: 210px; }
.tip-tab td input.t-txt:focus { background: #fff; border-color: var(--accent); }
.tip-tab td.nota { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tip-tab td.nota input.t-txt { min-width: 130px; }
.tip-tab td.t-lock svg { width: 16px; height: 16px; vertical-align: middle; }
.cal-periodo { background: #f2cfdf; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-height: 120px; }
.cal-periodo .p-testa { display: grid; grid-template-columns: 1fr 1fr 80px; gap: 8px; align-items: end; margin-bottom: 14px; }
.cal-periodo .p-testa label { color: var(--text); font-size: 12px; }
.cal-periodo .p-anno { padding-bottom: 8px; }
.cal-periodo .p-orari { display: flex; flex-direction: column; gap: 4px; }
.cal-periodo .p-riga { display: grid; grid-template-columns: minmax(270px, 1fr) 26px 72px 20px 72px 34px; gap: 6px; align-items: center; }
.cal-periodo .p-riga span { text-align: right; font-size: 13px; }
.cal-periodo .p-riga span.a { text-align: center; }
.cal-periodo .p-descr { text-align: right; background: transparent; border-color: transparent; }
.cal-periodo .p-riga[data-id] .p-descr:hover { border-color: rgba(0,0,0,.15); }
.cal-periodo .p-descr:focus { background: #fff; border-color: var(--accent); }
.cal-periodo .p-riga.nuova { margin-top: 6px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,.15); }
.cal-periodo .p-riga.nuova .p-descr { background: rgba(255,255,255,.7); border-color: rgba(0,0,0,.15); text-align: left; }
.cal-periodo input { background: rgba(255,255,255,.7); }
.cal-periodo input.p-ora { text-align: center; }
.cal-periodo input.salvato { background: #e9f7ef; transition: background .6s; }
/* sotto questa larghezza le due colonne non stanno affiancate senza tagliare il testo: una sotto l'altra */
@media (max-width: 1480px) { .cal-grid { grid-template-columns: minmax(0, 1fr); } .cal-col { max-width: 1000px; } }
@media (max-width: 640px) {
  .cal-blocco { grid-template-columns: 1fr; } .cal-lab { text-align: left; padding: 0; } .cal-anno { margin-left: 0; }
  .cal-riga { grid-template-columns: 130px minmax(0, 1fr) 36px; }
}

/* limite orario calendario */
.lim-testa { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lim-testa select { width: 120px; }
.lim-card { padding: 6px; }
.lim-tab { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 1100px; }
.lim-tab th { font-size: 12px; font-weight: 500; color: var(--muted); padding: 4px 0; text-align: center; }
.lim-tab th.l-anno, .lim-tab th.l-mese { width: 52px; } .lim-tab th.l-tot { width: 60px; }
.lim-tab td { height: 38px; border: 1px solid #e3e6ea; border-width: 0 1px 1px 0; text-align: center; padding: 0; font-size: 13px; }
.lim-tab td.l-anno, .lim-tab td.l-mese { border: none; color: var(--text); }
.lim-tab tbody tr:nth-child(even) td.l-anno, .lim-tab tbody tr:nth-child(even) td.l-mese { background: #f7f8fa; }
.lim-tab td.fine { background: #e6e7e9; }
.lim-tab td.infrasettimanale { background: #fdeccc; } .lim-tab td.festivo { background: #dfe8cf; } .lim-tab td.ponte { background: #d6cdf6; }
.lim-tab td.vuoto { border: none; background: transparent; }
.lim-tab td.lav input { width: 100%; height: 100%; border: none; border-radius: 0; background: #fff; text-align: center; padding: 0;
  min-width: 0; font-variant-numeric: tabular-nums; }
.lim-tab td.lav input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.lim-tab td.lav input.salvato { background: #e9f7ef; transition: background .6s; }
.lim-tab td.l-tot { background: #dfe8cf; font-weight: 600; }
.rec-card { max-width: 560px; }
.rec-card #cerca-record { margin-bottom: 8px; }
.rec-tab td.num input { width: 110px; text-align: right; }
.rec-tab tr.pieno td { color: var(--accent); font-weight: 600; }
.lim-legenda { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.lim-legenda span { display: flex; align-items: center; gap: 10px; }
.lim-legenda i { display: inline-block; width: 26px; height: 22px; border: 1px solid #c9ced4; border-radius: 3px; }
.lim-legenda i.giallo { background: #fdeccc; } .lim-legenda i.verde { background: #dfe8cf; }
.lim-legenda i.viola { background: #d6cdf6; } .lim-legenda i.grigio { background: #e6e7e9; }
#form-popola { display: flex; flex-direction: column; gap: 10px; }
#form-stampa-rapporti, #form-stampa-rapporto { display: flex; flex-direction: column; gap: 10px; }
.logo-pref { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.logo-box { width: 220px; height: 90px; border: 1px dashed var(--line); border-radius: 8px; display: flex;
  align-items: center; justify-content: center; padding: 6px; background: #fff; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-azioni { display: flex; flex-direction: column; gap: 8px; }
#form-stampa-rapporti .nota, #form-stampa-rapporto .nota { margin: 0; }
#form-popola .popola-ore { width: 70px; text-align: right; }

/* ricerche dal menu */
.ricerca-filtri { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.ricerca-filtri .cerca { width: 260px; }
.ricerca-filtri select { width: auto; max-width: 320px; }
.ricerca-filtri input[type=date] { width: auto; }
/* la pagina Cerca usa tutta la larghezza e scorre intera (niente barra interna) */
#ricerca.screen { max-width: none; }
.ricerca-wrap { overflow-x: auto; overflow-y: visible; }
.ricerca-tab th { background: var(--card); }
.ricerca-tab td { font-size: 13px; }
.ricerca-tab td.c, .ricerca-tab th.c { text-align: center; }
.ricerca-sotto { font-size: 16px; }
.ricerca-corpo.con-pannello { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: start; }
.ricerca-pannello { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 70px; }
.rp-tit { font-size: 12px; color: var(--muted); padding: 4px 8px 6px; }
.rp-voce { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--text); }
.rp-voce:hover { background: #f3f5f7; }
.rp-voce.attiva { background: var(--accent); color: #fff; }
.rp-voce.vuota:not(.attiva) { color: var(--muted); }
.rp-n { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 28px; text-align: center; padding: 1px 7px;
  border-radius: 10px; background: #eceff2; color: var(--text); }
.rp-voce.attiva .rp-n { background: rgba(255,255,255,.25); color: #fff; }
@media (max-width: 900px) { .ricerca-corpo.con-pannello { grid-template-columns: 1fr; } .ricerca-pannello { position: static; } }
/* colonne ridimensionabili */
.ricerca-tab th { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ricerca-tab[style*="fixed"] td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-maniglia { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; touch-action: none; }
.col-maniglia::after { content: ""; position: absolute; top: 25%; right: 3px; height: 50%; border-right: 1px solid var(--line); }
.col-maniglia:hover::after, .ridimensiona .col-maniglia::after { border-right: 2px solid var(--accent); }
.ricerca-tab.ridimensiona { cursor: col-resize; user-select: none; }
/* colonne visibili (ingranaggio) */
.colonne-wrap { position: relative; }
.btn-ingranaggio svg { width: 22px; height: 22px; }
.menu-colonne { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 10px 14px; min-width: 260px; display: flex;
  flex-direction: column; gap: 6px; }
.menu-colonne .mc-tit { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.menu-colonne label { font-size: 13px; }
.menu-colonne input { accent-color: var(--accent); }
.menu-colonne .mc-azioni { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
/* celle modificabili della ricerca */
.ricerca-tab td.mod { padding: 2px 3px; }
.ricerca-tab td.mod input:not([type=checkbox]):not([type=radio]), .ricerca-tab td.mod select { width: 100%; min-width: 60px; padding: 4px 6px;
  border-color: transparent; background: transparent; font-size: 13px; }
.ricerca-tab td.mod input:hover, .ricerca-tab td.mod select:hover { border-color: var(--line); }
.ricerca-tab td.mod input:focus, .ricerca-tab td.mod select:focus { background: #fff; border-color: var(--accent); }
.ricerca-tab td.mod input.salvato, .ricerca-tab td.mod select.salvato { background: #e9f7ef; transition: background .6s; }
.ricerca-tab td.mod input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
.ricerca-tab td.num.mod input { text-align: right; }
.ricerca-tab td.mod input[type=date] { min-width: 130px; }
/* lente sotto NM / GM nelle tabelle del rapporto */
.mov-tab td.flag-cella { vertical-align: top; padding-top: 4px; }
.mov-tab td.flag-cella .lente-allegato { display: block; margin: 2px auto 0; padding: 2px; line-height: 0; }
.mov-tab td.flag-cella .lente-allegato svg { width: 15px; height: 15px; }
.mov-tab td.flag-cella .lente-allegato.attiva { color: var(--accent); }
.ricerca-tab .radio-cella { display: inline-flex; gap: 10px; white-space: nowrap; padding: 0 4px; }
.ricerca-tab .radio-cella label { font-size: 12px; gap: 3px; }
.ricerca-tab .radio-cella input { width: 15px; height: 15px; min-width: 0; padding: 0; margin: 0; accent-color: var(--accent); }
.ricerca-tab .radio-cella input[value="fatturato"]:checked + * , .ricerca-tab .radio-cella label:has(input[value="fatturato"]:checked) { color: var(--ok); font-weight: 600; }

/* ---- barra laterale (menu principale) */
:root { --topbar-h: 54px; --sidebar-w: 236px; }
#app:not(.hidden) { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; align-content: start; }
#app > .topbar { grid-column: 1 / -1; }
#app > .sidebar { grid-column: 1; grid-row: 2; }
#app > .screen { grid-column: 2; grid-row: 2; width: 100%; }
.btn-sidebar { display: none; color: var(--bar-fg, #fff); }
.sidebar { position: sticky; top: var(--topbar-h); align-self: start; height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .sb-gruppo { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 12px 10px 4px; }
.sidebar button.sb-voce { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none;
  background: transparent; color: var(--text); padding: 9px 10px; border-radius: 7px; font-size: 14px; }
.sidebar button.sb-voce:hover { background: #f1f3f6; }
.sidebar .sb-sep { border: none; border-top: 1px solid var(--line); margin: 6px 10px; }
.sidebar button.sb-voce.attiva { background: var(--btn1-bg, var(--accent)); color: var(--btn1-fg, #fff); font-weight: 600; }
.sidebar button.sb-voce > svg.ico { width: 19px; height: 19px; margin: 0; color: var(--accent); flex-shrink: 0; }
.sidebar button.sb-voce.attiva > svg.ico { color: inherit; }
.toolbar > button[data-go="menu"] { display: none; }  /* il menu è sempre nella barra laterale */
@media (max-width: 900px) {
  #app:not(.hidden) { grid-template-columns: minmax(0, 1fr); }
  #app > .screen { grid-column: 1; }
  .btn-sidebar { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); width: 260px; z-index: 40; transform: translateX(-105%);
    transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); height: calc(100vh - var(--topbar-h)); }
  body.sidebar-aperta .sidebar { transform: none; }
}

/* ---- dashboard */
.dash-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.dash-tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; text-align: left;
  display: flex; flex-direction: column; gap: 4px; color: var(--text); cursor: default; }
button.dash-tile { cursor: pointer; font: inherit; }
button.dash-tile:hover { border-color: #aab4be; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.dash-tile .t-lab { font-size: 13px; color: var(--muted); }
.dash-tile .t-val { font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-tile .t-val small { font-size: 16px; font-weight: 500; color: var(--muted); }
.dash-tile .t-sub { font-size: 12px; color: var(--muted); }
/* ore per cantiere, ultimi rapporti e prossimi festivi uno sotto l'altro */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.dash-grid .card { margin: 0; }
.dash-grid h3 .muted { font-weight: 400; }
.barre { display: flex; flex-direction: column; gap: 4px; }
.barra-riga { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); align-items: center; gap: 10px;
  padding: 4px 6px; border-radius: 6px; cursor: default; }
.barra-riga:hover { background: #f6f8fa; }
.barra-nome { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-nome small { color: var(--muted); }
.barra-traccia { display: flex; align-items: center; gap: 8px; }
.barra { height: 14px; background: #2f6fb3; border-radius: 0 4px 4px 0; min-width: 2px; }
.barra-val { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-tabella { margin-top: 10px; font-size: 13px; }
.dash-tabella summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.dash-tooltip { position: fixed; z-index: 50; pointer-events: none; background: #1d2730; color: #fff; font-size: 12px;
  padding: 7px 10px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.2); line-height: 1.45; }
.dash-giorni { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dash-giorni li { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.dash-giorni .g-tipo { font-size: 11px; padding: 2px 8px; border-radius: 10px; color: var(--text); }
.dash-giorni .g-tipo.infrasettimanale { background: #fdeccc; } .dash-giorni .g-tipo.festivo { background: #dfe8cf; }
.dash-giorni .g-tipo.ponte { background: #d6cdf6; }

/* ---- registrazione oraria */
#ore.screen { max-width: none; }
:root { --ore-inv: #f6d79a; --ore-est: #cfe7f6; --ore-ven: #faf0a6; --ore-rosso: #e5534b; }
.ore-testa { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: end; margin-bottom: 14px; }
.ore-legenda { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.ore-legenda div { display: grid; grid-template-columns: 18px 1fr; gap: 2px 8px; align-items: center; }
.ore-legenda i { width: 18px; height: 16px; border: 1px solid #c9ced4; border-radius: 3px; }
.ore-legenda b { grid-column: 2; font-size: 12px; }
.ore-scelta { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.ore-campo { font-size: 12px; color: var(--text); }
.ore-campo input { width: 150px; } .ore-campo select { width: 90px; }
.ore-cantiere-nome { font-weight: 700; font-size: 14px; line-height: 1.2; min-width: 160px; padding-bottom: 4px; }
.btn-stampa-ore svg { width: 30px; height: 30px; color: var(--text); }
.ore-pop { position: absolute; z-index: 35; top: calc(100% + 8px); background: #9fb5ce; border-radius: 8px; padding: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.ore-pop::before { content: ""; position: absolute; top: -8px; left: 22px; border: 8px solid transparent; border-top: 0;
  border-bottom-color: #9fb5ce; }
.pop-fest { left: -40px; width: min(900px, 90vw); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pop-fest h4 { margin: 0 0 6px; text-align: center; font-size: 13px; font-weight: 500; }
.pop-fest ul { list-style: none; margin: 0; padding: 6px 10px; border-radius: 6px; max-height: 360px; overflow-y: auto; font-size: 13px; }
.pop-fest li { display: grid; grid-template-columns: 90px 1fr; gap: 8px; padding: 3px 0; }
.pop-fest ul.infrasettimanale { background: #fdeccc; } .pop-fest ul.festivo { background: #dfe8cf; } .pop-fest ul.ponte { background: #d6cdf6; }
.pop-stampa { right: -20px; left: auto; width: 380px; background: #9fb5ce; }
.pop-stampa::before { left: auto; right: 30px; }
.pop-stampa > * { background: #f2f3f5; }
.pop-stampa .ps-mesi, .pop-stampa .ps-cant, .pop-stampa .ps-voci, .pop-stampa .ps-pagine { padding: 8px 12px; }
.pop-stampa .ps-mesi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-radius: 6px 6px 0 0; }
.pop-stampa label { font-size: 12px; color: var(--text); }
.pop-stampa .ps-cant { display: flex; align-items: flex-end; gap: 8px; }
.pop-stampa .ps-voci { display: flex; flex-direction: column; gap: 6px; }
.pop-stampa .ps-voci button { text-align: left; }
.pop-stampa .ps-pagine { border-radius: 0 0 6px 6px; font-size: 12px; }
.pop-riga { width: 340px; background: #9fb5ce; display: flex; flex-direction: column; gap: 10px; }
.pop-riga label { color: var(--text); font-size: 12px; }
.pop-riga textarea { width: 100%; background: #fff; }
.ore-wrap { overflow-x: auto; }
.ore-tab { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; min-width: 1380px; font-size: 13px; }
.ore-tab col.c-imp { width: 200px; } .ore-tab col.c-tip { width: 180px; } .ore-tab col.c-info { width: 40px; }
.ore-tab col.c-tot { width: 56px; } .ore-tab col.c-x { width: 40px; }
.ore-tab th, .ore-tab td { padding: 0; height: 34px; text-align: center; border-right: 1px solid var(--ore-linea, #b9c0c8);
  border-bottom: 1px solid var(--ore-linea, #b9c0c8); }
.ore-tab tr:first-child td, .ore-tab tr:first-child th { border-top: 1px solid var(--ore-linea, #b9c0c8); }
.ore-tab td:first-child, .ore-tab th:first-child { border-left: 1px solid var(--ore-linea, #b9c0c8); }
.ore-tab tr.dow td { height: 22px; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.ore-tab tr.dow td:first-child { border-top: none; border-left: none; border-bottom: none; }  /* la linea a destra chiude il primo giorno */
.ore-tab tr.dow td:last-child { border-top: none; border-right: none; border-bottom: none; }
.ore-tab th { background: #e2e5e9; font-weight: 500; font-size: 12px; }
.ore-tab .o-imp { width: 210px; text-align: left; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ore-tab .o-tip { width: 190px; text-align: left; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ore-tab .o-info { width: 42px; } .ore-tab .o-tot { width: 58px; font-weight: 600; } .ore-tab .o-x { width: 40px; }
.ore-tab td.o-imp, .ore-tab td.o-tip { font-size: 12px; text-transform: uppercase; }
.ore-tab tr.cal td { height: 30px; font-size: 12px; }
.ore-tab tr.cal td.o-etich { text-align: right; padding-right: 10px; color: var(--muted); font-size: 12px; line-height: 1.1; }
.ore-tab tr.cal td.o-tot, .ore-tab td.o-tot.tot-cal { background: #dfe8cf; }
.ore-tab .fine { background: #e6e7e9; }
.ore-tab .chiuso-infrasettimanale { background: #fdeccc; } .ore-tab .chiuso-festivo { background: #dfe8cf; }
.ore-tab .chiuso-ponte { background: #d6cdf6; }
.ore-tab td.g input { width: 100%; height: 100%; border: none; border-radius: 0; background: transparent; text-align: center; padding: 0;
  min-width: 0; font-variant-numeric: tabular-nums; font-size: 13px; }
.ore-tab td.g input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.ore-tab td.g.s-invernale { background: var(--ore-inv); } .ore-tab td.g.s-estivo { background: var(--ore-est); }
.ore-tab td.g.s-estivo_venerdi { background: var(--ore-ven); }
.ore-tab td.g.diverso { background: var(--ore-diverso, #f8cfcb); } .ore-tab td.g.diverso input { color: #8c1d18; font-weight: 600; }
.ore-tab td.o-tot.muto { color: var(--muted); font-weight: 400; }
.ore-tab tr.cambio-imp td { border-top: 2px solid var(--ore-linea, #b9c0c8); }
.ore-tab th.o-azioni { text-align: left; padding: 0 6px; white-space: nowrap; }
.ore-tab th.o-azioni button { font-size: 12px; padding: 3px 8px; }
.ore-tab .icona.info svg { width: 20px; height: 20px; }
.nuova-ore-tip { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; max-height: 300px; overflow-y: auto; }
#form-nuova-ore { display: flex; flex-direction: column; gap: 10px; }
#wrap-ore-cantieri { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ore-cerca-lab { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; }
#ore-cantiere[readonly] { cursor: pointer; background: #fff; }
#menu-ore-cantieri { max-height: 60vh; overflow-y: auto; }
