:root {
  --bg: #eef1f6;
  --card-bg: #ffffff;
  --text: #1a1d24;
  --muted: #6b7480;
  --primary: #2f5fe0;
  --primary-dark: #2347b3;
  --primary-soft: #eaf0ff;
  --border: #e3e7ee;
  --danger: #d0392a;
  --danger-soft: #fdecea;
  --success: #1e8e3e;
  --success-soft: #e6f6ea;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 25, 40, 0.04), 0 8px 24px rgba(20, 25, 40, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #dfe7ff 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 80px;
}

header.top {
  text-align: center;
  margin-bottom: 28px;
}

header.top h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

header.top p {
  color: var(--muted);
  margin: 0;
  font-size: 0.92rem;
}

.stepper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 28px;
}

.stepper .step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 84px;
}

.stepper .step .circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.stepper .step .label {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

.stepper .step.active .circle {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.stepper .step.active .label { color: var(--text); font-weight: 600; }

.stepper .step.done .circle {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.stepper .connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin-top: 13px;
  max-width: 40px;
}

.stepper .connector.done { background: var(--success); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.card p.hint {
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

.doc-frame-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0 20px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
}

.doc-frame-wrap iframe {
  width: 100%;
  height: 420px;
  border: none;
  display: block;
  background: #fff;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: 10px;
}

.checkbox-row input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.checkbox-row label {
  font-size: 0.88rem;
  line-height: 1.45;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fbfcfe;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.error-text {
  color: var(--danger);
  font-size: 0.83rem;
  margin-top: 6px;
  display: none;
}

.error-text.show { display: block; }

.form-section-title {
  font-size: 0.95rem;
  margin: 22px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.form-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  cursor: pointer;
  flex: 1;
  justify-content: center;
}

.radio-option input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

#rep-block {
  margin-top: 8px;
  padding: 16px;
  background: var(--primary-soft);
  border-radius: 12px;
}

.sig-canvas-wrap {
  border: 2px dashed #c7cede;
  border-radius: 12px;
  position: relative;
  touch-action: none;
  background:
    linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
    repeating-linear-gradient(transparent, transparent 39px, #edf0f6 40px);
}

.sig-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
}

.sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.sig-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  width: 100%;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.99); }
.btn:disabled { background: #c3c9d4; cursor: not-allowed; }

.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  width: auto;
  padding: 9px 16px;
  font-size: 0.87rem;
  font-weight: 600;
}

.btn.secondary:hover { background: #f7f8fb; }

.btn.link {
  background: none;
  color: var(--primary);
  width: auto;
  padding: 4px 0;
  font-size: 0.87rem;
  font-weight: 600;
}

.actions-row {
  display: flex;
  gap: 10px;
}

.actions-row .btn { flex: 1; }

.doc-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.doc-list-item:last-child { border-bottom: none; }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.success-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  margin: 0 auto 18px;
}

.hidden { display: none !important; }

.top-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5c6c0;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.center-loading {
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
}
