html, body {
  height: auto !important;
  min-height: 100vh;
  overflow-y: auto !important;
}

:root {
  --form-text-strong: #0f172a;
  --form-text-body: #334155;
  --form-text-muted: #64748b;
  --form-border-soft: #dbe3ee;
  --form-divider-soft: #e7edf5;
  --form-weight-heading: 800;
  --form-weight-subheading: 700;
  --form-weight-label: 600;
  --form-weight-body: 400;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 28px;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  display: block;
  overflow-x: hidden;
  background:
    radial-gradient(900px 440px at 0% 0%, rgba(79, 70, 229, 0.10), transparent 60%),
    radial-gradient(760px 440px at 100% 0%, rgba(37, 99, 235, 0.08), transparent 60%),
    linear-gradient(170deg, #f8fbff, #eef4ff);
  color: var(--form-text-body);
}

.form-page {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-5) 16px 36px;
}

.form-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 24px;
  box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.card-head {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(2, 6, 23, 0.07);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.45));
}

.hero {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.hero-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  padding: 6px;
}

.hero-text h1 {
  margin: 0;
  font-size: 1.38rem;
  font-weight: var(--form-weight-heading);
  letter-spacing: -0.01em;
  color: var(--form-text-strong);
}

.hero-text p {
  margin: 3px 0 0;
  color: var(--form-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.stepper {
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid rgba(2, 6, 23, 0.07);
}

.progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
}

.progress-wrap {
  flex: 1;
}

.progress-label {
  font-size: 0.8rem;
  font-weight: var(--form-weight-subheading);
  color: var(--form-text-muted);
}

.progress-track {
  margin-top: 8px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f46e5, #2563eb);
  transition: width 0.28s ease;
}

.hero-badges {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-badge,
.save-status {
  font-size: 0.74rem;
  font-weight: var(--form-weight-subheading);
  line-height: 1;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1e3a8a;
  white-space: nowrap;
}

.save-status {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
}

.save-status.saving {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

.save-status.saved {
  border-color: #6ee7b7;
  background: #ecfdf5;
  color: #065f46;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border-top: 1px solid rgba(2, 6, 23, 0.06);
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 8px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: rgba(255, 255, 255, 0.22);
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.step-item:hover {
  background: #f8fafc;
}

.step-item .dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--form-text-muted);
  display: grid;
  place-items: center;
  font-size: 0.73rem;
  font-weight: 700;
}

.step-item .label {
  font-size: 0.7rem;
  font-weight: 600;
  color: inherit;
  text-align: center;
  line-height: 1.2;
  padding: 0;
}

.step-item.active {
  color: #3730a3;
  border-bottom-color: #4f46e5;
  background: #fff;
}

.step-item.active .dot {
  color: #fff;
  border-color: #4f46e5;
  background: #4f46e5;
}

.step-item.done {
  color: #166534;
}

.step-item.done .dot {
  border-color: #10b981;
  background: #d1fae5;
  color: #047857;
}

.wizard-content {
  padding: var(--space-4) var(--space-5) 88px;
}

.review-banner {
  margin-bottom: var(--space-3);
  border: 1px solid rgba(245, 158, 11, 0.40);
  background: rgba(254, 243, 199, 0.72);
  color: #78350f;
  border-radius: 12px;
  padding: var(--space-2) var(--space-3);
  font-size: 0.86rem;
  line-height: 1.45;
  font-weight: 600;
}

.auth-gate {
  border: 1px solid rgba(59, 130, 246, 0.25);
  background: rgba(239, 246, 255, 0.8);
  border-radius: 12px;
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.auth-gate h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  font-weight: var(--form-weight-heading);
  color: var(--form-text-strong);
}

.auth-grid {
  margin-top: var(--space-2);
}

.auth-actions,
.verify-actions {
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.auth-message {
  min-height: 1.2rem;
  color: #78350f;
  font-size: 0.84rem;
  font-weight: 500;
}

.step-panel {
  display: none;
  animation: fadeIn 0.24s ease;
}

.step-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-panel h2 {
  margin: var(--space-1) 0 var(--space-3);
  color: var(--form-text-strong);
  font-size: 1.12rem;
  font-weight: var(--form-weight-heading);
  border-bottom: 1px solid var(--form-divider-soft);
  padding-bottom: var(--space-2);
}

.step-panel h3 {
  margin: var(--space-4) 0 var(--space-2);
  color: #1f2937;
  font-size: 0.95rem;
  font-weight: var(--form-weight-subheading);
}

.grid {
  display: grid;
  gap: var(--space-3);
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--form-text-body);
  font-size: 0.82rem;
  font-weight: var(--form-weight-label);
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--form-border-soft);
  border-radius: 12px;
  background: #fff;
  color: var(--form-text-body);
  font-size: 0.93rem;
  padding: 10px 11px;
  outline: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

input:hover, select:hover, textarea:hover {
  border-color: #b8c5d8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.hint {
  font-size: 0.8rem;
  color: var(--form-text-muted);
  font-weight: var(--form-weight-body);
  line-height: 1.5;
}

.notice {
  border: 1px solid rgba(59, 130, 246, 0.22);
  background: rgba(191, 219, 254, 0.23);
  border-radius: 12px;
  padding: var(--space-2) var(--space-3);
  color: var(--form-text-body);
  font-size: 0.86rem;
  line-height: 1.55;
  font-weight: var(--form-weight-body);
  white-space: pre-wrap;
}

.notice.small {
  margin-top: var(--space-2);
}

/* Dependents spacing harmony */
#dependentsNote {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-color: rgba(59, 130, 246, 0.18);
  background: rgba(191, 219, 254, 0.18);
}

#dependentsContainer {
  margin-top: var(--space-2);
  display: grid;
  gap: var(--space-3);
}

.doc-copy {
  border: 1px solid var(--form-border-soft);
  border-radius: 12px;
  background: #f8fafc;
  padding: var(--space-3);
  font-size: 0.85rem;
  line-height: 1.58;
  color: var(--form-text-body);
  font-weight: var(--form-weight-body);
  white-space: pre-wrap;
}

.doc-copy strong {
  font-weight: var(--form-weight-subheading);
  color: var(--form-text-strong);
}

.upload-box {
  margin-top: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.files-list {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.file-group {
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  padding: var(--space-2);
}

.file-group-title {
  font-size: 0.78rem;
  font-weight: var(--form-weight-subheading);
  color: #1e3a8a;
  margin: 2px 2px var(--space-2);
}

.file-row {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.file-meta {
  font-size: 0.82rem;
  color: var(--form-text-body);
  line-height: 1.45;
  font-weight: var(--form-weight-body);
}

.doc-type-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(15, 23, 42, 0.45);
}

.doc-type-modal-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  box-shadow: 0 22px 40px rgba(15, 23, 42, 0.24);
  padding: var(--space-4);
}

.doc-type-modal-card h3 {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
  color: var(--form-text-strong);
  font-weight: var(--form-weight-subheading);
}

.doc-type-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.check-line {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 11px;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--form-text-body);
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.check-line input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .check-line {
    font-size: 15px;
    line-height: 1.35;
  }

  .check-line input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }
}

.sig-wrap {
  margin-top: var(--space-3);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: var(--space-2);
  background: #fff;
}

#signatureCanvas {
  width: 100%;
  height: 220px;
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  display: block;
}

.sig-actions {
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.doc-preview {
  border: 1px solid #dbeafe;
  background: #fff;
  border-radius: 12px;
  padding: var(--space-4);
}

.preview-paper {
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  padding: var(--space-4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.preview-paper h3 {
  margin: 0 0 var(--space-2);
  color: var(--form-text-strong);
  font-size: 1.06rem;
  font-weight: var(--form-weight-heading);
}

.summary-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: var(--space-1) var(--space-2);
  margin-bottom: var(--space-3);
}

.summary-k {
  font-size: 0.75rem;
  color: var(--form-text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .04em;
}

.summary-v {
  font-size: 0.86rem;
  color: var(--form-text-body);
  font-weight: 500;
  line-height: 1.5;
}

.sig-preview {
  margin-top: var(--space-3);
  border-top: 1px dashed #cbd5e1;
  padding-top: var(--space-2);
  max-width: 100%;
  overflow: hidden;
}

.sig-preview .summary-v {
  max-width: 100%;
  overflow: hidden;
}

.sig-preview img,
.sig-preview canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
}

.thanks-box {
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
  border-radius: 12px;
  padding: var(--space-4);
}

.thanks-box h3 {
  margin: 0;
  font-size: 1.3rem;
  color: #065f46;
}

.thanks-box p {
  margin: var(--space-1) 0 0;
  color: #065f46;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
}

.step-actions {
  margin-top: var(--space-3);
  display: flex;
  justify-content: flex-start;
  gap: var(--space-2);
  align-items: center;
}

.btn-primary,
.btn-secondary {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-1px);
}

.btn-primary {
  border: none;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.22);
}

.btn-secondary {
  border: 1px solid #d1d5db;
  background: #fff;
  color: var(--form-text-body);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.error-box {
  margin-top: var(--space-2);
  color: #78350f;
  font-size: 0.84rem;
  font-weight: 600;
  min-height: 1.25rem;
  line-height: 1.45;
}

.actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
  border-top: 1px solid rgba(2, 6, 23, 0.08);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  padding: var(--space-3) var(--space-5) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
}

.action-left,
.action-right {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.wizard-content p {
  line-height: 1.55;
  color: var(--form-text-body);
}

@media (max-width: 1024px) {
  .wizard-steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .form-page {
    padding: 14px 10px 24px;
  }

  .card-head,
  .wizard-content,
  .actions-sticky {
    padding-left: 14px;
    padding-right: 14px;
  }

  .progress-row {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-badges {
    justify-content: flex-start;
  }

  .wizard-content {
    padding-bottom: 126px;
  }

  .wizard-steps {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    border-top: 1px solid rgba(2, 6, 23, 0.06);
  }

  .wizard-steps::-webkit-scrollbar {
    height: 6px;
  }

  .wizard-steps::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
  }

  .step-item {
    flex: 0 0 110px;
    min-width: 110px;
    scroll-snap-align: start;
  }

  .step-item .label {
    font-size: 0.66rem;
  }

  .grid.two,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .actions-sticky {
    flex-direction: column;
    align-items: stretch;
  }

  .action-left,
  .action-right {
    width: 100%;
  }

  .action-left .btn-secondary,
  .action-right .btn-primary {
    flex: 1 1 140px;
  }

}

/* Dependents definitive spacing (keep at file end to win cascade) */
#dependentsContainer .dep-card {
  margin-top: 8px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--form-border-soft);
  background: #f8fbff;
  white-space: normal;
}

#dependentsContainer .dep-card strong,
#dependentsContainer .dep-card .dep-title {
  margin: 0 0 10px;
  display: block;
  color: var(--form-text-strong);
  font-weight: var(--form-weight-subheading);
  line-height: 1.25;
}

#dependentsContainer .dep-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  row-gap: 14px;
  column-gap: 18px;
  align-items: start;
}

#dependentsContainer .dep-grid > label {
  margin: 0 !important;
  padding: 0;
  align-self: start;
}

#dependentsContainer .dep-grid > label:has(select[data-field="gender"]) {
  margin: 0;
  padding: 0;
}

#dependentsContainer select[data-field="gender"] {
  margin: 0;
}
