:root {
  --bg-0: #f2f6f3;
  --bg-1: #e6eee8;
  --ink: #1c2a22;
  --ink-strong: #101a14;
  --muted: #4d6255;
  --line: #c8d5cb;
  --surface: #ffffff;
  --surface-soft: #f6faf7;
  --brand: #135a3f;
  --brand-strong: #0d3e2c;
  --brand-glow: rgba(19, 90, 63, 0.22);
  --accent: #b46b3a;
  --accent-soft: #f5e7d6;
  --info: #2d6db8;
  --info-soft: #e6f0fb;
  --warn-bg: #fff6e8;
  --warn-line: #e4c79a;
  --ok-bg: #edf9f0;
  --ok-line: #b8dbbf;
  --danger: #b32837;
  --danger-soft: #ffeef0;
  --danger-line: #efc6cb;
  --shadow-lg: 0 18px 46px rgba(16, 36, 24, 0.12);
  --shadow-sm: 0 6px 18px rgba(16, 36, 24, 0.08);
  --shadow-pop: 0 22px 60px rgba(13, 62, 44, 0.28);
  --r-xl: 20px;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle at 7% 0%, #ffffff 0%, transparent 30%),
    radial-gradient(circle at 93% 0%, #eef5f0 0%, transparent 35%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

h1, h2, h3 {
  color: var(--ink-strong);
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0 0 10px; line-height: 1.52; }

.hidden { display: none !important; }

.muted { color: var(--muted); }
.tiny  { font-size: 12px; }

/* ===========================================================
   Brand
   =========================================================== */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #14523a 0%, #197a54 100%);
  color: #ecf6ef;
  box-shadow: 0 8px 22px rgba(19, 90, 63, 0.35);
}

/* ===========================================================
   Auth Screen (dedicated)
   =========================================================== */
.auth-screen {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  overflow: hidden;
}

.auth-screen__bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(25, 122, 84, 0.22), transparent 38%),
    radial-gradient(circle at 88% 84%, rgba(180, 107, 58, 0.16), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.6), transparent 55%);
  z-index: 0;
}

.auth-screen__inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  display: grid;
  gap: 22px;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: stretch;
  animation: fadeUp 480ms ease both;
}

.auth-pitch {
  padding: 28px;
  border-radius: 22px;
  background: linear-gradient(160deg, #103a2a 0%, #14523a 55%, #197a54 100%);
  color: #eaf5ee;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
  overflow: hidden;
}

.auth-pitch::after {
  content: '';
  position: absolute; right: -40px; bottom: -40px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%);
}

.auth-pitch__brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 0.02em;
}

.auth-pitch h1 {
  margin: 6px 0 2px;
  font-size: clamp(1.6rem, 3.2vw, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: #fff;
}

.auth-pitch__lead { color: #d8ece1; max-width: 36ch; }

.auth-pitch__list {
  list-style: none; padding: 0; margin: 8px 0 0;
  display: grid; gap: 8px;
}
.auth-pitch__list li {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: #f1faf3;
}
.auth-pitch__list svg { color: #b6e8ca; flex: 0 0 auto; }

.auth-pitch__note {
  margin-top: auto;
  display: inline-block;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  color: #eaf5ee;
  font-weight: 600;
  font-size: 13px;
}

.auth-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 12px;
}

.auth-card__tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #eef5f0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 4px;
}
.auth-card__tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: #345a45;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}
.auth-card__tab.is-active {
  background: #fff;
  color: var(--brand-strong);
  box-shadow: 0 4px 12px rgba(19, 90, 63, 0.12);
}

.auth-form { display: flex; flex-direction: column; gap: 2px; }
.auth-form .label { margin-top: 4px; }

.auth-card__msg { margin: 4px 2px 0; min-height: 16px; }
.auth-card__msg.is-error { color: var(--danger); }
.auth-card__msg.is-ok    { color: var(--brand-strong); }

.auth-card__resend,
.auth-card__dev {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--info-soft);
  border: 1px solid #c6dcef;
  font-size: 13px;
  color: #1b3f6a;
  display: flex; flex-direction: column; gap: 4px;
}
.auth-card__dev { background: #fff6e8; border-color: #e4c79a; color: #6a4a14; }

.link-btn {
  background: transparent; border: 0; padding: 0;
  color: var(--brand-strong);
  font: inherit; font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
  word-break: break-all;
}
.link-btn:hover { color: #0a2f20; }

.input-wrap { position: relative; }
.input-wrap__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted);
  display: inline-flex;
}
.input-wrap input { padding-left: 36px; }
.input-wrap--bare input { padding-left: 11px; }
.input-wrap--password input { padding-right: 42px; }

.pwd-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-top: -2px;
}
.pwd-toggle:hover { background: #eef5f0; color: var(--ink-strong); }
.pwd-toggle.is-on { color: var(--brand-strong); }

.auth-form__inline {
  display: flex; justify-content: flex-end;
  margin: -4px 0 8px;
}

/* ===========================================================
   Workspace shell
   =========================================================== */
.workspace { min-height: 100vh; display: flex; flex-direction: column; }

.workspace__topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #b7cabd;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  animation: fadeDown 320ms ease both;
}

.workspace__brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.workspace__brand strong { color: var(--ink-strong); }

.workspace__nav {
  display: flex; gap: 6px; justify-content: center;
  flex-wrap: nowrap; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.workspace__nav .tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent;
  background: transparent;
  flex-shrink: 0; white-space: nowrap;
  color: #345a45;
  font: inherit; font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.workspace__nav .tab:hover { background: #eef5f0; }
.workspace__nav .tab.is-active {
  color: #fff;
  border-color: var(--brand-strong);
  background: linear-gradient(180deg, #14523a 0%, var(--brand-strong) 100%);
  box-shadow: 0 8px 18px rgba(19, 90, 63, 0.25);
}

.workspace__profile {
  display: flex; align-items: center; gap: 8px;
  position: relative;
}
.workspace__profile select {
  width: auto; min-width: 0; max-width: 220px;
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
}

.avatar-btn {
  border: 1px solid var(--line);
  background: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.avatar-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: #a7bfae; }

.avatar {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #14523a 0%, #1d8a60 100%);
  letter-spacing: 0.02em;
}
.avatar--lg { width: 44px; height: 44px; font-size: 16px; }

.profile-menu {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  padding: 10px;
  z-index: 40;
  animation: popIn 160ms ease both;
}
.profile-menu__head {
  display: flex; gap: 10px; align-items: center;
  padding: 8px;
  border-radius: 10px;
  background: #f6faf7;
  margin-bottom: 8px;
}
.profile-menu__head strong { display: block; color: var(--ink-strong); }
.profile-menu__head p { margin: 0; }

.profile-menu__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit; font-weight: 600;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
}
.profile-menu__item:hover { background: #eef5f0; }
.profile-menu__item--danger { color: var(--danger); }
.profile-menu__item--danger:hover { background: var(--danger-soft); }

.workspace__main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 16px 32px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.workspace { min-width: 0; overflow-x: hidden; }

/* ===========================================================
   Generic UI
   =========================================================== */
.card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 360ms ease both;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.wrap { flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font: inherit; font-weight: 700;
  cursor: pointer;
  padding: 10px 14px;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-loading { opacity: 0.65; cursor: progress; pointer-events: none; }
.btn-block  { width: 100%; padding: 12px 14px; }

.btn-primary {
  color: #fff;
  border-color: var(--brand);
  background: linear-gradient(180deg, #176a49 0%, var(--brand) 100%);
  box-shadow: 0 10px 22px var(--brand-glow);
}
.btn-primary:hover { box-shadow: 0 14px 26px var(--brand-glow); }

.btn-light {
  color: #234434;
  border-color: #c8d7cb;
  background: #f2f7f3;
}
.btn-light:hover { background: #eaf2ed; }

.btn-danger {
  color: #fff;
  border-color: #8a1f2a;
  background: linear-gradient(180deg, #c4313f 0%, #a82230 100%);
  box-shadow: 0 10px 22px rgba(168, 34, 48, 0.28);
}
.btn-danger:hover { box-shadow: 0 14px 26px rgba(168, 34, 48, 0.32); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: #eef5f0; color: var(--ink-strong); }

select, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea {
  width: 100%;
  margin: 6px 0 10px;
  padding: 11px;
  font: inherit;
  color: var(--ink);
  border-radius: var(--r-md);
  border: 1px solid #c3d1c7;
  background: var(--surface-soft);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
select:focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
textarea:focus {
  outline: 0;
  box-shadow: 0 0 0 3px var(--brand-glow);
  border-color: var(--brand);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin: 0 6px 0 0;
  padding: 0;
  accent-color: var(--brand);
  vertical-align: middle;
  cursor: pointer;
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  cursor: pointer;
  font-weight: 600;
  color: #2a4938;
}

input[type="file"] {
  width: 100%;
  margin: 6px 0 10px;
  padding: 8px;
  font: inherit;
}

.label { font-size: 13px; font-weight: 700; color: #2a4938; }

.page h2 { margin: 0 0 10px; }

.section-title {
  margin: 14px 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4d6255;
  font-weight: 800;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 9px;
}
.metric {
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid #cedcce;
  background: linear-gradient(180deg, #f9fdf9 0%, #f1f7f2 100%);
}
.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 1.28rem;
  color: #163025;
}
button.metric--link {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  padding: 0;
  background: none;
  border: none;
}
button.metric--link > .metric {
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
button.metric--link:hover > .metric {
  border-color: var(--brand);
  box-shadow: 0 2px 10px rgba(42,120,75,.15);
}
button.metric--link:focus-visible > .metric {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
button.metric--link:active > .metric {
  transform: translateY(1px);
}

.pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #c9ddcc;
  color: #194830;
  background: #eef7f0;
}

.badge {
  display: inline-block;
  margin-right: 4px;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid #cfdbd0;
  color: #234a37;
  background: #f2f7f3;
}
.badge--admin {
  margin-top: 4px;
  color: #5f2a09;
  background: var(--accent-soft);
  border-color: #e0c098;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge--ok      { color: #194830; background: #eaf6ee; border-color: #b8dbbf; }
.badge--warn    { color: #6a4a14; background: var(--warn-bg); border-color: var(--warn-line); }
.badge--danger  { color: #7a1d27; background: var(--danger-soft); border-color: var(--danger-line); }
.badge--info    { color: #1b3f6a; background: var(--info-soft); border-color: #c6dcef; }

.tab--admin {
  position: relative;
}
.tab--admin::after {
  content: "ADMIN";
  position: absolute;
  top: -8px; right: -6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: #fff;
  padding: 2px 5px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(180, 107, 58, 0.35);
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid #e1e9e3;
  vertical-align: middle;
}
.admin-table th {
  background: #f6faf7;
  color: #2a4938;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.admin-table tr:hover td { background: #fafdfb; }
.admin-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table .btn { padding: 6px 10px; font-size: 12px; }
.admin-table-wrap { overflow-x: auto; }

.month-row {
  margin-bottom: 10px;
  border-radius: var(--r-lg);
  border: 1px solid #cfdbd1;
  padding: 12px;
  background: linear-gradient(180deg, #fdfffd 0%, #f7fbf8 100%);
  animation: cardIn 400ms ease both;
}

.stack { display: grid; gap: 8px; }

.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid #d0dbd2;
  background: #fbfdfb;
}

.cols2 {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}
.cols2 > * { min-width: 0; }
.cols2-full { grid-column: 1 / -1; }

.card, .month-row, .doc-row { min-width: 0; }

/* Forza word-wrap su testi lunghi (nomi file, fornitori, hash, IBAN) */
.card p, .card strong, .month-row p, .month-row strong, .doc-row p, .doc-row strong {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.warn {
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  border-radius: var(--r-md);
  padding: 10px;
}

.ok {
  border: 1px solid var(--ok-line);
  background: var(--ok-bg);
  border-radius: var(--r-md);
  padding: 10px;
}

hr {
  border: 0;
  border-top: 1px solid #d4ddd6;
  margin: 14px 0;
}

/* ===========================================================
   Modal
   =========================================================== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(13, 26, 19, 0.42);
  backdrop-filter: blur(2px);
  animation: fadeIn 180ms ease both;
}
.modal__panel {
  position: relative;
  width: min(520px, calc(100vw - 24px));
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn 200ms ease both;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal__body { padding: 16px; display: grid; gap: 6px; }
.modal__list { margin: 4px 0 10px; padding-left: 18px; color: var(--muted); }
.modal__list li { margin-bottom: 2px; }
.modal__foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fafcfa;
}

/* ===========================================================
   Toast
   =========================================================== */
.toast-root {
  position: fixed;
  z-index: 200;
  right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px; max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow-pop);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toastIn 200ms ease both;
  font-size: 14px;
  color: var(--ink);
}
.toast.is-leaving { animation: toastOut 200ms ease both; }
.toast--ok    { border-left-color: var(--brand); }
.toast--info  { border-left-color: var(--info); }
.toast--warn  { border-left-color: var(--accent); }
.toast--error { border-left-color: var(--danger); }
.toast__icon { flex: 0 0 auto; margin-top: 2px; color: var(--muted); }
.toast--ok    .toast__icon { color: var(--brand); }
.toast--info  .toast__icon { color: var(--info); }
.toast--warn  .toast__icon { color: var(--accent); }
.toast--error .toast__icon { color: var(--danger); }
.toast__body { flex: 1 1 auto; line-height: 1.4; }

/* ===========================================================
   Animations
   =========================================================== */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ===========================================================
   Responsive
   =========================================================== */
@media (max-width: 960px) {
  .auth-screen__inner { grid-template-columns: 1fr; }
  .auth-pitch { order: 2; }
  .auth-card  { order: 1; }
  .workspace__topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand profile"
      "nav   nav";
  }
  .workspace__brand   { grid-area: brand; }
  .workspace__profile { grid-area: profile; }
  .workspace__nav     { grid-area: nav; justify-content: flex-start; overflow-x: auto; }
  .workspace__profile select { display: none; }
}

@media (max-width: 720px) {
  .workspace__main { padding: 14px 12px 22px; }
  .card { padding: 12px; border-radius: 14px; }
  .doc-row { grid-template-columns: minmax(0, 1fr); }
  .cols2 { grid-template-columns: minmax(0, 1fr); }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-pitch { padding: 20px; }
  .auth-card  { padding: 20px; }
  .modal__foot .btn { flex: 1 1 auto; }
}

/* ── Drop zone ─────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.drop-zone:hover,
.drop-zone.drag-hover {
  border-color: var(--brand);
  background: #f0f9f4;
}
.drop-zone.drag-hover {
  box-shadow: 0 0 0 4px rgba(19,90,63,.12);
}
.drop-zone__icon {
  display: block;
  margin: 0 auto 10px;
  width: 40px; height: 40px;
  color: var(--brand);
  opacity: .7;
}
.drop-zone__label { font-size: .95rem; color: var(--ink); }
.drop-zone__hint  { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.drop-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

/* ── File chip list (selected files preview) ───────────── */
.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px 4px 10px;
  font-size: .78rem;
  background: var(--surface);
  max-width: 220px;
  overflow: hidden;
}
.file-chip__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.file-chip__remove {
  background: none; border: none; padding: 0;
  cursor: pointer; color: var(--muted);
  font-size: 1rem; line-height: 1;
  flex-shrink: 0;
}
.file-chip__remove:hover { color: var(--danger); }

/* ── Document search bar ───────────────────────────────── */
.doc-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.doc-search {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: .88rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s;
}
.doc-search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(19,90,63,.10);
}
.doc-search-count {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Preview modal (wide) ──────────────────────────────── */
.modal__panel--preview {
  width: min(900px, calc(100vw - 24px));
  height: min(88vh, 820px);
  display: flex;
  flex-direction: column;
}
.modal__panel--preview .modal__body {
  flex: 1;
  padding: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #111;
}
.preview-frame {
  width: 100%; height: 100%;
  border: none;
  display: block;
  flex-shrink: 0;
}
.preview-img {
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* ── Upload mode selector cards ────────────────────────── */
.upload-mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 0;
}
.upload-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: inherit;
}
.upload-mode-card:hover {
  border-color: var(--brand);
  background: var(--surface-soft);
}
.upload-mode-card--active {
  border-color: var(--brand);
  background: var(--ok-bg);
  box-shadow: 0 0 0 3px rgba(19, 90, 63, .12);
}
.upload-mode-card__icon {
  font-size: 1.7rem;
  line-height: 1;
  margin-bottom: 6px;
}
.upload-mode-card__label {
  font-size: .97rem;
  font-weight: 700;
  color: var(--ink-strong);
}
.upload-mode-card__sub {
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.35;
}
@media (max-width: 520px) {
  .upload-mode-cards { grid-template-columns: 1fr; }
}

/* ── Radio row (EC type picker) ────────────────────────── */
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 6px 0 10px;
}
.radio-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--ink);
}

/* ── Info box (blue) ───────────────────────────────────── */
.info-box {
  padding: 12px 14px;
  background: var(--info-soft);
  border: 1px solid #c0d6f0;
  border-radius: var(--r-md);
}
.info-box strong { color: var(--info); display: block; margin-bottom: 3px; }
.info-box p { font-size: .8rem; color: #1c4070; margin: 2px 0 0; line-height: 1.4; }

/* ── Onboarding tutorial overlay ───────────────────────── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(13, 26, 19, .6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 200ms ease both;
}
.onboarding-panel {
  position: relative;
  width: min(460px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 38px 32px 30px;
  box-shadow: var(--shadow-pop);
  animation: popIn 220ms ease both;
  text-align: center;
}
.onboarding-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 8px;
  line-height: 1;
}
.onboarding-close:hover { background: var(--bg-1); color: var(--ink); }
.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 22px;
}
.onboarding-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background .2s, transform .2s;
}
.onboarding-dot--active {
  background: var(--brand);
  transform: scale(1.35);
}
.onboarding-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 14px;
}
.onboarding-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink-strong);
  margin: 0 0 10px;
}
.onboarding-text {
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 28px;
}
.onboarding-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* ── Workflow stepper (dettaglio mese) ─────────────────── */
.workflow-steps {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 16px 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.workflow-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  text-align: center;
  border-right: 1px solid var(--line);
  font-size: .75rem;
  color: var(--muted);
  position: relative;
  transition: background .15s;
}
.workflow-step:last-child { border-right: none; }
.workflow-step__num {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  background: var(--bg-1);
  color: var(--muted);
  margin-bottom: 2px;
  flex-shrink: 0;
}
.workflow-step__label { font-weight: 600; color: var(--ink); font-size: .78rem; line-height: 1.2; }
.workflow-step__sub { font-size: .7rem; color: var(--muted); }
.workflow-step--done { background: var(--ok-bg); }
.workflow-step--done .workflow-step__num { background: var(--brand); color: #fff; }
.workflow-step--done .workflow-step__num::after { content: '✓'; }
.workflow-step--active { background: #fff8e8; }
.workflow-step--active .workflow-step__num { background: var(--accent); color: #fff; }
.workflow-step--pending { opacity: .55; }
@media (max-width: 600px) {
  .workflow-step__sub { display: none; }
  .workflow-step { padding: 10px 4px; }
}

/* ── Next-action card (dashboard) ──────────────────────── */
.next-action-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border: 1.5px solid var(--brand);
  border-radius: var(--r-lg);
  background: var(--ok-bg);
  margin-bottom: 20px;
}
.next-action-card__icon { font-size: 1.8rem; flex-shrink: 0; line-height: 1; }
.next-action-card__body { flex: 1; }
.next-action-card__title { font-weight: 700; font-size: 1rem; color: var(--ink-strong); margin: 0 0 4px; }
.next-action-card__sub { font-size: .85rem; color: var(--muted); margin: 0 0 12px; line-height: 1.45; }

/* ── Help hint (inline contextual text) ───────────────── */
.help-hint {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.45;
  padding: 8px 12px;
  background: var(--surface-soft);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-bottom: 12px;
}
.help-hint strong { color: var(--ink); }

/* ── Collega documento — pannello modale ───────────────── */
.link-doc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 900;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .15s ease;
}
@media (min-width: 600px) {
  .link-doc-overlay { align-items: center; padding: 24px; }
}
.link-doc-panel {
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 32px rgba(0,0,0,.18);
  overflow: hidden;
  animation: slideUp .18s ease;
}
@media (min-width: 600px) {
  .link-doc-panel { border-radius: var(--r-lg); box-shadow: 0 8px 40px rgba(0,0,0,.22); animation: fadeIn .18s ease; }
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.link-doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.link-doc-header__title { font-weight: 700; font-size: 1rem; }
.link-doc-header__sub   { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.link-doc-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  line-height: 1;
}
.link-doc-close:hover { background: var(--surface-soft); color: var(--ink); }
.link-doc-body {
  overflow-y: auto;
  padding: 14px 18px;
  flex: 1;
}
.link-doc-section-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 8px 0 6px;
}
.link-doc-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.link-doc-item:hover, .link-doc-item:focus {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
  outline: none;
}
.link-doc-item__name { font-size: .88rem; font-weight: 600; color: var(--ink); }
.link-doc-item__meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.link-doc-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.ns-doc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 8px;
  background: var(--surface-soft);
}
.ns-doc-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .1s;
}
.ns-doc-row:hover { background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.ns-doc-row input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--brand); }
.ns-doc-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
