:root {
  --navy: #1D3774;       /* colore primario brand Biolab */
  --navy-d: #152a59;
  --accent: #3C86CC;     /* azzurro brand */
  --ok: #0b7a5b;         /* stati semantici sync */
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #1c2330;
  --muted: #6b7280;
  --amber: #c97a09;
  --red: #b3261e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: "Roboto", -apple-system, system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; color: var(--navy);
  border-bottom: 1px solid #e6e9ef;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 34px; width: auto; display: block; }
.brand span {
  font-weight: 500; font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent); border-left: 1px solid #d7dce6; padding-left: 10px;
}
.right { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: var(--muted); }
.link { background: none; border: none; color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px; }

/* Status bar sync */
.status { text-align: center; font-size: 13px; padding: 8px; font-weight: 600; }
.status.ok { background: #d6f0e6; color: var(--ok); }
.status.pending { background: #fdeccd; color: var(--amber); }
.status.offline { background: #f7d7d5; color: var(--red); }

/* Layout */
.view { padding: 16px; max-width: 560px; margin: 0 auto; }
.view.wide { max-width: 1100px; }
.hidden { display: none !important; }

/* Card */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.06); margin-bottom: 16px;
}
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 14px; }

/* Form */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 12px;
  border: 1px solid #d3dad7; border-radius: 10px; font-size: 16px; background: #fff;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lbl { font-size: 13px; color: var(--muted); margin: 6px 0; }
.lbl-mut { font-weight: 400; color: var(--accent); font-size: 11px; }

/* Chips interessi */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  background: #eef3f1; border: 1px solid #d3dad7; padding: 8px 12px;
  border-radius: 999px; font-size: 14px; color: var(--ink);
}
.chip input { width: auto; margin: 0; accent-color: var(--navy); }
.chip:has(input:checked) { background: #e4ecf9; border-color: var(--accent); color: var(--navy); font-weight: 500; }

/* Logo nella schermata di login */
.login-logo { display: block; max-width: 220px; width: 70%; height: auto; margin: 4px auto 22px; }

/* Box informativa privacy (poco invasivo, a fisarmonica) */
.privacy-box { border: 1px solid #e1e6ef; border-radius: 10px; margin-bottom: 12px; background: #fbfcfe; }
.privacy-box > summary {
  cursor: pointer; list-style: none; padding: 10px 12px;
  font-size: 13px; font-weight: 500; color: var(--navy); user-select: none;
}
.privacy-box > summary::-webkit-details-marker { display: none; }
.privacy-box[open] > summary { border-bottom: 1px solid #e1e6ef; }
.privacy-content { padding: 10px 12px; max-height: 220px; overflow-y: auto;
  font-size: 12px; line-height: 1.5; color: #3a4254; }
.privacy-content p { margin: 0 0 8px; }
.privacy-content a { color: var(--accent); }

/* Campo "Altro" interessi */
#altro-wrap { margin: -4px 0 12px; }

/* Consenso */
.consent { display: flex; gap: 10px; align-items: flex-start; background: #eef3fb;
  padding: 12px; border-radius: 10px; font-size: 13px; color: var(--ink); }
.consent input { width: auto; margin-top: 3px; }

/* Firma digitale */
.sig-wrap { margin: 14px 0; }
.sig-head { display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--navy); font-weight: 500; margin-bottom: 6px; }
.link-sm { background: none; border: none; color: var(--accent); font-weight: 600; font-size: 13px; }
.sig-pad {
  width: 100%; height: 170px; display: block; background: #fff;
  border: 1px dashed #b9c2d6; border-radius: 10px;
  touch-action: none;            /* il dito disegna, non scrolla */
  cursor: crosshair;
}
.sig-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Bottoni */
button { cursor: pointer; font-size: 16px; font-family: inherit; }
.primary { background: var(--navy); color: #fff; border: none; padding: 13px;
  border-radius: 10px; font-weight: 600; width: 100%; }
.primary:active { background: var(--navy-d); }
.primary.big { padding: 16px; font-size: 17px; }
.ghost { background: #fff; border: 1px solid #d3dad7; padding: 11px 14px; border-radius: 10px; }
.actions { margin-bottom: 14px; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* Scanner */
#qr-reader { width: 100%; border-radius: 10px; overflow: hidden; margin-bottom: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Dashboard */
.toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  align-items: center; margin-bottom: 14px; }
.toolbar input { width: auto; display: inline-block; margin-left: 10px; }
.export { display: flex; gap: 8px; flex-wrap: wrap; }
.export button { width: auto; }
.tablewrap { overflow-x: auto; background: #fff; border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef1f5; white-space: nowrap; }
th { background: #eef3fb; color: var(--navy); position: sticky; top: 0; }
tbody tr:hover { background: #f7f9fc; }
.sig-thumb { height: 30px; width: auto; max-width: 110px; border: 1px solid #d7dce6;
  border-radius: 6px; background: #fff; cursor: zoom-in; vertical-align: middle; }

/* QR autoregistrazione */
.qr-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.qr-box { width: 200px; height: 200px; flex: 0 0 auto; border: 1px solid #e6e9ef;
  border-radius: 10px; padding: 8px; background: #fff; display: flex; align-items: center; justify-content: center; }
.qr-box svg { width: 100%; height: 100%; }
.qr-meta { flex: 1 1 260px; }
.qr-meta input { font-size: 13px; }
.qr-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.qr-actions button { width: auto; }

/* Lightbox firma */
.sig-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.65);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.sig-overlay img { max-width: 90vw; max-height: 80vh; background: #fff;
  border-radius: 12px; padding: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
