:root {
  --ink: var(--brand-ink);
  --muted: var(--brand-muted-light);
  --paper: #f8f8f4;
  --canvas: var(--brand-paper-soft);
  --line: rgba(8, 11, 9, .14);
  --lime: var(--brand-lime);
  --lime-soft: #d5ffd5;
  --orange: #009e00;
  --blue: #00a800;
  --danger: var(--brand-danger);
  --white: #fff;
  --radius: var(--brand-radius);
  --shadow: var(--brand-shadow);
  --ease: var(--brand-ease);
}

* { box-sizing: border-box; }
html { width: 100%; max-width: 100%; overflow-x: hidden; overflow-x: clip; overscroll-behavior-x: none; scroll-behavior: smooth; }
body { width: 100%; max-width: 100%; margin: 0; overflow-x: hidden; overflow-x: clip; color: var(--ink); background: var(--canvas); font-family: var(--font-body); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
em { color: #009e00; font-family: inherit; font-style: normal; font-weight: 650; }
img { max-width: 100%; height: auto; }
.workspace-shell > *, .project-main, .project-main form, .form-step, .admin-shell, .clients-panel { min-width: 0; }

.skip-link { position: fixed; z-index: 1000; top: 10px; left: 10px; padding: 10px 14px; color: var(--white); background: var(--ink); border-radius: 10px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--brand-focus); outline-offset: 3px; }

.portal-header { position: relative; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 86px; padding: 0 clamp(22px, 4vw, 64px); }
.portal-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.portal-brand svg { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 2; }
.portal-brand span { display: flex; flex-direction: column; font-size: 19px; font-weight: 800; letter-spacing: .11em; line-height: 1; }
.portal-brand small { margin-top: 6px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.text-link, .link-button { padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; text-decoration: none; cursor: pointer; }
.text-link span { display: inline-block; margin-left: 5px; transition: transform .25s var(--ease); }
.text-link:hover span { transform: rotate(45deg); }
.link-button:hover, .text-link:hover { color: var(--ink); }
.portal-kicker { margin: 0 0 14px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }

.portal-button { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-height: 48px; padding: 12px 22px; border: 1px solid transparent; border-radius: 999px; font-size: 13px; font-weight: 800; cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s; }
.portal-button:hover:not(:disabled) { transform: translateY(-2px); }
.portal-button:disabled { cursor: not-allowed; opacity: .55; }
.portal-button.primary { color: var(--white); background: var(--ink); box-shadow: 0 12px 30px rgba(32, 35, 31, .16); }
.portal-button.primary:hover:not(:disabled) { box-shadow: 0 16px 36px rgba(32, 35, 31, .24); }
.portal-button.secondary { border-color: var(--line); background: var(--white); }
.portal-button.danger { border-color: #efd0cb; color: var(--danger); background: #fff8f7; }
.portal-button.wide { width: 100%; }
.portal-button.large { min-height: 56px; padding-inline: 30px; }
.portal-button.small { min-height: 39px; padding: 8px 16px; font-size: 12px; }

.portal-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.portal-field label, .message-preview-label { color: var(--ink); font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.portal-field label small { color: var(--muted); font-weight: 500; }
.portal-field input, .portal-field textarea, .portal-field select, .message-preview { width: 100%; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); outline: none; transition: border-color .2s, box-shadow .2s, background .2s; }
.portal-field input, .portal-field select { height: 52px; padding: 0 15px; }
.portal-field textarea, .message-preview { min-height: 100px; padding: 14px 15px; resize: vertical; line-height: 1.55; }
.portal-field input:focus, .portal-field textarea:focus, .portal-field select:focus, .message-preview:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(85, 119, 255, .11); background: var(--white); }
.portal-field input::placeholder, .portal-field textarea::placeholder { color: #a0a69d; }
.portal-field small { color: var(--muted); font-size: 11px; }
.portal-field.invalid input, .portal-field.invalid textarea, .portal-field.invalid select { border-color: var(--danger); }
.portal-error { min-height: 0; color: var(--danger); font-size: 11px; font-weight: 700; }
.portal-error:not(:empty) { min-height: 17px; }
.portal-error.standalone { display: block; margin: 8px 0; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.field-label-row > span { color: var(--muted); font-size: 11px; }
.form-grid { display: grid; gap: 20px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-two { grid-column: 1 / -1; }
.form-response { min-height: 21px; margin: 14px 0 0; color: var(--danger); font-size: 12px; font-weight: 700; text-align: center; }
.form-response[data-kind="success"] { color: #38730d; }

.global-toast { position: fixed; z-index: 500; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 14px 20px; border-radius: 14px; color: var(--white); background: var(--ink); box-shadow: var(--shadow); font-size: 13px; font-weight: 700; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .25s var(--ease); }
.global-toast.visible { opacity: 1; transform: translateY(0); }
.global-toast[data-kind="error"] { background: var(--danger); }
.global-toast[data-kind="success"] { color: var(--ink); background: var(--lime); }

/* Accesso */
.auth-page { min-height: 100vh; overflow-x: hidden; background: var(--paper); }
.auth-backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.auth-backdrop::before { position: absolute; inset: 0; background-image: linear-gradient(rgba(32,35,31,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(32,35,31,.04) 1px, transparent 1px); background-size: 56px 56px; content: ""; mask-image: linear-gradient(to right, #000, transparent 72%); }
.auth-backdrop span { position: absolute; border-radius: 50%; filter: blur(1px); }
.auth-backdrop span:nth-child(1) { right: 3%; bottom: -20%; width: 42vw; height: 42vw; background: rgba(182,242,56,.8); }
.auth-backdrop span:nth-child(2) { right: 31%; bottom: -30%; width: 26vw; height: 26vw; background: rgba(255,116,73,.78); }
.auth-backdrop span:nth-child(3) { top: 22%; left: -8%; width: 24vw; height: 24vw; border: 1px solid var(--line); background: rgba(255,255,255,.35); }
.auth-header { max-width: 1440px; margin: auto; }
.auth-layout { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(400px, 520px); gap: clamp(50px, 9vw, 150px); align-items: center; width: min(1240px, calc(100% - 44px)); min-height: calc(100vh - 110px); margin: auto; padding: 40px 0 90px; }
.auth-intro h1 { margin: 0; font-size: clamp(60px, 7.2vw, 110px); font-weight: 800; letter-spacing: -.075em; line-height: .86; }
.auth-intro > p:not(.portal-kicker) { max-width: 540px; margin: 34px 0; color: var(--muted); font-size: 17px; }
.auth-features { display: flex; flex-wrap: wrap; gap: 10px; }
.auth-features span { padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.68); font-size: 11px; font-weight: 700; }
.auth-features i { margin-right: 6px; color: var(--orange); font-style: normal; }
.auth-card { padding: clamp(28px, 4vw, 52px); border: 1px solid rgba(223,226,216,.8); border-radius: 30px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.auth-card-heading { margin-bottom: 28px; }
.auth-card-heading h2, .portal-dialog h2 { margin: 0 0 10px; font-size: clamp(31px, 3vw, 43px); letter-spacing: -.045em; line-height: 1; }
.auth-card-heading > p:last-child, .portal-dialog > p:not(.portal-kicker) { margin: 0; color: var(--muted); font-size: 13px; }
.auth-card form { display: grid; gap: 18px; }
.auth-card-actions { display: flex; justify-content: space-between; margin-top: 20px; }
.auth-help { margin: 28px 0 0; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; text-align: center; }
.notice { margin-bottom: 24px; padding: 12px 14px; border-radius: 12px; color: #315e10; background: var(--lime-soft); font-size: 12px; font-weight: 700; }

.portal-dialog { width: min(520px, calc(100vw - 30px)); padding: 38px; border: 1px solid var(--line); border-radius: 25px; color: var(--ink); background: var(--paper); box-shadow: 0 40px 100px rgba(15,20,14,.28); }
.portal-dialog::backdrop, .client-detail-dialog::backdrop { background: rgba(20, 24, 19, .62); backdrop-filter: blur(7px); }
.portal-dialog form:not(.dialog-close-form) { display: grid; gap: 18px; margin-top: 25px; }
.dialog-close-form { position: absolute; top: 14px; right: 14px; }
.dialog-close-form button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font-size: 24px; cursor: pointer; }

/* Header area di lavoro */
.workspace-page, .admin-page { min-height: 100vh; }
.workspace-header { position: sticky; top: 0; z-index: 30; min-height: 76px; border-bottom: 1px solid var(--line); background: rgba(255,254,249,.94); backdrop-filter: blur(18px); }
.workspace-header-meta { display: flex; align-items: center; gap: 18px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip > span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: var(--ink); background: var(--lime); font-size: 13px; font-weight: 900; }
.user-chip div { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip strong { max-width: 180px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.icon-button { display: grid; width: 40px; height: 40px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font-size: 17px; cursor: pointer; transition: transform .2s, background .2s; }
.icon-button:hover { background: var(--lime-soft); transform: rotate(8deg); }
.save-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.save-state i { width: 7px; height: 7px; border-radius: 50%; background: #78af40; }
.save-state[data-state="dirty"] i { background: #dca12f; }
.save-state[data-state="saving"] i { background: var(--blue); animation: pulse 1s infinite; }
.save-state[data-state="error"] { color: var(--danger); }
.save-state[data-state="error"] i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; transform: scale(.72); } }

/* Area cliente */
.workspace-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.project-sidebar { position: sticky; top: 76px; align-self: start; height: calc(100vh - 76px); padding: 34px 26px; overflow-y: auto; border-right: 1px solid var(--line); background: #e9ebe4; }
.project-progress-card { padding: 24px; border-radius: 20px; background: var(--ink); color: var(--white); }
.project-progress-card .portal-kicker { color: #b6bdb2; }
.progress-number { display: flex; align-items: flex-start; margin: 5px 0 10px; line-height: 1; }
.progress-number strong { font-size: 48px; letter-spacing: -.06em; }
.progress-number span { margin: 6px 0 0 4px; color: var(--lime); font-size: 15px; font-weight: 800; }
.progress-track { height: 4px; overflow: hidden; border-radius: 99px; background: #3c423a; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--lime); transition: width .5s var(--ease); }
.project-progress-card > p:last-child { margin: 14px 0 0; color: #aeb5ab; font-size: 10px; line-height: 1.6; }
.step-navigation { display: grid; margin-top: 24px; }
.step-navigation button { position: relative; display: grid; grid-template-columns: 28px 7px 1fr; gap: 10px; align-items: center; width: 100%; padding: 14px 8px; border: 0; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.step-navigation button::before { position: absolute; inset: 0; border-radius: 13px; background: var(--white); opacity: 0; content: ""; transition: opacity .2s; }
.step-navigation button:hover::before, .step-navigation button.active::before { opacity: 1; }
.step-navigation button > * { position: relative; }
.step-navigation button > span { font-size: 9px; font-weight: 800; }
.step-navigation button > i { width: 7px; height: 7px; border: 1px solid #99a093; border-radius: 50%; background: transparent; }
.step-navigation button.complete > i { border-color: #75a733; background: var(--lime); }
.step-navigation button.active > i { border-color: var(--orange); background: var(--orange); box-shadow: 0 0 0 4px rgba(255,116,73,.14); }
.step-navigation button div { display: flex; flex-direction: column; }
.step-navigation button strong { color: var(--ink); font-size: 12px; }
.step-navigation button small { margin-top: 2px; font-size: 9px; }
.sidebar-help { display: flex; gap: 10px; margin-top: 20px; padding: 16px; border-top: 1px solid #d4d7cf; color: var(--muted); }
.sidebar-help > span { display: grid; flex: 0 0 24px; width: 24px; height: 24px; place-items: center; border: 1px solid #b9beb5; border-radius: 50%; font-size: 10px; }
.sidebar-help p { margin: 0; font-size: 9px; line-height: 1.6; }
.sidebar-help strong { color: var(--ink); }

.project-main { width: min(920px, calc(100% - 56px)); margin: 0 auto; padding: 58px 0 120px; }
.form-step { display: none; animation: stepIn .35s var(--ease); }
.form-step.active { display: block; }
@keyframes stepIn { from { opacity: 0; transform: translateY(12px); } }
.step-heading { margin-bottom: 42px; }
.step-heading > span { display: block; margin-bottom: 15px; color: var(--orange); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.step-heading h1 { margin: 0; font-size: clamp(44px, 5vw, 72px); letter-spacing: -.065em; line-height: .98; }
.step-heading p { max-width: 620px; margin: 20px 0 0; color: var(--muted); font-size: 14px; }
.step-tip { display: flex; gap: 14px; margin-top: 28px; padding: 18px 20px; border: 1px solid #dde6c8; border-radius: 15px; background: #f6ffe5; }
.step-tip span { color: #5a880d; }
.step-tip p { margin: 0; color: var(--muted); font-size: 11px; }
.state-banner { display: flex; gap: 10px; align-items: center; margin-bottom: 32px; padding: 15px 18px; border-radius: 14px; font-size: 12px; }
.state-banner strong { white-space: nowrap; }
.state-banner span { color: var(--muted); }
.state-banner.submitted { background: var(--lime-soft); }
.state-banner.reopened { background: #fff1e9; }

.repeatable-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 50px 0 18px; }
.repeatable-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.repeatable-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.repeatable-list { display: grid; gap: 12px; }
.repeatable-row { position: relative; display: grid; grid-template-columns: 36px minmax(140px, .8fr) minmax(220px, 1.4fr) minmax(100px, .5fr); gap: 14px; align-items: start; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.65); }
.repeatable-row.social-row { grid-template-columns: minmax(120px, .5fr) 1fr; padding-right: 56px; }
.row-number { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: var(--muted); background: var(--canvas); font-size: 9px; font-weight: 800; }
.repeatable-row .portal-field label { font-size: 10px; }
.repeatable-row .portal-field input { height: 44px; }
.repeatable-row .portal-field textarea { min-height: 80px; }
.remove-row { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 21px; cursor: pointer; }
.remove-row:hover { color: var(--danger); background: #fff0ed; }

.hours-heading { margin-top: 50px; }
.hours-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.65); }
.hours-row { display: grid; grid-template-columns: 110px 90px 1fr 1fr; gap: 14px; align-items: center; min-height: 66px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.hours-row:last-child { border-bottom: 0; }
.hours-row > strong { font-size: 11px; }
.closed-toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; cursor: pointer; }
.closed-toggle input { position: absolute; opacity: 0; }
.closed-toggle span { width: 28px; height: 16px; padding: 2px; border-radius: 99px; background: #cdd1c8; transition: .2s; }
.closed-toggle span::after { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--white); content: ""; transition: .2s; }
.closed-toggle input:checked + span { background: var(--ink); }
.closed-toggle input:checked + span::after { transform: translateX(12px); }
.time-period { display: flex; align-items: center; gap: 7px; }
.time-period input { min-width: 0; width: 100%; height: 39px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); font-size: 11px; }
.time-period span { color: var(--muted); }
.hours-row.closed .time-period { opacity: .32; }

.social-fields { display: grid; gap: 14px; }
.social-field { display: grid; grid-template-columns: 48px 1fr; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.6); }
.social-field > div { display: flex; flex-direction: column; gap: 6px; }
.social-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--white); background: var(--ink); font-size: 10px; font-weight: 900; }
.social-field:nth-child(2) .social-icon { background: linear-gradient(135deg, #8b46dc, #ff5a65, #ffb24a); }
.social-field:nth-child(3) .social-icon { background: #1877f2; font-family: Georgia, serif; font-size: 20px; }
.social-field input { height: 42px; border: 0; padding: 0; background: transparent; box-shadow: none; }
.social-field input:focus { box-shadow: none; }

.upload-dropzone { display: flex; flex-direction: column; align-items: center; width: 100%; padding: 44px 24px; border: 1px dashed #aeb4aa; border-radius: 20px; background: rgba(255,255,255,.5); cursor: pointer; transition: border .2s, background .2s, transform .2s; }
.upload-dropzone:hover, .upload-dropzone.dragging { border-color: var(--blue); background: rgba(85,119,255,.05); transform: translateY(-2px); }
.upload-icon { display: grid; width: 48px; height: 48px; margin-bottom: 16px; place-items: center; border-radius: 50%; color: var(--white); background: var(--ink); font-size: 21px; }
.upload-dropzone strong { font-size: 14px; }
.upload-dropzone small { margin-top: 8px; color: var(--muted); font-size: 10px; }
.file-usage { display: flex; justify-content: space-between; margin: 11px 2px 22px; color: var(--muted); font-size: 9px; }
.file-list { display: grid; gap: 9px; }
.file-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 13px; align-items: center; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.file-type { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 10px; color: var(--muted); background: var(--canvas); font-size: 8px; font-weight: 900; }
.file-row > div:not(.file-actions) { display: flex; min-width: 0; flex-direction: column; }
.file-row strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.file-actions { display: flex; gap: 7px; }
.file-actions a, .file-actions button { padding: 7px 10px; border: 0; border-radius: 8px; color: var(--muted); background: var(--canvas); font-size: 9px; font-weight: 800; text-decoration: none; cursor: pointer; }
.file-actions button:hover { color: var(--danger); }

.submission-card { margin-top: 48px; padding: clamp(24px, 4vw, 40px); border-radius: 22px; color: var(--white); background: var(--ink); }
.submission-card h2 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.submission-card > div > p:last-child { max-width: 620px; color: #aeb5ab; font-size: 12px; }
.portal-consent { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; margin: 28px 0 8px; cursor: pointer; }
.portal-consent input { position: absolute; opacity: 0; }
.portal-consent > span { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid #656b61; border-radius: 6px; }
.portal-consent input:checked + span { border-color: var(--lime); background: var(--lime); }
.portal-consent input:checked + span::after { color: var(--ink); content: "✓"; font-size: 13px; font-weight: 900; }
.portal-consent small { color: #c4cbc0; font-size: 10px; line-height: 1.55; }
.submission-card .portal-button { margin-top: 16px; color: var(--ink); background: var(--lime); box-shadow: none; }

.project-actions { position: fixed; z-index: 15; right: 0; bottom: 0; left: 300px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 74px; padding: 10px max(28px, calc((100vw - 300px - 920px) / 2)); border-top: 1px solid var(--line); background: rgba(255,254,249,.94); backdrop-filter: blur(18px); }
.mobile-save-state { display: none; margin-right: auto; }

/* Pannello amministratore */
.admin-header .portal-brand small { color: var(--orange); }
.admin-user > span { color: var(--white); background: var(--ink); }
.admin-shell { width: min(1320px, calc(100% - 48px)); margin: auto; padding: 60px 0 100px; }
.admin-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; }
.admin-hero h1 { margin: 0; font-size: clamp(52px, 6vw, 82px); letter-spacing: -.07em; line-height: .9; }
.admin-hero > div > p:last-child { max-width: 560px; margin: 23px 0 0; color: var(--muted); font-size: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-top: 48px; }
.metric-grid article { position: relative; display: flex; min-height: 150px; flex-direction: column; justify-content: space-between; padding: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.metric-grid article::after { position: absolute; right: -25px; bottom: -40px; width: 100px; height: 100px; border: 1px solid var(--line); border-radius: 50%; content: ""; }
.metric-grid article.accent { border-color: var(--ink); color: var(--white); background: var(--ink); }
.metric-grid article.accent::after { border: 0; background: var(--lime); }
.metric-grid article > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.metric-grid article.accent > span { color: #aeb5ab; }
.metric-grid article strong { font-size: 44px; letter-spacing: -.06em; line-height: 1; }
.metric-grid article small { color: var(--muted); font-size: 9px; }
.metric-grid article.accent small { color: #aeb5ab; }

.clients-panel { margin-top: 24px; padding: clamp(20px, 3vw, 32px); border: 1px solid var(--line); border-radius: 22px; background: var(--paper); }
.clients-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding-bottom: 24px; }
.clients-toolbar h2 { margin: 0; font-size: 29px; letter-spacing: -.04em; }
.toolbar-controls { display: flex; gap: 8px; }
.search-control, .filter-control { display: flex; align-items: center; min-height: 42px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); }
.search-control { gap: 7px; padding: 0 14px; }
.search-control span { color: var(--muted); font-size: 18px; }
.search-control input, .filter-control select { border: 0; outline: none; background: transparent; font-size: 11px; }
.search-control input { width: 210px; }
.filter-control { padding: 0 8px 0 14px; }
.filter-control select { padding-right: 8px; }
.refresh { width: 42px; height: 42px; }
.refresh.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.client-table-wrap { overflow-x: auto; }
.client-table { width: 100%; border-collapse: collapse; }
.client-table th { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-align: left; text-transform: uppercase; }
.client-table td { padding: 16px 14px; border-bottom: 1px solid #e9ebe5; font-size: 11px; }
.client-table tbody tr { transition: background .15s; }
.client-table tbody tr:hover { background: #f8f9f4; }
.client-identity { display: flex; align-items: center; gap: 11px; }
.client-avatar { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--lime-soft); font-weight: 900; }
.client-identity > div { display: flex; min-width: 0; flex-direction: column; }
.client-identity strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.client-identity small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: var(--canvas); font-size: 9px; font-weight: 800; }
.status-badge i { width: 6px; height: 6px; border-radius: 50%; background: #9ca298; }
.status-badge.submitted { background: var(--lime-soft); }
.status-badge.submitted i { background: #6e9e20; }
.status-badge.reopened { background: #fff0e8; }
.status-badge.reopened i { background: var(--orange); }
.status-badge.disabled { color: var(--danger); background: #fff0ee; }
.status-badge.disabled i { background: var(--danger); }
.table-progress { display: flex; align-items: center; gap: 9px; min-width: 120px; }
.table-progress > span { width: 90px; height: 5px; overflow: hidden; border-radius: 99px; background: var(--canvas); }
.table-progress i { display: block; height: 100%; background: var(--ink); }
.table-progress strong { font-size: 9px; }
.table-open { border: 0; color: var(--ink); background: transparent; font-size: 10px; font-weight: 800; cursor: pointer; }
.loading-cell { padding: 50px !important; color: var(--muted); text-align: center; }
.error-cell { color: var(--danger); }
.client-cards { display: none; }
.empty-state { padding: 60px 20px; color: var(--muted); text-align: center; }
.empty-state > span { font-size: 40px; }
.empty-state h3 { margin: 10px 0 4px; color: var(--ink); }
.empty-state p { margin: 0; font-size: 11px; }

.create-dialog { width: min(640px, calc(100vw - 30px)); }
.create-dialog .portal-consent { color: var(--ink); }
.create-dialog .portal-consent small { color: var(--muted); }
.create-dialog .portal-consent > span { border-color: var(--line); }
.credential-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0; }
.credential-grid > div { display: flex; flex-direction: column; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.credential-grid span { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.credential-grid strong { margin-top: 5px; font-family: Consolas, monospace; font-size: 14px; }
.success-mark { display: grid; width: 46px; height: 46px; margin-bottom: 20px; place-items: center; border-radius: 50%; background: var(--lime); font-size: 20px; font-weight: 900; }
.message-preview-label { display: block; margin-bottom: 8px; }
.message-preview { background: var(--white); font-size: 11px; }

.client-detail-dialog { width: min(1000px, calc(100vw - 34px)); max-height: calc(100vh - 34px); padding: 0; overflow: auto; border: 0; border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 40px 100px rgba(15,20,14,.3); }
.detail-topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 24px 30px; border-bottom: 1px solid var(--line); background: rgba(255,254,249,.96); backdrop-filter: blur(18px); }
.detail-topbar h2 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.detail-topbar > div > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.detail-topbar-actions { display: flex; align-items: center; gap: 9px; }
.detail-topbar-actions form { margin: 0; }
.detail-content { display: grid; gap: 16px; padding: 26px 30px; }
.detail-loading { padding: 60px; color: var(--muted); text-align: center; }
.detail-section { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); break-inside: avoid; }
.detail-section h3 { margin: 0 0 18px; font-size: 16px; letter-spacing: -.02em; }
.detail-section dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; margin: 0; }
.detail-section dl > div { min-width: 0; }
.detail-section dl .wide { grid-column: 1 / -1; }
.detail-section dt { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.detail-section dd { margin: 5px 0 0; font-size: 11px; white-space: pre-line; overflow-wrap: anywhere; }
.detail-repeatable { display: grid; gap: 8px; color: var(--muted); font-size: 11px; }
.detail-repeatable article { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 12px; border-radius: 11px; background: var(--canvas); }
.detail-repeatable article > span { color: var(--orange); font-size: 9px; font-weight: 800; }
.detail-repeatable article div { display: flex; flex-direction: column; }
.detail-repeatable p { margin: 4px 0; color: var(--muted); white-space: pre-line; }
.detail-repeatable small { color: var(--ink); }
.detail-file-list { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.detail-file-list a { display: grid; grid-template-columns: 1fr auto 25px; gap: 10px; align-items: center; padding: 12px; border-radius: 10px; background: var(--canvas); text-decoration: none; }
.detail-file-list a small { color: var(--muted); }
.detail-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 18px 30px; border-top: 1px solid var(--line); background: rgba(255,254,249,.96); backdrop-filter: blur(18px); }

@media (max-width: 1000px) {
  .auth-layout { grid-template-columns: minmax(280px, .8fr) minmax(380px, 1fr); gap: 45px; }
  .workspace-shell { grid-template-columns: 245px minmax(0, 1fr); }
  .project-actions { left: 245px; }
  .repeatable-row { grid-template-columns: 30px 1fr 1fr; }
  .repeatable-row .price { grid-column: 2 / -1; }
  .hours-row { grid-template-columns: 90px 80px 1fr; }
  .time-period.second { grid-column: 3; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .portal-header { width: 100%; max-width: 100%; min-height: 68px; padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
  .portal-brand svg { width: 33px; height: 33px; }
  .portal-brand { min-width: 0; }
  .auth-layout { display: block; width: min(520px, calc(100% - 30px)); padding: 38px 0 65px; }
  .auth-intro { margin-bottom: 38px; }
  .auth-intro h1 { font-size: clamp(54px, 17vw, 80px); }
  .auth-intro > p:not(.portal-kicker) { margin: 24px 0; font-size: 14px; }
  .auth-card { padding: 28px 22px; border-radius: 23px; }
  .text-link { font-size: 11px; }
  .workspace-header .save-state:not(.mobile-save-state), .workspace-header .user-chip div, .workspace-header .portal-brand small { display: none; }
  .workspace-header-meta { gap: 8px; }
  .workspace-shell { display: block; }
  .project-sidebar { position: relative; top: 0; width: 100%; max-width: 100%; height: auto; padding: 14px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .project-progress-card { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 18px; }
  .project-progress-card .portal-kicker { grid-column: 1; margin: 0; }
  .progress-number { grid-column: 2; grid-row: 1 / 3; margin: 0; }
  .progress-number strong { font-size: 37px; }
  .progress-track { grid-column: 1; width: calc(100% - 15px); margin-top: 9px; }
  .project-progress-card > p:last-child, .sidebar-help { display: none; }
  .step-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; width: 100%; max-width: 100%; margin-top: 12px; overflow: visible; padding: 0; }
  .step-navigation button { display: flex; min-width: 0; min-height: 44px; justify-content: center; gap: 6px; width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); text-align: center; }
  .step-navigation button::before, .step-navigation button div small, .step-navigation button > span { display: none; }
  .step-navigation button div { display: block; min-width: 0; }
  .step-navigation button strong { display: block; overflow-wrap: anywhere; font-size: 10px; line-height: 1.2; }
  .step-navigation button.active { border-color: var(--ink); color: var(--white); background: var(--ink); }
  .step-navigation button.active strong { color: var(--white); }
  .project-main { width: min(calc(100% - 28px), 720px); padding: 38px 0 116px; }
  .step-heading { margin-bottom: 30px; }
  .step-heading h1 { font-size: clamp(40px, 12vw, 58px); overflow-wrap: break-word; }
  .step-heading p { font-size: 13px; }
  .state-banner { align-items: flex-start; flex-direction: column; }
  .state-banner strong { white-space: normal; }
  .field-label-row { align-items: flex-start; flex-wrap: wrap; gap: 6px 14px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .repeatable-row { grid-template-columns: 28px 1fr; padding: 15px; }
  .repeatable-row .grow, .repeatable-row .price { grid-column: 2; }
  .repeatable-row.social-row { grid-template-columns: 1fr; }
  .repeatable-row.social-row .grow { grid-column: 1; }
  .hours-row { grid-template-columns: 1fr auto; gap: 8px; padding: 14px; }
  .time-period, .time-period.second { grid-column: 1 / -1; }
  .project-actions { left: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; min-height: 68px; padding: 9px max(14px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .project-actions .portal-button { min-height: 44px; padding: 10px 14px; font-size: 11px; }
  .mobile-save-state { display: inline-flex; min-width: 0; margin-right: 0; justify-self: start; }
  .repeatable-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .repeatable-heading .portal-button { width: 100%; }
  .portal-field input, .portal-field textarea, .portal-field select, .message-preview { font-size: 16px; }
  .upload-dropzone { padding: 34px 18px; text-align: center; }
  .upload-dropzone strong, .upload-dropzone small { overflow-wrap: anywhere; }
  .file-row { grid-template-columns: 38px 1fr; }
  .file-actions { grid-column: 2; }
  .admin-shell { width: min(100% - 30px, 720px); padding-top: 42px; }
  .admin-hero { display: block; }
  .admin-hero h1 { font-size: clamp(48px, 14vw, 70px); }
  .admin-hero .portal-button { width: 100%; margin-top: 30px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article { min-height: 125px; padding: 18px; }
  .metric-grid article strong { font-size: 35px; }
  .clients-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-controls { flex-wrap: wrap; }
  .search-control { flex: 1 1 100%; }
  .search-control input { width: 100%; }
  .filter-control { flex: 1; }
  .client-table-wrap { display: none; }
  .client-cards { display: grid; gap: 10px; }
  .client-card { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
  .client-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .client-card p { margin: 0; color: var(--muted); font-size: 9px; }
  .client-card .table-open { justify-self: end; }
  .credential-grid { grid-template-columns: 1fr; }
  .portal-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); margin: auto; overflow-y: auto; }
  .client-detail-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 18px; }
  .detail-topbar { align-items: flex-start; gap: 14px; padding: 20px; }
  .detail-topbar > div:first-child { min-width: 0; }
  .detail-topbar h2 { overflow-wrap: anywhere; font-size: 25px; }
  .detail-topbar-actions .portal-button { display: none; }
  .detail-content { padding: 18px; }
  .detail-section dl { grid-template-columns: 1fr; }
  .detail-section dl .wide { grid-column: auto; }
  .detail-actions { padding: 14px 18px; }
}

@media (max-width: 450px) {
  .auth-features span:nth-child(3) { display: none; }
  .portal-dialog { padding: 32px 21px 24px; }
  .form-grid { gap: 15px; }
  .project-main { width: calc(100% - 24px); }
  .step-heading h1 { font-size: 42px; }
  .repeatable-heading { align-items: flex-start; }
  .social-field { grid-template-columns: 38px 1fr; padding: 12px; }
  .submission-card { padding: 24px 19px; }
  .project-actions { grid-template-columns: auto minmax(0, 1fr) auto; }
  .project-actions #save-project { display: none; }
  .project-actions .portal-button { padding-inline: 12px; }
  .mobile-save-state { justify-self: center; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { min-height: 115px; }
  .admin-user { display: none; }
}

@media (max-width: 360px) {
  .workspace-header .portal-brand > .brand-wordmark { font-size: 14px; }
  .workspace-header-meta { gap: 6px; }
  .project-actions .mobile-save-state > span { display: none; }
  .project-actions .mobile-save-state { justify-self: center; }
  .portal-dialog { padding: 29px 18px 22px; }
}

@media print {
  body { background: var(--white); }
  body > *:not(.client-detail-dialog), .detail-topbar-actions, .detail-actions, .global-toast { display: none !important; }
  .client-detail-dialog[open] { position: static; display: block; width: 100%; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
  .detail-topbar { position: static; padding: 0 0 20px; }
  .detail-content { padding: 20px 0; }
  .detail-section { border-color: #bbb; }
  .detail-file-list a { color: var(--ink); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Identità CALEIDO 2026 */
.portal-header { font-family: var(--font-body); }
.portal-brand { gap: 12px; }
.portal-brand > .brand-symbol { width: 46px; height: 46px; display: grid; flex: 0 0 46px; padding: 7px; place-items: center; border: 1px solid var(--brand-line-dark); border-radius: 14px; color: inherit; background: var(--brand-ink); }
.portal-brand > .brand-symbol img { width: 100%; height: 100%; display: block; }
.portal-brand > .brand-wordmark { display: flex; flex-direction: column; color: inherit; font-family: var(--font-display); font-size: 19px; font-weight: 800; letter-spacing: .08em; line-height: 1; }
.portal-brand > .brand-wordmark small { margin-top: 6px; color: currentColor; font-family: var(--font-body); font-size: 7px; font-weight: 600; letter-spacing: .19em; opacity: .62; }
.portal-kicker { font-family: var(--font-body); letter-spacing: .17em; }
.portal-button { font-family: var(--font-body); }
.portal-button.primary { color: var(--ink); background: var(--lime); box-shadow: 0 12px 30px rgba(0, 158, 0, .12); }
.portal-button.primary:hover:not(:disabled) { box-shadow: 0 16px 38px rgba(0, 158, 0, .2); }
.portal-button.secondary { border-color: var(--line); background: rgba(255,255,255,.78); }
.portal-field input:focus, .portal-field textarea:focus, .portal-field select:focus, .message-preview:focus { border-color: #00a800; box-shadow: 0 0 0 3px rgba(0, 168, 0, .1); }
.global-toast[data-kind="success"] { color: var(--ink); background: var(--lime); }

.auth-page { color: var(--brand-paper-soft); background: var(--ink); }
.auth-backdrop::before { opacity: .9; background-image: linear-gradient(rgba(233,231,230,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(233,231,230,.035) 1px, transparent 1px); mask-image: linear-gradient(to right, #000, transparent 76%); }
.auth-backdrop span:nth-child(1) { right: -5%; bottom: -34%; background: radial-gradient(circle at 42% 38%, rgba(0,255,0,.3), rgba(0,255,0,.03) 64%, transparent 65%); }
.auth-backdrop span:nth-child(2) { right: 30%; bottom: -36%; border: 1px solid rgba(0,255,0,.22); background: transparent; }
.auth-backdrop span:nth-child(3) { top: 17%; left: -10%; border-color: var(--brand-line-dark); background: rgba(255,255,255,.015); }
.auth-header .portal-brand, .auth-header .text-link { color: var(--brand-paper-soft); }
.auth-header .text-link:hover { color: var(--lime); }
.auth-intro h1 { max-width: 720px; font-family: var(--font-display); font-weight: 630; letter-spacing: -.07em; }
.auth-intro h1 em { color: var(--lime); }
.auth-intro > p:not(.portal-kicker) { color: #a6ada7; }
.auth-features span { border-color: var(--brand-line-dark); color: #d6dbd7; background: rgba(255,255,255,.035); }
.auth-features i { color: var(--lime); }
.auth-card { color: var(--ink); border-color: rgba(233,231,230,.16); background: rgba(248,248,244,.97); box-shadow: 0 40px 110px rgba(0,0,0,.42); }
.auth-card-heading h2, .portal-dialog h2, .step-heading h1, .admin-hero h1, .clients-toolbar h2 { font-family: var(--font-display); }
.notice { color: #124d12; background: var(--lime-soft); }

.workspace-header { color: var(--brand-paper-soft); border-color: var(--brand-line-dark); background: rgba(8,11,9,.94); box-shadow: 0 10px 32px rgba(8,11,9,.12); }
.workspace-header .save-state { color: #aab2ab; }
.workspace-header .user-chip > span { color: var(--ink); background: var(--lime); }
.workspace-header .user-chip small { color: #939c95; }
.workspace-header .icon-button { border-color: var(--brand-line-dark); color: #d4d9d5; background: rgba(255,255,255,.04); }
.workspace-header .icon-button:hover { color: var(--ink); background: var(--lime); }
.project-sidebar { border-color: var(--brand-line-dark); color: #d6dbd7; background: #111612; }
.project-progress-card { border: 1px solid rgba(0,255,0,.18); background: #090d0a; box-shadow: inset 0 0 48px rgba(0,255,0,.03); }
.project-progress-card .portal-kicker, .project-progress-card > p:last-child { color: #8f9991; }
.progress-track { background: #303932; }
.progress-track i { background: var(--lime); }
.step-navigation button { color: #9ea7a0; }
.step-navigation button:hover { color: var(--white); background: rgba(255,255,255,.04); }
.step-navigation button.active { color: var(--ink); background: var(--lime); box-shadow: 0 12px 28px rgba(0,0,0,.2); }
.step-navigation button.active small { color: #185018; }
.step-navigation button.active > i { border-color: var(--ink); }
.step-navigation button.complete:not(.active) > i { border-color: var(--lime); background: var(--lime); }
.sidebar-help { border-color: var(--brand-line-dark); color: #8e978f; }
.sidebar-help > span { border-color: #4b554d; color: var(--lime); }
.project-main { background: linear-gradient(180deg, rgba(255,255,255,.2), transparent 340px); }
.step-heading > span { color: #008d00; }
.step-heading h1 { font-weight: 650; }
.step-heading h1 em { color: #009e00; }
.step-tip { border-color: #bde5bd; background: #efffef; }
.step-tip span { color: #008d00; }
.upload-dropzone:hover { border-color: #00a800; background: #f1fff1; }
.submission-card { background: #111612; box-shadow: 0 25px 70px rgba(8,11,9,.13); }
.project-actions { border-color: var(--line); background: rgba(248,248,244,.94); }

.admin-page { background: #ecece7; }
.admin-header .portal-brand small { color: var(--lime); }
.admin-user > span { color: var(--ink); background: var(--lime); }
.admin-hero h1 { font-weight: 650; }
.admin-hero h1 em { color: #009e00; }
.metric-grid article { border-radius: 20px; background: rgba(248,248,244,.9); }
.metric-grid article.accent { border-color: var(--ink); background: var(--ink); }
.metric-grid article.accent::after { background: var(--lime); }
.clients-panel { background: rgba(248,248,244,.94); box-shadow: 0 25px 80px rgba(8,11,9,.07); }
.client-avatar { color: #134313; background: var(--lime-soft); }
.client-table tbody tr:hover { background: #efffef; }
.status-badge.submitted { color: #174b17; background: var(--lime-soft); }
.portal-dialog, .client-detail-dialog { background: var(--paper); box-shadow: 0 40px 110px rgba(8,11,9,.34); }
.success-mark { color: var(--ink); background: var(--lime); }
.detail-topbar { border-color: var(--line); background: rgba(248,248,244,.96); }

@media (max-width: 760px) {
  .auth-page { background: var(--ink); }
  .auth-layout { padding-top: 18px; }
  .auth-intro h1 { font-size: clamp(48px, 15vw, 70px); }
  .workspace-header .portal-brand > .brand-symbol { width: 40px; height: 40px; flex-basis: 40px; }
  .workspace-header .portal-brand > .brand-wordmark { font-size: 16px; }
  .project-sidebar { color: var(--ink); background: var(--paper); }
  .project-sidebar .step-navigation button { color: var(--muted); }
  .project-sidebar .step-navigation button.active { color: var(--ink); }
}
