:root {
  --navy: #041a45;
  --gold: #d9b45a;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #15181e;
  --muted: #5d6573;
  --line: #e2e5ea;
  --accent: #0f2f6b;
  --accent-ink: #ffffff;
  --ok: #12805c;
  --ok-bg: #e6f5ef;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --err: #c22b2b;
  --err-bg: #fdecec;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --line: #2a2f3a;
    --accent: #5b8dee;
    --ok: #3ecf96;
    --ok-bg: #12291f;
    --warn: #f0b247;
    --warn-bg: #2d2412;
    --err: #ff6b6b;
    --err-bg: #331818;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0 0 8px; font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: .01em; color: var(--navy); }
@media (prefers-color-scheme: dark) { h1, h2 { color: var(--text); } }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 26px; line-height: 1.2; }
.lead { font-size: 16px; color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); margin: 0 0 16px; }
.note { font-size: 13px; color: var(--muted); background: var(--bg); padding: 10px 12px; border-radius: 10px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 8px 20px; background: radial-gradient(ellipse 70% 140% at 50% 50%, #062354 0%, #021539 55%, #01102e 100%);
  border-bottom: 2px solid var(--gold); color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand .logo {
  height: 52px; width: auto; display: block;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
@media (max-width: 560px) {
  .top { flex-direction: column; gap: 6px; padding: 8px 12px 10px; }
  .brand .logo { height: 48px; }
}
.top .btn.ghost { color: rgba(255,255,255,.85); }
.mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px;
}
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: rgba(255,255,255,.7); }
.steps li { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px; }
.steps li span {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.4); font-size: 12px;
}
.steps em { font-style: normal; }
.steps li.current { color: #fff; background: rgba(255,255,255,.12); }
.steps li.current span { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 700; }
.steps li.done span { border-color: #3ecf96; color: #3ecf96; }
@media (max-width: 560px) { .steps em { display: none; } .steps li { padding: 4px; } }

main { max-width: 760px; margin: 24px auto; padding: 0 16px 40px; }
.card {
  display: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: 0 6px 24px rgba(11,36,81,.06);
}
.card.active { display: block; }
@media (max-width: 560px) { .card { padding: 18px; } }

.how { list-style: none; counter-reset: s; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.how li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; }
.how li::before {
  content: counter(s); grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--bg); font-weight: 600; font-size: 13px;
}
.how span { color: var(--muted); }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; cursor: pointer; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }
.check.agree { background: var(--bg); padding: 14px; border-radius: 12px; font-weight: 500; }
.check.agree input { width: 20px; height: 20px; flex: none; }
#confirmSummary { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0 0 16px; font-size: 15px; }
#confirmSummary dd { font-weight: 600; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.row.end { justify-content: flex-end; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: #0b2f73; border-color: #0b2f73; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.status { font-size: 14px; min-height: 22px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.err { color: var(--err); }
.status.busy::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.viewer {
  position: relative; background: #0d0f13; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
}
.viewer.doc { aspect-ratio: 16 / 10; }
@media (max-width: 560px) { .viewer.doc { aspect-ratio: 4 / 5; } }
.viewer.live video { object-fit: cover; }
.viewer video, .viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer .placeholder { color: #8a93a3; font-size: 14px; position: absolute; }
.docframe {
  position: absolute; left: 6%; width: 88%; aspect-ratio: 1.586; top: 50%; transform: translateY(-50%);
  border: 3px solid rgba(255,255,255,.85); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; transition: border-color .15s, box-shadow .15s;
}
.docframe.ok { border-color: #3ecf96; box-shadow: 0 0 0 9999px rgba(20,120,80,.5), 0 0 0 6px rgba(62,207,150,.45); }
.mrzframe {
  position: absolute; left: 5%; right: 5%; top: 50%; transform: translateY(-50%); aspect-ratio: 5 / 1;
  border: 2px solid rgba(255,255,255,.9); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  pointer-events: none; display: grid; place-items: center; color: rgba(255,255,255,.65); font-size: 12px; font-weight: 600;
}
.viewer.scan video { object-fit: cover; }
.viewer.selfie { aspect-ratio: 3 / 4; max-width: 420px; margin: 0 auto; }
.viewer.selfie video { object-fit: cover; transform: scaleX(-1); }
.oval {
  position: absolute; width: 72%; aspect-ratio: 3 / 4; border-radius: 50%; top: 8%;
  border: 4px solid rgba(255,255,255,.8); box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  transition: border-color .15s, box-shadow .15s;
}
.oval.ok {
  border-color: #3ecf96;
  box-shadow: 0 0 0 9999px rgba(20,120,80,.55), 0 0 0 8px rgba(62,207,150,.5), inset 0 0 80px rgba(62,207,150,.45);
}
.instr {
  position: absolute; bottom: 14px; left: 12px; right: 12px; text-align: center; font-size: 17px;
  background: rgba(0,0,0,.65); color: #fff; font-weight: 700; padding: 12px 14px; border-radius: 12px;
  transition: background .15s;
}
.instr.ok { background: #12805c; }
.instr[data-dir="left"]::before { content: "← "; }
.instr[data-dir="right"]::after { content: " →"; }
.stepok {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  background: rgba(62,207,150,.35); opacity: 0; transition: opacity .15s;
}
.stepok span {
  width: 110px; height: 110px; border-radius: 50%; background: #12805c; color: #fff; font-size: 64px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.35); transform: scale(.6); transition: transform .2s;
}
.stepok.show { opacity: 1; }
.stepok.show span { transform: scale(1); }
.progress { display: flex; justify-content: center; gap: 10px; margin: 16px 0 6px; }
.progress i { width: 48px; height: 10px; border-radius: 5px; background: var(--line); transition: background .2s; }
.progress i.done { background: var(--ok); }
.progress i.current { background: var(--accent); }

.grid2 { display: grid; grid-template-columns: 160px 1fr; gap: 12px; margin: 16px 0; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.tag { text-transform: none; letter-spacing: 0; background: var(--bg); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.face { width: 100%; max-width: 180px; aspect-ratio: 3 / 4; border-radius: 8px; background: var(--bg) center / cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.mrz { margin: 0; font: 13px/1.5 ui-monospace, Consolas, monospace; overflow-x: auto; white-space: pre; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--err-bg); color: var(--err); }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.fields input, .fields select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; width: 100%;
}
.fields input:focus, .fields select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.decision { border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.decision h2 { margin: 0 0 4px; }
.decision p { margin: 0; }
.decision.approved { background: var(--ok-bg); color: var(--ok); }
.decision.review { background: var(--warn-bg); color: var(--warn); }
.decision.rejected { background: var(--err-bg); color: var(--err); }
.decision small { color: var(--muted); }

.faces { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; max-width: 460px; margin: 0 auto 18px; }
.faces figure { margin: 0; text-align: center; }
.faces img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: var(--bg); }
.faces figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.score { text-align: center; font-weight: 700; font-size: 14px; }
.score b { display: block; font-size: 22px; }

.checks { list-style: none; padding: 0; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 12px; }
.checks li { display: grid; grid-template-columns: 24px 1fr; gap: 2px 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; }
.checks li::before { grid-row: span 2; font-weight: 700; }
.checks li.ok::before { content: "✓"; color: var(--ok); }
.checks li.warn::before { content: "!"; color: var(--warn); }
.checks li.fail::before { content: "✕"; color: var(--err); }
.checks small { color: var(--muted); }

.summary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- client: link & final ---------- */
.hello { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.alert { background: var(--err-bg); color: var(--err); padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; }
#doneBox { text-align: center; padding: 24px 8px 8px; }
.done-icon {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok); font-size: 30px; font-weight: 700;
}
#doneBox small { color: var(--muted); }

/* ---------- admin ---------- */
main.wide { max-width: 1040px; display: grid; gap: 16px; }
#dash { display: grid; gap: 16px; }
#dash[hidden] { display: none; }
.card.narrow { max-width: 380px; margin: 40px auto; display: block; }
.brand .tag { font-weight: 600; font-size: 12px; color: var(--gold); background: rgba(255,255,255,.1); }
.row.head { margin: 0 0 12px; align-items: flex-start; }
.row.head h2 { margin: 0; }
.filters { display: flex; gap: 8px; align-items: center; }
.filters select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.fields.one { grid-template-columns: 1fr; }
.fields.inline { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }
@media (max-width: 700px) { .fields.inline { grid-template-columns: 1fr; } }
.linkbox { display: flex; gap: 8px; margin-top: 14px; }
.linkbox input {
  flex: 1; min-width: 0; font: 14px ui-monospace, Consolas, monospace; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
.tablewrap { overflow-x: auto; }
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--bg); }
.list small { color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.review, .badge.submitted { background: var(--warn-bg); color: var(--warn); }
.badge.rejected, .badge.expired { background: var(--err-bg); color: var(--err); }
.noimg { aspect-ratio: 3 / 4; border-radius: 10px; background: var(--bg); display: grid; place-items: center; color: var(--muted); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.docs img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.summary { margin-bottom: 16px; }
.summary .mrz { font-size: 12px; }
.review { border-top: 1px solid var(--line); padding-top: 14px; }
.review .fields span { font-size: 13px; color: var(--muted); }
.btn.danger { color: var(--err); }
.btn.danger-ghost { color: var(--err); border-color: var(--err); background: transparent; }

.btn.small { font-size: 14px; padding: 6px 10px; margin: -6px 0 12px; text-decoration: underline; }
#confirmBox .fields { margin: 0 0 16px; }
