/* Easy Sign – design system
   Morbido e leggibile, mobile first: barre e pulsanti a misura di dito (≥ 44 px), testo dei campi a 16 px
   (niente zoom automatico su iPhone), aree sicure di notch e barra Home, tema chiaro e scuro. */

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --border: #e7e9f1;
  --border-strong: #d4d8e3;
  --primary: #5b5bf0;
  --primary-strong: #4644d6;
  --primary-soft: #eef0ff;
  --primary-text: #ffffff;
  --primary-rgb: 99 102 241;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c026d3 120%);
  --ok: #0f9a4c; --ok-soft: #e7f8ee;
  --info: #2563eb; --info-soft: #eaf1ff;
  --warn: #b26b00; --warn-soft: #fff4e0;
  --partial: #9a6400; --partial-soft: #fff6d9;
  --danger: #dc3a3f; --danger-soft: #fff0f0;
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 28px rgba(16, 24, 40, .06);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .14);
  --ring: 0 0 0 4px rgb(var(--primary-rgb) / .18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 256px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d15;
    --surface: #141826;
    --surface-2: #1a1f31;
    --text: #eef0f7;
    --text-2: #cdd2df;
    --muted: #98a1b6;
    --border: #252b40;
    --border-strong: #343b55;
    --primary: #8f90ff;
    --primary-strong: #a9aaff;
    --primary-soft: #23264a;
    --ok: #4ade80; --ok-soft: #12291d;
    --info: #7aa7ff; --info-soft: #172443;
    --warn: #fbbf4c; --warn-soft: #33270f;
    --partial: #f5cf6a; --partial-soft: #33290f;
    --danger: #ff7a7e; --danger-soft: #3a1a20;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 8px 28px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
    --ring: 0 0 0 4px rgb(var(--primary-rgb) / .25);
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text); letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.9rem); font-weight: 750; margin: 0 0 6px; }
h2 { font-size: 1.12rem; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 1rem; font-weight: 700; margin: 20px 0 10px; }
p { margin: 0 0 12px; }
small { font-size: .82rem; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i-lg { width: 28px; height: 28px; }
.i-xl { width: 44px; height: 44px; stroke-width: 1.6; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .88em; }
.hash { word-break: break-all; font-size: .78rem; color: var(--text-2); }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; margin: 6px 0; }
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* ------------------------------------------------------------------ struttura dell'area mittente */
.sidebar { display: none; }
.app { min-height: 100vh; min-height: 100dvh; }
.content { width: 100%; max-width: 1080px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 32px); }

.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  min-height: calc(56px + var(--safe-t)); padding: var(--safe-t) 12px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.appbar-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.08rem; color: var(--text); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 4px 14px rgb(var(--primary-rgb) / .35); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar-h);
  color: var(--muted); font-size: .7rem; font-weight: 600;
}
.tab:hover { text-decoration: none; color: var(--text-2); }
.tab .i { width: 23px; height: 23px; }
.tab[aria-current="page"] { color: var(--primary); }
.tab-fab { position: relative; }
.tab-fab span.fab {
  display: grid; place-items: center; width: 54px; height: 54px; margin-top: -26px; border-radius: 18px;
  background: var(--grad); color: #fff; box-shadow: 0 10px 24px rgb(var(--primary-rgb) / .45);
}
.tab-fab .i { width: 26px; height: 26px; stroke-width: 2.4; }

@media (min-width: 960px) {
  .appbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    padding: 22px 16px; background: var(--surface); border-right: 1px solid var(--border); z-index: 10;
  }
  .sidebar .brand { padding: 4px 10px 18px; }
  .sidebar .btn { margin: 4px 0 14px; }
  .side-link {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--text-2); font-weight: 600;
  }
  .side-link:hover { background: var(--surface-2); text-decoration: none; }
  .side-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  .sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
  .sidebar-foot button.side-link { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; }
  .app { margin-left: var(--sidebar-w); }
  .content { padding: 32px 36px 56px; }
}

/* ------------------------------------------------------------------ pagine semplici (firmatario, verifica, errori) */
.topbar {
  position: sticky; top: 0; z-index: 20; padding: var(--safe-t) 0 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: calc(40px + var(--safe-b)); }
body.signer main.wrap, body.public main.wrap { max-width: 760px; }
.site-foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 8px 16px calc(24px + var(--safe-b)); }
.site-foot a { color: var(--muted); text-decoration: underline; }

/* ------------------------------------------------------------------ componenti */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card.tight { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.card.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.card-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); flex: none; }
.card-icon.ok { background: var(--ok-soft); color: var(--ok); }
.card-icon.warn { background: var(--warn-soft); color: var(--warn); }
.card-icon.danger { background: var(--danger-soft); color: var(--danger); }
.card-icon .i { width: 19px; height: 19px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.cards > .card { margin-bottom: 0; }
.cards + .card, .cards + section, .cards + details { margin-top: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 0 10px; }
.stack > * + * { margin-top: 12px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 600; margin-bottom: 4px; }

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px;
  border: 0; border-radius: 13px; background: var(--grad); color: #fff; font: inherit; font-weight: 650; font-size: .97rem;
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: 0 6px 18px rgb(var(--primary-rgb) / .28);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
}
.btn:hover { text-decoration: none; box-shadow: 0 8px 24px rgb(var(--primary-rgb) / .38); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn .i { width: 19px; height: 19px; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--primary); box-shadow: none; }
.btn-ghost:hover { background: var(--primary-soft); box-shadow: none; }
.btn-danger { background: var(--danger); box-shadow: 0 6px 18px rgba(220, 58, 63, .25); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: .88rem; border-radius: 11px; }
.btn-block { display: flex; width: 100%; }
button.link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 599px) {
  .actions.stack-mobile { flex-direction: column; align-items: stretch; }
  .actions.stack-mobile > *, .actions.stack-mobile form, .actions.stack-mobile .btn { width: 100%; }
}

/* Moduli */
.form label { display: block; font-weight: 600; font-size: .9rem; color: var(--text-2); margin-bottom: 14px; }
.opt { font-weight: 500; color: var(--muted); font-size: .8rem; margin-left: 4px; }
.req { color: var(--danger); margin-left: 2px; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]), .form textarea, .form select, .field {
  display: block; width: 100%; margin-top: 6px; min-height: 48px; padding: 11px 14px;
  font: inherit; font-size: 16px; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.form select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.form textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.form input:focus, .form textarea:focus, .form select:focus, .field:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.form input::placeholder, .form textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.form input[type=file] {
  display: block; width: 100%; margin-top: 6px; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: 14px;
  background: var(--surface-2); font: inherit; font-size: .95rem; color: var(--text-2); cursor: pointer;
}
.form input[type=file]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border: 0; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font: inherit; font-weight: 650; cursor: pointer;
}
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; margin: 1px 0 0; }
label.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; font-size: .95rem; color: var(--text); margin-bottom: 12px; cursor: pointer; }
label.check.boxed { padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
label.check.boxed:has(input:checked) { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); background: var(--primary-soft); }
label.disabled { color: var(--muted); cursor: not-allowed; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 700; font-size: .92rem; padding: 0; margin-bottom: 10px; color: var(--text-2); }
fieldset.step { border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: var(--surface-2); margin-bottom: 14px; }
fieldset.step legend { float: left; width: 100%; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
fieldset.step legend + * { clear: both; }
.step-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--grad); color: #fff; font-size: .8rem; font-weight: 700; }
.form-actions { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); z-index: 5; display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px; margin: 0 -4px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
@media (min-width: 960px) { .form-actions { bottom: 16px; } }
@media (max-width: 599px) { .form-actions .btn { flex: 1; } }

/* Messaggi */
.alert {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 14px; margin: 0 0 16px;
  background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent); font-size: .95rem;
}
.alert > .i { color: var(--warn); margin-top: 1px; }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-ok > .i { color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-error > .i { color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert-info > .i { color: var(--info); }
.alert p:last-child { margin-bottom: 0; }
.alert .body { flex: 1; min-width: 0; }

/* Stati */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: .8rem; font-weight: 650; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-bozza { color: var(--muted); }
.badge-inviato, .badge-aperto { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-firmato_in_parte { background: var(--partial-soft); color: var(--partial); border-color: transparent; }
.badge-completato, .badge-controfirmato { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-rifiutato, .badge-annullato, .badge-scaduto { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* Elenchi a schede (stile app) */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 18px;
  color: inherit; border-bottom: 1px solid var(--border); transition: background .12s;
}
.list li:last-child .list-row, .list > .list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-main { min-width: 0; }
.list-title { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { display: block; color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.list-side small { color: var(--muted); }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-weight: 700; font-size: .92rem;
  background: var(--primary-soft); color: var(--primary); flex: none;
}
.avatar.c1 { background: #e8f1ff; color: #2459c9; } .avatar.c2 { background: #fdeefa; color: #b02a8f; }
.avatar.c3 { background: #e9f8ef; color: #12854a; } .avatar.c4 { background: #fff3e2; color: #b0610b; }
.avatar.c5 { background: #f1ecff; color: #6941c6; }
@media (prefers-color-scheme: dark) {
  .avatar.c1 { background: #17284a; color: #8db4ff; } .avatar.c2 { background: #3a1834; color: #f39ad9; }
  .avatar.c3 { background: #12291d; color: #6ee7a0; } .avatar.c4 { background: #33250f; color: #fbbf6a; }
  .avatar.c5 { background: #261d47; color: #b9a2ff; }
}
@media (max-width: 599px) {
  .list-row { grid-template-columns: auto 1fr; padding: 14px 16px; }
  .list-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; margin-top: -4px; }
}

/* Statistiche */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-value { font-size: 1.7rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; margin-top: 4px; }
.stat.accent { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 10px 28px rgb(var(--primary-rgb) / .32); }
.stat.accent .stat-label { color: rgba(255, 255, 255, .85); }
@media (max-width: 599px) { .stat { padding: 13px; } .stat-value { font-size: 1.4rem; } .stat-label { font-size: .74rem; } }

/* Filtri a pillole e ricerca */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.search { position: relative; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%; min-height: 48px; padding: 10px 14px 10px 44px; font: inherit; font-size: 16px; color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); -webkit-appearance: none;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 15px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: .88rem;
}
.chip:hover { text-decoration: none; border-color: var(--border-strong); }
.chip[aria-current="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .count { font-size: .76rem; opacity: .7; }

/* Stato vuoto */
.empty { text-align: center; padding: 44px 20px; }
.empty .icon-wrap { display: inline-grid; place-items: center; width: 76px; height: 76px; border-radius: 24px; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 380px; margin: 0 auto 18px; }

/* Avanzamento della pratica */
.tracker { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; margin: 18px -4px 2px; padding: 0 4px; }
.tracker::-webkit-scrollbar { display: none; }
.tracker li { list-style: none; flex: 1 0 84px; position: relative; text-align: center; font-size: .76rem; font-weight: 600; color: var(--muted); padding-top: 30px; }
.tracker li::before {
  content: ""; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong); z-index: 1;
}
.tracker li::after { content: ""; position: absolute; top: 12px; left: calc(-50% + 12px); right: calc(50% + 12px); height: 2px; background: var(--border-strong); }
.tracker li:first-child::after { display: none; }
.tracker li.done { color: var(--text-2); }
.tracker li.done::before { background: var(--primary); border-color: var(--primary); box-shadow: inset 0 0 0 3px var(--surface); }
.tracker li.done::after, .tracker li.current::after { background: var(--primary); }
.tracker li.current { color: var(--primary); }
.tracker li.current::before { border-color: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.tracker li.stop { color: var(--danger); }
.tracker li.stop::before { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 3px var(--surface); }
.tracker ol { display: contents; }

/* Elenco descrittivo */
.dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 10px 18px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 599px) {
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dt { font-size: .8rem; margin-top: 10px; }
  .dl dt:first-child { margin-top: 0; }
}
.kv { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .i { color: var(--muted); }
.kv .k { color: var(--muted); font-size: .82rem; }
.kv .v { font-weight: 600; word-break: break-word; }

/* Tabelle (diventano schede su smartphone) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.table tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 9px 10px; font-size: .9rem; }
.table tr.current td { background: var(--ok-soft); }
@media (max-width: 699px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .table.responsive tr:last-child { border-bottom: 0; }
  .table.responsive td { border: 0; padding: 3px 0; }
  .table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: .74rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .table.responsive tr.current { background: var(--ok-soft); border-radius: 12px; padding: 12px; }
  .table.responsive tr.current td { background: none; }
}

/* Timeline del registro */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline li::after { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .t-title { font-weight: 650; }
.timeline .t-meta { color: var(--muted); font-size: .82rem; }
.timeline details { margin-top: 4px; }
.timeline details summary { font-size: .82rem; color: var(--primary); cursor: pointer; }
.timeline pre { white-space: pre-wrap; word-break: break-word; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 6px 0 0; }

/* Sezioni espandibili */
details.card > summary, details.acc > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700;
}
details.card > summary::-webkit-details-marker, details.acc > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
details.card > summary::after, details.acc > summary::after {
  content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s; margin: -4px 6px 0 0; flex: none;
}
details[open].card > summary::after, details[open].acc > summary::after { transform: rotate(225deg); margin-top: 4px; }
details.card[open] > summary { margin-bottom: 16px; }
details.card.nested { box-shadow: none; background: var(--surface-2); }

/* Link e chiavi da copiare */
.link-box { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; margin-top: 8px; }
.link-box input {
  flex: 1; min-width: 200px; min-height: 44px; font-family: var(--mono); font-size: .82rem; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text);
}

/* ------------------------------------------------------------------ accesso */
body.auth-page { background: var(--surface); }
.auth { display: grid; min-height: 100vh; min-height: 100dvh; grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; background: var(--grad);
  padding: calc(28px + var(--safe-t)) 24px 34px;
}
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); }
.auth-hero::before { width: 380px; height: 380px; right: -140px; top: -120px; background: radial-gradient(circle, rgba(255,255,255,.28), rgba(255,255,255,0) 70%); }
.auth-hero::after { width: 300px; height: 300px; left: -120px; bottom: -150px; background: radial-gradient(circle, rgba(255,255,255,.18), rgba(255,255,255,0) 70%); }
.auth-hero > * { position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.auth-brand img { width: 44px; height: 44px; border-radius: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); border: 2px solid rgba(255, 255, 255, .35); }
.auth-slogan { font-size: clamp(2.2rem, 1.6rem + 3vw, 3.6rem); font-weight: 800; letter-spacing: -.04em; line-height: 1.02; margin: 28px 0 12px; color: #fff; }
.auth-lead { font-size: 1.08rem; color: rgba(255, 255, 255, .9); max-width: 470px; margin-bottom: 22px; }
.auth-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-features li { display: flex; gap: 12px; align-items: flex-start; color: rgba(255, 255, 255, .95); }
.auth-features .i { width: 22px; height: 22px; flex: none; padding: 4px; box-sizing: content-box; border-radius: 9px; background: rgba(255, 255, 255, .18); }
.auth-features strong { display: block; }
.auth-features span { color: rgba(255, 255, 255, .78); font-size: .92rem; }
.auth-note { margin-top: 26px; font-size: .78rem; color: rgba(255, 255, 255, .7); }
.auth-panel { display: flex; align-items: flex-start; justify-content: center; padding: 28px 20px calc(28px + var(--safe-b)); background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-links { margin-top: 22px; text-align: center; font-size: .9rem; color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px !important; }
.pw-toggle { position: absolute; right: 4px; bottom: 3px; }
@media (max-width: 899px) {
  .auth-features, .auth-note { display: none; }
  .auth-hero { padding-bottom: 28px; border-radius: 0 0 28px 28px; }
  .auth-slogan { margin-top: 18px; font-size: 2.1rem; }
  .auth-lead { font-size: 1rem; margin-bottom: 0; }
}
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1.1fr) minmax(420px, 1fr); grid-template-rows: 1fr; }
  .auth-panel { align-items: center; }
  .auth-hero { display: flex; flex-direction: column; justify-content: center; padding: 56px 64px; }
  .auth-panel { padding: 48px; }
}

/* ------------------------------------------------------------------ firmatario */
.signer-hero { display: flex; gap: 14px; align-items: flex-start; }
.signer-hero .doc-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--grad); color: #fff; flex: none; box-shadow: 0 8px 20px rgb(var(--primary-rgb) / .3); }
.signer-hero .doc-icon .i { width: 26px; height: 26px; }
.signer-hero h1 { font-size: 1.35rem; margin: 2px 0 4px; }
.signer-hero p { margin: 0; color: var(--text-2); }
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 4px; list-style: none; padding: 0; }
.stepper li { display: flex; flex-direction: column; gap: 8px; font-size: .78rem; font-weight: 650; color: var(--muted); }
.stepper li::before { content: ""; height: 5px; border-radius: 999px; background: var(--border); }
.stepper li.done::before, .stepper li.current::before { background: var(--grad); }
.stepper li.current { color: var(--primary); }
.stepper li.done { color: var(--text-2); }
.doc-meta summary { font-size: .88rem; color: var(--primary); font-weight: 600; cursor: pointer; list-style: none; margin-top: 12px; }
.doc-meta summary::-webkit-details-marker { display: none; }
.doc-meta[open] summary { margin-bottom: 10px; }
.legal { max-height: 300px; overflow-y: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); margin-bottom: 14px; font-size: .93rem; color: var(--text-2); }
.legal-details { margin-bottom: 14px; }
.legal-details summary { cursor: pointer; font-weight: 650; margin-bottom: 8px; color: var(--primary); }
.step-text { padding: 14px 16px; border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 0 14px 14px 0; margin: 12px 0 16px; color: var(--text); }
.steps-progress { list-style: none; padding: 0; margin: 0; }
.steps-progress li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.steps-progress li:last-child { border-bottom: 0; }
.steps-progress li::before {
  content: ""; flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); margin-top: 1px;
}
.steps-progress li.done::before { border: 0; background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/14px no-repeat; }
.steps-progress li.current::before { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.steps-progress li.current > span { font-weight: 700; }
.steps-progress small { display: block; }
.otp-form { padding: 18px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 16px; }
.otp-input {
  font-family: var(--mono) !important; font-size: 1.9rem !important; letter-spacing: .45em; text-align: center;
  max-width: 280px; margin-left: auto; margin-right: auto; padding-left: calc(14px + .45em) !important;
}
.channels label.check { margin-bottom: 10px; }
.success-mark { display: grid; place-items: center; width: 84px; height: 84px; margin: 6px auto 16px; border-radius: 28px; background: var(--ok-soft); color: var(--ok); }
.success-mark .i { width: 44px; height: 44px; stroke-width: 2.2; }
.center { text-align: center; }

/* Visualizzatore PDF */
.viewer {
  height: 62vh; height: 62dvh; overflow-y: auto; background: color-mix(in srgb, var(--border) 70%, var(--bg));
  border-radius: 16px; padding: 12px 8px; outline: none; -webkit-overflow-scrolling: touch;
}
.viewer .page { display: flex; flex-direction: column; align-items: center; margin-bottom: 14px; }
.viewer canvas { background: #fff; box-shadow: 0 2px 10px rgba(16, 24, 40, .16); border-radius: 4px; max-width: 100%; }
.page-label { font-size: .78rem; color: var(--muted); margin: 6px 0 0; font-weight: 600; }
.viewer-status { margin: 10px 0 0; font-size: .9rem; }
.sticky-actions, .cta-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 12px -20px -20px; padding: 14px 20px calc(14px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
.sticky-actions .btn, .cta-bar .btn { width: 100%; }

/* Scelta della posizione dei riquadri */
.picker { margin-top: 12px; overflow-x: auto; }
.picker-stage { position: relative; display: inline-block; line-height: 0; }
.picker-stage canvas { cursor: crosshair; box-shadow: 0 2px 10px rgba(16, 24, 40, .16); background: #fff; border-radius: 4px; }
.picker-box { position: absolute; border: 2px solid var(--primary); background: rgb(var(--primary-rgb) / .16); border-radius: 4px; pointer-events: none; }

/* ------------------------------------------------------------------ verifica pubblica */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 150px; padding: 20px;
  border: 2px dashed var(--border-strong); border-radius: 18px; cursor: pointer; text-align: center; position: relative;
  background: var(--surface-2); color: var(--text-2); font-weight: 600; transition: border-color .15s, background .15s;
}
.dropzone .i { width: 34px; height: 34px; color: var(--primary); }
.dropzone small { font-weight: 500; color: var(--muted); }
.dropzone.over, .dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { box-shadow: var(--ring); }
.verify-result h3 { margin: 22px 0 10px; }
.result-banner { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 18px; margin-bottom: 16px; }
.result-banner.ok { background: var(--ok-soft); }
.result-banner.ko { background: var(--danger-soft); }
.result-banner .i { width: 34px; height: 34px; flex: none; }
.result-banner.ok .i { color: var(--ok); }
.result-banner.ko .i { color: var(--danger); }
.result-banner strong { display: block; font-size: 1.05rem; }

/* Registro (vecchio formato tabellare) */
.audit pre { white-space: pre-wrap; font-size: .8rem; max-width: 420px; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 12px; }
.appbar-logo { width: 30px; height: 30px; border-radius: 9px; }
.badge .i { width: 14px; height: 14px; margin: 0 -2px 0 -2px; }
.badge:has(.i)::before { display: none; }
details.acc { margin: 4px 0 12px; }
details.acc > summary { padding: 10px 0; font-weight: 600; color: var(--text-2); }
details.acc > summary span { display: inline-flex; align-items: center; gap: 8px; }
details.step-extra > summary { color: var(--primary); }
.hint .i { width: 16px; height: 16px; margin: -2px 4px 0 0; }
fieldset.step .btn { margin-top: 4px; }
.mt { margin-top: 16px; }
.card .dl + .actions, .card .kv + .actions, .card .dl + form { margin-top: 16px; }
.tracker.card { padding: 16px 12px 14px; margin: 0 0 16px; }
.tracker.card li { padding-top: 28px; }
.list-row > .i { color: var(--muted); }
.card:not(.tight) .list { margin: 8px -20px -20px; border-top: 1px solid var(--border); }
.success-mark.declined { background: var(--danger-soft); color: var(--danger); }
.step-card h3 { margin-top: 4px; font-size: 1.1rem; }
.otp-form p { margin-bottom: 14px; }
.cta-bar { margin-top: 16px; }

/* Ritocchi per smartphone */
.btn-block, .sticky-actions .btn, .cta-bar .btn { white-space: normal; text-align: center; line-height: 1.25; padding-top: 10px; padding-bottom: 10px; }
.list-row:has(> .i) { grid-template-columns: auto 1fr auto; }
.list-row:has(> .i) .list-side { grid-column: auto; }
@media (max-width: 599px) {
  .signer-hero { flex-direction: column; gap: 12px; }
  .signer-hero .doc-icon { width: 46px; height: 46px; border-radius: 14px; }
  .signer-hero h1 { font-size: 1.3rem; }
  .hide-mobile { display: none !important; }
  .page-head .actions .btn-small { flex: 1; }
  .card { padding: 18px 16px; }
  .card:not(.tight) .list { margin: 8px -16px -18px; }
  .sticky-actions, .cta-bar { margin: 12px -16px -18px; padding-left: 16px; padding-right: 16px; }
}
.steps-progress li > div { flex: 1; min-width: 0; }
.brand-custom img { width: 38px; height: 38px; border-radius: 11px; object-fit: cover; box-shadow: var(--shadow-sm); background: #fff; }
.brand-custom span { max-width: 52vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Aspetto: logo e tema */
.logo-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 112px; height: 112px; border-radius: 26px; overflow: hidden; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); flex: none; }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-actions { flex: 1; min-width: 240px; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-bottom: 8px; }
.theme-option { position: relative; display: flex !important; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px; margin: 0 !important;
  border: 1.5px solid var(--border); border-radius: 16px; background: var(--surface); cursor: pointer; font-weight: 650; font-size: .86rem; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option .swatch { width: 44px; height: 44px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .06); }
.theme-option:has(input:checked) { border-color: var(--primary); box-shadow: var(--ring); }
.theme-option:has(input:focus-visible) { box-shadow: var(--ring); }
fieldset.step legend .step-label { flex: 1; }
fieldset.step legend .step-num + .step-label [data-step-num] { font-weight: inherit; }
.step-remove { min-height: 34px; padding: 0 10px; color: var(--danger); }
.step-remove:hover { background: var(--danger-soft); }
.step-remove .i { width: 16px; height: 16px; }
