/* POA Web — anteprima. Layout: app shell con barra laterale fissa, area di lavoro a schede, toggle "Access originale / Nuova interfaccia". */
/* Linea grafica (design-taste adattata a un gestionale): un solo accento petrolio,
 * neutri freddi con leggero bias verde, ambra e rosso solo come stati clinici (attenzione, critico).
 * Forme: 8px controlli, 12px card, 16px pannelli grandi, pill solo per chip e segmented. */
:root {
  --bg: #f4f6f5;
  --surface: #fcfdfc;
  --surface-2: #ebf0ee;
  --line: #dce4e1;
  --line-strong: #c6d2ce;
  --ink: #0f2723;
  --ink-2: #3c524d;
  --ink-3: #5c716c;
  --primary: #0b6b5c;
  --primary-ink: #f6fbfa;
  --primary-soft: #dcefea;
  --amber: #9a5b06;
  --amber-soft: #fbefd8;
  --red: #a8322b;
  --red-soft: #f9e2df;
  --blue: #2d5b8f;
  --blue-soft: #e1eaf4;
  --violet: #5f4a8c;
  --violet-soft: #ebe5f4;
  --shadow: 0 1px 2px rgba(15, 39, 35, .05), 0 8px 24px -12px rgba(15, 39, 35, .12);
  --shadow-lg: 0 2px 4px rgba(15, 39, 35, .05), 0 24px 48px -20px rgba(15, 39, 35, .22);
  --hi: inset 0 1px 0 rgba(255, 255, 255, .7);

  /* Tipografia: una famiglia (Geist), gerarchia con peso e colore; Geist Mono per numeri e codici */
  --font-display: "Geist", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Geist", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --font-data: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sidebar: 236px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1110; --surface: #111917; --surface-2: #18221f; --line: #23302c; --line-strong: #2f3e3a;
    --ink: #e5edeb; --ink-2: #aebdb9; --ink-3: #8a9c97;
    --primary: #45b8a2; --primary-ink: #04201a; --primary-soft: #15332d;
    --amber: #e3a54a; --amber-soft: #33270f; --red: #e8766c; --red-soft: #3a1d1a;
    --blue: #86ade0; --blue-soft: #1a2738; --violet: #b6a1de; --violet-soft: #261f38;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.5);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 24px 48px -20px rgba(0,0,0,.6);
    --hi: inset 0 1px 0 rgba(255,255,255,.04);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1110; --surface: #111917; --surface-2: #18221f; --line: #23302c; --line-strong: #2f3e3a;
  --ink: #e5edeb; --ink-2: #aebdb9; --ink-3: #8a9c97;
  --primary: #45b8a2; --primary-ink: #04201a; --primary-soft: #15332d;
  --amber: #e3a54a; --amber-soft: #33270f; --red: #e8766c; --red-soft: #3a1d1a;
  --blue: #86ade0; --blue-soft: #1a2738; --violet: #b6a1de; --violet-soft: #261f38;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.5);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 24px 48px -20px rgba(0,0,0,.6);
  --hi: inset 0 1px 0 rgba(255,255,255,.04);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; margin: 0; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.num, .mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100%; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding-block: 18px; padding-inline: 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding-inline: 6px; }
.brand-mark { width: 34px; height: 34px; border-radius: var(--r-sm); box-shadow: var(--hi); background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; }
.brand b { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -.01em; display: block; }
.brand small { color: var(--ink-3); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 14px 10px 4px; }
.nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; transition: background-color .18s var(--ease), color .18s var(--ease); }
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--primary); }
.nav button[aria-current="page"] svg { color: var(--primary); }
.nav button:focus-visible { outline: 2px solid var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .soon { margin-left: auto; font-size: 10.5px; color: var(--ink-3); }
.side-foot { margin-top: auto; font-size: 11.5px; color: var(--ink-3); padding-inline: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding-block: 10px; padding-inline: 24px; flex-wrap: wrap; }
.topbar h1 { font-size: 19px; }
.topbar .crumb { color: var(--ink-3); font-size: 12px; }
.topbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { all: unset; cursor: pointer; padding: 5px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); transition: background-color .2s var(--ease), color .2s var(--ease); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--primary); }
.stage { padding-block: 24px 48px; padding-inline: 28px; min-width: 0; }

/* Vista Access: contenitore scrollabile, la pagina non scorre mai in orizzontale */
.legacy-wrap { overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.legacy-note { font-size: 12.5px; color: var(--ink-2); margin: 0 0 12px; max-width: 80ch; }

/* ---------- Componenti condivisi (usati dalle schermate moderne) ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--hi), 0 1px 2px rgba(15, 39, 35, .03); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; transition: background-color .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease); }
.btn:hover { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(11, 107, 92, .25); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg { width: 16px; height: 16px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--primary-soft); color: var(--primary); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.crit { background: var(--red-soft); color: var(--red); }
.chip.info { background: var(--blue-soft); color: var(--blue); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field input, .field select, .field textarea { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); padding: 8px 10px; min-width: 0; width: 100%; transition: border-color .18s var(--ease), box-shadow .18s var(--ease); }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { all: unset; cursor: pointer; padding: 10px 12px; font-size: 13px; font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; transition: color .18s var(--ease), border-color .18s var(--ease); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--primary); font-weight: 600; }
.tabs button:focus-visible { outline: 2px solid var(--primary); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl tr:hover td { background: var(--surface-2); }
.toast { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r-md); font-size: 13px; font-weight: 500; z-index: 50; box-shadow: var(--shadow-lg); }
.example-flag { font-size: 11px; color: var(--amber); background: var(--amber-soft); padding: 2px 8px; border-radius: 999px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; align-content: start; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding-inline: 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .side-foot { display: none; }
  .topbar, .stage { padding-inline: 16px; }
}
/* Motion: solo transizioni di stato e ingresso schermata (segnala il cambio di contesto). Nessun loop decorativo. */
@media (prefers-reduced-motion: no-preference) {
  .screen { animation: poa-enter .38s var(--ease) both; }
  .toast { animation: poa-toast .32s var(--ease) both; }
}
@keyframes poa-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes poa-toast { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
