/* ═══════════════════════════════════════════════════════════════════════════
   TeleLILT Design System — v1
   Identità: il cremisi e il grigio caldo del marchio LILT, su neutri "carta"
   che trasmettono calma clinica. Nessuna dipendenza esterna.
   Indice: 1 font · 2 token · 3 base · 4 form · 5 bottoni · 6 feedback
           7 superfici · 8 accesso · 9 shell del pannello · 10 utilità · 11 stampa
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Font (self-hosted, licenza OFL) ─────────────────────────────────── */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterVariable.woff2") format("woff2");
}

/* ── 2. Token ───────────────────────────────────────────────────────────── */
:root {
  /* Cremisi LILT */
  --brand-50: #fff1f3;  --brand-100: #ffe1e6; --brand-200: #ffc8d0; --brand-300: #ff9eac;
  --brand-400: #f8647b; --brand-500: #e93651; --brand-600: #d0112b; --brand-700: #ae0c22;
  --brand-800: #8f0e20; --brand-900: #780f1f; --brand-950: #43030d;

  /* Grigi caldi (dal grigio del marchio) */
  --stone-0: #ffffff;   --stone-25: #fdfcfb;  --stone-50: #faf8f6;  --stone-100: #f3f0ec;
  --stone-200: #e7e2dc; --stone-300: #d5cec6; --stone-400: #a89f95; --stone-500: #7a7168;
  --stone-600: #5c544d; --stone-700: #443e39; --stone-800: #2b2724; --stone-900: #1c1917; --stone-950: #120f0e;

  /* Semantici */
  --green-50: #ecfdf5;  --green-600: #15805a; --green-700: #0f6a4a;
  --amber-50: #fff8eb;  --amber-600: #b26a0c; --amber-700: #8f5408;
  --blue-50: #eff6ff;   --blue-600: #2563a8;  --blue-700: #1d4f87;

  /* Ruoli (tema chiaro) */
  --bg: var(--stone-50);
  --surface: var(--stone-0);
  --surface-2: var(--stone-25);
  --surface-sunken: var(--stone-100);
  --line: var(--stone-200);
  --line-strong: var(--stone-300);
  --ink: var(--stone-900);
  --ink-2: var(--stone-600);
  --ink-3: var(--stone-500);
  --primary: var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-soft: var(--brand-50);
  --primary-ink: #ffffff;
  --focus: rgb(208 17 43 / 0.28);
  --success: var(--green-600); --success-soft: var(--green-50);
  --warning: var(--amber-600); --warning-soft: var(--amber-50);
  --danger: var(--brand-700);  --danger-soft: var(--brand-50);
  --info: var(--blue-600);     --info-soft: var(--blue-50);

  /* Forma e ritmo */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-full: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  --shadow-xs: 0 1px 2px rgb(28 25 23 / 0.05);
  --shadow-sm: 0 1px 2px rgb(28 25 23 / 0.04), 0 2px 8px rgb(28 25 23 / 0.04);
  --shadow-md: 0 2px 4px rgb(28 25 23 / 0.04), 0 12px 32px -8px rgb(28 25 23 / 0.10);
  --shadow-lg: 0 4px 8px rgb(28 25 23 / 0.04), 0 32px 64px -16px rgb(28 25 23 / 0.18);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

/* Tema scuro: automatico, con possibilità di forzatura da data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--stone-950); --surface: #1a1614; --surface-2: #201b19; --surface-sunken: #151110;
    --line: #2e2825; --line-strong: #3d3531;
    --ink: #f6f2ee; --ink-2: #b9b0a7; --ink-3: #8d847b;
    --primary: var(--brand-500); --primary-hover: var(--brand-400); --primary-soft: rgb(233 54 81 / 0.12);
    --focus: rgb(248 100 123 / 0.35);
    --success: #4ade9b; --success-soft: rgb(21 128 90 / 0.16);
    --warning: #f5b754; --warning-soft: rgb(178 106 12 / 0.18);
    --danger: #ff8a9b;  --danger-soft: rgb(208 17 43 / 0.16);
    --info: #7db4f0;    --info-soft: rgb(37 99 168 / 0.18);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3); --shadow-md: 0 12px 32px -8px rgb(0 0 0 / 0.5); --shadow-lg: 0 32px 64px -16px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--stone-950); --surface: #1a1614; --surface-2: #201b19; --surface-sunken: #151110;
  --line: #2e2825; --line-strong: #3d3531;
  --ink: #f6f2ee; --ink-2: #b9b0a7; --ink-3: #8d847b;
  --primary: var(--brand-500); --primary-hover: var(--brand-400); --primary-soft: rgb(233 54 81 / 0.12);
  --focus: rgb(248 100 123 / 0.35);
  --success: #4ade9b; --success-soft: rgb(21 128 90 / 0.16);
  --warning: #f5b754; --warning-soft: rgb(178 106 12 / 0.18);
  --danger: #ff8a9b;  --danger-soft: rgb(208 17 43 / 0.16);
  --info: #7db4f0;    --info-soft: rgb(37 99 168 / 0.18);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3); --shadow-md: 0 12px 32px -8px rgb(0 0 0 / 0.5); --shadow-lg: 0 32px 64px -16px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* ── 3. Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.6 var(--font);
  font-feature-settings: "cv11", "ss01", "calt";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 28px; letter-spacing: -0.03em; } h2 { font-size: 20px; } h3 { font-size: 16px; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--primary); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand-200); color: var(--brand-950); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; } .icon--lg { width: 24px; height: 24px; }

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

/* ── 4. Form ────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: var(--s-5); }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.field__hint { font-size: 13px; color: var(--ink-3); }
.field__error { font-size: 13px; color: var(--danger); font-weight: 500; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 14px; color: var(--ink-3); pointer-events: none; transition: color 0.15s var(--ease); }
.input-wrap:focus-within > .icon { color: var(--primary); }
.input {
  width: 100%; height: 48px; padding: 0 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input-wrap > .icon ~ .input { padding-left: 44px; }
.input::placeholder { color: var(--ink-3); opacity: 0.8; }
.input:hover { border-color: var(--stone-400); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-action {
  position: absolute; right: 6px; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-3); cursor: pointer;
}
.input-action:hover { background: var(--surface-sunken); color: var(--ink); }
.input-wrap:has(.input-action) .input { padding-right: 48px; }

/* Codice a 6 cifre */
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.otp__gap { grid-column: 4; }
.otp input {
  width: 100%; aspect-ratio: 1 / 1.15; min-height: 56px; text-align: center;
  font: 650 24px/1 var(--font); font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs); caret-color: var(--primary);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.otp input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); transform: translateY(-1px); }
.otp input.is-filled { border-color: var(--primary); background: var(--primary-soft); }
.otp.is-error input { border-color: var(--danger); animation: shake 0.35s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* Indicatore di robustezza */
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.strength span { height: 4px; border-radius: var(--r-full); background: var(--line); transition: background 0.2s var(--ease); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--warning); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--info); }
.strength[data-score="4"] span { background: var(--success); }

/* ── 5. Bottoni ─────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface); --btn-ink: var(--ink); --btn-line: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-md);
  border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--btn-ink);
  font-weight: 600; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap; cursor: pointer; user-select: none;
  box-shadow: var(--shadow-xs);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover { text-decoration: none; border-color: var(--stone-400); background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--primary { --btn-bg: var(--primary); --btn-ink: var(--primary-ink); --btn-line: transparent;
  box-shadow: 0 1px 2px rgb(120 15 31 / 0.3), inset 0 1px 0 rgb(255 255 255 / 0.14); }
.btn--primary:hover { background: var(--primary-hover); border-color: transparent; box-shadow: 0 4px 14px -2px rgb(208 17 43 / 0.45), inset 0 1px 0 rgb(255 255 255 / 0.14); }
.btn--ghost { --btn-bg: transparent; --btn-line: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-sunken); border-color: transparent; color: var(--ink); }
.btn--lg { height: 50px; font-size: 15px; padding: 0 22px; }
.btn--sm { height: 36px; font-size: 13px; padding: 0 12px; border-radius: var(--r-sm); }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { pointer-events: none; opacity: 0.75; }
.btn.is-disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 6. Feedback ────────────────────────────────────────────────────────── */
.alert {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  padding: 14px 16px; border-radius: var(--r-md); font-size: 14px; line-height: 1.5;
  background: var(--info-soft); color: var(--ink); border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; color: var(--info); }
.alert--danger  { background: var(--danger-soft); }  .alert--danger .icon  { color: var(--danger); }
.alert--warning { background: var(--warning-soft); } .alert--warning .icon { color: var(--warning); }
.alert--success { background: var(--success-soft); } .alert--success .icon { color: var(--success); }
.alert ul { margin: 0; padding-left: 18px; }
.alert strong { font-weight: 650; }

.toast-region { position: fixed; z-index: 100; right: 24px; bottom: 24px; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 48px)); }
.toast {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 14px 14px 14px 16px; border-radius: var(--r-lg);
  background: var(--stone-900); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: toast-in 0.4s var(--ease) both;
}
:root[data-theme="dark"] .toast { background: var(--stone-100); color: var(--stone-900); }
.toast.is-leaving { animation: toast-out 0.25s var(--ease) both; }
.toast .icon { color: #6ee7b7; } .toast--error .icon { color: #fda4af; } .toast--warning .icon { color: #fcd34d; }
.toast__close { border: 0; background: transparent; color: inherit; opacity: 0.6; cursor: pointer; padding: 4px; border-radius: 6px; }
.toast__close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full); white-space: nowrap; flex: none;
  font-size: 12px; font-weight: 600; background: var(--surface-sunken); color: var(--ink-2); }
.badge--brand { background: var(--primary-soft); color: var(--primary); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── 7. Superfici ───────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card__body { padding: var(--s-6); }
.card__header { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-4); flex-wrap: wrap; }
.card__header .row { flex-wrap: wrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-800)); color: #fff; font-weight: 650; font-size: 13px; letter-spacing: 0.02em; }

/* ── 8. Accesso ─────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth__brand {
  position: relative; overflow: hidden; isolation: isolate; color: #fff;
  padding: var(--s-12); display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(120% 90% at 0% 0%, rgb(255 255 255 / 0.16), transparent 55%),
    radial-gradient(90% 80% at 100% 100%, rgb(67 3 13 / 0.75), transparent 60%),
    linear-gradient(155deg, var(--brand-600) 0%, var(--brand-800) 58%, var(--brand-950) 100%);
}
.auth__swoosh { position: absolute; z-index: -1; inset: auto -22% -30% auto; width: 125%; opacity: 0.9; pointer-events: none; }
.auth__swoosh path { fill: none; stroke-linecap: round; }
.auth__swoosh .s1 { stroke: rgb(255 255 255 / 0.10); stroke-width: 120; }
.auth__swoosh .s2 { stroke: rgb(255 255 255 / 0.07); stroke-width: 70; }
.auth__swoosh circle { fill: rgb(255 255 255 / 0.10); }
.auth__logo { display: flex; align-items: center; gap: 14px; font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.auth__logo img { width: 44px; height: 44px; }
.auth__logo small { display: block; font-weight: 500; font-size: 12px; letter-spacing: 0.02em; opacity: 0.75; }
.auth__pitch h1 { font-size: clamp(30px, 3.2vw, 44px); letter-spacing: -0.035em; line-height: 1.08; max-width: 14ch; }
.auth__pitch h1 em { font-style: normal; color: var(--brand-200); }
.auth__pitch p { margin-top: var(--s-4); max-width: 40ch; font-size: 16px; color: rgb(255 255 255 / 0.78); }
.auth__trust { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; font-size: 14px; color: rgb(255 255 255 / 0.85); }
.auth__trust li { display: flex; gap: 12px; align-items: center; }
.auth__trust .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgb(255 255 255 / 0.12); backdrop-filter: blur(6px); }

.auth__main { display: grid; place-items: safe center; padding: var(--s-12) var(--s-6) var(--s-8); background: var(--bg); position: relative; }
.auth__brand { position: sticky; top: 0; height: 100vh; height: 100dvh; }
.auth__panel { width: 100%; max-width: 420px; animation: rise 0.6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.auth__eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: var(--s-4); font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); }
.auth__title { font-size: 30px; letter-spacing: -0.035em; }
.auth__lead { margin-top: var(--s-2); color: var(--ink-2); }
.auth__form { margin-top: var(--s-8); }
.auth__form .btn { margin-top: var(--s-6); }
.auth__form .alert { margin-bottom: var(--s-5); }
.auth__foot { margin-top: var(--s-8); padding-top: var(--s-5); border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); display: flex; gap: 10px; align-items: flex-start; }
.auth__foot .icon { color: var(--success); margin-top: 1px; }
.auth__legal { margin-top: var(--s-5); font-size: 13px; text-align: center; }
.auth__legal a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r-full); color: var(--ink-3); text-decoration: none; transition: color 0.15s, background 0.15s; }
.auth__legal a span { text-decoration: underline; text-underline-offset: 3px; }
.auth__legal a:hover { color: var(--primary); background: var(--primary-soft); }
.auth__theme { position: absolute; top: 20px; right: 20px; }
.auth__steps { display: flex; gap: 6px; margin-bottom: var(--s-6); }
.auth__steps span { height: 4px; flex: 1; border-radius: var(--r-full); background: var(--line); }
.auth__steps span.is-done { background: var(--primary); }
.auth__steps span.is-current { background: linear-gradient(90deg, var(--primary) 50%, var(--line) 50%); }
.linklike { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; font-size: inherit; }
.linklike:hover { text-decoration: underline; }

/* Configurazione 2FA */
.setup { display: grid; gap: var(--s-5); margin-top: var(--s-6); }
.setup__step { display: grid; grid-template-columns: 28px 1fr; gap: 14px; }
.setup__num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.setup__step h3 { font-size: 15px; margin-top: 3px; }
.setup__step p { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.qr { margin-top: 12px; display: flex; gap: var(--s-5); align-items: center; padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.qr img { width: 148px; height: 148px; border-radius: var(--r-sm); background: #fff; padding: 6px; image-rendering: pixelated; }
.qr__secret { font: 600 14px/1.7 var(--font-mono); letter-spacing: 0.06em; word-spacing: 0.2em; color: var(--ink); user-select: all; }
.qr__label { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }

.codes { list-style: none; margin: var(--s-5) 0 0; padding: var(--s-5); display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px dashed var(--line-strong);
  font: 600 15px/1.4 var(--font-mono); letter-spacing: 0.08em; counter-reset: code; }
.codes li { counter-increment: code; display: flex; gap: 10px; }
.codes li::before { content: counter(code, decimal-leading-zero); color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.codes-actions { display: flex; gap: 8px; margin-top: var(--s-4); flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: var(--s-6); font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth__theme { top: 6px; right: 10px; }
  .auth__brand { position: static; height: auto; padding: var(--s-5) var(--s-6); flex-direction: row; align-items: center; }
  .auth__pitch, .auth__trust, .auth__swoosh { display: none; }
  .auth__main { place-items: start center; padding-top: var(--s-10); }
}

/* ── 9. Shell del pannello ──────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: var(--s-6);
  padding: var(--s-5) var(--s-4); background: var(--surface); border-right: 1px solid var(--line); }
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; color: var(--ink); }
.sidebar__brand:hover { text-decoration: none; }
.sidebar__brand img { width: 34px; height: 34px; }
.nav { display: grid; gap: 2px; }
.nav__label { padding: 0 12px; margin: var(--s-4) 0 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.nav__item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 550; font-size: 14px;
  transition: background 0.12s var(--ease), color 0.12s var(--ease); }
.nav__item:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.nav__item.is-active { background: var(--primary-soft); color: var(--primary); }
.nav__item.is-soon { opacity: 0.5; pointer-events: none; }
.nav__item > span:not(.badge) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__item .badge { margin-left: auto; flex: none; height: 20px; padding: 0 8px; font-size: 11px; white-space: nowrap; }
.sidebar__user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); }
.sidebar__user div { min-width: 0; flex: 1; line-height: 1.3; }
.sidebar__user strong { display: block; font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user small { font-size: 12px; color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--s-4); height: 64px; padding: 0 var(--s-8);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar__spacer { flex: 1; }
.content { padding: var(--s-8); width: 100%; max-width: 1240px; margin: 0 auto; animation: rise 0.45s var(--ease) both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); margin-bottom: var(--s-8); flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 6px; }

.grid { display: grid; gap: var(--s-5); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: var(--s-5) var(--s-6); display: grid; gap: 6px; }
.stat__icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 8px; }
.stat__icon--success { background: var(--success-soft); color: var(--success); }
.stat__icon--info { background: var(--info-soft); color: var(--info); }
.stat__label { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.stat__value { font-size: 22px; font-weight: 680; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: 13px; color: var(--ink-3); }
.roadmap { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.roadmap li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.roadmap li:last-child { border-bottom: 0; }
.roadmap .icon { color: var(--ink-3); } .roadmap li.is-done .icon { color: var(--success); }
.roadmap span { margin-left: auto; }

.nav-toggle { display: none; }
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s-3);
    padding: var(--s-3) var(--s-4); border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-toggle { display: inline-flex; margin-left: auto; }
  /* Il menu diventa un pannello a comparsa sotto la barra. */
  .sidebar .nav { display: none; order: 3; flex-basis: 100%; padding-bottom: var(--s-3); max-height: calc(100dvh - 72px); overflow-y: auto; }
  .sidebar.is-open .nav { display: grid; animation: rise 0.2s var(--ease) both; }
  .sidebar__user { order: 4; flex-basis: 100%; margin: 0; display: none; }
  .sidebar.is-open .sidebar__user { display: flex; }
  .topbar { position: static; height: 52px; }
  .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: var(--s-5); padding-right: var(--s-5); }
  .content { padding-top: var(--s-6); }
}

/* ── 9a. Componenti del pannello ────────────────────────────────────────── */
/* Campi aggiuntivi */
.select, .textarea { width: 100%; padding: 0 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-xs); transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.select { height: 48px; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a7168' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.select--sm, .input--sm { height: 40px; font-size: 14px; border-radius: var(--r-sm); }
.textarea { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.6; }
.select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.form-grid .field + .field { margin-top: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }
form > .form-grid + .field, form > .field + .form-grid, form > .form-grid + .form-grid { margin-top: var(--s-5); }
.form-section { padding: var(--s-6); border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.form-section > h2 { font-size: 16px; } .form-section > p { color: var(--ink-2); font-size: 14px; margin: 4px 0 var(--s-5); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-5) var(--s-6); background: var(--surface-2); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; font-size: 14px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease); }
.choice:hover { border-color: var(--line-strong); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.choice small { display: block; color: var(--ink-3); font-size: 13px; }
.choices { display: grid; gap: 10px; } .choices--inline { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Barra di ricerca e filtri */
.toolbar { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.toolbar__search { flex: 1 1 320px; }
.toolbar .select { width: auto; min-width: 150px; }
.kbd { font: 600 11px/1 var(--font-mono); padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--ink-3); background: var(--surface-2); position: absolute; right: 12px; }

/* Tabelle */
.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 14px; }  /* sotto gli 820px scorre in orizzontale, non va a capo */
.table .person { white-space: nowrap; }
.table .truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .badges { flex-wrap: nowrap; }
.table th { text-align: left; padding: 12px var(--s-5); font-size: 12px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px var(--s-5); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background 0.12s var(--ease); position: relative; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.table__link { color: inherit; font-weight: 600; }
.table__link::after { content: ""; position: absolute; inset: 0; }  /* tutta la riga è cliccabile */
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person small { display: block; color: var(--ink-3); font-size: 13px; font-weight: 400; }
.avatar--lg { width: 64px; height: 64px; font-size: 22px; }
.avatar[data-tint="1"] { background: linear-gradient(135deg, #2563a8, #173f6e); } .avatar[data-tint="2"] { background: linear-gradient(135deg, #15805a, #0b4d36); }
.avatar[data-tint="3"] { background: linear-gradient(135deg, #b26a0c, #6f4105); } .avatar[data-tint="4"] { background: linear-gradient(135deg, #7c3aed, #4c1d95); }
.avatar[data-tint="5"] { background: linear-gradient(135deg, #5c544d, #2b2724); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge--danger { background: var(--danger-soft); color: var(--danger); } .badge--info { background: var(--info-soft); color: var(--info); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.pagination__pages { display: flex; gap: 6px; }

.empty { padding: var(--s-16) var(--s-6); text-align: center; display: grid; justify-items: center; gap: 8px; }
.empty__icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink-3); margin-bottom: 8px; }
.empty p { color: var(--ink-2); max-width: 44ch; } .empty .btn { margin-top: var(--s-3); }

/* Cartella del paziente */
.record-head { display: flex; gap: var(--s-5); align-items: center; padding: var(--s-6); flex-wrap: wrap; }
.record-head__main { flex: 1 1 320px; min-width: 0; }
.record-head h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.record-head__meta { display: flex; gap: var(--s-4); flex-wrap: wrap; margin-top: 8px; color: var(--ink-2); font-size: 14px; }
.record-head__meta span { display: inline-flex; align-items: center; gap: 6px; }
.record-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 0 var(--s-4); border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 14px 14px; font-size: 14px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab.is-soon { opacity: 0.45; pointer-events: none; font-weight: 500; }
.tab .badge { height: 20px; padding: 0 7px; font-size: 11px; }
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-6); margin: 0; }
.dl dt { font-size: 12px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.dl dd { margin: 0; font-size: 15px; word-break: break-word; } .dl dd.mono { font-family: var(--font-mono); letter-spacing: 0.04em; }
.dl .span-2 { grid-column: 1 / -1; }
.stack { display: grid; gap: var(--s-5); } .split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list li:last-child { border-bottom: 0; } .list li:first-child { padding-top: 0; }
.list__grow { flex: 1; min-width: 0; } .list__grow small { display: block; color: var(--ink-3); font-size: 13px; }
.list__actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
@media (max-width: 720px) {
    .list--wrap li { flex-wrap: wrap; align-items: flex-start; }
    .list--wrap .list__actions { flex-basis: 100%; justify-content: flex-end; }
}
.action-list { display: grid; gap: 8px; } .action-list form { display: contents; }
.action-list .btn { justify-content: flex-start; width: 100%; }

/* Diario clinico */
.note { display: grid; grid-template-columns: 36px 1fr; gap: 14px; padding: var(--s-5) 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note__head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.note__head strong { font-weight: 650; } .note__head time, .note__head span { color: var(--ink-3); font-size: 13px; }
.note__body { margin-top: 6px; font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.composer { padding: var(--s-5) var(--s-6); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.composer__bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin-top: var(--s-3); flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-sm); background: var(--surface-sunken); gap: 2px; }
.segmented label { position: relative; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); }

/* Dialogo di conferma */
dialog.dialog { border: 0; padding: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - 32px)); }
dialog.dialog::backdrop { background: rgb(18 15 14 / 0.55); backdrop-filter: blur(3px); }
dialog.dialog[open] { animation: rise 0.25s var(--ease) both; }
.dialog__body { padding: var(--s-8) var(--s-6) var(--s-5); } .dialog__body h2 { font-size: 18px; margin-bottom: 8px; } .dialog__body p { color: var(--ink-2); font-size: 15px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6) var(--s-6); }
.btn--danger { --btn-bg: var(--brand-700); --btn-ink: #fff; --btn-line: transparent; } .btn--danger:hover { background: var(--brand-800); border-color: transparent; }

/* Calendario settimanale (le posizioni arrivano da un blocco <style nonce> generato dal template) */
.cal { overflow-x: auto; }
.cal__head, .cal__grid { display: grid; grid-template-columns: 56px repeat(7, minmax(104px, 1fr)); min-width: 800px; }
.cal__head { border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.cal__day { display: grid; justify-items: center; gap: 2px; padding: 10px 4px; color: var(--ink-2); border-left: 1px solid var(--line); }
.cal__day:hover { background: var(--surface-sunken); text-decoration: none; }
.cal__day small { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.cal__day strong { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; font-size: 15px; color: var(--ink); }
.cal__day.is-today strong { background: var(--primary); color: #fff; }
.cal__grid { position: relative; column-gap: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, transparent 55px, var(--line) 55px, var(--line) 56px, transparent 56px);
  background-size: 100% 80px, 100% 100%; }
.cal__hour { grid-column: 1; font-size: 11px; color: var(--ink-3); text-align: right; padding: 2px 8px 0 0; font-variant-numeric: tabular-nums; }
.cal__avail { margin: 0 1px; background: var(--success-soft); border-left: 1px solid var(--line); }
.cal__event { z-index: 1; margin: 1px 3px; padding: 3px 8px; border-radius: 8px; overflow: hidden; display: grid; align-content: start; gap: 1px; font-size: 12px; line-height: 1.25;
  color: var(--ink); background: color-mix(in srgb, var(--ev) 14%, var(--surface)); border-left: 3px solid var(--ev); box-shadow: var(--shadow-xs);
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease); }
.cal__event:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 3; }
.cal__event strong { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal__time { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cal__time .icon { width: 12px; height: 12px; }
.cal__event.is-requested { background: var(--warning-soft); border-left-color: var(--warning); outline: 1px dashed var(--warning); outline-offset: -1px; }
.cal__event.is-proposed { background: var(--info-soft); border-left-color: var(--info); outline: 1px dashed var(--info); outline-offset: -1px; }
.cal__event.is-completed { opacity: 0.6; } .cal__event.is-no_show { opacity: 0.6; border-left-color: var(--danger); text-decoration: line-through; }
.cal__legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.cal__legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 8px; }
.cal__legend i.cal__avail { border: 1px solid var(--line-strong); margin-left: 0; }
.cal__dot.is-requested { background: var(--warning); } .cal__dot.is-proposed { background: var(--info); } .cal__dot.is-confirmed { background: var(--primary); }

/* Linea del tempo dello stato di un appuntamento */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.steps li { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding-bottom: 18px; position: relative; font-size: 14px; }
.steps li::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.steps li:last-child { padding-bottom: 0; } .steps li:last-child::before { display: none; }
.steps__dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink-3); }
.steps li.is-done .steps__dot { background: var(--success-soft); color: var(--success); }
.steps li.is-bad .steps__dot { background: var(--danger-soft); color: var(--danger); }
.steps small { display: block; color: var(--ink-3); }
.quote { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-sunken); font-size: 14px; white-space: pre-wrap; word-break: break-word; }

/* Grafici SVG generati lato server */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart__band { fill: var(--success-soft); }
.chart__threshold { stroke: var(--success); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.6; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__label { fill: var(--ink-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart__dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart__dot.is-alert { fill: var(--danger); stroke: var(--surface); stroke-width: 2; }

/* Domande e risposte (anamnesi), piani, dettagli ripiegabili */
.qa { margin: 0; display: grid; }
.qa__section { margin-top: var(--s-6); padding-bottom: 8px; font-size: 12px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); border-bottom: 1px solid var(--line); }
.qa__section:first-child { margin-top: 0; }
.qa__row { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s-5); padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.qa__row:last-child { border-bottom: 0; }
.qa__row dt { color: var(--ink-2); } .qa__row dd { margin: 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.qa__row.is-alert dd { color: var(--danger); } .qa__row.is-alert .icon { align-self: center; }
.plan { padding: var(--s-4) 0; border-bottom: 1px solid var(--line); } .plan:first-child { padding-top: 0; } .plan:last-child { border-bottom: 0; padding-bottom: 0; }
.plan__items { margin: 10px 0 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; }
.plan .quote { margin-top: 10px; }
.details summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.details summary::before { content: "›"; display: inline-block; transition: transform 0.15s var(--ease); }
.details[open] summary::before { transform: rotate(90deg); }
.details summary::-webkit-details-marker { display: none; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); }
.item-row:has(.item-row__toggle input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.item-row__config { display: grid; grid-template-columns: 160px minmax(0, 1fr) 110px 170px; gap: var(--s-3); align-items: end; }
.item-row:not(:has(.item-row__toggle input:checked)) .item-row__config { display: none; }
.item-row__toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-weight: 600; font-size: 14px; }
.item-row__toggle input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.item-row__toggle small { display: block; font-weight: 400; color: var(--ink-3); }
@media (max-width: 1000px) { .qa__row, .item-row__config { grid-template-columns: 1fr; gap: 6px; } }

/* Orari di apertura e campioni colore */
.hours { display: grid; gap: 8px; }
.hours__row { display: grid; grid-template-columns: 110px repeat(2, minmax(0, 1fr)); gap: var(--s-4); align-items: center; }
.hours__day { font-size: 14px; font-weight: 600; }
.hours__slot { display: flex; align-items: center; gap: 8px; }
.hours__slot .input { padding: 0 10px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); }
.input[type="color"] { padding: 4px; cursor: pointer; }
.input--file { height: auto; padding: 8px 10px; font-size: 13px; cursor: pointer; }
.input--file::file-selector-button { margin-right: 10px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
@media (max-width: 700px) { .hours__row { grid-template-columns: 1fr; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); } }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); margin-bottom: var(--s-5); }
.breadcrumb a { color: var(--ink-2); font-weight: 550; }

@media (max-width: 1000px) { .form-grid, .dl, .split { grid-template-columns: 1fr; } }

/* ── 9b. Pagine pubbliche per i pazienti (link dalle email) ─────────────── */
body.web { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: var(--s-6); padding: 0 var(--s-5) var(--s-6);
  background: linear-gradient(180deg, var(--brand-700) 0, var(--brand-600) 240px, var(--bg) 240px); }
.web__brand { width: 100%; max-width: 460px; display: flex; align-items: center; gap: 14px; padding-top: var(--s-10); color: #fff; font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.web__brand small { display: block; font-weight: 500; font-size: 13px; letter-spacing: 0; opacity: 0.8; }
.web__card { width: 100%; max-width: 460px; align-self: start; padding: var(--s-10) var(--s-8); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: rise 0.5s var(--ease) both; }
.web__card h1 { font-size: 24px; margin-bottom: var(--s-2); }
.web__icon { width: 56px; height: 56px; border-radius: var(--r-lg); display: grid; place-items: center; margin-bottom: var(--s-5); background: var(--primary-soft); color: var(--primary); }
.web__icon--success { background: var(--success-soft); color: var(--success); }
.web__icon--warning { background: var(--warning-soft); color: var(--warning); }
.web__form .alert { margin-bottom: var(--s-5); }
.web__foot { font-size: 12px; color: var(--ink-3); text-align: center; max-width: 460px; }
@media (max-width: 520px) { .web__card { padding: var(--s-8) var(--s-5); } }

/* ── 9b. Messaggi ───────────────────────────────────────────────────────── */
.chat { --chat-offset: 128px; display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: var(--s-5);
  height: calc(100dvh - var(--chat-offset)); min-height: 460px; }
.chat > .card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat__inbox-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.chat__inbox-head h1 { font-size: 18px; }
.segmented a { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.segmented a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.chat__list { overflow: hidden auto; flex: 1; overscroll-behavior: contain; }
.chat__inbox-empty { padding: var(--s-10) var(--s-5); }

.chat-item { display: flex; gap: 12px; padding: 14px var(--s-5); border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; position: relative; transition: background 0.15s; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.is-active { background: var(--primary-soft); }
.chat-item.is-active::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary); }
.chat-item__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.chat-item__top, .chat-item__bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-item__top strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item__top time { font-size: 12px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.chat-item__preview { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item__top strong { min-width: 0; } .chat-item .badge { flex: none; }
.chat-item.is-unread .chat-item__top strong { font-weight: 720; }
.chat-item.is-unread .chat-item__preview { color: var(--ink); font-weight: 550; }
.chat-item.is-unread .chat-item__top time { color: var(--primary); font-weight: 600; }
.chat-item__tag { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat__placeholder { margin: auto; }
.chat__head { display: flex; align-items: center; gap: 12px; padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.chat__head-main { flex: 1; min-width: 0; display: grid; }
.chat__head-main a { color: inherit; text-decoration: none; } .chat__head-main a:hover { text-decoration: underline; }
.chat__head-main small { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__head-main small .icon { flex: none; }
.chat__back { display: none; }
.chat__scroll { flex: 1; overflow-y: auto; padding: var(--s-5); background: var(--surface-sunken); overscroll-behavior: contain; }
.chat__scroll:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.chat__older { text-align: center; margin-bottom: var(--s-4); }
.chat__hint { text-align: center; color: var(--ink-3); font-size: 13px; max-width: 46ch; margin: var(--s-8) auto; }
.chat__messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chat__day { align-self: center; margin: var(--s-3) 0 var(--s-2); }
.chat__day span { padding: 4px 12px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: capitalize; }

.msg { display: flex; max-width: min(78%, 620px); animation: rise 0.25s var(--ease) both; }
.msg--me, .msg--colleague { align-self: flex-end; }
.msg--other { align-self: flex-start; }
.msg--system { align-self: center; max-width: 90%; }
.msg__bubble { display: grid; gap: 4px; padding: 9px 12px 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-xs); min-width: 84px; }
.msg--other .msg__bubble { border-bottom-left-radius: 4px; }
.msg--me .msg__bubble { background: var(--primary); border-color: transparent; color: var(--primary-ink); border-bottom-right-radius: 4px; }
.msg--colleague .msg__bubble { background: var(--primary-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.msg--system .msg__bubble { background: transparent; border: 0; box-shadow: none; color: var(--ink-3); font-size: 13px; text-align: center; }
.msg.is-pending { opacity: 0.6; } .msg.is-failed .msg__bubble { outline: 2px solid var(--danger); }
.msg__sender { font-size: 12px; font-weight: 650; color: var(--primary); }
.msg__body { margin: 0; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg__meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; opacity: 0.72; font-variant-numeric: tabular-nums; }
.msg__receipt { display: inline-flex; } .msg__receipt .icon { width: 14px; height: 14px; }
.msg--colleague .msg__receipt.is-read, .msg--me .msg__receipt.is-read { opacity: 1; }
.msg--colleague .msg__receipt.is-read { color: var(--info); }
.msg__file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgb(0 0 0 / 0.06); color: inherit; text-decoration: none; min-width: 200px; }
.msg--me .msg__file { background: rgb(255 255 255 / 0.16); }
.msg__file:hover { filter: brightness(0.97); } .msg__file.is-gone { opacity: 0.6; font-style: italic; }
.msg__file span { display: grid; min-width: 0; } .msg__file strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg__file small { font-size: 12px; opacity: 0.75; }

.chat__typing { display: flex; align-items: center; gap: 8px; margin: var(--s-3) 0 0; font-size: 13px; color: var(--ink-3); }
.chat__dots { display: inline-flex; gap: 3px; padding: 8px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.chat__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: typing 1.2s infinite ease-in-out; }
.chat__dots i:nth-child(2) { animation-delay: 0.15s; } .chat__dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { transform: none; opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat__dots i { animation: none; } }

.chat__compose { border-top: 1px solid var(--line); padding: var(--s-3) var(--s-4); display: grid; gap: 8px; background: var(--surface); }
.chat__compose-row { display: flex; align-items: flex-end; gap: 8px; }
.chat__input { flex: 1; min-height: 44px; max-height: 160px; resize: none; padding: 11px 16px; border-radius: 22px; line-height: 1.4; overflow-y: hidden; }
.chat__attach, .chat__send { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; position: relative; }
.chat__attach:has(input:focus-visible) { outline: 3px solid var(--focus); }
.chat__attachment { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: var(--r-sm); background: var(--surface-sunken); font-size: 13px; }
.chat__attachment span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__error { margin: 0; font-size: 13px; color: var(--danger); }
.chat__closed { display: flex; align-items: center; gap: 10px; padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); background: var(--warning-soft); color: var(--ink-2); font-size: 13px; }
.chat__closed .icon { flex: none; color: var(--warning); }

@media (max-width: 1000px) {
  .chat { --chat-offset: 176px; grid-template-columns: 1fr; }
  .chat--open .chat__inbox, .chat:not(.chat--open) .chat__thread { display: none; }
  .chat__back { display: inline-flex; }
  .chat__head .btn span { display: none; }
  .msg { max-width: 88%; }
}

/* ── 9c. Videovisita ────────────────────────────────────────────────────── */
/* Il palco è sempre scuro, in entrambi i temi: è lo sfondo naturale di un video. */
.call { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-5); height: calc(100dvh - 176px); min-height: 480px; }
.call__stage { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #0f0d0c; color: #f6f2ee; display: grid; place-items: center; box-shadow: var(--shadow-md); }
.call__remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0f0d0c; }
.call__placeholder { position: relative; display: grid; justify-items: center; gap: 10px; text-align: center; padding: var(--s-6); }
.call__placeholder strong { font-size: 22px; letter-spacing: -0.02em; }
.call__placeholder p { margin: 0; color: #b9b0a7; }
.call__placeholder .avatar { animation: ring 1.6s var(--ease) infinite; }
.call[data-status="active"] .call__placeholder .avatar { animation: none; }
.avatar--xl { width: 112px; height: 112px; font-size: 38px; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgb(233 54 81 / 0.55); } 100% { box-shadow: 0 0 0 28px rgb(233 54 81 / 0); } }
@media (prefers-reduced-motion: reduce) { .call__placeholder .avatar { animation: none; } }
.call__top { position: absolute; inset: 0 0 auto 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: var(--s-4) var(--s-5);
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.55), transparent); }
.badge--dark { background: rgb(255 255 255 / 0.14); color: #f6f2ee; backdrop-filter: blur(6px); }
.call__timer { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 15px; padding: 4px 10px; border-radius: var(--r-full); background: rgb(0 0 0 / 0.45); }
.call__self { position: absolute; right: var(--s-5); bottom: 96px; width: min(24%, 220px); aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-md);
  border: 2px solid rgb(255 255 255 / 0.85); background: #2b2724; box-shadow: var(--shadow-lg); transform: scaleX(-1); }
.call__notice { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); margin: 0; max-width: min(90%, 560px); padding: 10px 16px; border-radius: var(--r-md);
  background: rgb(0 0 0 / 0.72); font-size: 14px; text-align: center; }
.call__unmute { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); }
.call__controls { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; align-items: center; gap: var(--s-4); padding: var(--s-5);
  background: linear-gradient(to top, rgb(0 0 0 / 0.6), transparent); }
.call__button { width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff; background: rgb(255 255 255 / 0.18);
  backdrop-filter: blur(6px); transition: background 0.15s, transform 0.15s; }
.call__button:hover { background: rgb(255 255 255 / 0.28); } .call__button:active { transform: scale(0.95); }
.call__button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.call__button[aria-pressed="false"] { background: #f6f2ee; color: #1c1917; }
.call__button--end { width: 68px; background: var(--brand-600); border-radius: 28px; } .call__button--end:hover { background: var(--brand-700); }
.call__side { overflow-y: auto; }
.call__tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 13px; color: var(--ink-2); }
.call__tips li { display: flex; gap: 10px; } .call__tips .icon { flex: none; margin-top: 2px; color: var(--ink-3); }
.call-summary { display: grid; justify-items: center; gap: 8px; text-align: center; padding: var(--s-16) var(--s-6); max-width: 640px; margin: 0 auto; }
.call-summary h1 { font-size: 24px; } .call-summary p { margin: 0; }
.call-summary__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: var(--s-5); }
.msg--call { align-self: center; max-width: 90%; }
.msg--call .msg__bubble { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-full); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 550; min-width: 0; }
.msg--call .msg__meta { opacity: 0.7; font-weight: 400; }
@media (max-width: 1000px) {
  .call { grid-template-columns: 1fr; height: auto; }
  .call__stage { height: calc(100dvh - 200px); min-height: 420px; }
  .call__self { bottom: 92px; right: var(--s-3); width: 30%; }
}

/* ── 9d. Contenuti: editor Markdown, anteprima, copertine ───────────────── */
.md-editor__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: 6px; }
.segmented button { padding: 6px 12px; border: 0; border-radius: 6px; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.md-editor__input { font-family: var(--font-mono); font-size: 14px; line-height: 1.6; min-height: 280px; }
.md-editor__preview { min-height: 280px; padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.md-editor code { padding: 1px 5px; border-radius: 4px; background: var(--surface-sunken); font-size: 12px; white-space: nowrap; }
/* Testo reso dal Markdown: stessa gerarchia che avrà nell'app */
.prose { font-size: 16px; line-height: 1.7; color: var(--ink); max-width: 68ch; overflow-wrap: anywhere; }
.prose > * + * { margin-top: 0.9em; } .prose p, .prose ul, .prose ol, .prose blockquote { margin-bottom: 0; }
.prose h2 { font-size: 22px; margin-top: 1.4em; letter-spacing: -0.02em; } .prose h3 { font-size: 18px; margin-top: 1.2em; }
.prose ul, .prose ol { padding-left: 1.4em; } .prose li + li { margin-top: 0.3em; }
.prose blockquote { margin-left: 0; padding: 4px 0 4px 16px; border-left: 3px solid var(--primary); color: var(--ink-2); font-style: italic; }
.prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose:empty::before { content: "Niente da mostrare: scrivi qualcosa nella scheda «Scrivi»."; color: var(--ink-3); font-size: 14px; }
.cover-preview { display: block; width: 100%; max-width: 420px; height: auto; border-radius: var(--r-md); border: 1px solid var(--line); margin-bottom: 8px; }

/* Simulatore del paziente (solo sviluppo) */
.devsim { min-height: 100dvh; display: grid; place-items: start center; padding: var(--s-6) var(--s-4); background: var(--surface-sunken); }
.devsim__phone { width: min(100%, 420px); display: grid; gap: var(--s-5); padding: var(--s-5); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.devsim__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.devsim h1 { font-size: 22px; } .devsim section { display: grid; gap: var(--s-3); }
.devsim__actions { display: flex; justify-content: center; gap: var(--s-8); margin-top: var(--s-4); }
.devsim__accept { background: var(--green-600); } .devsim__accept:hover { background: var(--green-700); }
.devsim__stage { position: relative; aspect-ratio: 3 / 4; border-radius: var(--r-lg); overflow: hidden; background: #0f0d0c; }
.devsim__stage video[data-remote] { width: 100%; height: 100%; object-fit: cover; }
.devsim__stage video[data-self] { position: absolute; right: 10px; bottom: 10px; width: 32%; border-radius: var(--r-sm); border: 2px solid #fff; }
.devsim__log { margin: 0; max-height: 160px; overflow: auto; padding: 10px; border-radius: var(--r-sm); background: var(--surface-sunken); font: 11px/1.5 var(--font-mono); color: var(--ink-2); white-space: pre-wrap; }

/* ── 10. Utilità ────────────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-2); } .center { text-align: center; } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.row { display: flex; align-items: center; gap: var(--s-3); } .row--between { justify-content: space-between; }
[hidden] { display: none !important; }

/* ── 11. Stampa (codici di recupero) ────────────────────────────────────── */
@media print {
  .auth__brand, .auth__theme, .codes-actions, .check, .auth__form .btn, .toast-region, .no-print { display: none !important; }
  .auth { display: block; } .auth__main { padding: 0; background: #fff; }
  .codes { border: 1px solid #999; }
}
