:root {
  --blue: #0f6fc6;
  --blue-deep: #0063be;
  --accent: #1db6e8;
  --ink: #313131;
  --bg: #f7f7f7;
  --line: #e2e6ea;
  --bad: #c62828;
  --ok: #1b7f3b;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
header {
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; position: sticky; top: 0; z-index: 10;
}
header img.logo { height: 40px; display: block; }
header .who { font-size: 15px; color: #666; display: flex; align-items: center; gap: 12px; }
header .who button { min-height: 36px; padding: 6px 14px; font-size: 14px; }

#progressWrap { background: #fff; border-bottom: 1px solid var(--line); }
#progressBar { height: 6px; background: var(--accent); width: 0%; transition: width .25s ease; }
#progressLabel { font-size: 13px; color: #777; padding: 6px 20px 8px; }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 120px; }
.card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--line);
  padding: 24px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
h1 { font-size: 26px; margin: 0 0 6px; color: var(--ink); }
h2 { font-size: 21px; margin: 0 0 4px; }
.sub { color: #6b7480; margin: 0 0 18px; font-size: 15px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

label.field { display: block; }
label.field .lbl { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
label.field .lbl .req { color: var(--bad); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date],
input[type=password], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 17px; color: var(--ink);
  border: 1.5px solid #cfd6dd; border-radius: 10px; background: #fff; appearance: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15,111,198,.15); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--bad); background: #fff7f7; }
.hint { font-size: 13px; color: #8a93a0; margin-top: 4px; }

.check { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 2px; cursor: pointer; font-size: 16px; }
.check input { width: 26px; height: 26px; accent-color: var(--blue); flex: none; }
.check.locked { opacity: .75; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 10px;
  min-height: 48px; padding: 12px 22px; font-weight: 600;
}
button.primary { background: var(--blue); color: #fff; }
button.primary:hover { background: var(--blue-deep); }
button.primary:disabled { background: #9db8d0; cursor: default; }
button.ghost { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
button.ghost:hover { background: #eef5fc; }
button.plain { background: #eef1f4; color: var(--ink); }

#navBar {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--line); padding: 12px 16px;
  display: flex; justify-content: space-between; gap: 12px; z-index: 10;
}
#navBar .spacer { flex: 1; }
#navBar button { min-width: 130px; }

.error-banner {
  background: #fdecec; border: 1px solid #f3b8b8; color: var(--bad);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 15px;
}
.notice {
  background: #eef7fd; border: 1px solid #bfe3f5; color: #0b567f;
  border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 15px;
}
.warn {
  background: #fff7e8; border: 1px solid #f1d99b; color: #7a5b0e;
  border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 15px;
}

.pinpad { max-width: 380px; margin: 0 auto; text-align: center; }
.pinpad input { text-align: center; font-size: 30px; letter-spacing: 12px; }

.applist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.applist .row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: #fff; cursor: pointer;
}
.applist .row:hover { border-color: var(--blue); }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #eef1f4; color: #556; white-space: nowrap; }
.badge.draft { background: #eef1f4; }
.badge.ready { background: #e4f2ff; color: var(--blue-deep); }
.badge.sent_for_signature { background: #fff3d6; color: #8a6d1a; }
.badge.signed, .badge.submitted { background: #e2f5e8; color: var(--ok); }

.ownerCard { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.ownerCard h3 { margin: 0 0 12px; font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.ownerCard h3 button { min-height: 36px; padding: 6px 12px; font-size: 14px; }

.reveal-toggle { background: none; border: none; color: var(--blue); font-weight: 600; padding: 8px 0; min-height: 44px; }
.mix-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.mix-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.mix-table input { min-height: 44px; max-width: 110px; }
.mix-total { font-weight: 700; }
.mix-total.bad { color: var(--bad); }

.fee-table { width: 100%; border-collapse: collapse; margin: 10px 0 4px; }
.fee-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); font-size: 15px; }
.fee-table td:last-child { text-align: right; width: 130px; }
.fee-table input { min-height: 44px; text-align: right; }

.filelist { list-style: none; margin: 10px 0 0; padding: 0; }
.filelist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; font-size: 15px; }
.filelist button { min-height: 38px; padding: 6px 12px; font-size: 14px; background: #fdecec; color: var(--bad); }
.upload-btn { display: inline-flex; align-items: center; gap: 8px; }
.upload-btn input { display: none; }

.review-section { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.review-section h3 { margin: 0 0 8px; font-size: 17px; display: flex; justify-content: space-between; }
.review-section h3 a { font-size: 14px; color: var(--blue); text-decoration: none; font-weight: 600; }
.review-section dl { margin: 0; display: grid; grid-template-columns: 200px 1fr; gap: 6px 12px; font-size: 15px; }
.review-section dt { color: #778; }
.review-section dd { margin: 0; word-break: break-word; }
@media (max-width: 560px) { .review-section dl { grid-template-columns: 1fr; } .review-section dt { margin-top: 6px; } }

.previews { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0; }
.previews img { height: 300px; border: 1px solid var(--line); border-radius: 8px; background: #fff; flex: none; }

.sendResult { text-align: center; }
.sendResult .qr { width: 240px; height: 240px; margin: 12px auto; display: block; border: 1px solid var(--line); border-radius: 10px; }
.sendResult .link { word-break: break-all; font-size: 14px; background: #f2f5f8; padding: 10px; border-radius: 8px; }

/* sign page */
.consent-box { background: #f6f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 14px; color: #556; max-height: 180px; overflow-y: auto; margin-bottom: 12px; }
#sigCanvas { width: 100%; height: 200px; border: 2px dashed #b9c4cf; border-radius: 10px; background: #fff; touch-action: none; display: block; }
.sig-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.success-big { text-align: center; padding: 40px 10px; }
.success-big .tick { font-size: 64px; color: var(--ok); }
.center { text-align: center; }
.mt { margin-top: 16px; }
.muted { color: #8a93a0; font-size: 14px; }
