:root {
  --bg: #f5f7f9; --surface: #ffffff; --ink: #18202b; --muted: #5a6573; --line: #d9e0e7;
  --accent: #0f5c8c; --accent-ink: #ffffff; --accent-soft: #e6f0f7; --err: #b3261e; --err-soft: #fdecea;
  --ok: #1e7a45; --warn-soft: #fff6dc; --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c; --surface: #1a2129; --ink: #e8edf2; --muted: #9aa6b2; --line: #2e3843;
    --accent: #5fb0e5; --accent-ink: #0b1620; --accent-soft: #1b3142; --err: #ff8a80; --err-soft: #3a1f1f;
    --ok: #6fd39a; --warn-soft: #3a3320; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wide .wrap { max-width: 1100px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: .2em 0 .6em; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: .2em 0 .8em; }
h3 { font-size: 1.05rem; margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 600; color: var(--accent); margin: 24px 0 0; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 600; }
.brand-mark { background: var(--accent); color: var(--accent-ink); font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; font-size: .9rem; }
.footer { color: var(--muted); font-size: .8rem; padding-top: 32px; padding-bottom: 40px; }

.intro p { margin: 0 0 .8em; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.field { margin-bottom: 18px; position: relative; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--muted); }
input[type=text], input:not([type]), input[type=email], input[type=password], input[type=date], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; min-height: 44px; }
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.err { color: var(--err); font-size: .9rem; margin: 6px 0 0; min-height: 0; }
.err:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; cursor: pointer; }
.check input, .opt-row input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }

.ta-list { position: absolute; z-index: 10; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 260px; overflow: auto; }
.ta-list li { padding: 10px 12px; border-radius: 6px; cursor: pointer; }
.ta-list li.on, .ta-list li:hover { background: var(--accent-soft); }
.ta-list li.ta-empty { color: var(--muted); cursor: default; background: none; }

.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 18px; min-height: 44px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 4px; text-decoration: underline; }
.actions { margin-top: 20px; display: flex; gap: 12px; }
.actions.split { justify-content: space-between; }
.actions .btn.primary { flex: 0 1 auto; }

.q { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; min-width: 0; }
.q.has-err { border-color: var(--err); background: linear-gradient(var(--err-soft), var(--err-soft)) top/100% 4px no-repeat, var(--surface); }
.q legend { float: left; width: 100%; padding: 0; font-weight: 600; margin-bottom: 4px; }
.q legend + * { clear: both; }
.qn { color: var(--accent); font-weight: 700; margin-right: 2px; }
.part-prompt { font-weight: 600; margin: 4px 0 2px; clear: both; }
.part + .part-prompt { margin-top: 16px; }
.part { margin-top: 8px; }
.part.disabled { opacity: .45; }
.options { display: grid; gap: 4px; margin-top: 6px; }
.opt-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.opt-row:hover { background: var(--accent-soft); }
.opt-row input { margin-top: 2px; }
.text-row { display: flex; align-items: center; gap: 8px; }
.text-row textarea, .text-row input { flex: 1; }
.inline-label { font-weight: 600; min-width: 4.5em; }
.suffix { color: var(--muted); font-weight: 600; }

.progress { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px; }
.progress .bar { max-width: 728px; margin: 0 auto; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--accent); transition: width .2s; }

.review-who { position: relative; }
.review-who dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.review-who dt, dl.info dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.review-who dd, dl.info dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.review-who .link { position: absolute; top: 10px; right: 10px; }
.review-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.review-section ol { margin: 0; padding-left: 1.8em; }
.review-section li { margin: 0 0 12px; }
.rq { margin: 0; color: var(--muted); font-size: .92rem; }
.ra { margin: 2px 0 0; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.missing { color: var(--err); font-weight: 600; }
.submit-box { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; margin-top: 18px; }
.submit-box #send-note { margin: 0; font-weight: 600; }

.done { text-align: center; padding: 48px 0 16px; }
.done-mark { width: 64px; height: 64px; line-height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--ok); color: var(--surface); font-size: 34px; font-weight: 700; }

/* Admin */
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 6px; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav form { margin: 0; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 16px 0 0; background: var(--accent-soft); }
.flash.error { background: var(--err-soft); color: var(--err); }
.flash.warning, .banner { background: var(--warn-soft); }
.banner { padding: 10px 14px; border-radius: 8px; margin: 16px 0 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 16px 0; }
.toolbar .field { margin: 0; flex: 1 1 160px; }
.toolbar .field.grow { flex: 3 1 240px; }
.toolbar .field label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--line); }
.tag.ok { background: #dff3e6; color: #1e7a45; }
.tag.bad { background: var(--err-soft); color: var(--err); }
@media (prefers-color-scheme: dark) { .tag.ok { background: #1d3a2a; color: var(--ok); } }
.pager { display: flex; gap: 12px; align-items: center; margin: 14px 0; }
dl.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 0; }
.answers h3 { margin: 22px 0 8px; color: var(--accent); }
.answers ol { padding-left: 1.8em; }
.answers li { margin-bottom: 12px; }
.login-box { max-width: 420px; margin: 40px auto; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline { display: inline; }
@media (max-width: 520px) {
  h1 { font-size: 1.5rem; }
  .card, .q { padding: 14px; }
  .actions.split .btn { flex: 1; }
  .hide-sm { display: none; }
}
@media print {
  .topbar, .footer, .progress, .actions, .no-print { display: none !important; }
}
.page-head { justify-content: space-between; align-items: center; }
.page-head h1 { margin: 0; }
.nav.tabs { margin-bottom: 12px; }
.login-box.flush { margin-top: 0; }
