:root {
  --navy: #1b2566;
  --navy-strong: #121a4d;
  --ink: #15182b;
  --muted: #5d6075;
  --paper: #f5f4ef;
  --surface: #ffffff;
  --line: #dcdad1;
  --accent: #f0bf2a;
  --danger: #b42318;
  --radius: 10px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
[hidden] { display: none !important; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: auto; height: 34px; }
.brand-divider { width: 1px; height: 28px; background: var(--line); }
.topbar-label { font-size: 13px; font-weight: 500; color: var(--muted); display: none; }

.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
}
.narrow { max-width: 460px; margin: 8vh auto 0; gap: 12px; }
.narrow h1 { font-size: 26px; letter-spacing: -0.01em; }
.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy); }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

.contract { display: flex; flex-direction: column; gap: 20px; border-top: 4px solid var(--navy); }
.contract-title { font-size: 24px; letter-spacing: -0.01em; margin-top: 6px; }

.steps ol {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.steps li { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.steps li::before { content: ""; height: 4px; border-radius: 2px; background: var(--line); }
.steps li.done::before { background: var(--navy); }
.steps li[aria-current="step"]::before { background: var(--accent); }
.steps li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.step-num { display: none; }
.step-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

form { display: flex; flex-direction: column; gap: 16px; }
fieldset { margin: 0; min-width: 0; }
.step { display: flex; flex-direction: column; gap: 18px; }
.step-title { float: left; width: 100%; padding: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.step-title + * { clear: both; }
.subsection {
  font-size: 14px; font-weight: 600; color: var(--navy);
  padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 8px;
}

.grid { display: grid; grid-template-columns: 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label { font-size: 14px; font-weight: 500; }
.optional { font-size: 12px; font-weight: 400; color: var(--muted); }
input, select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font: inherit; color: inherit;
  background: var(--surface);
  border: 1px solid #c9c7bd; border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235d6075' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
input:hover, select:hover { border-color: #9e9c92; }
input:focus, select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27, 37, 102, 0.15); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); }
.field-error:empty, .form-error:empty { display: none; }
.field-error { font-size: 13px; color: var(--danger); font-weight: 500; }
.form-error {
  font-size: 14px; color: var(--danger); font-weight: 500;
  padding: 10px 12px; border-radius: 8px; background: #fdf0ef; border: 1px solid #f3c7c3;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px;
  font: inherit; font-weight: 600; text-decoration: none;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-strong); }
.btn-ghost { background: var(--surface); color: var(--navy); border-color: #c9c7bd; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-link {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--navy);
  text-decoration: underline; text-underline-offset: 3px;
}

.actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 75%, transparent);
}
.actions .btn { flex: 1; }

.dependents { display: flex; flex-direction: column; gap: 12px; }
.dependent { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fbfaf7; display: flex; flex-direction: column; gap: 12px; }
.dependent-head { display: flex; justify-content: space-between; align-items: center; }
.dependent-title { font-weight: 600; font-size: 14px; }
#add-dependent { align-self: flex-start; }

.review { display: flex; flex-direction: column; gap: 12px; }
.review-section { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.review-head h3 { font-size: 15px; }
.review dl { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; }
.review dt { font-size: 12px; color: var(--muted); }
.review dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin-top: 2px; accent-color: var(--navy); flex: none; }

@media (min-width: 640px) {
  .page { padding: 40px 24px 80px; }
  .panel { padding: 32px; }
  .topbar-label { display: block; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .span-2 { grid-column: span 2; }
  .contract-grid { grid-template-columns: 2fr 1.2fr 1fr; }
  .review dl { grid-template-columns: repeat(2, 1fr); }
  .actions .btn { flex: none; }
  .step-num { display: inline; font-variant-numeric: tabular-nums; color: var(--muted); }
  .steps li { flex-direction: row; flex-wrap: wrap; column-gap: 6px; }
  .steps li::before { flex-basis: 100%; }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
