:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --side: #0f1b24;
  --side-text: #c9d6df;
  --text: #15202b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0d9488;
  --accent-2: #0f766e;
  --accent-soft: #ccfbf1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --red: #be123c;
  --red-soft: #ffe4e6;
  --a: #047857; --a-soft: #d1fae5;
  --b: #a16207; --b-soft: #fef9c3;
  --c: #475569; --c-soft: #e2e8f0;
  --radius: 10px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1117; --panel: #121a22; --text: #e2e8f0; --muted: #94a3b8; --line: #243241;
    --accent-soft: #134e4a; --warn-soft: #3b2a0a; --red-soft: #3f0d1b;
    --a-soft: #064e3b; --b-soft: #3f3409; --c-soft: #1e293b; --a: #6ee7b7; --b: #fde047; --c: #cbd5e1;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 24px; margin: 4px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button {
  font: inherit; border-radius: 8px; padding: 7px 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-2); }
.ghost:hover:not(:disabled) { border-color: var(--accent); }
.link { border: 0; background: none; padding: 0; color: var(--accent); }
.link.big { font-size: 15px; font-weight: 600; }
.link.danger { color: var(--red); }
.block { width: 100%; justify-content: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.gap { gap: 8px; }
.grow { flex: 1; }
code { font-size: 12px; background: var(--c-soft); padding: 2px 5px; border-radius: 4px; word-break: break-all; }

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 18px 14px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 20px; font-weight: 700; color: #fff; padding: 2px 4px 8px; letter-spacing: -.02em; }
.brand span { color: #5eead4; }
.search { background: #1a2833; border-color: #263845; color: #fff; }
.client-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.client-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; }
.client-list li small { color: #7f93a3; }
.client-list li:hover { background: #172530; }
.client-list li.on { background: #134e4a; color: #fff; }
.client-list .empty { cursor: default; }
.bottom-nav { display: flex; flex-direction: column; gap: 4px; }
.bottom-nav button { background: none; border: 0; color: var(--side-text); justify-content: flex-start; }
.bottom-nav button.on, .bottom-nav button:hover { background: #172530; color: #fff; }

.content { padding: 22px 28px 60px; min-width: 0; }
.welcome { max-width: 560px; margin: 80px auto; text-align: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.span2 { grid-column: 1 / -1; }
.screen.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; align-items: start; }
.screen.cols .card { margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 11px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.check input { width: auto; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs.small button { padding: 8px 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.toolbar { margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 13px; }
.session-head { margin-bottom: 6px; }
.session-head .field { flex-direction: row; align-items: center; margin: 0; }
.session-head .field input { width: 160px; }
.save { font-size: 12px; color: var(--muted); }
.save.error { color: var(--red); }

.canvas-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #0b0f14; }
.canvas-wrap canvas { display: block; touch-action: none; }
.canvas-wrap canvas.pick { cursor: crosshair; }
.canvas-help { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: #cbd5e1; background: rgba(11,15,20,.6); padding: 3px 8px; border-radius: 6px; pointer-events: none; }
.camera select { max-width: 320px; }
.video-box { margin-top: 10px; background: #0b0f14; border-radius: var(--radius); overflow: hidden; display: flex; justify-content: center; align-items: center; min-height: 360px; }
.video-box video { max-width: 100%; max-height: 520px; }

.landmarks { list-style: none; margin: 0; padding: 0; }
.landmarks li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.landmarks li:hover { background: var(--bg); }
.landmarks li.on { background: var(--accent-soft); font-weight: 600; }
.landmarks li .link { margin-left: auto; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.dot.ok { background: var(--accent); border-color: var(--accent); }

.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.lvl-A { background: var(--a-soft); color: var(--a); }
.lvl-B { background: var(--b-soft); color: var(--b); }
.lvl-C { background: var(--c-soft); color: var(--c); }
.findings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.findings li { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.findings li.st-oltre_soglia { border-left-color: var(--warn); }
.findings li.st-nella_norma { border-left-color: var(--a); }
.findings li.red { border-left-color: var(--red); background: var(--red-soft); }
.notice { padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.red-card { border-color: var(--red); background: var(--red-soft); }

.table, .kv, .fpi { width: 100%; border-collapse: collapse; }
.table th, .table td, .kv td, .fpi td, .fpi th { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th, .fpi th { font-size: 12px; color: var(--muted); }
.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.fpi td:first-child { font-size: 12px; }
.fpi select { width: 64px; }
.foot-metrics { margin-bottom: 10px; }

.priorities { padding-left: 18px; display: flex; flex-direction: column; gap: 12px; }
.exercises { margin: 6px 0 0; padding-left: 16px; }
.lib { list-style: none; padding: 0; margin: 0; }
.lib li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.sessions { list-style: none; padding: 0; margin: 0; }
.sessions li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; margin: 6px 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--accent); }
.report-head h2 { margin: 0; }
.right { text-align: right; }
.sources ul { padding-left: 18px; }
.print-only { display: none; }
.pre { white-space: pre-wrap; }

.modal-back { position: fixed; inset: 0; background: rgba(15,27,36,.55); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px; width: min(640px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.loading { padding: 40px; }

@media print {
  :root { --bg: #fff; --panel: #fff; --text: #000; }
  .no-print, .sidebar { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { break-inside: avoid; border-color: #ccc; }
  .report textarea { display: none; }
  .print-only { display: block; }
}

/* Accesso (versione online) */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-brand { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 2px; }
.login-error { color: var(--red); font-size: 13px; margin: 4px 0 10px; }
.login-card .primary { margin: 6px 0 12px; }
