* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #1d2738;
  --muted: #64748b;
  --line: #dbe4ef;
  --soft: #f8fafc;
  --primary: #0b9fe8;
  --primary-dark: #0879bf;
  --danger: #dc2626;
  --focus: rgba(11, 159, 232, 0.14);
  --shadow: 0 12px 36px rgba(38, 62, 92, 0.1);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr);
  gap: 1.5rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0;
}

.brand-panel,
.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-panel {
  position: sticky;
  top: 1rem;
  align-self: start;
  min-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding: 1.5rem;
  border-radius: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.5rem 0;
  border-radius: 0.75rem;
  background: #ffffff;
}

.brand img {
  display: block;
  width: 11rem;
  height: auto;
}

.hero-copy {
  display: grid;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0;
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-copy h1,
.form-header h2,
.section-heading h3 {
  margin: 0;
  line-height: 1.1;
}

.hero-copy h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.5rem);
  max-width: 15ch;
}

.hero-copy p:not(.eyebrow),
.section-heading p {
  margin: 0;
  color: var(--muted);
}

.progress-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--soft);
}

.progress-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.progress-label {
  color: var(--muted);
  font-size: 0.9rem;
}

#progressText {
  color: var(--primary-dark);
}

.progress-track {
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: #d7e8f7;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.step-list {
  display: grid;
  gap: 0.9rem;
  padding: 0;
  margin: auto 0 0;
  list-style: none;
}

.step-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.step-list li::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid #b8c6d8;
  border-radius: 999px;
  background: #ffffff;
}

.step-list li.is-active {
  color: var(--ink);
}

.step-list li.is-active::before {
  border-color: var(--primary);
  background: var(--primary);
}

.form-panel {
  overflow: hidden;
  border-radius: 1rem;
}

.form-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem clamp(1.1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.form-header img {
  display: none;
  width: 8.5rem;
  height: auto;
}

.form-header h2 {
  margin-top: 0.25rem;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
}

form {
  display: grid;
  gap: 0;
}

.form-section {
  display: grid;
  gap: 1.35rem;
  padding: clamp(1.3rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.form-section:nth-child(even) {
  background: #fcfdff;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.section-heading > span {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
  color: #ffffff;
  background: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 900;
}

.section-heading h3 {
  font-size: 1.2rem;
}

.field-grid {
  display: grid;
  gap: 1rem;
}

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

.field {
  display: grid;
  gap: 0.45rem;
}

.field span,
.purpose-group legend,
.signature-label span {
  color: #334155;
  font-weight: 800;
}

b {
  color: var(--danger);
}

input,
textarea {
  width: 100%;
  border: 1px solid #cbd6e4;
  border-radius: 0.6rem;
  color: var(--ink);
  background: #ffffff;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

input {
  min-height: 3.1rem;
  padding: 0 0.95rem;
}

textarea {
  min-height: 8rem;
  padding: 0.9rem 0.95rem;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.28rem var(--focus);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

small {
  min-height: 1.1rem;
  color: var(--danger);
  font-size: 0.82rem;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 0.7rem;
}

.purpose-group {
  display: grid;
  gap: 0.8rem;
  padding: 0;
  border: 0;
  margin: 0;
}

.purpose-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.purpose-options label {
  position: relative;
  min-height: 3.1rem;
}

.purpose-options input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.purpose-options span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 3.1rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #cbd6e4;
  border-radius: 0.6rem;
  color: #334155;
  background: #ffffff;
  font-weight: 800;
  text-align: center;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    background-color 160ms ease;
}

.purpose-options input:focus-visible + span {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.28rem var(--focus);
}

.purpose-options input:checked + span {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: #eef9ff;
}

.other-purpose[hidden] {
  display: none;
}

.agreement-box {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: #40506a;
  background: var(--soft);
}

.agreement-box h4 {
  margin: 0 0 0.5rem;
  color: var(--ink);
  font-size: 1rem;
}

.agreement-box p {
  margin: 0.25rem 0;
}

.consent-field {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #ffffff;
}

.consent-field input {
  width: 1.25rem;
  height: 1.25rem;
  min-height: auto;
  margin-top: 0.18rem;
  accent-color: var(--primary);
}

.consent-field span {
  font-weight: 700;
}

.signature-field {
  display: grid;
  gap: 0.55rem;
}

.signature-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.signature-label button {
  border: 0;
  border-radius: 0.6rem;
  padding: 0.55rem 0.85rem;
  color: var(--primary-dark);
  background: #e8f7ff;
  font-weight: 800;
}

.signature-label button:hover,
.signature-label button:focus-visible {
  background: #d6f0ff;
}

#signatureCanvas {
  width: 100%;
  height: 14rem;
  border: 1px solid #cbd6e4;
  border-radius: 0.75rem;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3.2rem,
      #eef3f8 3.25rem
    );
  cursor: crosshair;
  touch-action: none;
}

#signatureCanvas.is-invalid {
  border-color: var(--danger);
}

.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1.1rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line);
  background: #ffffff;
}

#formStatus {
  min-height: 1.5rem;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

#formStatus.is-success {
  color: #0f8a5f;
}

#formStatus.is-error {
  color: var(--danger);
}

.submit-button {
  min-width: 12rem;
  border: 0;
  border-radius: 0.65rem;
  padding: 0.95rem 1.4rem;
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 10px 24px rgba(11, 159, 232, 0.22);
  font-weight: 900;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.submit-button:hover,
.submit-button:focus-visible {
  transform: translateY(-1px);
  background: var(--primary-dark);
  box-shadow: 0 12px 28px rgba(8, 121, 191, 0.26);
}

.submit-button:disabled {
  cursor: wait;
  filter: grayscale(0.3);
  opacity: 0.74;
  transform: none;
}

.success-page {
  min-height: 100vh;
  background: var(--bg);
}

.success-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.success-card {
  display: grid;
  gap: 1rem;
  width: 100%;
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.success-logo {
  width: 11rem;
  height: auto;
  margin-bottom: 1rem;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
  color: #ffffff;
  background: #15803d;
  font-size: 1.7rem;
  font-weight: 900;
}

.success-card h1 {
  max-width: 38rem;
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.4rem);
  line-height: 1.15;
}

.success-copy {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
}

.success-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  width: min(100%, 42rem);
  margin: 0.5rem 0 0;
}

.success-summary div {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--soft);
}

.success-summary dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.success-summary dd {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-weight: 800;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border: 1px solid var(--primary);
  border-radius: 0.65rem;
  padding: 0.85rem 1.2rem;
  color: var(--primary-dark);
  background: #ffffff;
  font-weight: 900;
  text-decoration: none;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: #eef9ff;
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(740px, calc(100% - 1rem));
    padding: 0.5rem 0;
  }

  .brand-panel {
    position: static;
    min-height: auto;
    gap: 1.2rem;
    border-radius: 1.2rem;
  }

  .hero-copy h1 {
    max-width: none;
    font-size: 2rem;
  }

  .step-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
  }
}

@media (max-width: 700px) {
  body {
    background: var(--bg);
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .brand-panel {
    border-radius: 0;
    box-shadow: none;
  }

  .form-panel {
    border-radius: 0;
    box-shadow: none;
  }

  .form-header img {
    display: block;
  }

  .brand {
    display: none;
  }

  .two-columns,
  .purpose-options,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .section-heading {
    gap: 0.75rem;
  }

  .step-list {
    grid-template-columns: 1fr;
  }

  .submit-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .submit-button {
    width: 100%;
  }

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

  .secondary-button {
    width: 100%;
  }
}
