:root {
  --navy: #061221;
  --ink: #1b2330;
  --muted: #5f6672;
  --line: #e3e1db;
  --bg: #f6f4ef;
  --card: #ffffff;
  --ok: #1f7a4d;
  --warn: #a86a12;
  --err: #b42318;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2 { font-family: "Source Serif 4", Georgia, serif; color: var(--navy); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(26px, 6vw, 34px); line-height: 1.15; }
h2 { font-size: 24px; line-height: 1.2; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.top { padding: 20px 16px; display: flex; justify-content: center; border-bottom: 1px solid var(--line); background: var(--card); }
.logo { height: 22px; width: auto; display: block; }

main { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.intro { padding: 32px 0 20px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.intro .muted { margin-top: 6px; }
.steps { list-style: none; padding: 0; margin: 22px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px 6px 6px; }
.steps span { width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }

.doc { margin: 8px 0 24px; }
#pages { display: flex; flex-direction: column; gap: 12px; }
.page { width: 100%; height: auto; display: block; background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgba(6,18,33,.06), 0 6px 20px rgba(6,18,33,.06); }
.link { display: inline-block; margin-top: 14px; color: var(--navy); font-weight: 500; font-size: 15px; text-underline-offset: 3px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; margin: 8px 0 40px; scroll-margin-top: 16px; }
.card > .muted { margin: 6px 0 22px; }
.field { display: block; margin-bottom: 18px; }
.field > span, .row > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.row { display: flex; justify-content: space-between; align-items: baseline; }
input[type=text], input:not([type]), input[type=email], input[type=password] {
  width: 100%; font: inherit; font-size: 16px; padding: 13px 14px; border: 1px solid #cfccc4; border-radius: 10px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(6,18,33,.12); }

.pad-wrap { position: relative; height: 180px; border: 1px dashed #bdb9af; border-radius: 10px; background: #fcfbf8; overflow: hidden; }
#pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad-hint { position: absolute; left: 0; right: 0; bottom: 46px; text-align: center; color: #a8a499; font-family: "Source Serif 4", Georgia, serif; font-style: italic; font-size: 18px; pointer-events: none; transition: opacity .2s; }
.pad-line { position: absolute; left: 20px; right: 20px; bottom: 36px; border-bottom: 1px solid #d8d4ca; pointer-events: none; }

.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink); margin: 4px 0 20px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--navy); }

button { font: inherit; cursor: pointer; }
.primary { width: 100%; border: 0; border-radius: 10px; padding: 15px 18px; background: var(--navy); color: #fff; font-weight: 600; font-size: 16px; transition: transform .1s, opacity .15s; }
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .6; cursor: default; }
.ghost { border: 0; background: none; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }
.secondary { border: 1px solid #cfccc4; background: #fff; color: var(--navy); border-radius: 8px; padding: 8px 12px; font-size: 14px; font-weight: 500; }
.error { color: var(--err); background: #fdf1f0; border: 1px solid #f5cdc9; border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }

.jump { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 420px; margin: 0 auto; text-align: center; background: var(--navy); color: #fff; text-decoration: none; font-weight: 600; padding: 14px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(6,18,33,.25); transition: opacity .2s, transform .2s; }
.jump.gone { opacity: 0; transform: translateY(12px); pointer-events: none; }

.state { text-align: center; padding: 80px 8px; max-width: 440px; margin: 0 auto; }
.state h1 { margin: 18px 0 10px; }
.state p { color: var(--muted); }
.icon { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; font-size: 26px; font-weight: 600; color: #fff; }
.icon.ok { background: var(--ok); }
.icon.warn { background: var(--warn); }
.icon.err { background: var(--err); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--navy); border-radius: 50%; margin: 0 auto 16px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 16px 96px; }

/* Admin */
.admin main { max-width: 860px; }
.admin .card { margin-top: 24px; }
.admin h2 { font-size: 20px; margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.linkbox { display: flex; gap: 8px; align-items: center; margin-top: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.linkbox code { flex: 1; font-size: 14px; word-break: break-all; color: var(--navy); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.b-awaiting_pdf { background: #f1efe9; color: var(--muted); }
.b-awaiting_signature { background: #fff4e0; color: var(--warn); }
.b-signed { background: #e6f4ec; color: var(--ok); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.step-label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
@media (max-width: 640px) {
  table.list thead { display: none; }
  table.list tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.list td { display: block; border: 0; padding: 3px 0; }
}
