:root {
  --navy: #0a3d82;
  --blue: #1565c0;
  --blue-dark: #0d47a1;
  --teal: #00796b;
  --red: #c62828;
  --amber: #b26a00;
  --ink: #1a1f29;
  --muted: #5b6573;
  --line: #d7dde5;
  --bg: #f3f5f8;
  --card: #ffffff;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.bar {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 800; letter-spacing: 0.14em; font-size: 15px; }
.brand small { display: block; font-weight: 500; letter-spacing: 0; opacity: 0.85; font-size: 12px; }
.bar .right { font-size: 13px; text-align: right; opacity: 0.95; overflow-wrap: anywhere; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 96px; }
main.wide { max-width: 980px; }
h1 { font-size: 22px; margin: 4px 0 8px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
p { margin: 8px 0; }
a { color: var(--blue); }
.muted { color: var(--muted); font-size: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.progress > div { height: 100%; background: var(--blue); width: 0; transition: width 0.2s; }
.steplabel { font-size: 13px; color: var(--muted); }
.field { margin: 14px 0; }
.field > label, .legend { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin: -2px 0 6px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="password"], select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}
input:focus, select:focus { outline: 3px solid rgba(21, 101, 192, 0.25); border-color: var(--blue); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); }
.err { color: var(--red); font-size: 14px; margin: 6px 0 0; min-height: 0; }
.err:empty { display: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 8px 0;
  background: #fff;
  cursor: pointer;
}
.choice input { margin-top: 3px; width: 20px; height: 20px; flex: none; }
.choice:has(input:checked) { border-color: var(--blue); background: #eef4fc; }
.inline-choices { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-choices .choice { flex: 1 1 120px; margin: 4px 0; }
button, .btn {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px 18px;
  min-height: 48px;
  border: 1.5px solid var(--blue);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover { background: var(--blue-dark); }
button.secondary, .btn.secondary { background: #fff; color: var(--blue); }
button.secondary:hover { background: #eef4fc; }
button.danger { background: #fff; color: var(--red); border-color: var(--red); }
button.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
button:disabled { opacity: 0.55; cursor: default; }
.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  justify-content: center;
}
.nav > * { flex: 1; max-width: 300px; }
.hidden { display: none !important; }
.uploads { display: grid; gap: 10px; margin-top: 10px; }
.upload-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.upload-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.upload-item .doc { width: 64px; height: 64px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.upload-item .meta { flex: 1; font-size: 14px; overflow-wrap: anywhere; }
.bar-mini { height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar-mini > div { height: 100%; width: 0; background: var(--teal); }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btnrow > * { flex: 1 1 140px; }
.summary dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; margin: 0; }
.summary dt { color: var(--muted); font-size: 14px; }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.summary h3 { font-size: 15px; margin: 16px 0 6px; color: var(--navy); }
.notice { border-left: 4px solid var(--amber); background: #fff8e8; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.notice.ok { border-color: var(--teal); background: #e8f5f3; }
.notice.bad { border-color: var(--red); background: #fdecec; }
.big-ref { font-size: 28px; font-weight: 800; letter-spacing: 0.06em; color: var(--navy); }
.selfie-preview { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; display: block; margin: 8px auto; border: 3px solid var(--line); }
footer.site { text-align: center; font-size: 12px; color: var(--muted); padding: 16px; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; margin: 4px 0 12px; overflow-x: auto; }
.tabs button { background: #fff; color: var(--ink); border-color: var(--line); min-height: 40px; padding: 8px 14px; flex: none; }
.tabs button[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.list { display: grid; gap: 10px; }
.list .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; color: var(--ink); width: 100%; font-weight: 400; }
.list .item:hover { background: #f7faff; }
.pill { font-size: 12px; font-weight: 700; border-radius: 99px; padding: 3px 9px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.new { background: #fff3cd; color: #7a5200; }
.pill.done { background: #dff3ef; color: var(--teal); }
.pill.open { background: #e3eefc; color: var(--blue-dark); }
.pill.left { background: #f1e6fb; color: #5b2a86; }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr auto; gap: 6px 10px; align-items: center; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.copy { min-height: 32px; padding: 4px 10px; font-size: 13px; background: #fff; color: var(--blue); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.check .who { font-size: 12px; color: var(--muted); }
.photo-view { max-width: 100%; max-height: 420px; border-radius: 10px; display: block; margin: 8px 0; }
table.audit { width: 100%; border-collapse: collapse; font-size: 13px; }
table.audit td, table.audit th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
dialog { border: 0; border-radius: 14px; padding: 18px; width: min(92vw, 460px); }
dialog::backdrop { background: rgba(10, 20, 40, 0.45); }
.linkbox { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--bg); padding: 10px; border-radius: 8px; overflow-wrap: anywhere; }
.pin { font-size: 34px; font-weight: 800; letter-spacing: 0.3em; color: var(--navy); }
@media (max-width: 420px) {
  .kv { grid-template-columns: 1fr auto; }
  .kv dt { grid-column: 1 / -1; margin-top: 6px; }
}
.notice.safe { margin: 12px 0; line-height: 1.45; }
.notice.safe b { display: block; margin-bottom: 2px; }
