:root {
  --navy: #173D6C;
  --navy-deep: #122E52;
  --navy-soft: #E7EDF5;
  --gold: #F0B00C;
  --gold-text: #8A661B;
  --red: #A81B1A;
  --paper: #FBFAF7;
  --card: #FFFFFF;
  --ink: #26303B;
  --ink-soft: #56616F;
  --line: #E3DED4;
  --da-fare: #5B6B80;
  --da-fare-bg: #EEF1F5;
  --in-corso: #B7791F;
  --in-corso-bg: #FDF3DC;
  --finito: #2F7D4A;
  --finito-bg: #E3F3E8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 46, 82, .08), 0 2px 8px rgba(18, 46, 82, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
.boot { padding: 40vh 16px 0; text-align: center; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--navy); color: #fff;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 700; letter-spacing: .2px; }
.top h1 small { display: block; font-size: 13px; font-weight: 400; opacity: .8; }
.sync {
  border: 0; border-radius: 999px; padding: 6px 12px;
  background: rgba(255,255,255,.14); color: #fff; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.sync i { width: 9px; height: 9px; border-radius: 50%; background: #5CD08A; display: inline-block; }
.sync.wait i { background: var(--gold); }
.sync.off i { background: #C9CFD6; }
.icon-btn {
  border: 0; background: rgba(255,255,255,.14); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
}

.demo-bar {
  background: #FFF6DA; color: var(--gold-text); font-size: 14px;
  padding: 8px 16px; border-bottom: 1px solid #F1E2B0;
}

/* ---------- Toolbar ---------- */
.bar {
  position: sticky; top: calc(var(--safe-top) + 60px); z-index: 4;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: grid; gap: 10px;
}
.daynav { display: flex; align-items: center; gap: 8px; }
.daynav .arrow {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 22px; color: var(--navy); flex: none;
}
.daylabel {
  position: relative; flex: 1; height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.15; overflow: hidden;
}
.daylabel b { font-size: 17px; display: block; }
.daylabel span { font-size: 13px; color: var(--ink-soft); }
.daylabel input {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; cursor: pointer;
}
.seg { display: flex; background: var(--navy-soft); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 6px;
  font-size: 15px; font-weight: 600; color: var(--navy);
}
.seg button.on { background: var(--card); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 14px; font-size: 15px; white-space: nowrap;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- Lista lavori ---------- */
main { padding: 12px 16px calc(var(--safe-bottom) + 110px); max-width: 720px; margin: 0 auto; }
.day-head {
  margin: 18px 2px 8px; font-size: 15px; font-weight: 700; color: var(--navy);
  display: flex; justify-content: space-between;
}
.day-head:first-child { margin-top: 4px; }
.day-head.today { color: var(--gold-text); }
.empty {
  text-align: center; color: var(--ink-soft); padding: 28px 12px;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--card);
}
.card {
  display: block; width: 100%; text-align: left; border: 0; margin: 0 0 10px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 14px 18px; position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--da-fare); }
.card.in_corso::before { background: var(--in-corso); }
.card.finito::before { background: var(--finito); }
.card.finito .c-cliente { color: var(--ink-soft); }
.c-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.c-ora { font-weight: 700; color: var(--navy); font-size: 15px; }
.c-cliente { font-size: 18px; font-weight: 700; margin: 4px 0 2px; }
.c-ind { color: var(--ink-soft); font-size: 15px; }
.c-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; }
.tag { background: var(--navy-soft); color: var(--navy); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.tag.warn { background: #FBE4E4; color: var(--red); }
.tag.plain { background: transparent; color: var(--ink-soft); padding-left: 0; }
.pill { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pill.da_fare { background: var(--da-fare-bg); color: var(--da-fare); }
.pill.in_corso { background: var(--in-corso-bg); color: var(--in-corso); }
.pill.finito { background: var(--finito-bg); color: var(--finito); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--safe-bottom) + 18px); z-index: 6;
  height: 60px; padding: 0 22px 0 18px; border-radius: 30px; border: 0;
  background: var(--gold); color: var(--navy-deep); font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 18px rgba(18,46,82,.28); display: flex; align-items: center; gap: 8px;
}
.fab span { font-size: 28px; line-height: 1; margin-top: -3px; }

/* ---------- Fogli (dettaglio, modulo) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--paper);
  display: flex; flex-direction: column; animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-top {
  background: var(--navy); color: #fff; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 8px) 8px 8px;
}
.sheet-top h2 { margin: 0; font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { border: 0; background: transparent; color: #fff; font-size: 16px; padding: 10px 12px; display: flex; gap: 4px; align-items: center; }
.back b { font-size: 24px; line-height: 1; margin-top: -2px; }
.top-act { border: 0; background: rgba(255,255,255,.14); color: #fff; border-radius: 10px; padding: 9px 14px; font-size: 15px; font-weight: 600; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(var(--safe-bottom) + 32px); }
.sheet-body > * { max-width: 680px; margin-left: auto; margin-right: auto; }

.d-cliente { font-size: 24px; font-weight: 800; margin: 2px 0 4px; }
.d-when { font-size: 17px; color: var(--navy); font-weight: 600; }
.d-when::first-letter, .day-head span:first-child::first-letter, .daylabel b::first-letter { text-transform: uppercase; }
.box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-top: 14px; }
.box h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); }
.desc { white-space: pre-wrap; }
.actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  font-weight: 700; color: var(--navy); padding: 10px 14px; font-size: 16px;
}
.btn.disabled { opacity: .45; pointer-events: none; }
.btn.big { min-height: 64px; font-size: 19px; width: 100%; border: 0; }
.btn.go { background: var(--navy); color: #fff; }
.btn.done { background: var(--finito); color: #fff; }
.btn.small { min-height: 44px; font-size: 15px; font-weight: 600; }
.btn.danger { color: var(--red); }
.stato-now { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stamp { font-size: 14px; color: var(--ink-soft); margin-top: 8px; }
.stack { display: grid; gap: 10px; }

textarea, input[type=text], input[type=tel], input[type=date], input[type=time], input[type=password], input[type=number] {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px; min-height: 50px; font-size: 17px;
}
textarea { min-height: 96px; resize: vertical; }
textarea:focus, input:focus { outline: 2px solid var(--navy); outline-offset: 0; border-color: var(--navy); }
label.f { display: block; margin-top: 14px; }
label.f > span { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin: 0 0 6px 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick .chip { padding: 11px 16px; font-size: 16px; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.photos button { border: 0; padding: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--navy-soft); position: relative; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .pend { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 2px 6px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; }

.lightbox { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; flex-direction: column; }
.lightbox img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.lightbox .lb-bar { display: flex; justify-content: space-between; padding: calc(var(--safe-top) + 8px) 12px 8px; }
.lightbox .lb-bar button { border: 0; background: rgba(255,255,255,.16); color: #fff; border-radius: 10px; padding: 10px 16px; font-size: 16px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px calc(var(--safe-bottom) + 24px); max-width: 420px; margin: 0 auto; }
.login img { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 12px; display: block; }
.login h1 { text-align: center; margin: 0 0 4px; color: var(--navy); }
.login p { text-align: center; margin: 0 0 18px; }
.login .btn { margin-top: 18px; }
.who { display: grid; gap: 8px; }
.who button { justify-content: space-between; }
.err { color: var(--red); text-align: center; margin-top: 12px; min-height: 1.4em; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 92px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 760px) {
  .bar { padding-left: max(16px, calc(50% - 344px)); padding-right: max(16px, calc(50% - 344px)); }
}

/* ================= Versione 1 ================= */
main { padding-bottom: calc(var(--safe-bottom) + 170px); }
.fab { bottom: calc(var(--safe-bottom) + 84px); }
#toast { bottom: calc(var(--safe-bottom) + 160px); }

/* Barra in basso */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
}
.tabs button {
  border: 0; background: transparent; padding: 6px 4px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 13px; font-weight: 700; color: var(--ink-soft); position: relative;
}
.tabs button span { font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--navy); background: var(--navy-soft); }
.tabs button.on span { filter: none; opacity: 1; }
.tabs em {
  position: absolute; top: 2px; left: calc(50% + 8px); font-style: normal;
  background: var(--red); color: #fff; font-size: 12px; min-width: 20px; height: 20px;
  border-radius: 10px; padding: 0 6px; display: flex; align-items: center; justify-content: center;
}
.bar { top: calc(var(--safe-top) + 60px); }
.hint { font-size: 14px; color: var(--ink-soft); }

/* Urgente e più giorni */
.urg { background: var(--red); color: #fff; border-radius: 5px; padding: 1px 6px; font-size: 12px; letter-spacing: .4px; margin-right: 4px; }
.c-multi { font-size: 14px; color: var(--gold-text); font-weight: 600; margin-top: 3px; }
.tag.mat { background: #FFF1CC; color: var(--gold-text); font-weight: 700; }
.assenti { background: #FFF6DA; border: 1px solid #F1E2B0; color: var(--gold-text); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin-bottom: 10px; }
.chip.assente { border-style: dashed; color: var(--ink-soft); }
.chip.assente small { color: var(--red); font-weight: 700; }
.chip.assente.on { color: #fff; background: var(--red); border-color: var(--red); }
.chip.assente.on small { color: #fff; }
.lbl { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin: 14px 0 6px 2px; }

/* Materiale */
.mat { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.box > .mat:first-of-type, .g-head + .mat { border-top: 0; }
.mat .check {
  flex: none; width: 34px; height: 34px; border-radius: 9px; border: 2px solid var(--line-strong, #D3CBBC);
  background: #fff; color: #fff; font-size: 20px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.mat .check:disabled { opacity: 1; cursor: default; }
.mat.preso .check { background: var(--finito); border-color: var(--finito); }
.m-txt { flex: 1; min-width: 0; font-size: 17px; }
.m-txt small { display: block; font-size: 13px; color: var(--ink-soft); }
.mat.preso .m-txt > div { text-decoration: line-through; color: var(--ink-soft); }
.x { flex: none; border: 0; background: transparent; color: var(--ink-soft); font-size: 18px; width: 36px; height: 36px; border-radius: 50%; }
.addrow { display: flex; gap: 8px; margin-top: 10px; }
.addrow input { flex: 1; min-width: 0; }
.addrow .btn { flex: none; }
.group { padding-top: 6px; }
.g-head { width: 100%; border: 0; background: transparent; text-align: left; padding: 6px 0 10px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.g-head > div { flex: 1; min-width: 0; }
.g-head b { display: block; font-size: 17px; }
.g-head small { display: block; color: var(--ink-soft); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-head > span { font-size: 24px; color: var(--navy); }

/* Note */
.nota { background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--line); }
main > .nota { box-shadow: var(--shadow); border: 0; }
.nota.mia { background: #F3F7FC; }
.n-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.n-head span { color: var(--ink-soft); }
.n-lav { border: 0; background: transparent; padding: 0 0 4px; font-weight: 800; color: var(--navy); font-size: 16px; }
.nota audio { width: 100%; height: 40px; margin: 4px 0; }
.n-act { display: flex; gap: 14px; margin-top: 6px; }
.n-act button { border: 0; background: transparent; padding: 4px 0; color: var(--navy); font-size: 14px; font-weight: 600; }
.n-act button:last-child { color: var(--ink-soft); }
.rec {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px;
  background: #FBE4E4; color: var(--red); border-radius: 12px; font-size: 15px; flex-wrap: wrap;
}
.rec b { font-variant-numeric: tabular-nums; margin-right: auto; }
.rec .btn { min-height: 42px; }
.rec .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Assenze */
select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px; min-height: 50px; font-size: 17px; }
.ass-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.ass-row:first-of-type { border-top: 0; }
.ass-row > div { flex: 1; }

/* ================= Tabellone, settori, regole ================= */
:root { --privati: #173D6C; --privati-bg: #E3ECF7; --minuto: #B3261E; --minuto-bg: #FBE3E0; --sovrapp: #F08C00; }
.tabs { grid-template-columns: repeat(4, 1fr); }
.tag.set-privati { background: var(--privati-bg); color: var(--privati); font-weight: 700; }
.tag.set-minuto { background: var(--minuto-bg); color: var(--minuto); font-weight: 700; }
.chip.set-privati.on { background: var(--privati); border-color: var(--privati); }
.chip.set-minuto.on { background: var(--minuto); border-color: var(--minuto); }
.set-seg button.set-privati.on { background: var(--privati); color: #fff; }
.set-seg button.set-minuto.on { background: var(--minuto); color: #fff; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.quick .chip { padding: 7px 12px; font-size: 14px; }

main.wide { max-width: none; padding-left: 0; padding-right: 0; }
main.wide > .legend, main.wide > .hint { padding: 0 16px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .set-privati::before { background: var(--privati); }
.legend .set-minuto::before { background: var(--minuto); }
.legend .lg-conf::before { display: none; }
.legend .lg-conf { color: var(--sovrapp); font-weight: 700; }
.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); }
.grid { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th { position: sticky; top: 0; background: var(--paper); font-size: 16px; font-weight: 800; color: var(--navy); padding: 6px 4px; text-align: center; min-width: 118px; }
.grid thead th small { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; }
.grid thead th.today { background: #FFF1CC; }
.grid .g-name {
  position: sticky; left: 0; z-index: 2; background: var(--paper); min-width: 84px; max-width: 84px;
  font-size: 14px; font-weight: 700; text-align: left; padding: 8px 6px; color: var(--ink);
  box-shadow: 2px 0 4px rgba(18,46,82,.06);
}
.grid thead .g-name { z-index: 3; }
.grid tr.g-me .g-name { color: var(--gold-text); }
.grid tr.g-liberi .g-name { color: var(--red); }
.grid tr.g-liberi td { background: #FFF8F8; }
.grid td { padding: 4px; min-width: 118px; height: 64px; }
.grid td.today { background: #FFFBEF; }
.grid td.g-assente { background: repeating-linear-gradient(135deg, #F6F2EA 0 8px, #EFE9DD 8px 16px); }
.g-ass { font-size: 12px; font-weight: 700; color: var(--gold-text); padding: 2px 4px; }
.g-job {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 8px; margin-bottom: 4px;
  padding: 5px 6px; font-size: 12px; line-height: 1.25; color: #fff; background: var(--privati);
}
.g-job.set-minuto { background: var(--minuto); }
.g-job span { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 108px; }
.g-job.st-finito { opacity: .45; }
.g-job.conf { outline: 3px solid var(--sovrapp); outline-offset: -1px; }
.g-add { display: block; width: 100%; border: 1px dashed var(--line); background: transparent; color: var(--ink-soft); border-radius: 8px; font-size: 18px; padding: 2px 0; opacity: .55; }
.g-add:hover { opacity: 1; }

.nota.auto { background: #FFF6DA; border-color: #F1E2B0; }
.nota.nuova { box-shadow: inset 4px 0 0 var(--gold), var(--shadow); }

details.regola summary { list-style: none; display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 17px; cursor: pointer; }
details.regola summary::-webkit-details-marker { display: none; }
details.regola summary::after { content: "›"; font-size: 24px; color: var(--navy); transform: rotate(90deg); transition: .15s; margin-left: 8px; }
details.regola:not([open]) summary::after { transform: none; }
details.regola summary small { margin-left: auto; color: var(--ink-soft); font-weight: 600; }
details.regola[open] summary { margin-bottom: 8px; }
.regole-list { margin: 0; padding-left: 22px; }
.regole-list li { margin: 8px 0; }

/* ================= Liste in foto/voce, zoom, squadre ================= */
.m-foto { display: block; border: 0; padding: 0; background: var(--navy-soft); border-radius: 10px; overflow: hidden; width: 100%; max-width: 320px; margin-bottom: 6px; position: relative; }
.m-foto img { display: block; width: 100%; max-height: 220px; object-fit: cover; object-position: top; }
.m-foto span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(18,46,82,.75); color: #fff; font-size: 13px; font-weight: 700; padding: 5px 8px; }
.m-txt audio { width: 100%; height: 40px; margin-bottom: 4px; }
.m-edit { border: 0; background: transparent; color: var(--navy); font-weight: 700; font-size: 14px; padding: 2px 0 4px; }
.mat { align-items: flex-start; }
.mat .check { margin-top: 2px; }
.lb-bar { align-items: center; gap: 8px; }
.lb-zoom { display: flex; gap: 8px; }
.lb-zoom button { min-width: 48px; font-size: 22px !important; font-weight: 700; }
.lb-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: manipulation; -webkit-overflow-scrolling: touch; }
.lb-scroll.zoomed { display: block; }
.lb-scroll img { flex: none; max-width: none; height: auto; display: block; margin: auto; object-fit: contain; }
.lb-scroll:not(.zoomed) img { max-height: 100%; width: auto !important; max-width: 100%; }

.g-name button { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; text-align: left; display: flex; flex-direction: column; gap: 3px; width: 100%; }
.g-name .t { font-size: 11px; font-weight: 800; border-radius: 5px; padding: 1px 5px; color: #fff; width: fit-content; }
.g-name .t.privati { background: var(--privati); }
.g-name .t.minuto { background: var(--minuto); }
.g-name .t.nessuno { background: transparent; color: var(--ink-soft); border: 1px dashed var(--line); font-weight: 600; }
.grid tr.tr-privati .g-name { box-shadow: inset 4px 0 0 var(--privati), 2px 0 4px rgba(18,46,82,.06); }
.grid tr.tr-minuto .g-name { box-shadow: inset 4px 0 0 var(--minuto), 2px 0 4px rgba(18,46,82,.06); }
.grid tr.tr-minuto td { background-color: #FDF3F2; }
.grid tr.tr-privati td { background-color: #F6F9FD; }
.copy-turni { margin: 0 16px 10px; }
.chip small.alt { color: var(--minuto); }

/* Squadre giorno per giorno */
.grid td.c-privati { background-color: #F3F7FC; }
.grid td.c-minuto { background-color: #FCEDEB; }
.grid td.today.c-privati, .grid td.today.c-minuto { box-shadow: inset 0 0 0 2px #F5D27A; }
.g-sq { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 3px 2px; }
.g-sq.privati { color: var(--privati); }
.g-sq.minuto { color: var(--minuto); }
.g-name .t.misto { background: linear-gradient(90deg, var(--privati) 50%, var(--minuto) 50%); }
.sq-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.sq-row:first-of-type { border-top: 0; }
.sq-row.today .sq-day { color: var(--gold-text); }
.sq-day { width: 92px; flex: none; font-weight: 700; text-transform: capitalize; }
.sq-day small { display: block; font-size: 12px; color: var(--red); text-transform: none; }
.sq-row .seg { flex: 1; }
.set-seg button:not(.set-privati):not(.set-minuto).on { background: var(--card); color: var(--ink); }

/* Nessuno sparisce: altra squadra in fondo, gruppi nel modulo */
.grid tr.g-fuori th, .grid tr.g-fuori td { opacity: .5; }
.grid tr.g-sep th, .grid tr.g-sep td { background: var(--paper); height: auto; padding: 10px 6px 4px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); border-right: 0; }
.pick-h { flex-basis: 100%; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); margin: 8px 0 0 2px; }
.pick-h:first-child { margin-top: 0; }

/* Materiale generico per squadra */
.dot-set { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.dot-set.minuto { background: var(--minuto); }
.dot-set.privati { background: var(--privati); }
.group.gen-minuto { box-shadow: inset 4px 0 0 var(--minuto), var(--shadow); }
.group.gen-privati { box-shadow: inset 4px 0 0 var(--privati), var(--shadow); }
.bar > .btn.go { width: 100%; }

/* ---------- Materiale: urgente per cantiere / scorta magazzino ---------- */
.tag.mat-urg { background: var(--red); color: #fff; font-weight: 700; }
.mat-seg button em {
  font-style: normal; background: var(--red); color: #fff; font-size: 12px; border-radius: 10px;
  padding: 1px 7px; margin-left: 2px; vertical-align: 1px;
}
.mat-seg button.v-urg.on { color: var(--red); }
.group.urg-group { box-shadow: inset 4px 0 0 var(--red), var(--shadow); }
.m-tipo {
  display: inline-flex; align-items: center; gap: 4px; margin: 4px 0 2px; border: 0; border-radius: 6px;
  padding: 3px 8px; font-size: 13px; font-weight: 700; background: var(--navy-soft); color: var(--navy);
}
.m-tipo.urgente { background: #FBE3E2; color: var(--red); }
.m-tipo i { font-style: normal; opacity: .6; }
.mat.preso .m-tipo { opacity: .6; }
.tipo-seg { margin: 10px 0 2px; }
.tipo-seg button { font-size: 14px; padding: 8px 4px; }
.tipo-seg button.t-urgente.on { background: var(--red); color: #fff; }

/* ---------- Lavori da pianificare e carico di lavoro ---------- */
.vista-seg button { font-size: 14px; padding: 9px 4px; }
.vista-seg button em {
  font-style: normal; background: var(--navy); color: #fff; font-size: 12px; border-radius: 10px;
  padding: 1px 7px; margin-left: 2px; vertical-align: 1px;
}
.bk-tot { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px 10px 16px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.bk-tot.set-privati { box-shadow: inset 4px 0 0 var(--privati), var(--shadow); }
.bk-tot.set-minuto { box-shadow: inset 4px 0 0 var(--minuto), var(--shadow); }
.bk-tot span { font-size: 14px; color: var(--ink-soft); }
.bk-tot span b { color: var(--ink); }
.carico { width: 100%; border-collapse: collapse; font-size: 14px; }
.carico th, .carico td { padding: 6px 2px; text-align: center; border-bottom: 1px solid var(--line); }
.carico th:first-child, .carico td:first-child { text-align: left; font-weight: 600; white-space: nowrap; padding-left: 8px; }
.carico td.n-privati { box-shadow: inset 3px 0 0 var(--privati); }
.carico td.n-minuto { box-shadow: inset 3px 0 0 var(--minuto); }
.carico thead button { border: 0; background: none; font-weight: 700; color: var(--navy); padding: 2px; font-size: 13px; }
.carico td span { display: inline-block; min-width: 44px; border-radius: 6px; padding: 2px 4px; font-weight: 700; }
.carico .l-libero span { background: var(--finito-bg); color: var(--finito); }
.carico .l-medio span { background: var(--in-corso-bg); color: var(--in-corso); }
.carico .l-pieno span { background: #FBE4E4; color: var(--red); }
.carico .l-assente span { color: var(--ink-soft); font-weight: 400; font-size: 12px; }
.carico tr.c-tot td { border-bottom: 0; color: var(--navy); }
.bk-h { margin: 20px 2px 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); }
.card.bk { padding: 0; }
.card.bk::before { background: var(--privati); }
.card.bk.set-minuto::before { background: var(--minuto); }
.bk-main { display: block; border: 0; background: none; text-align: left; padding: 14px 14px 6px 18px; width: 100%; }
.bk-desc { font-size: 15px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; }
.card.bk > .btn { display: block; width: calc(100% - 32px); margin: 4px 14px 14px 18px; border: 0; }
.bk-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 4px; align-items: center; }
.bk-strip > b { font-size: 13px; color: var(--ink-soft); flex: none; }
.bk-chip { flex: none; border: 2px solid var(--privati); background: var(--card); color: var(--privati); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; cursor: grab; }
.bk-chip small { font-weight: 600; opacity: .75; }
.bk-chip.set-minuto { border-color: var(--minuto); color: var(--minuto); }
.bk-chip.on { background: var(--privati); color: #fff; }
.bk-chip.set-minuto.on { background: var(--minuto); }
.piazza-bar { background: #FFF1CC; color: var(--gold-text); border-radius: 12px; padding: 8px 10px 8px 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; font-size: 15px; }
.piazza-bar span { flex: 1; }
.piazzando .g-add { opacity: 1; border: 2px dashed var(--gold); color: var(--gold-text); background: #FFFBEF; font-weight: 800; }
.grid td.drop-on { box-shadow: inset 0 0 0 3px var(--gold) !important; }
.modo-seg { margin-bottom: 4px; }
#modulo .solo-coda { display: none; }
#modulo.coda .solo-coda { display: block; }
#modulo.coda .solo-data { display: none; }
.grid td.g-riposo { background: repeating-linear-gradient(135deg, #F4F4F4 0 8px, #ECECEC 8px 16px); }
.carico small.gl { display: block; font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.gl-seg button { font-size: 14px; padding: 9px 2px; }
.gl-seg button.on { background: var(--navy); color: #fff; }
