/* SABBA Productions: carta chiara o corpo camera scuro, accento rosso REC del marchio. Il rosso pieno resta per i pulsanti principali, il tally "Motore" usa lo stesso rosso. */
:root {
  --bg: #F2F1EE; --surface: #ffffff; --raised: #f7f6f3; --line: #e1dfda; --line-strong: #cfccc5;
  --text: #101113; --muted: #5f6166; --accent: #C23B2E; --accent-bg: #C23B2E; --accent-ink: #ffffff;
  --ok: #23855a; --ok-bg: #e2f3ea; --warn: #9a6400; --warn-bg: #fbf0d9; --bad: #c4372e; --bad-bg: #fbe5e3;
  --info: #2c69b0; --info-bg: #e3eef9; --tally: #e0352b; --focus: #2c69b0;
  --slate-bg: #1c1e21; --slate-text: #f3f1ec; --slate-line: #3a3e44;
  --radius-l: 14px; --radius: 10px; --radius-s: 7px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101113; --surface: #191a1d; --raised: #212226; --line: #2c2d32; --line-strong: #3a3b41;
    --text: #EDEDED; --muted: #9c9ea4; --accent: #E2675B; --accent-bg: #E2675B; --accent-ink: #101113;
    --ok: #5fc08f; --ok-bg: #173327; --warn: #eab052; --warn-bg: #3a2c12; --bad: #f0685f; --bad-bg: #3d1a18;
    --info: #79aef0; --info-bg: #182a40; --focus: #79aef0;
    --slate-bg: #0a0b0c; --slate-line: #2c2d32; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101113; --surface: #191a1d; --raised: #212226; --line: #2c2d32; --line-strong: #3a3b41;
  --text: #EDEDED; --muted: #9c9ea4; --accent: #E2675B; --accent-bg: #E2675B; --accent-ink: #101113;
  --ok: #5fc08f; --ok-bg: #173327; --warn: #eab052; --warn-bg: #3a2c12; --bad: #f0685f; --bad-bg: #3d1a18;
  --info: #79aef0; --info-bg: #182a40; --focus: #79aef0;
  --slate-bg: #0a0b0c; --slate-line: #2c2d32; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
body.locked { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0 0 .6em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 600; } .block { display: block; }
.mono { font-family: var(--mono); font-size: .92em; } .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error { color: var(--bad); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- struttura */
.shell { min-height: 100vh; }
.rail { display: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.main { padding: 0 16px calc(env(safe-area-inset-bottom) + 88px); max-width: 1180px; margin: 0 auto; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 48px;
  color: var(--muted); font-size: 11px; background: none; border: 0; text-decoration: none; }
.tabbar .on { color: var(--accent); }
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .topbar, .tabbar { display: none; }
  .rail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; padding: 20px 12px;
    border-right: 1px solid var(--line); background: var(--surface); }
  .rail nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
  .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-s); color: var(--text); }
  .nav-item:hover { background: var(--raised); text-decoration: none; }
  .nav-item.on { background: var(--raised); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
  .nav-item .ico { width: 20px; height: 20px; }
  .rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
  .main { padding: 0 32px 48px; width: 100%; }
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; padding: 0 6px; }
.logo { display: inline-flex; align-items: center; flex: none; }
.logo-img { height: 34px; width: auto; display: none; }
.logo.big .logo-img { height: 48px; }
.topbar .logo-img { height: 28px; }
.logo-light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]):not([data-theme="night"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light, :root[data-theme="night"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
:root[data-theme="night"] .logo-night { display: block; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--slate-bg); color: var(--accent-bg);
  font-family: var(--font-num); font-weight: 800; border: 1px solid var(--slate-line); }
.brand.big { font-size: 22px; padding: 0; } .brand.big .brand-mark { width: 40px; height: 40px; font-size: 22px; }
.project-switch { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); cursor: pointer; }
.project-switch:disabled { cursor: default; }
.project-switch b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.project-switch.compact { flex-direction: row; align-items: center; gap: 6px; width: auto; max-width: 42vw; margin-right: auto; padding: 6px 10px; border: 0; background: none; font-size: 17px; }

.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync.ok i { background: var(--ok); } .sync.warn { color: var(--warn); } .sync.warn i { background: var(--warn); }
.sync.bad { color: var(--bad); } .sync.bad i { background: var(--bad); }

/* ---------- pagina */
.page { padding-top: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-title { min-width: 0; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-block; font-size: 15px; margin-bottom: 6px; }
@media (min-width: 960px) { .page { padding-top: 32px; } .page-head h1 { font-size: 34px; } }

.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; align-items: start; }
@media (min-width: 1100px) { .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); margin-bottom: 18px; overflow: hidden; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 0; }
.group-head h2 { font-size: 15px; font-weight: 650; }
.group-body { padding: 6px 0; }
.group-foot { margin: 0; padding: 0 16px 12px; color: var(--muted); font-size: 13px; }
.pad { padding: 8px 16px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.wrap { flex-wrap: wrap; }
.row.gap > .field { flex: 1 1 140px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

.compose { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- campi */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 13px; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
input, select, textarea { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--raised); color: var(--text); font-size: 16px; }
textarea { resize: vertical; line-height: 1.4; }
input[readonly], textarea[readonly] { background: transparent; border-style: dashed; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.checks { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 12px; }
.checks legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- pulsanti */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--raised); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.primary { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 600; }
.btn.danger-plain { color: var(--bad); border-color: transparent; background: none; padding: 0 8px; }
.btn.block { width: 100%; }
.link, .plain-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; }
.plain-btn { color: inherit; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius); background: var(--bad-bg); }
.photo-input { position: relative; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--raised); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; }
.seg button { flex: 1; min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius-s); background: none; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.18); }

/* ---------- elenchi */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px; border: 0; background: none; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.list-row:hover { background: var(--raised); text-decoration: none; }
.list-row.static { cursor: default; } .list-row.static:hover { background: none; }
.list-row.top { align-items: flex-start; }
.list-row.on { background: var(--raised); }
.omitted .list-row { opacity: .5; } .omitted .strong { text-decoration: line-through; }
.scene-num { flex: none; min-width: 44px; padding: 4px 6px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line);
  font-family: var(--font-num); font-weight: 700; text-align: center; }
.scene-num.small { min-width: 36px; font-size: 14px; }
.w-4 { width: 4.5em; flex: none; }
.day-date { display: flex; flex-direction: column; align-items: center; width: 44px; flex: none; line-height: 1.05; }
.day-date b { font-family: var(--font-num); font-size: 22px; } .day-date span { font-size: 12px; color: var(--muted); }
.pick-list, .menu-list { display: flex; flex-direction: column; margin: 8px -4px 0; }
.pick-list button, .menu-list a, .menu-list button { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 12px; border: 0; border-radius: var(--radius);
  background: none; color: var(--text); text-align: left; cursor: pointer; text-decoration: none; }
.pick-list button:hover, .menu-list a:hover, .menu-list button:hover { background: var(--raised); text-decoration: none; }
.pick-list .on, .menu-list .on { background: var(--raised); color: var(--accent); }
.plain { margin: 0 0 12px; padding-left: 20px; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chip.soft { font-weight: 400; color: var(--muted); }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; font-size: 11px; }
.chip.action { cursor: pointer; } .chip.action:hover { border-color: var(--accent); color: var(--accent); }
.tagged { margin-bottom: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters .search { width: auto; flex: 1 1 180px; min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
.filters .seg { flex: none; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 2px 16px; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat-v { font-family: var(--font-num); font-size: 22px; font-weight: 700; }
.stat-l { color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty p { max-width: 46ch; margin: 0 auto 14px; }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.note { margin-top: 18px; padding: 14px; border-radius: var(--radius); background: var(--raised); font-size: 14px; }
.code { display: block; margin: 8px 0; padding: 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ---------- ciak: l'elemento forte */
.slate { position: relative; background: var(--slate-bg); color: var(--slate-text); border-radius: 18px; padding: 16px; margin-bottom: 14px;
  border: 1px solid var(--slate-line); overflow: hidden; }
.slate::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px;
  background: repeating-linear-gradient(-55deg, var(--slate-text) 0 16px, var(--slate-bg) 16px 32px); opacity: .9; }
.slate-grid { display: grid; grid-template-columns: 1.15fr 1fr .9fr; gap: 1px; background: var(--slate-line); border-radius: 12px; overflow: hidden; margin: 10px 0 14px; }
.slate-cell { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 10px 12px 12px; background: var(--slate-bg);
  border: 0; color: inherit; text-align: left; cursor: pointer; min-width: 0; }
.slate-cell:disabled { cursor: default; }
.slate-cell:hover:not(:disabled):not(.take) { background: #1a1c1f; }
.slate-l { font-size: 13px; color: #a7abb1; }
.slate-v { font-family: var(--font-num); font-weight: 750; font-size: clamp(40px, 13vw, 96px); line-height: 1; letter-spacing: -.03em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper { display: flex; gap: 6px; margin-top: 8px; }
.stepper button { width: 40px; height: 36px; border-radius: 8px; border: 1px solid var(--slate-line); background: #26292d; color: var(--slate-text); font-size: 20px; cursor: pointer; }
.slate .seg { display: flex; width: 100%; background: #202327; border-color: var(--slate-line); }
.slate .seg button { color: #a7abb1; min-height: 48px; font-size: 16px; }
.slate .seg button.on { background: #34383d; color: #fff; }
.slate-tally { position: absolute; top: 20px; right: 16px; width: 12px; height: 12px; border-radius: 50%; background: #3a3e44; }
.slate.is-rolling { border-color: var(--tally); box-shadow: 0 0 0 1px var(--tally) inset; }
.slate.is-rolling .slate-tally { background: var(--tally); box-shadow: 0 0 12px var(--tally); animation: tally 1.2s ease-in-out infinite; }
.slate.is-rolling .seg button.on { background: var(--tally); }
@keyframes tally { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .slate.is-rolling .slate-tally { animation: none; } }

.take-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.result-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result { min-height: 58px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 700; font-size: 17px; cursor: pointer; }
.result.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.result.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.result.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.result:active { transform: scale(.98); }
.take-actions .row .field { flex: 0 1 160px; }

/* ---------- luce */
.measures .list-row { gap: 10px; }
.stop-input { width: 84px; flex: none; text-align: right; font-family: var(--font-num); font-weight: 700; font-size: 18px; }
.zchip { display: inline-grid; place-items: center; min-width: 46px; height: 34px; padding: 0 6px; border-radius: 8px; font-weight: 700; font-size: 14px; border: 1px solid rgba(0,0,0,.15); }
.zchip.empty { background: var(--raised); color: var(--muted); }
.zone-legend { display: grid; grid-template-columns: repeat(14, 1fr); margin: 4px 16px 14px; border-radius: 6px; overflow: hidden; }
.zone-legend span { font-size: 10px; font-weight: 700; text-align: center; padding: 4px 0; }
.zone-strip { display: inline-flex; gap: 2px; } .zone-strip i { width: 8px; height: 20px; border-radius: 2px; background: var(--raised); border: 1px solid var(--line); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi, .calc-out { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.kpi-k { font-size: 13px; color: var(--muted); } .kpi-v { font-family: var(--font-num); font-size: 24px; font-weight: 750; } .kpi-n { font-size: 13px; color: var(--muted); }
.kpi.ok .kpi-v, td.ok { color: var(--ok); } .kpi.warn .kpi-v, td.warn { color: var(--warn); } .kpi.bad .kpi-v, td.bad { color: var(--bad); }
.calc-out { flex: 1 1 200px; }
.light { padding: 10px 16px 14px; } .light + .light { border-top: 1px solid var(--line); }
.light-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--muted); font-size: 13px; }
.table .num { text-align: right; font-family: var(--font-num); white-space: nowrap; }
.table tr.diff td { background: var(--warn-bg); }
.table tr:last-child td { border-bottom: 0; }

/* ---------- foto */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 8px 16px 14px; }
.photo-grid.small { padding: 0; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.photo-tile { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font-size: 13px; color: var(--muted); }
.photo-tile img, .photo-tile .photo-missing { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--raised); }
.photo-missing { display: grid; place-items: center; font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }
.photo-full { width: 100%; max-height: 62vh; object-fit: contain; border-radius: 8px; background: #000; margin-bottom: 12px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: var(--radius); margin-bottom: 12px; }
.qr img { width: 264px; height: 264px; image-rendering: pixelated; }

.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.history-v { color: var(--muted); word-break: break-word; }
.conflict .cmp { display: flex; flex-direction: column; margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--raised); }

/* ---------- fogli modali */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.45); }
.sheet { width: 100%; max-height: 92vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 18px 18px 0 0; border: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); animation: rise .22s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 12px 6px 18px; }
.sheet-head h2 { font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 4px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { max-width: 560px; border-radius: 18px; max-height: 86vh; }
  .sheet.wide { max-width: 900px; }
}

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.ok { background: var(--ok); color: #fff; } .toast.bad { background: var(--bad); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
@media (min-width: 960px) { .toast { bottom: 28px; } }

/* ---------- accesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 26px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.auth-card .link { align-self: center; font-size: 14px; }
.h-md { font-size: 20px; }

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-head h1 { font-size: 28px; }
  .page-actions { width: 100%; } .page-actions .btn { flex: 1 1 auto; }
  .w-4 { display: none; }
  .zone-strip { display: none; }
}

/* ---------- schema esposizione */
.settings-box { border: 1px solid var(--accent); border-radius: var(--radius-l); padding: 14px 16px; margin-bottom: 16px; background: var(--surface); }
.settings-box h2 { font-size: 15px; color: var(--accent); margin-bottom: 6px; }
.settings-box p { margin: 0 0 4px; font-size: 14px; }
.steps { margin-bottom: 16px; }
.zone-table td { vertical-align: middle; }
.zchip.big { min-width: 64px; height: 38px; font-size: 16px; }
.zone-key { color: var(--accent); }
.checks-list { display: flex; flex-direction: column; gap: 2px; }

/* ---------- scheda stampata */
.print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 9mm; }
  :root { color-scheme: light; }
  body { background: #fff !important; color: #111 !important; font-size: 10.5px; }
  .rail, .topbar, .tabbar, .toast, .sheet-backdrop, .page > :not(.print-sheet):not(.odg) { display: none !important; }
  .shell { display: block; } .main { padding: 0; max-width: none; } .page { padding: 0; }
  .print-sheet { display: block; color: #111; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ps-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #111; padding-bottom: 4px; margin-bottom: 6px; }
  .ps-head h1 { font-size: 18px; text-transform: none; } .ps-head span { font-size: 10px; color: #444; }
  .print-sheet h2 { font-size: 12px; margin: 8px 0 3px; } .print-sheet h2 small { font-weight: 400; color: #555; margin-left: 6px; }
  .ps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid #999; border-right: 0; border-bottom: 0; }
  .ps-cell { display: flex; flex-direction: column; min-height: 30px; padding: 2px 5px; border-right: 1px solid #999; border-bottom: 1px solid #999; }
  .ps-cell span { font-size: 8px; color: #555; } .ps-cell b { font-size: 11px; font-weight: 600; white-space: pre-wrap; }
  .ps-cell.wide { border: 1px solid #999; margin-top: 6px; min-height: 44px; }
  .ps-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 5px 0; font-size: 10px; }
  .ps-table { width: 100%; border-collapse: collapse; } .ps-table th, .ps-table td { border: 1px solid #999; padding: 3px 5px; text-align: left; font-size: 10px; }
  .ps-table th { background: #eee; font-size: 9px; } .ps-table small { color: #555; }
  .ps-table.lights td { height: 18px; }
  .ps-num { font-weight: 700; text-align: right !important; width: 60px; }
  .ps-zone { display: inline-block; min-width: 34px; text-align: center; padding: 1px 4px; border-radius: 3px; font-weight: 700; border: 1px solid #0003; }
  .ps-scale { display: grid; grid-template-columns: repeat(14, 1fr); margin: 5px 0; border: 1px solid #999; }
  .ps-scale span { text-align: center; font-size: 9px; font-weight: 700; padding: 2px 0; }
  .ps-grid.four { margin-top: 4px; }
  .ps-warn { margin: 3px 0 0; font-weight: 600; }
  .ps-photos { display: flex; gap: 6px; margin-top: 6px; } .ps-photos img { width: 32%; height: 110px; object-fit: cover; }
  .ps-foot { margin-top: 8px; font-size: 9px; color: #333; border-top: 1px solid #999; padding-top: 4px; }
}

.zone-rows { display: flex; flex-direction: column; }
.zone-row { display: grid; grid-template-columns: 76px 130px 90px 1fr; gap: 4px 12px; align-items: center; padding: 8px 16px; }
.zone-row + .zone-row { border-top: 1px solid var(--line); }
.zone-row.head { color: var(--muted); font-size: 13px; font-weight: 600; }
.zr-stop .muted { display: none; }
@media (max-width: 700px) { .zr-stop .muted { display: inline; } }
.zr-text .zone-key { display: block; }
@media (max-width: 700px) {
  .zone-row { grid-template-columns: 64px 1fr; grid-template-areas: "chip stop" "chip text"; }
  .zone-row.head { display: none; }
  .zr-chip { grid-area: chip; } .zr-stop { grid-area: stop; font-size: 14px; }
  .zr-ire { display: none; }
  .zr-text { grid-area: text; font-size: 14px; }
}

/* ---------- guida "i" */
.info-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 6px; vertical-align: middle; border-radius: 50%;
  border: 1.5px solid var(--muted); background: none; color: var(--muted); font: italic 700 13px/1 Georgia, "Times New Roman", serif; cursor: pointer; padding: 0; }
.info-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-head h1 .info-btn { width: 24px; height: 24px; position: relative; top: -3px; }
.group-head h2 .info-btn { width: 20px; height: 20px; font-size: 12px; margin-left: 4px; top: -1px; position: relative; }
.help h3 { font-size: 13px; color: var(--accent); margin: 10px 0 4px; font-weight: 650; }
.help h3:first-child { margin-top: 0; }
.help p, .help li { font-size: 15px; line-height: 1.5; }
.help ol, .help ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
@media print { .info-btn { display: none !important; } }
.sheet-backdrop { font: 400 16px/1.45 var(--font); letter-spacing: normal; text-align: left; }
.sheet-head h2 { font-size: 18px; font-weight: 650; }

/* ---------- striscia di produzione */
.strip-int-giorno { box-shadow: inset 4px 0 0 #e9e6dc; }
.strip-est-giorno { box-shadow: inset 4px 0 0 #f2c94c; }
.strip-int-notte { box-shadow: inset 4px 0 0 #4f7fd6; }
.strip-est-notte { box-shadow: inset 4px 0 0 #3fa36b; }
.scene-num[class*="strip-"] { padding-left: 9px; }
.strip-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); width: 100%; }
.strip-legend span { display: inline-flex; align-items: center; gap: 5px; }
.strip-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); background: var(--raised); }

/* ---------- schede interne su telefono e iPad verticale */
.detail-tabs { display: none; margin-bottom: 14px; }
.detail-tabs .seg { display: flex; width: 100%; }
@media (max-width: 1099px) {
  .detail-tabs { display: block; }
  .cols.tabbed.tab-dati > :nth-child(2), .cols.tabbed.tab-spoglio > :nth-child(1) { display: none; }
}

/* ---------- elenco e scheda affiancati (iPad orizzontale, desktop) */
.split { display: grid; grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); gap: 0 28px; align-items: start; }
.split-list { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding-right: 4px; }
.split-list .stats, .split-list .page-sub, .split-list .zone-strip, .split-list .w-4 { display: none; }
.split-list .page-head h1 { font-size: 26px; }
.split-list .page-actions .btn { min-height: 36px; padding: 0 10px; font-size: 13px; }
.split-detail .detail-tabs { display: none; }
.split-detail .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1400px) { .split-detail .cols { grid-template-columns: minmax(0, 1fr); } .split-detail .detail-tabs { display: block; }
  .split-detail .cols.tabbed.tab-dati > :nth-child(2), .split-detail .cols.tabbed.tab-spoglio > :nth-child(1) { display: none; } }

/* ---------- azioni della pagina compatte su telefono */
@media (max-width: 700px) {
  .page-actions { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 32px); margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none; }
  .page-actions::-webkit-scrollbar { display: none; }
  .page-actions .btn { flex: none; min-height: 38px; padding: 0 14px; font-size: 14px; }
}

/* ---------- iPad verticale */
@media (min-width: 701px) and (max-width: 959px) {
  .main { max-width: 860px; padding-left: 28px; padding-right: 28px; }
  .tabbar { padding-left: 10%; padding-right: 10%; }
  .result { min-height: 64px; font-size: 18px; }
}

/* ---------- barra del ciak */
.set-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.clip-chip { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 6px 12px; border-radius: var(--radius); border: 1px dashed var(--line-strong); background: var(--surface); cursor: pointer; line-height: 1.2; }
.clip-chip b { font-size: 16px; letter-spacing: .02em; }

/* ---------- meteo e ordine del giorno */
.wx-main { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.wx-main b { font-size: 18px; } .wx-main span { font-family: var(--font-num); font-size: 22px; font-weight: 700; }
.wx-grid { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.wx-grid b { color: var(--text); }
.odg-btn { margin-bottom: 18px; }
.odg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.odg-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--text); padding-bottom: 10px; flex-wrap: wrap; }
.odg-head h2 { font-size: 24px; } .odg-head p { margin: 2px 0 0; color: var(--muted); }
.odg-day { text-align: right; display: flex; flex-direction: column; } .odg-day b { font-size: 20px; } .odg-day span { color: var(--muted); }
.odg-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.odg-grid div { display: flex; flex-direction: column; padding: 8px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.odg-grid div.wide { grid-column: span 4; } .odg-grid span { font-size: 12px; color: var(--muted); } .odg-grid b { font-size: 17px; }
.odg section h3 { font-size: 13px; color: var(--accent); margin-bottom: 6px; }
.odg-scene { padding: 10px 0; border-top: 1px solid var(--line); }
.odg-scene-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; } .odg-scene-head b { flex: 1; }
.odg-shot { display: flex; gap: 10px; font-size: 14px; padding: 3px 0 3px 46px; color: var(--muted); } .odg-shot b { color: var(--text); width: 26px; }
@media (max-width: 600px) { .odg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .odg-grid div.wide { grid-column: span 2; } .odg-shot { padding-left: 0; } .odg-day { text-align: left; } }
@media print {
  .page > :not(.print-sheet):not(.odg) { display: none !important; }
  .odg { border: 0; padding: 0; color: #111; background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .odg * { color: #111 !important; } .odg section h3 { color: #111 !important; text-transform: uppercase; font-size: 11px; }
  .odg-grid, .odg-grid div { border-color: #999 !important; }
}

/* ---------- macchina del tempo */
.tm { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
@media (min-width: 900px) { .tm { grid-template-columns: 340px minmax(0, 1fr); align-items: start; } .tm-line { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; } }
.tm-day h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 4px 26px; text-transform: none; }
.tm-moment { position: relative; display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 10px 8px 26px; border: 0; border-radius: var(--radius); background: none; color: var(--text); text-align: left; cursor: pointer; }
.tm-moment::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tm-dot { position: absolute; left: 6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.tm-moment:hover { background: var(--raised); }
.tm-moment.on { background: var(--raised); } .tm-moment.on .tm-dot { background: var(--accent); border-color: var(--accent); }

/* ---------- modalità notte: tutto rosso, non abbaglia e non illumina il set */
:root[data-theme="night"] {
  --bg: #000000; --surface: #0d0000; --raised: #180202; --line: #2e0707; --line-strong: #4a0d0d;
  --text: #E5322D; --muted: #9e221e; --accent: #E5322D; --accent-bg: #7a1009; --accent-ink: #ffb3ab;
  --ok: #ff6a5e; --ok-bg: #1f0303; --warn: #ff8a6e; --warn-bg: #1f0505; --bad: #ff2d20; --bad-bg: #2a0404;
  --info: #ff6a5e; --info-bg: #1f0303; --focus: #ff4a3d; --tally: #ff2d20;
  --slate-bg: #000000; --slate-text: #E5322D; --slate-line: #3a0808; color-scheme: dark;
}
:root[data-theme="night"] .slate-l, :root[data-theme="night"] .slate .seg button { color: #a8261d; }
:root[data-theme="night"] .slate .seg button.on { background: #3a0808; color: #ff4a3d; }
:root[data-theme="night"] img:not(.logo-img), :root[data-theme="night"] .zchip, :root[data-theme="night"] .zone-legend, :root[data-theme="night"] .zone-strip { filter: grayscale(1) sepia(1) hue-rotate(-50deg) saturate(4) brightness(.55); }
:root[data-theme="night"] .stepper button { background: #120202; color: #ff4a3d; border-color: #3a0808; }
@media print { .odg .scene-num { background: #eee !important; border-color: #999 !important; } }
.ct { display: flex; flex-direction: column; }
.ct-row { display: grid; grid-template-columns: 80px 64px minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; align-items: center; padding: 7px 4px; border-top: 1px solid var(--line); }
.ct-row.head { color: var(--muted); font-size: 12px; font-weight: 600; border-top: 0; }
.ct-row.on { background: var(--raised); border-radius: 8px; box-shadow: inset 3px 0 0 var(--accent); }
.ct-ex { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.ct-ex .zchip { min-width: 0; height: 26px; font-size: 12px; padding: 0 6px; }
.ct-box summary { padding: 12px 16px; font-weight: 650; font-size: 15px; cursor: pointer; }
@media (max-width: 600px) { .ct-row { grid-template-columns: 62px 54px minmax(0, 1fr); } .ct-row > :nth-child(4) { grid-column: 1 / -1; color: var(--muted); } .ct-row.head > :nth-child(4) { display: none; } }
.doc-img { width: 100%; height: auto; border-radius: 8px; background: #fff; }
.row.wrap { flex-wrap: wrap; }
.msg-preview summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.msg-preview pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; background: var(--raised); padding: 12px; border-radius: var(--radius); margin: 8px 0 0; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }
