/* Presidio IA · stile dell'applicazione
   Indice: base · cornice · pulsanti · elementi · campi · finestre · panoramica · registro · scheda · percorso guidato
           · obblighi · formazione · documenti · incidenti · FRIA · impostazioni e guida · stampa · movimento */

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; text-wrap: balance; letter-spacing: -0.005em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }
kbd { font-family: var(--font-mono); font-size: 12px; padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.tabnum { font-variant-numeric: tabular-nums; }
.notes { list-style: disc; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.link { color: var(--accent); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link.small { font-size: var(--fs-sm); }
.link.ext { display: inline-flex; align-items: center; gap: 4px; }
.late-text { color: var(--warn); font-weight: 600; }
.error-text { color: var(--critical); font-weight: 600; font-size: var(--fs-sm); }
.ico { flex: none; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 300; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); border-radius: var(--r-md); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
.noscript { padding: 24px; }

/* ============ Cornice ============ */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 14px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 2px 6px; }
.brand-mark { flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.org-name { display: flex; align-items: center; gap: 8px; margin: -4px 6px 0; font-size: var(--fs-sm); color: var(--muted); min-width: 0; }
.org-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--r-md);
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px;
  transition: background 0.15s, color 0.15s;
}
.nav-item .ico { color: var(--muted); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); }
.nav-item.is-active .ico { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; }
.nav-badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--warn-soft); color: var(--warn);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.deadline-mini {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.deadline-mini:hover { border-color: var(--line-strong); }
.deadline-date { font-weight: 700; font-size: 15px; }
.deadline-title { font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.deadline-rel { font-size: 12px; color: var(--accent); font-weight: 600; }
.basis { font-variant-numeric: tabular-nums; font-size: 12px; line-height: 1.5; color: var(--faint); padding: 0 6px; }

.topbar, .tabbar { display: none; }
.main { min-width: 0; padding: 32px 40px 80px; outline: none; }
.page { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-narrow { max-width: 860px; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
    padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .brand-sm .brand-mark { width: 28px; height: 28px; }
  .brand-sm .brand-name { font-size: 18px; }
  .topbar-actions { display: flex; gap: 4px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab-item {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; border: 0; background: none; color: var(--muted);
    font-size: 11.5px; font-weight: 600; text-decoration: none;
  }
  .tab-item.is-active { color: var(--accent); }
  .tab-item .nav-label { flex: none; }
  .tab-item .nav-badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
  .tab-add {
    justify-self: center; width: 48px; height: 48px; border-radius: 16px; border: 0;
    display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
    box-shadow: var(--shadow-md);
  }
  .main { padding: 20px 16px 112px; }
  .page { gap: 18px; }
}
body.is-focus .sidebar, body.is-focus .topbar, body.is-focus .tabbar { display: none; }
body.is-focus .app { grid-template-columns: minmax(0, 1fr); }
body.is-focus .main { padding: 0; }

.sheet-nav { display: flex; flex-direction: column; }
.sheet-link { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }
.sheet-link span { flex: 1; }
.sheet-link:last-child { border-bottom: 0; }

/* ============ Pulsanti ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--r-md);
  border: 1px solid transparent; font-weight: 600; font-size: 15px; line-height: 1.2;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn-danger-text { color: var(--critical); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 14px; border-radius: 8px; gap: 6px; }
.btn-icon { padding: 8px; min-width: 40px; }
.btn-sm.btn-icon { min-width: 32px; padding: 5px; }
.btn-block { width: 100%; }

/* ============ Elementi ============ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.page-head-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 760px; }
.crumb { font-size: var(--fs-sm); color: var(--muted); }
.crumb-link { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumb-link:hover { color: var(--accent); text-decoration: underline; }
.eyebrow { font-size: 14px; font-weight: 600; color: var(--muted); }
.page-title { font-size: var(--fs-2xl); letter-spacing: -0.015em; }
.lead { color: var(--ink-2); font-size: 17px; max-width: 66ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.head-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; align-items: center; }
@media (max-width: 640px) {
  .page-title { font-size: 25px; }
  .lead { font-size: 16px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; }
.card-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.count-pill { min-width: 26px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 13px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.section-h { font-size: 14px; font-weight: 600; color: var(--muted); }
.big { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }

.demo-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px 12px 16px; border-radius: var(--r-lg);
  background: var(--accent-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.demo-icon { color: var(--accent); display: grid; }
.demo-text { flex: 1 1 320px; font-size: 15px; }
.demo-actions { flex: none; }

.callout {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--info-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--info) 22%, transparent);
}
.callout-icon { color: var(--info); padding-top: 2px; display: grid; }
.callout-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 15px; }
.callout-title { font-weight: 700; }
.callout-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.callout[data-kind="warn"] { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout[data-kind="warn"] .callout-icon { color: var(--warn); }
.callout[data-kind="danger"] { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 28%, transparent); }
.callout[data-kind="danger"] .callout-icon { color: var(--critical); }
.callout[data-kind="ok"] { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.callout[data-kind="ok"] .callout-icon { color: var(--ok); }
.callout[data-kind="tip"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.callout[data-kind="tip"] .callout-icon { color: var(--accent); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 32px 16px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty h3 { font-size: 18px; }
.empty p { color: var(--muted); max-width: 52ch; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.ring { position: relative; display: grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; }
.ring-label { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ring-bar { transition: stroke-dashoffset 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }

.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s; }
.bar[data-tone="warn"] > span { background: var(--warn); }

/* Etichette di rischio */
.risk {
  --rc: var(--risk-bozza); --rs: var(--risk-bozza-soft);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 700; line-height: 1.35; white-space: nowrap;
  color: var(--rc); background: var(--rs);
}
.risk::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
[data-risk="vietato"] { --rc: var(--risk-vietato); --rs: var(--risk-vietato-soft); }
[data-risk="alto"] { --rc: var(--risk-alto); --rs: var(--risk-alto-soft); }
[data-risk="non_alto"] { --rc: var(--risk-non-alto); --rs: var(--risk-non-alto-soft); }
[data-risk="trasparenza"] { --rc: var(--risk-trasparenza); --rs: var(--risk-trasparenza-soft); }
[data-risk="minimo"] { --rc: var(--risk-minimo); --rs: var(--risk-minimo-soft); }
[data-risk="fuori"] { --rc: var(--risk-fuori); --rs: var(--risk-fuori-soft); }
[data-risk="bozza"] { --rc: var(--risk-bozza); --rs: var(--risk-bozza-soft); }
[data-risk="org"] { --rc: var(--accent); --rs: var(--accent-soft); }
.risk[data-risk="bozza"] { box-shadow: inset 0 0 0 1px var(--line-strong); }
.risk.is-provisional { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rc); }
.risk.is-provisional::before { background: transparent; border: 1.5px solid currentColor; }
.risk-note { font-weight: 600; font-size: 11.5px; opacity: 0.85; }
.risk.is-large { font-size: 15px; padding: 5px 14px 5px 11px; }
.risk.is-large::before { width: 10px; height: 10px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tag-soft { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--muted); font-size: 12px; padding: 2px 8px; }
.tag-danger { background: var(--critical-soft); color: var(--critical); }
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--ink-2); margin-left: 8px; white-space: nowrap; letter-spacing: 0.01em; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.ref {
  display: inline-block; font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; line-height: 1.5;
  padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.when { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.when.is-live { color: var(--ok); }
.when.is-late { color: var(--warn); }
.when.is-future { color: var(--info); }
.when.is-advice { color: var(--muted); }

/* ============ Campi ============ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.label { font-weight: 700; font-size: 15px; color: var(--ink); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.opt { font-weight: 400; font-size: 13px; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); margin-top: -2px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--critical); }
.textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.inline-check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Scelte a scheda */
.choices { display: grid; gap: 10px; }
.choices.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .choices.cols-2, .choices.cols-3 { grid-template-columns: minmax(0, 1fr); } }
.choice {
  position: relative; display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line-strong);
  cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.choices.is-compact .choice { padding: 11px 14px; }
.choice:hover { border-color: var(--accent); }
.choice input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 20px; height: 20px; margin: 1px 0 0;
  border: 1.5px solid var(--line-strong); border-radius: 50%;
  background: var(--surface); display: grid; place-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.choice input[type="checkbox"] { border-radius: 6px; }
.choice input:checked { background: var(--accent); border-color: var(--accent); }
.choice input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); }
.choice input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 5px; border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink); transform: translateY(-1px) rotate(-45deg); }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); box-shadow: inset 0 0 0 1px var(--accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice.tone-danger:has(input:checked) { border-color: var(--critical); background: var(--critical-soft); box-shadow: inset 0 0 0 1px var(--critical); }
.choice.tone-danger input:checked { background: var(--critical); border-color: var(--critical); }
.choice.is-disabled { opacity: 0.5; cursor: not-allowed; }
.choice-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.choice-title { font-weight: 700; font-size: 15.5px; line-height: 1.3; }
.choice-desc { font-size: 14px; color: var(--muted); line-height: 1.4; }
.choice-body .ref { align-self: flex-start; margin-top: 3px; }
.choice-none { margin-top: 10px; }

/* Pastiglie */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-toggle { position: relative; cursor: pointer; }
.pill-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill-toggle span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  font-weight: 600; font-size: 14.5px; color: var(--ink-2);
  transition: all 0.15s;
}
.pill-toggle span::before { content: "+"; font-weight: 700; color: var(--muted); }
.pill-toggle:hover span { border-color: var(--accent); }
.pill-toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill-toggle input:checked + span::before { content: "✓"; color: var(--accent-ink); }
.pill-toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Segmentato */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-3); max-width: 100%; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14.5px; color: var(--ink-2); white-space: nowrap; transition: background 0.15s, color 0.15s; }
.seg:hover span { color: var(--ink); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg-count { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Interruttori */
.switch-group { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.switch-group > .label { padding: 14px 0 2px; }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.switch-text { display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; }
.switch-title { font-weight: 700; font-size: 15.5px; line-height: 1.3; }
.switch-desc { font-size: 14px; color: var(--muted); }
.switch-text .ref { align-self: flex-start; margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 2px 0 0;
  position: relative; width: 44px; height: 26px; border-radius: 999px;
  background: var(--line-strong); cursor: pointer; transition: background 0.18s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.18s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

/* ============ Finestre e notifiche ============ */
body.has-modal { overflow: hidden; }
.backdrop {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  padding: 24px 16px; background: var(--backdrop);
  animation: fade-in 0.16s ease-out;
}
.backdrop.is-leaving { animation: fade-out 0.14s ease-in forwards; }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; outline: none;
  animation: rise-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-sm { width: min(460px, 100%); }
.modal-lg { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 4px 24px; }
.modal-head h2 { font-size: 20px; }
.modal-head .eyebrow { margin-bottom: 4px; }
.modal-body { padding: 12px 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 24px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 640px) {
  .backdrop { place-items: end center; padding: 0; }
  .modal, .modal-sm, .modal-lg { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; animation: sheet-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .btn { flex: 1 1 auto; }
}

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 250; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--ground); box-shadow: var(--shadow-lg);
  font-size: 15px; animation: rise-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.is-leaving { animation: fade-out 0.18s ease-in forwards; }
.toast-ok .ico { color: var(--accent-soft); }
.toast-text { flex: 1; min-width: 0; }
.toast-action { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; padding: 6px 8px; border-radius: 8px; }
.toast-action:hover { background: color-mix(in srgb, var(--ground) 14%, transparent); }
.toast-x { border: 0; background: transparent; color: inherit; opacity: 0.7; padding: 6px; border-radius: 8px; display: grid; }
@media (max-width: 960px) { .toasts { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); } }
body.is-focus .toasts { top: calc(76px + env(safe-area-inset-top, 0px)); bottom: auto; }

/* ============ Panoramica ============ */
.dash-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.readiness { display: flex; align-items: center; gap: 24px; }
.readiness-text { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.readiness-late, .readiness-ok { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; }
.readiness-late { color: var(--warn); }
.readiness-late .link { color: var(--warn); }
.readiness-ok { color: var(--ok); }
.readiness-future { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

.next-card { display: flex; flex-direction: column; gap: 12px; }
.next-main { display: flex; gap: 16px; align-items: center; }
.next-date {
  flex: none; width: 76px; padding: 8px 0 10px; border-radius: 14px; text-align: center;
  background: var(--accent); color: var(--accent-ink); display: flex; flex-direction: column; line-height: 1;
}
.next-day { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
/* avoid-ai-design-ignore: SD4 — foglio di calendario */
.next-month { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 4px; }
.next-title { font-weight: 700; font-size: 17px; line-height: 1.3; }
.next-count { font-size: 14px; color: var(--muted); margin-top: 2px; }
.next-count strong { color: var(--accent); }
.next-list { list-style: none; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.next-list li { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.next-li-date { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.next-li-title { color: var(--ink-2); }
.next-li-count { color: var(--faint); font-size: 13px; white-space: nowrap; }
.next-li-count:empty { display: none; }
.next-li-count.has { color: var(--info); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  color: var(--ink); text-decoration: none; position: relative; overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
a.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.kpi.tone-warn .kpi-sub { color: var(--warn); font-weight: 600; }
.kpi.tone-amber .kpi-sub { color: var(--risk-alto); font-weight: 600; }
.kpi.tone-critical .kpi-sub { color: var(--critical); font-weight: 600; }
.kpi.tone-ok .kpi-sub { color: var(--ok); }
.kpi-label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.kpi-sub { font-size: 13.5px; color: var(--muted); }
.kpi.tone-critical .kpi-value { color: var(--critical); }

.dash-mid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.todo-list { list-style: none; display: flex; flex-direction: column; }
.todo { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.todo:first-child { border-top: 0; padding-top: 2px; }
.todo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--info); }
.todo.tone-critical .todo-dot { background: var(--critical); box-shadow: 0 0 0 4px var(--critical-soft); }
.todo.tone-warn .todo-dot { background: var(--warn); }
.todo.tone-neutral .todo-dot { background: transparent; border: 2px solid var(--muted); }
.todo-title { font-weight: 600; line-height: 1.3; }
.todo-meta { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.todo-empty { display: flex; gap: 12px; align-items: center; color: var(--ok); padding: 8px 0; }
.todo-empty p { color: var(--ink-2); }

.riskbar { display: flex; gap: 3px; height: 14px; margin-bottom: 16px; }
.riskbar span { border-radius: 4px; background: var(--rc); min-width: 10px; }
.risk-legend { list-style: none; display: flex; flex-direction: column; }
.risk-legend a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.risk-legend li:first-child a { border-top: 0; }
.risk-legend a:hover .risk { filter: brightness(0.95); }
.risk-count { font-weight: 700; font-size: 17px; }

.tl-scroll { overflow-x: auto; margin: 8px -20px -20px; padding: 0 20px 20px; scrollbar-width: thin; }
.tl-track { position: relative; min-width: 820px; height: 208px; }
.tl-line { position: absolute; left: 0; right: 0; top: 104px; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.tl-past { display: block; height: 100%; background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.tl-year { position: absolute; top: 112px; transform: translateX(-50%); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--faint); }
.tl-year::before { content: ""; position: absolute; left: 50%; top: -10px; width: 1px; height: 6px; background: var(--line-strong); }
.tl-today { position: absolute; top: 106px; width: 0; z-index: 3; }
.tl-today > span {
  position: absolute; top: 0; left: 0; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--surface);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tl-today-date { font-weight: 600; opacity: 0.85; }
.tl-item { position: absolute; top: 0; bottom: 0; width: 0; }
.tl-dot { position: absolute; top: 99px; left: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line-strong); z-index: 1; }
.tl-item.is-past .tl-dot { border-color: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); background: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); }
.tl-item.is-mine .tl-dot { border-color: var(--info); }
.tl-item.is-mine:not(.is-past) .tl-dot { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }
.tl-label { position: absolute; left: -8px; width: 150px; display: flex; flex-direction: column; gap: 1px; padding-left: 8px; border-left: 1px solid var(--line-strong); }
.tl-item.is-above .tl-label { bottom: 118px; }
.tl-item.is-below .tl-label { top: 126px; }
.tl-item.is-end .tl-label { left: auto; right: -8px; padding-left: 0; padding-right: 8px; border-left: 0; border-right: 1px solid var(--line-strong); text-align: right; align-items: flex-end; }
.tl-date { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }
.tl-title { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--ink-2); }
.tl-item.is-past .tl-title { color: var(--muted); font-weight: 400; }
.tl-mine { font-size: 12px; font-weight: 700; color: var(--info); }

@media (max-width: 1080px) {
  .dash-top, .dash-mid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .readiness { flex-direction: column; align-items: flex-start; gap: 14px; }
  .kpis-3 { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 26px; }
  .next-list li { grid-template-columns: 80px minmax(0, 1fr); }
  .next-li-count { grid-column: 2; }
}

/* ============ Registro ============ */
.registry-top { padding: 16px 20px 12px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 14px;
}
.fchip:hover { border-color: var(--line-strong); }
.fchip.is-active { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.fchip:not([data-risk="tutti"])::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rc); }
.fchip.is-active::before { box-shadow: 0 0 0 2px var(--ground); }
.fchip-count { font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters .select { width: auto; min-width: 150px; flex: 0 1 auto; min-height: 40px; padding-top: 8px; padding-bottom: 8px; font-size: 15px; background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px; }
.search { position: relative; flex: 1 1 240px; min-width: 200px; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 38px; min-height: 40px; font-size: 15px; }
.sys-head, .sys-row { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1.15fr); gap: 16px; align-items: center; padding: 0 20px; }
.sys-head { padding-top: 10px; padding-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.sys-list { display: flex; flex-direction: column; }
.sys-row { padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: background 0.12s; }
.sys-row:last-child { border-bottom: 0; }
.sys-row:hover { background: var(--surface-2); }
.sys-row.is-muted { opacity: 0.6; }
.sys-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sys-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.sys-sub { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sys-cell { font-size: 14.5px; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sys-risk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; overflow: visible; }
.sys-progress { display: grid; grid-template-columns: auto minmax(40px, 1fr); gap: 4px 10px; align-items: center; font-size: 13.5px; font-weight: 600; }
.sys-progress .late-tag { grid-column: 1 / -1; }
.late-tag { font-size: 12.5px; color: var(--warn); font-weight: 700; }
.list-empty { padding: 32px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
@media (max-width: 900px) {
  .sys-head { display: none; }
  .sys-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name risk" "meta meta" "prog prog"; gap: 8px 12px; padding: 14px 16px; }
  .sys-name { grid-area: name; }
  .sys-risk { grid-area: risk; justify-content: flex-end; }
  .sys-row > .sys-cell:nth-child(2), .sys-row > .sys-cell:nth-child(3) { display: none; }
  .sys-row > .sys-cell:last-child { grid-area: prog; }
  .registry-top { padding: 14px 16px 10px; }
  .filters .select { flex: 1 1 140px; }
}

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.preset { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.preset:hover { border-color: var(--accent); }
.preset input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.preset:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.preset-body { display: flex; flex-direction: column; gap: 2px; }
.preset-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.preset-hint { font-size: 13px; color: var(--muted); }

/* ============ Scheda del sistema ============ */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.detail-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 24px; }
.detail-aside h2 { font-size: 16px; margin-bottom: 12px; }
@media (max-width: 1080px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail-aside { position: static; order: -1; }
}
.tabs-row { display: flex; }
.obl-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 260px); gap: 12px 24px; align-items: center; }
.obl-summary .big { font-size: 19px; margin: 2px 0; }
.obl-summary-bar .bar { height: 10px; }
.obl-summary .inline-check { grid-column: 1 / -1; }
@media (max-width: 640px) { .obl-summary { grid-template-columns: minmax(0, 1fr); } }
.obl-group .card-head { margin-bottom: 4px; }
.obl-group.is-late { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.obl-list { display: flex; flex-direction: column; }
.obl { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.obl:first-child { border-top: 0; }
.obl.is-urgent .obl-title span { color: var(--critical); }
.status-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; padding: 0; color: #fff; margin-top: -2px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.status-btn:hover { border-color: var(--accent); transform: scale(1.06); }
.status-btn[data-status="in_corso"] { border-color: var(--warn); background: conic-gradient(var(--warn) 0 50%, var(--surface) 50% 100%); }
.status-btn[data-status="fatto"] { border-color: var(--ok); background: var(--ok); color: var(--surface); }
.status-btn[data-status="na"] { border-style: dashed; border-color: var(--faint); }
.na-dash { width: 10px; height: 2px; background: var(--faint); border-radius: 2px; }
.obl.is-late .status-btn[data-status="da_fare"] { border-color: var(--warn); }
.obl-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.obl-title {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; width: 100%;
  border: 0; background: none; padding: 0; text-align: left; font-weight: 700; font-size: 15.5px; line-height: 1.35; color: var(--ink);
}
.obl-title .ico { margin-top: 2px; color: var(--muted); transition: transform 0.2s; }
.obl.is-open .obl-title .ico { transform: rotate(180deg); }
.obl-title:hover span { color: var(--accent); }
.obl[data-status="fatto"] .obl-title span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.obl[data-status="na"] .obl-title span { color: var(--faint); }
.obl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.obl-sys { font-weight: 700; color: var(--ink-2); text-decoration: none; }
.obl-sys:hover { color: var(--accent); text-decoration: underline; }
.obl-owner { display: inline-flex; align-items: center; gap: 4px; }
.obl-auto { color: var(--ok); font-weight: 600; }
.obl-detail { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; padding: 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); animation: fade-in 0.18s ease-out; }
.obl-desc { color: var(--ink-2); font-size: 15px; max-width: 70ch; }
.obl-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.obl-detail .label { font-size: 13.5px; }
.obl-detail .input { min-height: 40px; font-size: 15px; padding-top: 8px; padding-bottom: 8px; }
.obl-detail .select { background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px; }
.obl-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.why { border-top: 4px solid var(--rc); }
.why-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.why-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 15px; line-height: 1.4; padding-left: 16px; position: relative; }
.why-list li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--rc, var(--muted)); }
.why-role { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.why > .muted { margin-top: 12px; }
.facts { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 8px 16px; font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.facts-wide { grid-template-columns: minmax(160px, 34%) minmax(0, 1fr); }
@media (max-width: 560px) { .facts-wide { grid-template-columns: minmax(0, 1fr); gap: 2px; } .facts-wide dd { margin-bottom: 10px; } }
.exposure-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.exposure p + p { margin-top: 6px; }
.log-list { list-style: none; display: flex; flex-direction: column; }
.log-list li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.log-list li:first-child { border-top: 0; }
.log-when { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 2px; }
@media (max-width: 560px) { .log-list li { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* ============ Percorso guidato ============ */
.wz { min-height: 100vh; display: flex; flex-direction: column; }
.wz-top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.wz-back-link { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--ink-2); font-weight: 600; padding: 8px 10px 8px 4px; border-radius: 8px; }
.wz-back-link:hover { background: var(--surface-3); color: var(--ink); }
.wz-top-title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.wz-top-title strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wz-kicker { font-size: 13px; font-weight: 600; color: var(--muted); }
.wz-chip { display: none; border: 0; background: none; padding: 4px; border-radius: 999px; }
.wz-top-actions { display: flex; gap: 6px; }
.wz-progress { height: 3px; background: var(--line); position: sticky; top: calc(61px + env(safe-area-inset-top, 0px)); z-index: 39; }
.wz-progress > span { display: block; height: 100%; background: var(--accent); transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.wz-body { flex: 1; display: grid; grid-template-columns: 220px minmax(0, 660px) 300px; justify-content: center; gap: 40px; padding: 40px 24px 64px; }
.wz-rail-wrap { position: sticky; top: 104px; align-self: start; }
.wz-rail { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.wz-step button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 10px;
  background: none; color: var(--muted); font-weight: 600; font-size: 14.5px; text-align: left;
}
.wz-step button:not(:disabled):hover { background: var(--surface-3); color: var(--ink); }
.wz-step button:disabled { cursor: default; }
.wz-dot { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; border: 1.5px solid var(--line-strong); background: var(--surface); font-variant-numeric: tabular-nums; }
.wz-step.is-done .wz-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wz-step.is-done button { color: var(--ink-2); }
.wz-step.is-current button { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.wz-step.is-current .wz-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wz-step.is-seen .wz-dot { border-color: var(--accent); }
.wz-main { min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.wz-step-head { display: flex; flex-direction: column; gap: 8px; }
.wz-count { font-size: 14px; font-weight: 700; color: var(--accent); }
.wz-title { font-size: 30px; letter-spacing: -0.02em; line-height: 1.15; }
.wz-lead { font-size: 17px; color: var(--ink-2); max-width: 60ch; }
.wz-help { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.wz-help summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--accent); list-style: none; }
.wz-help summary::-webkit-details-marker { display: none; }
.wz-help[open] summary { border-bottom: 1px solid var(--line); }
.wz-help-body { padding: 12px 14px 14px; font-size: 14.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; }
.wz-help-refs { display: flex; flex-wrap: wrap; gap: 6px; }
.wz-fields { display: flex; flex-direction: column; gap: 22px; }
.wz-error { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--critical-soft); color: var(--critical); font-weight: 600; font-size: 15px; animation: shake 0.3s; }
.wz-nav {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; gap: 12px;
  padding: 16px 0 calc(16px + env(safe-area-inset-bottom, 0px)); margin-top: 8px;
  background: linear-gradient(to bottom, transparent, var(--ground) 28%);
}
.wz-nav .btn { min-height: 48px; padding: 10px 22px; font-size: 16px; }
.wz-aside { position: sticky; top: 104px; align-self: start; }
.reveal { animation: reveal 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@media (max-width: 1240px) {
  .wz-body { grid-template-columns: 200px minmax(0, 1fr); gap: 32px; max-width: 1000px; margin: 0 auto; width: 100%; }
  .wz-aside { grid-column: 2; position: static; }
}
@media (max-width: 860px) {
  .wz-body { grid-template-columns: minmax(0, 1fr); padding: 20px 16px 24px; gap: 20px; }
  .wz-rail-wrap, .wz-aside { display: none; }
  .wz-chip { display: inline-flex; }
  .wz-save span { display: none; }
  .wz-save { padding: 8px; min-width: 40px; }
  .wz-title { font-size: 24px; }
  .wz-lead { font-size: 16px; }
  .wz-top { padding: 8px 12px; gap: 8px; }
  .wz-progress { top: calc(57px + env(safe-area-inset-top, 0px)); }
  .wz-nav .btn { flex: 1; }
}

.preset-strip { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px dashed var(--line-strong); }
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.preset-chip:hover { border-color: var(--accent); color: var(--accent); }
.preset-chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.areas { display: flex; flex-direction: column; gap: 8px; }
.area { border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.area:hover { border-color: var(--risk-alto); }
.area.is-on { border-color: var(--risk-alto); box-shadow: inset 0 0 0 1px var(--risk-alto); }
.area-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.area-head input { width: 20px; height: 20px; accent-color: var(--risk-alto); flex: none; margin: 0; }
.area-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.area-name { font-weight: 700; font-size: 15.5px; }
.area-desc { font-size: 13.5px; color: var(--muted); }
.area-num { flex: none; }
.area-points { padding: 0 14px 14px 46px; animation: reveal 0.2s ease-out; }
.area-points .choice { border-color: var(--line); }
@media (max-width: 560px) { .area-num { display: none; } .area-points { padding-left: 14px; } }

.verdict {
  display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--rc);
  box-shadow: var(--shadow-md); animation: rise-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.verdict-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.verdict-desc { font-size: 16px; color: var(--ink-2); }
.verdict-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.verdict-stats > div { display: flex; flex-direction: column; }
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }
.preview-obl { display: flex; flex-direction: column; gap: 12px; }
.preview-group { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 12px 14px; }
.preview-group-title { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.preview-group ul { list-style: none; display: flex; flex-direction: column; }
.preview-group li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.preview-group li:first-child { border-top: 0; }

.live {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--rc);
  transition: border-color 0.3s;
}
.live .risk { align-self: flex-start; }
.live-wait { color: var(--muted); font-size: 14.5px; }
.live-desc { font-size: 14px; color: var(--ink-2); }
.live-role { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.live-stats { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.live-stats div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.live-stats dt { color: var(--muted); }
.live-stats dd { margin: 0; font-weight: 700; }
.live-missing { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; color: var(--muted); padding-top: 8px; border-top: 1px dashed var(--line); }
.aside-note { font-size: 12.5px; color: var(--faint); padding: 0 4px; }
.org-impact { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.org-impact li { display: flex; flex-direction: column; font-size: 14px; gap: 2px; color: var(--ink-2); }
.org-impact strong { color: var(--ink); }

/* ============ Obblighi ============ */
.obl-controls { display: flex; flex-direction: column; gap: 12px; }
.obl-controls .filters .segmented { flex: none; }
.h-link { color: var(--ink); text-decoration: none; }
.h-link:hover { color: var(--accent); text-decoration: underline; }

/* ============ Formazione ============ */
.train-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.train { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: start; }
/* avoid-ai-design-ignore: SD4 — foglio di calendario */
.train-date { display: flex; flex-direction: column; align-items: center; padding: 8px 0; border-radius: 12px; background: var(--surface-3); font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.1; }
.train-day { font-size: 24px; color: var(--ink); letter-spacing: -0.02em; }
.train-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.train-body .ico { vertical-align: -3px; }
.train-actions { display: flex; gap: 2px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.check-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.check-list li { display: flex; gap: 8px; font-size: 14.5px; align-items: flex-start; }
.check-list .ico { color: var(--ok); margin-top: 3px; }
@media (max-width: 560px) { .train { grid-template-columns: 56px minmax(0, 1fr); } .train-actions { grid-column: 2; } }

/* ============ Documenti ============ */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.doc-card {
  display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.doc-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.doc-title { font-weight: 700; font-size: 16.5px; line-height: 1.3; }
.doc-desc { font-size: 14px; color: var(--muted); flex: 1; }
.doc-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-foot .badge { margin-left: 0; }
.doc-gen { display: flex; flex-direction: column; gap: 16px; }
.doc-toolbar { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 12px; z-index: 5; }
.doc-options { display: flex; flex-direction: column; gap: 12px; }
.doc-options:empty { display: none; }
.doc-options .select { max-width: 420px; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 960px) { .doc-toolbar { position: static; } }
.paper-wrap { overflow-x: auto; padding: 8px 0 24px; }
.paper {
  max-width: 820px; margin: 0 auto; padding: 64px 72px; border-radius: 4px;
  background: var(--paper); color: var(--paper-ink); font-family: var(--font-doc); font-size: 15.5px; line-height: 1.65;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 12px 40px rgba(16, 34, 33, 0.12);
  outline: none; color-scheme: light;
}
.paper:focus-visible { box-shadow: 0 0 0 3px var(--focus), 0 12px 40px rgba(16, 34, 33, 0.12); }
.paper h1 { font-family: var(--font-doc); font-size: 26px; font-weight: 600; line-height: 1.25; margin-bottom: 6px; letter-spacing: -0.01em; }
.paper h2 { font-family: var(--font-doc); font-size: 18px; font-weight: 600; margin: 28px 0 8px; }
.paper p { margin: 0 0 10px; }
.paper ul, .paper ol { margin: 0 0 12px; padding-left: 22px; }
.paper li { margin-bottom: 4px; }
.paper table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 14px; line-height: 1.45; }
.paper th, .paper td { border: 1px solid var(--paper-line); padding: 7px 9px; text-align: left; vertical-align: top; }
.paper thead th { background: #F1F4F3; font-family: var(--font-ui); font-size: 13px; font-weight: 700; }
.paper .kv th { width: 36%; background: #F7F9F8; font-weight: 600; font-family: var(--font-ui); font-size: 13.5px; }
.paper .doc-meta { font-family: var(--font-ui); font-size: 13.5px; color: #58625F; margin-bottom: 20px; }
.paper .blank { background: var(--paper-mark); border-radius: 3px; padding: 0 3px; font-family: var(--font-ui); font-size: 0.92em; color: #6B5300; }
/* avoid-ai-design-ignore: K4 — riquadro d'avviso stampabile nei documenti */
.paper .notice { border: 1px solid var(--paper-line); border-left: 4px solid #0B5C62; border-radius: 4px; padding: 10px 14px; margin: 8px 0; font-family: var(--font-ui); font-size: 15px; background: #FAFCFB; }
.paper .applies { font-family: var(--font-ui); font-size: 13px; color: #0B5C62; font-weight: 600; }
.paper .sign { margin-top: 28px; }
.paper .answer { border-bottom: 1px solid var(--paper-line); height: 30px; margin: 4px 0 10px; }
.paper .cite { font-family: var(--font-mono); font-size: 12px; color: #58625F; }
.paper-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 0; font-family: var(--font-ui); }
@media (max-width: 720px) { .paper { padding: 28px 20px; font-size: 15px; } .paper h1 { font-size: 22px; } }

/* ============ Incidenti ============ */
.incident { display: flex; flex-direction: column; gap: 12px; border-left: 4px solid var(--line-strong); }
.incident.sev-grave, .incident.sev-decesso, .incident.sev-diffuso { border-left-color: var(--critical); }
.incident-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.incident-head h2 { font-size: 17px; }
.incident-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.countdown { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--info-soft); color: var(--info); }
.countdown.is-close { background: var(--warn-soft); color: var(--warn); }
.countdown.is-late { background: var(--critical-soft); color: var(--critical); }
.incident-steps { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; color: var(--ink-2); }
.incident-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.incident-foot .select { width: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; background-position: calc(100% - 18px) 15px, calc(100% - 13px) 15px; }
.deadline-note { padding: 10px 12px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--ink); font-size: 14.5px; font-weight: 600; }

/* ============ FRIA ============ */
.fria-outline { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.rights { display: flex; flex-direction: column; gap: 8px; }
.right { border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); }
.right.is-on { border-color: var(--accent); }
.right-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; font-weight: 700; }
.right-head input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.right-body { display: flex; flex-direction: column; gap: 10px; padding: 0 14px 14px 46px; }
@media (max-width: 560px) { .right-body { padding-left: 14px; } }

/* ============ Impostazioni e guida ============ */
.settings-section .card-head { margin-bottom: 16px; }
.keys { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; align-items: center; font-size: 15px; }
.keys dd { margin: 0; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; }
.toc-link { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 14px; text-decoration: none; }
.toc-link:hover { border-color: var(--accent); color: var(--accent); }
.tl-v { list-style: none; display: flex; flex-direction: column; margin-top: 12px; }
.tl-v-item { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 16px; position: relative; padding: 0 0 18px; }
.tl-v-item::before { content: ""; position: absolute; left: 110px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.tl-v-item:last-child::before { display: none; }
.tl-v-item::after { content: ""; position: absolute; left: 105px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.tl-v-item.is-past::after { background: var(--accent); border-color: var(--accent); }
.tl-v-item.is-next::after { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-v-date { font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--muted); padding-top: 2px; }
.tl-v-body { padding-left: 16px; display: flex; flex-direction: column; gap: 2px; }
.tl-v-title { font-weight: 700; }
.tl-v-item.is-past .tl-v-title { color: var(--ink-2); }
.tl-v-who { font-size: 12.5px; font-weight: 600; color: var(--accent); }
@media (max-width: 560px) {
  .tl-v-item { grid-template-columns: minmax(0, 1fr); gap: 2px; padding-left: 24px; }
  .tl-v-item::before { left: 5px; }
  .tl-v-item::after { left: 0; }
  .tl-v-body { padding-left: 0; }
}
.cat-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 16px; align-items: center; margin-top: 12px; }
.cat-list dd { margin: 0; font-size: 15px; color: var(--ink-2); }
@media (max-width: 560px) { .cat-list { grid-template-columns: minmax(0, 1fr); gap: 4px; } .cat-list dd { margin-bottom: 10px; } .cat-list dt { justify-self: start; } }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 520px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 13px; font-weight: 600; color: var(--muted); }
.sources { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.sources li { display: flex; flex-direction: column; gap: 2px; }
#g-cal h2, #g-cat h2, #g-ruoli h2, #g-sanz h2, #g-aut h2, #g-gloss h2, #g-fonti h2 { margin-bottom: 8px; }
#g-ruoli .callout, #g-gloss .facts, #g-aut .facts, #g-ruoli .facts { margin-top: 12px; }

/* ============ Stampa ============ */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .tabbar, .toasts, .page-head, .doc-toolbar, .demo-banner, .callout, .skip { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .paper { box-shadow: none; padding: 0; max-width: none; }
  .paper .blank { background: none; border: 1px dashed #999; }
}

/* ============ Movimento ============ */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
