  /* Siti e Social · Area clienti
     Layout: app a una colonna centrale (max 1120px); accesso diviso in due con gli archi dell'atrio a sinistra.
     Tema scuro unico, per continuità con la hero 3D del sito. */
  :root {
    --bg: #05070b;
    --surface: #0b0f17;
    --surface-2: #111724;
    --line: rgba(159, 184, 255, 0.16);
    --line-strong: rgba(159, 184, 255, 0.32);
    --ink: #ece4d6;
    --text: #dfe3ea;
    --muted: #8a93a6;
    --accent: #9fb8ff;
    --accent-ink: #0a0d14;
    --ok: #8ff0d0;
    --warn: #ffc58a;
    --danger: #ff9f9f;
    --serif: "Instrument Serif", "Bodoni 72", Didot, Georgia, serif;
    --sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color-scheme: dark;
  }
  *, *::before, *::after { box-sizing: border-box; }
  html, body { min-height: 100%; }
  body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: var(--sans); font-size: 15px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  button, input, textarea, select { font: inherit; color: inherit; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
  h1, h2, h3 { margin: 0; text-wrap: balance; }
  a { color: inherit; }

  /* ---------- Pulsanti e campi ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 999px; padding: 10px 20px; cursor: pointer; white-space: nowrap;
    font-size: 0.9rem; letter-spacing: 0.02em; border: 1px solid var(--line-strong);
    background: transparent; transition: background .25s, border-color .25s, color .25s;
  }
  .btn:hover { border-color: var(--accent); background: rgba(159,184,255,.08); }
  .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
  .btn-primary:hover { background: #c3d2ff; border-color: #c3d2ff; }
  .btn-small { padding: 6px 14px; font-size: 0.82rem; }
  .btn:disabled { opacity: .45; cursor: not-allowed; }
  .link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(159,184,255,.4); }
  .link:hover { text-decoration-color: currentColor; }

  .field { display: grid; gap: 6px; }
  .field label { font-size: 0.82rem; color: var(--muted); }
  .input, textarea.input, select.input {
    width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 13px; transition: border-color .2s;
  }
  .input:hover { border-color: var(--line-strong); }
  .input:focus { outline: none; border-color: var(--accent); }
  textarea.input { min-height: 96px; resize: vertical; }
  .field .hint { font-size: 0.78rem; color: var(--muted); }
  .field .error { font-size: 0.8rem; color: var(--danger); }
  .field.invalid .input { border-color: var(--danger); }
  .pw-wrap { position: relative; }
  .pw-wrap .input { padding-right: 76px; }
  .pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: 0.78rem; cursor: pointer; padding: 6px; }
  .pw-toggle:hover { color: var(--text); }
  .form { display: grid; gap: 16px; }
  .form-error { padding: 10px 12px; border-radius: 10px; background: rgba(255,159,159,.08); border: 1px solid rgba(255,159,159,.3); color: var(--danger); font-size: 0.86rem; }
  .notice { padding: 12px 14px; border-radius: 10px; background: rgba(143,240,208,.07); border: 1px solid rgba(143,240,208,.28); color: var(--ok); font-size: 0.88rem; }

  /* ---------- Schermate di accesso ---------- */
  .auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .auth-art {
    position: relative; overflow: hidden; border-right: 1px solid var(--line);
    background: radial-gradient(120% 80% at 50% 0%, #0d1630 0%, #060a14 60%, var(--bg) 100%);
    padding: 40px; cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  }
  /* Sfondo animato (js/inchiostro.js); se WebGL2 manca resta la sfumatura qui sopra */
  .auth-art .stage { position: absolute; inset: 0; z-index: 0; }
  .auth-art .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
  /* Velo scuro dietro al testo, così resta leggibile sopra l'inchiostro */
  .auth-art .scrim {
    position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(80% 45% at 0% 0%, rgba(5,7,11,.78), rgba(5,7,11,0) 70%), linear-gradient(180deg, rgba(5,7,11,0) 70%, rgba(5,7,11,.35));
  }
  .art-top { position: relative; z-index: 2; display: grid; gap: 18px; justify-items: start; pointer-events: none; }
  .art-top a { pointer-events: auto; }
  .arches { width: 92px; height: auto; display: block; }
  .brand { font-family: var(--serif); font-size: 1.7rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink); line-height: 1; }
  a.brand { position: relative; align-self: flex-start; text-decoration: none; transition: opacity .25s; }
  a.brand:hover { opacity: .75; }
  .auth-art .tagline { margin: 0; font-family: var(--serif); color: var(--ink); font-size: clamp(2rem, 3.6vw, 3.2rem); line-height: 1.02; max-width: 12ch; text-wrap: balance; }
  .auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
  .auth-card { width: min(400px, 100%); display: grid; gap: 22px; }
  .auth-card h1 { font-family: var(--serif); font-weight: 400; font-size: 2.4rem; line-height: 1; color: var(--ink); }
  .auth-card .lead { margin: 0; color: var(--muted); }
  .auth-foot { font-size: 0.88rem; color: var(--muted); }

  /* ---------- Struttura dell'app ---------- */
  .topbar {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px clamp(16px, 3vw, 40px); background: rgba(5,7,11,.86);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  }
  .topbar .left { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
  .topbar .area { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  .topbar .right { display: flex; align-items: center; gap: 10px; }
  .who { font-size: 0.86rem; color: var(--muted); text-align: right; line-height: 1.25; }
  .who strong { display: block; color: var(--text); font-weight: 500; }
  .page { max-width: 1120px; margin: 0 auto; padding: 36px clamp(16px, 3vw, 40px) 120px; display: grid; gap: 28px; }
  .page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
  .page-head h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.2rem, 4.4vw, 3.4rem); line-height: 1; color: var(--ink); }
  .page-head p { margin: 8px 0 0; color: var(--muted); max-width: 60ch; }
  .grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
  .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: grid; gap: 18px; min-width: 0; }
  .panel-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .panel-title h2 { font-size: 0.82rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

  /* ---------- Timeline delle fasi ---------- */
  .progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .progress span { height: 4px; border-radius: 4px; background: var(--surface-2); }
  .progress span.done { background: var(--accent); }
  .progress span.now { background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 50%, var(--surface-2) 50%); }
  .steps { list-style: none; margin: 0; padding: 0; display: grid; }
  .step { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
  .step:last-child { border-bottom: 0; }
  .step .dot { width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; border: 1.5px solid var(--line-strong); justify-self: center; }
  .step.done .dot { background: var(--accent); border-color: var(--accent); }
  .step.now .dot { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(159,184,255,.15); }
  .step .name { font-weight: 500; color: var(--text); }
  .step .desc { font-size: 0.86rem; color: var(--muted); }
  .step.todo .name { color: var(--muted); }
  .step .date { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .step.now .date { color: var(--accent); }

  .preview { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
  .preview .url { font-size: 0.86rem; color: var(--muted); overflow-wrap: anywhere; }

  /* ---------- Richieste ---------- */
  .requests { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
  .req { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; background: var(--surface); }
  .req-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
  .req-text { color: var(--text); overflow-wrap: anywhere; }
  .req-meta { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
  .reply { font-size: 0.86rem; color: var(--text); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 2px solid var(--accent); }
  .reply b { display: block; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
  .pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; padding: 3px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
  .pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .pill.ricevuta { color: var(--warn); border-color: rgba(255,197,138,.35); }
  .pill.lavorazione { color: var(--accent); border-color: rgba(159,184,255,.4); }
  .pill.completata { color: var(--ok); border-color: rgba(143,240,208,.35); }
  .pill.fase { color: var(--text); border-color: var(--line-strong); }
  .pill.fase::before { display: none; }

  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 14px; background: none; cursor: pointer; font-size: 0.86rem; }
  .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

  .empty { display: grid; gap: 14px; justify-items: start; padding: 8px 0; }
  .empty h2 { font-family: var(--serif); font-weight: 400; font-size: 2rem; line-height: 1.05; color: var(--ink); }
  .empty p { margin: 0; color: var(--muted); max-width: 52ch; }

  /* ---------- Vista amministratori ---------- */
  .tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); white-space: nowrap; }
  .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
  .tab .count { margin-left: 6px; font-size: 0.74rem; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text); }
  .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
  table { width: 100%; border-collapse: collapse; min-width: 640px; }
  th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  th { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--surface); }
  tbody tr { cursor: pointer; transition: background .2s; }
  tbody tr:hover, tbody tr.selected { background: rgba(159,184,255,.05); }
  tbody tr:last-child td { border-bottom: 0; }
  td .sub { display: block; font-size: 0.8rem; color: var(--muted); }
  .num { font-variant-numeric: tabular-nums; }
  .open-count { color: var(--warn); }
  .phase-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .admin-req { display: grid; gap: 10px; }
  .admin-req .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .admin-req select.input { width: auto; padding: 7px 10px; }
  .saved { font-size: 0.8rem; color: var(--ok); }

  /* ---------- Finestra cambio password ---------- */
  .modal-back { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
  .modal { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; display: grid; gap: 18px; }
  .modal h2 { font-family: var(--serif); font-weight: 400; font-size: 1.9rem; color: var(--ink); }
  .row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }


  .toast { position: fixed; z-index: 50; left: 50%; transform: translateX(-50%); top: calc(76px + env(safe-area-inset-top, 0px)); padding: 10px 16px; border-radius: 999px; background: var(--ok); color: var(--accent-ink); font-size: 0.86rem; font-weight: 500; }

  /* ---------- Caricamento ---------- */
  .loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
  .btn[aria-busy="true"] { opacity: .6; cursor: progress; }

  @media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth-art { min-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); padding: 24px 16px; }
    .auth-art .tagline { display: none; }
    .auth-main { padding: 32px 16px 64px; align-items: flex-start; }
    .grid-2 { grid-template-columns: 1fr; }
    .who { display: none; }
  }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
