:root {
  --navy: #1f3557;
  --teal: #2e6e65;
  --grey: #595959;
  --fill: #eaeff5;
  --line: #cdd5df;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1b2430;
  --bad: #9b2226;
  --bad-fill: #fbeceb;
  --good: #1f6f43;
  --good-fill: #e6f4ec;
  --warn: #8a5a00;
  --warn-fill: #fdf3dc;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Calibri, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.bar .mark { font-weight: 700; letter-spacing: 3px; font-size: 18px; }
.bar .sub { color: #b9d6d1; letter-spacing: 2px; font-size: 14px; text-transform: uppercase; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; }
main.narrow { max-width: 560px; }

footer.site {
  border-top: 1px solid var(--line);
  padding: 16px 20px 24px;
  font-size: 14px;
  color: var(--grey);
  text-align: center;
}
footer.site a { color: var(--teal); }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 12px; color: var(--navy); }
h2 { font-size: 19px; margin: 0 0 10px; color: var(--navy); }
p { margin: 0 0 14px; }
a { color: var(--teal); }
ol, ul { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 6px; }
.muted { color: var(--grey); font-size: 15px; }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
}
.card + .card { margin-top: 16px; }

button, .btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  font-weight: 600;
  min-height: 46px;
}
button:hover { background: #162844; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, .pad:focus-visible {
  outline: 3px solid #7fb5ad;
  outline-offset: 2px;
}
button[disabled] { opacity: 0.55; cursor: not-allowed; }
button.wide { width: 100%; }
button.secondary { background: #fff; color: var(--navy); }
button.secondary:hover { background: var(--fill); }
button.link {
  background: none; border: none; color: var(--teal); padding: 6px 0; min-height: 0;
  font-weight: 400; text-decoration: underline;
}
button.link:hover { background: none; color: #1f4c46; }
button.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
button.danger:hover { background: var(--bad-fill); }

label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], textarea {
  font: inherit;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #9aa6b5;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
input.code {
  font-size: 30px;
  letter-spacing: 10px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px 8px;
}

.notice { border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; border: 1px solid transparent; }
.notice.error { background: var(--bad-fill); border-color: #e3b5b2; color: #6d1518; }
.notice.good { background: var(--good-fill); border-color: #a9d3ba; color: #15512f; }
.notice.warn { background: var(--warn-fill); border-color: #ecd08c; color: #5c3c00; }
.notice.info { background: var(--fill); border-color: var(--line); color: var(--navy); }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--teal);
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- document view ---------- */
.doc-head { margin-bottom: 16px; }
.doc-head .ref { color: var(--grey); font-size: 15px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.pages { min-width: 0; }
.page {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(31, 53, 87, 0.12);
  margin: 0 0 14px;
  width: 100%;
  overflow: hidden;
}
.page canvas { display: block; width: 100%; height: 100%; }
.page .num {
  position: absolute; right: 8px; bottom: 6px; font-size: 12px; color: var(--grey);
  background: rgba(255, 255, 255, 0.85); padding: 1px 6px; border-radius: 4px;
}
.field {
  position: absolute;
  border: 2px dashed var(--teal);
  background: rgba(46, 110, 101, 0.1);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: flex-start;
  overflow: hidden;
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  padding: 0 4px;
  white-space: nowrap;
}
.field.filled { border-style: solid; background: rgba(255, 255, 255, 0.7); color: #000; font-weight: 400; }
.field.sig.filled { color: var(--navy); font-family: "Times New Roman", Times, serif; font-style: italic; font-size: 20px; }
.field img { max-width: 100%; max-height: 100%; display: block; }

.panel { position: sticky; top: 16px; }
.panel .card { padding: 18px; }
.panel h2 { margin-top: 20px; }
.panel .card > h2:first-child, .panel .card > div > h2:first-child { margin-top: 0; }
.parties { list-style: none; padding: 0; margin: 0 0 4px; font-size: 15px; }
.parties li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--fill); margin: 0; }
.parties li:last-child { border-bottom: none; }
.parties .st { color: var(--grey); white-space: nowrap; }
.parties .st.done { color: var(--good); font-weight: 600; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; background: #fff; color: var(--navy); border-color: var(--line); min-height: 40px; padding: 8px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--fill); border-color: var(--navy); }
.typed-preview {
  font-family: "Times New Roman", Times, serif; font-style: italic; font-size: 30px; color: var(--navy);
  border-bottom: 1px solid #9aa6b5; min-height: 48px; padding: 4px 2px; margin-top: 8px;
  overflow: hidden; white-space: nowrap;
}
.pad {
  display: block; width: 100%; aspect-ratio: 3 / 1; border: 1px solid #9aa6b5; border-radius: 8px;
  background: #fff; touch-action: none; cursor: crosshair;
}
.pad-row { display: flex; justify-content: space-between; align-items: center; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; font-weight: 400; }
.consent input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--teal); }
.actions { display: flex; flex-direction: column; gap: 8px; }
.jump {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px;
  background: rgba(246, 248, 251, 0.96); border-top: 1px solid var(--line); z-index: 5;
}

/* ---------- verify page ---------- */
.drop {
  border: 2px dashed #9aa6b5; border-radius: 10px; padding: 34px 18px; text-align: center; background: #fff;
}
.drop.over { border-color: var(--teal); background: #eef6f4; }
.result { margin-top: 16px; }
.result dt { font-weight: 600; color: var(--grey); font-size: 14px; margin-top: 10px; }
.result dd { margin: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .jump { display: block; }
  main.has-jump { padding-bottom: 90px; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  h1 { font-size: 23px; }
  .card { padding: 18px 16px; }
  main { padding: 18px 12px 32px; }
}
