/* ==========================================================================
   Regolo SafeLine - foglio di stile
   Palette dal logo Regolo: blu notte + verde acqua. Font: Lexend (leggibilità).
   ========================================================================== */

@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/lexend-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/lexend-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Marchio */
  --navy: #062340;
  --navy-2: #0d3358;
  --teal: #098897;
  --teal-ink: #066a76;      /* verde acqua scurito: contrasto AA su bianco */
  --teal-soft: #e3f3f4;

  /* Superfici e testo */
  --bg: #f2f5f7;
  --surface: #ffffff;
  --line: #dde4ea;
  --line-strong: #c5d0d9;
  --ink: #14212e;
  --ink-2: #3a4a59;
  --muted: #5b6b7a;

  /* Stati */
  --ok: #1d7a4f;     --ok-bg: #e6f4ec;
  --warn: #975900;   --warn-bg: #fdf0db;
  --danger: #b42318; --danger-bg: #fdecea;
  --neutral: #5b6b7a; --neutral-bg: #edf1f4;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(6 35 64 / 6%);
  --shadow-lg: 0 12px 40px rgb(6 35 64 / 18%);
  --focus: 0 0 0 3px rgb(9 136 151 / 35%);

  --font: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 350;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--teal-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
strong, b { font-weight: 550; }
small { font-size: .8125rem; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  padding: .5rem 1rem; background: var(--navy); color: #fff; border-radius: var(--radius-sm);
}
.skip:focus { top: 1rem; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; }
.muted { color: var(--muted); }
.block { display: block; }
.num, .mono-num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ==========================================================================
   Struttura
   ========================================================================== */
.shell--staff {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.shell--staff .topbar { display: none; }

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 1.5rem 1rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar__brand { display: block; padding: 0 .5rem 1.75rem; }
.sidebar__brand img { width: 168px; height: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: .75rem;
  min-height: 44px; padding: .5rem .75rem;
  color: var(--ink-2); text-decoration: none; font-weight: 400;
  border-radius: var(--radius-sm);
}
.nav__item:hover { background: var(--bg); color: var(--ink); }
.nav__item.is-active { background: var(--teal-soft); color: var(--navy); font-weight: 550; }
.nav__item.is-active .icon { color: var(--teal-ink); }

.sidebar__foot { margin-top: auto; display: grid; gap: .5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.sidebar__user {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; line-height: 1.3;
}
.sidebar__user:hover, .sidebar__user.is-active { background: var(--bg); }
.sidebar__user strong { display: block; font-size: .9375rem; }
.sidebar__user small { color: var(--muted); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: .8125rem; font-weight: 550; letter-spacing: .02em;
}

.main { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1240px; width: 100%; }
.main:focus { outline: none; }

/* Portale cliente: barra in alto e contenuto centrato */
.shell--cliente { min-height: 100vh; }
.shell--cliente .main { margin: 0 auto; max-width: 1040px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .625rem clamp(1rem, 3vw, 2.5rem);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand img { width: 140px; height: auto; }
.topbar__menu { margin-left: auto; }
.topbar__account { margin-left: auto; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.topbar__user {
  color: var(--ink-2); text-decoration: none; font-size: .9375rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__user:hover { color: var(--navy); }

/* ==========================================================================
   Intestazioni, pannelli, griglie
   ========================================================================== */
.page-head { margin-bottom: 1.5rem; }
.back {
  display: inline-flex; align-items: center; gap: .25rem;
  margin: 0 0 .5rem -.25rem; padding: .25rem;
  color: var(--muted); text-decoration: none; font-size: .9375rem;
}
.back:hover { color: var(--navy); }
.back .icon { width: 1rem; height: 1rem; }
.page-head__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.page-title {
  font-size: clamp(1.5rem, 2.6vw, 1.875rem);
  font-weight: 500; line-height: 1.2; letter-spacing: -.015em;
  color: var(--navy);
  text-wrap: balance;
}
.page-sub { margin-top: .25rem; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.panel__head .panel__title { margin: 0; }
.panel__title { font-size: 1.0625rem; font-weight: 550; color: var(--navy); margin-bottom: .75rem; }
.panel__title .muted { font-weight: 350; }
.panel__lead { color: var(--muted); font-size: .9375rem; margin: -.25rem 0 .75rem; }
.panel > .list { margin: 0 -1.25rem -1.25rem; }
.panel > .list:last-child { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); overflow: hidden; }
.panel--form { padding: 0; }
.subhead { font-size: .9375rem; font-weight: 550; margin: 1.25rem 0 .5rem; color: var(--ink); }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-content: start; min-width: 0; }
.grid-2 > *, .grid-sidebar > * { min-width: 0; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.grid-sidebar { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); align-items: start; }

/* ==========================================================================
   Pulsanti
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 40px; padding: .5rem 1rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  font-size: .9375rem; font-weight: 450; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn .icon { width: 1.125rem; height: 1.125rem; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-2); }
.btn--ghost { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.btn--ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #962017; }
.btn--danger-text { color: var(--danger); border-color: transparent; background: none; }
.btn--danger-text:hover { color: #962017; background: var(--danger-bg); border-color: transparent; }
.btn--sm { min-height: 34px; padding: .375rem .75rem; font-size: .875rem; }
.btn--lg { min-height: 48px; font-size: 1rem; }
.btn--block { width: 100%; }
.btn--icon { min-height: 40px; width: 40px; padding: 0; border-color: transparent; }
.btn--icon.btn--ghost { background: none; color: var(--muted); }
.btn--icon.btn--ghost:hover { color: var(--navy); background: var(--bg); }

/* ==========================================================================
   Riepilogo (pagina iniziale staff)
   ========================================================================== */
.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 1.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.summary__item {
  display: grid; gap: .125rem; padding: 1rem 1.25rem;
  color: var(--ink); text-decoration: none;
  border-right: 1px solid var(--line);
  margin-right: -1px;
}
.summary__item:hover { background: var(--bg); }
.summary__num { font-size: 1.75rem; font-weight: 450; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--navy); }
.summary__label { font-size: .875rem; color: var(--muted); }
.summary__item--danger { box-shadow: inset 0 3px 0 var(--danger); }
.summary__item--danger .summary__num { color: var(--danger); }
.summary__item--warn { box-shadow: inset 0 3px 0 var(--warn); }
.summary__item--warn .summary__num { color: var(--warn); }

/* ==========================================================================
   Elenchi
   ========================================================================== */
.list > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: .875rem;
  width: 100%; min-height: 64px; padding: .875rem 1.25rem;
  color: inherit; text-decoration: none; text-align: left;
  background: none; border: 0; cursor: pointer;
}
a.row:hover, .row--button:hover { background: #f7f9fb; }
.row--compact { min-height: 52px; padding: .625rem 1.25rem; }
.row__main { display: grid; gap: .125rem; flex: 1; min-width: 0; }
.row__title { font-weight: 450; color: var(--ink); overflow-wrap: anywhere; }
.row__meta { display: flex; flex-wrap: wrap; column-gap: 1rem; row-gap: 0; font-size: .875rem; color: var(--muted); }
.row__side { display: grid; justify-items: end; gap: .125rem; text-align: right; flex: none; max-width: 45%; }
.row__status { font-size: .9375rem; font-weight: 450; }
.row__sub { font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.row__chevron { width: 1rem; height: 1rem; color: var(--line-strong); }
.row__icon { width: 1.5rem; height: 1.5rem; color: var(--teal-ink); }
.row__dot { width: .625rem; height: .625rem; border-radius: 50%; flex: none; }

.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); }
.dot--muted { background: var(--line-strong); }
.status--ok { color: var(--ok); }
.status--warn { color: var(--warn); }
.status--danger { color: var(--danger); }
.status--muted { color: var(--muted); }

.list--cards { display: grid; gap: .75rem; }
.list--cards > li + li { border-top: 0; }
.list--cards .row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 84px; padding: 1.125rem 1.25rem;
}
.list--cards .row__title { font-size: 1.0625rem; }

.doc { display: flex; align-items: center; padding-right: .75rem; }
.doc:hover, .doc:hover a.row:hover { background: #f7f9fb; }
.doc .row { flex: 1; min-width: 0; padding-right: .5rem; }
.doc__thumb { width: 2.5rem; height: 2.5rem; object-fit: cover; border-radius: 4px; flex: none; }

.empty {
  display: grid; justify-items: center; gap: 1rem;
  padding: 2.5rem 1.5rem; text-align: center; color: var(--muted);
}
.empty p { max-width: 46ch; }
.panel .empty { padding: 1.5rem 1rem; }
.empty--error p { color: var(--danger); }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .125rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 450; line-height: 1.5; vertical-align: .1em; white-space: nowrap;
}
.badge .icon { width: .875rem; height: .875rem; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--muted { background: var(--neutral-bg); color: var(--neutral); }

.notice { padding: .875rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9375rem; }
.notice--danger { background: var(--danger-bg); color: #7a1a12; }
.notice strong { display: block; }

/* ==========================================================================
   Barra strumenti, ricerca, filtri
   ========================================================================== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.toolbar--end { justify-content: flex-end; }
.search {
  display: flex; align-items: center; gap: .5rem; flex: 1 1 280px; max-width: 460px;
  padding: 0 .75rem; min-height: 42px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.search:focus-within { border-color: var(--teal); box-shadow: var(--focus); }
.search .icon { color: var(--muted); width: 1.125rem; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: .5rem 0; }

.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; background: #e6ecf0; border-radius: 8px; }
.segmented button {
  min-height: 36px; padding: .25rem .875rem; border: 0; border-radius: 6px;
  background: none; cursor: pointer; font-size: .875rem; color: var(--ink-2);
}
.segmented button:hover { color: var(--navy); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--navy); font-weight: 500; box-shadow: var(--shadow); }

/* ==========================================================================
   Schede (tabs)
   ========================================================================== */
.tabs {
  display: flex; gap: .25rem; margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs__item {
  display: inline-flex; align-items: center; gap: .5rem; flex: none;
  padding: .75rem 1rem; margin-bottom: -1px;
  color: var(--muted); text-decoration: none; font-weight: 450;
  border-bottom: 2px solid transparent;
}
.tabs__item:hover { color: var(--navy); }
.tabs__item[aria-current="page"] { color: var(--navy); border-bottom-color: var(--teal); }
.tabs__count {
  min-width: 1.375rem; padding: 0 .375rem; border-radius: 999px;
  background: var(--neutral-bg); color: var(--ink-2);
  font-size: .75rem; line-height: 1.375rem; text-align: center;
}

/* ==========================================================================
   Stato dell'impianto e "fune" delle scadenze
   ========================================================================== */
.status {
  --tone: var(--neutral); --tone-bg: var(--neutral-bg);
  margin-bottom: 1.25rem; padding: 1.125rem 1.25rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--tone);
}
.status--ok { --tone: var(--ok); --tone-bg: var(--ok-bg); }
.status--warn { --tone: var(--warn); --tone-bg: var(--warn-bg); }
.status--danger { --tone: var(--danger); --tone-bg: var(--danger-bg); }
.status__head { display: flex; gap: .75rem; align-items: flex-start; }
.status__dot { width: .75rem; height: .75rem; margin-top: .45rem; border-radius: 50%; background: var(--tone); flex: none; box-shadow: 0 0 0 4px var(--tone-bg); }
.status__title { font-size: 1.125rem; font-weight: 500; color: var(--tone); }
.status__text { color: var(--ink-2); font-size: .9375rem; max-width: 70ch; }

.fune { margin-top: 1.5rem; }
.fune__track { position: relative; height: 4px; margin: 1.75rem .5rem 0; background: var(--line); border-radius: 2px; }
.fune__fill { position: absolute; inset: 0 auto 0 0; background: var(--tone); border-radius: 2px; }
.fune__anchor {
  position: absolute; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  background: var(--surface); border: 3px solid var(--navy); border-radius: 50%;
}
.fune__anchor--start { left: -7px; }
.fune__anchor--end { right: -7px; border-color: var(--line-strong); }
.fune__today {
  position: absolute; top: -8px; width: 2px; height: 20px; margin-left: -1px;
  background: var(--tone);
}
.fune__today span {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  padding-bottom: .125rem; font-size: .75rem; font-weight: 500; color: var(--tone); white-space: nowrap;
}
.fune__labels { display: flex; justify-content: space-between; gap: 1rem; margin-top: .75rem; font-variant-numeric: tabular-nums; }
.fune__labels span { display: grid; font-weight: 450; }
.fune__labels span:last-child { text-align: right; }
.fune__labels small { color: var(--muted); font-weight: 350; }

/* ==========================================================================
   Dati (liste di definizioni), tabelle
   ========================================================================== */
.facts { display: grid; gap: .75rem; }
.facts > div { display: grid; gap: .0625rem; align-content: start; }
.facts dt { font-size: .8125rem; color: var(--muted); }
.facts dd { overflow-wrap: anywhere; }
.facts--grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 1rem 1.5rem; }
.facts--boxed { padding: 1rem; margin: 1rem 0; background: var(--bg); border-radius: var(--radius-sm); }
.facts--boxed dd { font-weight: 500; font-size: 1.0625rem; }
.note { margin-top: 1rem; padding: .75rem 1rem; background: var(--bg); border-radius: var(--radius-sm); white-space: pre-line; font-size: .9375rem; }
.panel > .note:first-of-type { margin-top: 0; }
.bullets { display: grid; gap: .25rem; }
.bullets li { position: relative; padding-left: 1.125rem; font-size: .9375rem; }
.bullets li::before { content: ''; position: absolute; left: .25rem; top: .6em; width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }
.address { margin-bottom: .75rem; }
.contact-name { font-weight: 500; margin-bottom: .75rem; }
.contact-links { display: flex; flex-wrap: wrap; gap: .5rem; }

.table-wrap { overflow-x: auto; margin: 0 -1.25rem; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th {
  padding: .5rem .75rem; text-align: left; font-size: .8125rem; font-weight: 450; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .625rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 1.25rem; }
.table th:last-child, .table td:last-child { padding-right: 1.25rem; }
.table .num { text-align: right; width: 1%; white-space: nowrap; }
.table--edit td { padding: .375rem .25rem; }
.table--edit input, .table--edit select { width: 100%; min-width: 7rem; }
.table--edit .input--xs { min-width: 4.5rem; width: 4.5rem; }

/* ==========================================================================
   Moduli
   ========================================================================== */
.form { display: grid; gap: 1rem; }
.fieldset { border: 0; margin: 0; padding: 1.25rem 1.5rem 1.5rem; display: grid; gap: 1rem; }
.fieldset + .fieldset { border-top: 1px solid var(--line); }
.fieldset legend { float: left; width: 100%; padding: 0; margin-bottom: .25rem; font-size: 1.0625rem; font-weight: 550; color: var(--navy); }
.fieldset legend + * { clear: both; }
.fields { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields--inner { gap: 1rem; }
.field { display: grid; gap: .375rem; align-content: start; }
.field--span2 { grid-column: 1 / -1; }
.field label, .field .label { font-size: .875rem; font-weight: 450; color: var(--ink-2); }
.req { color: var(--danger); }
.field__hint { font-size: .8125rem; color: var(--muted); }

input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 44px; padding: .5rem .75rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-weight: 350; transition: border-color .12s, box-shadow .12s;
}
.search input:not([type=checkbox]) { min-height: 0; border: 0; padding: .5rem 0; box-shadow: none; }
input:hover, select:hover, textarea:hover { border-color: #9fb0bf; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--focus); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; min-height: 88px; }
select {
  appearance: none; padding-right: 2.25rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6b7a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .625rem center; background-size: 1.125rem;
}
input[type=checkbox] { width: 1.125rem; height: 1.125rem; margin: .15rem 0 0; accent-color: var(--navy); flex: none; }

.check { display: flex; gap: .625rem; align-items: flex-start; cursor: pointer; }
.check span { display: grid; }
.check small { color: var(--muted); }
.checks { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin-top: .25rem; }
.check--compact { font-size: .9375rem; }

.form-error { padding: .75rem 1rem; background: var(--danger-bg); color: #7a1a12; border-radius: var(--radius-sm); font-size: .9375rem; }
.panel--form .form-error { margin: 0 1.5rem; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .5rem; }
.panel--form .form-actions { padding: 1rem 1.5rem; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }
.form-actions--sticky { position: sticky; bottom: 0; z-index: 5; }

/* ==========================================================================
   Documenti: galleria, caricamento
   ========================================================================== */
.doc-group + .doc-group { margin-top: 1rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(45%, 150px), 1fr)); gap: .75rem; }
.gallery li { position: relative; }
.gallery__item {
  display: grid; gap: .375rem; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; text-align: left;
  font-size: .8125rem; color: var(--ink-2);
}
.gallery__item img, .gallery__item .icon {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--bg);
}
.gallery__item .icon { padding: 30%; color: var(--muted); }
.gallery__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery li > .btn { position: absolute; top: .375rem; right: .375rem; background: rgb(255 255 255 / 92%); }
.lightbox img { max-height: 70vh; margin: 0 auto; border-radius: var(--radius-sm); }
.lightbox figcaption { margin-top: .75rem; color: var(--muted); }

.dropzone {
  position: relative; display: grid; justify-items: center; gap: .25rem;
  padding: 1.75rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg);
  transition: border-color .12s, background-color .12s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--teal); background: var(--teal-soft); }
.dropzone:focus-within { box-shadow: var(--focus); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone__icon { width: 2rem; height: 2rem; color: var(--teal-ink); margin-bottom: .25rem; }
.dropzone__title { font-weight: 450; }
.dropzone__hint { font-size: .8125rem; color: var(--muted); }
.file-list { display: grid; gap: .25rem; }
.file-list li { display: flex; align-items: center; gap: .5rem; font-size: .9375rem; }
.file-list span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list small { color: var(--muted); }
.file-list .icon { color: var(--teal-ink); width: 1.125rem; }
.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--teal); transition: width .2s; }

/* ==========================================================================
   Registro (timeline)
   ========================================================================== */
.timeline { position: relative; display: grid; gap: 1.25rem; }
.timeline::before { content: ''; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 2px; background: var(--line); }
.timeline__item { position: relative; display: flex; gap: 1rem; }
.timeline__dot { position: relative; width: 12px; height: 12px; margin-top: .375rem; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px var(--surface); }
.timeline__body { display: grid; gap: .25rem; font-size: .9375rem; min-width: 0; }
.timeline__body > .btn { justify-self: start; margin-top: .25rem; }
.timeline__title { font-weight: 500; font-size: 1rem; }
.timeline__meta { color: var(--muted); font-size: .875rem; }

/* ==========================================================================
   Dialoghi e notifiche
   ========================================================================== */
.dialog {
  width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
.dialog--wide { width: min(1040px, calc(100vw - 2rem)); }
.dialog::backdrop { background: rgb(6 35 64 / 45%); }
.dialog[open] { animation: dialog-in .16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }
.dialog__head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1rem 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.dialog__title { font-size: 1.125rem; font-weight: 550; color: var(--navy); overflow-wrap: anywhere; }
.dialog__body { padding: 1.25rem 1.5rem 1.5rem; }
.dialog__text { margin-bottom: 1rem; }
.dialog .table-wrap { margin: 0 -1.5rem .5rem; }

#toasts { position: fixed; left: 50%; bottom: 1.5rem; z-index: 1000; transform: translateX(-50%); display: grid; gap: .5rem; width: min(440px, calc(100vw - 2rem)); }
.toast {
  padding: .75rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  background: var(--navy); color: #fff; font-size: .9375rem;
  animation: toast-in .18s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast--warn { background: #6b4000; }
.toast--danger { background: var(--danger); }
.toast--out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   Accesso
   ========================================================================== */
.shell--auth { min-height: 100vh; }
.auth {
  min-height: 100vh; display: grid; place-content: center; gap: 1.5rem; padding: 2rem 1rem;
  background:
    linear-gradient(180deg, rgb(6 35 64 / 0%) 60%, rgb(6 35 64 / 5%)),
    var(--bg);
}
.auth__panel {
  width: min(420px, calc(100vw - 2rem)); padding: 2.25rem 2rem 2rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.auth__logo { width: 210px; height: auto; margin: 0 auto 2rem; }
.auth__title { font-size: 1.5rem; font-weight: 500; color: var(--navy); }
.auth__lead { color: var(--muted); margin: .25rem 0 1.5rem; }
.auth__hint { margin-top: 1.25rem; font-size: .875rem; color: var(--muted); text-align: center; }
.auth__foot { text-align: center; font-size: .8125rem; color: var(--muted); }
.auth__foot a { color: inherit; }

/* ==========================================================================
   Adattamento a tablet e smartphone
   ========================================================================== */
@media (max-width: 1080px) {
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .shell--staff { display: block; }
  .shell--staff .topbar { display: flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 85vw);
    transform: translateX(-100%); transition: transform .2s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open::after {
    content: ''; position: fixed; inset: 0; z-index: 40; background: rgb(6 35 64 / 35%);
  }
  .main { padding-top: 1.5rem; }
}

@media (max-width: 640px) {
  .main { padding: 1.25rem 1rem 5rem; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .fields--inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fieldset { padding: 1.125rem 1rem 1.25rem; }
  .panel { padding: 1rem; }
  .panel > .list { margin: 0 -1rem -1rem; }
  .table-wrap { margin: 0 -1rem; }
  .row { padding: .875rem 1rem; gap: .75rem; flex-wrap: wrap; }
  .row__side { justify-items: start; text-align: left; max-width: none; flex-basis: 100%; padding-left: 1.375rem; }
  .row__chevron { display: none; }
  .row--compact .row__side, .doc .row__side { flex-basis: auto; padding-left: 0; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .topbar__account .btn span { display: none; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .summary__item { border-bottom: 1px solid var(--line); }
  .dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  .dialog__body { padding: 1rem; }
  .dialog .table-wrap { margin: 0 -1rem .5rem; }
  .panel--form .form-actions { padding: 1rem; }
  .panel--form .form-error { margin: 0 1rem; }
  .form-actions .btn { flex: 1 1 auto; }
  .form-actions .spacer { display: none; }
  .auth__panel { padding: 1.75rem 1.25rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
