:root {
    --navy-950: #050b1f;
    --navy-900: #07112b;
    --navy-800: #0d1d42;
    --blue-700: #1440c4;
    --blue-600: #1e50e5;
    --blue-500: #3f6cf4;
    --blue-100: #e9f0ff;
    --paper: #f5f7fb;
    --surface: #ffffff;
    --ink: #0d1734;
    --ink-2: #33405f;
    --muted: #65708a;
    /* #8a94a9 was 3.05:1 — fails AA at the 10-11.5px sizes this token is used at. */
    --faint: #6b7688;
    --line: #dce2ed;
    --line-strong: #c8d0df;
    --success: #178957;
    --success-bg: #eaf7f0;
    --error: #bd2d36;
    --error-bg: #fff2f2;
    --radius: 9px;
    --shadow: 0 28px 70px -48px rgba(5, 11, 31, .7);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(rgba(13, 23, 52, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(13, 23, 52, .025) 1px, transparent 1px),
        var(--paper);
    background-size: 52px 52px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

/* #9db5ff was only ~2.0:1 against the white form surface — below the 3:1 WCAG
   requires for a focus indicator. Brand blue clears it comfortably. */
:focus-visible {
    outline: 3px solid var(--blue-600);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    left: 16px;
    top: 12px;
    z-index: 100;
    transform: translateY(-150%);
    padding: 10px 14px;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    transition: transform .18s ease;
}

.skip-link:focus {
    transform: none;
}

.container {
    width: min(960px, calc(100% - 40px));
    margin: 42px auto 28px;
}

/* Header */
.header {
    position: relative;
    overflow: hidden;
    padding: 0 46px 42px;
    color: #fff;
    background:
        radial-gradient(circle at 86% 8%, rgba(63, 108, 244, .28), transparent 28%),
        linear-gradient(135deg, var(--navy-950), var(--navy-900) 55%, #0b1b47);
    box-shadow: var(--shadow);
}

.header::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .25;
    background-image:
        linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: linear-gradient(90deg, transparent 20%, #000);
    pointer-events: none;
}

.header-top,
.header-copy {
    position: relative;
    z-index: 1;
}

.header-top {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.onboarding-brand {
    display: inline-flex;
    align-items: center;
}

.onboarding-brand img {
    display: block;
    width: auto;
    height: 30px;
    filter: brightness(0) invert(1);
}

.return-link {
    color: #a9b6d1;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: color .15s ease;
}

.return-link:hover {
    color: #fff;
}

.header-copy {
    max-width: 720px;
    padding-top: 44px;
}

.header-eyebrow,
.success-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #9db5ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .13em;
    line-height: 1.2;
    text-transform: uppercase;
}

.header-eyebrow::before,
.success-eyebrow::before {
    content: "";
    width: 20px;
    height: 2px;
    background: currentColor;
}

.header h1 {
    margin-top: 16px;
    font-family: "Sora", "Inter", sans-serif;
    font-size: clamp(30px, 5vw, 46px);
    letter-spacing: -.045em;
    line-height: 1.08;
}

.header-copy > p {
    max-width: 650px;
    margin-top: 15px;
    color: #b6c1d8;
    font-size: 16px;
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 28px;
    margin-top: 26px;
    color: #91a0bf;
    font-size: 12px;
}

.header-meta span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.header-meta svg {
    width: 17px;
    height: 17px;
    color: #7197ff;
}

/* Progress */
.progress-container {
    padding: 28px 44px 24px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: #fff;
}

.progress-bar {
    height: 4px;
    overflow: hidden;
    background: #e6eaf2;
}

.progress-fill {
    width: 14.2857%;
    height: 100%;
    background: var(--blue-600);
    transition: width .32s ease;
}

.steps-indicator {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 18px;
}

.step-dot {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--faint);
}

.step-dot span {
    width: 27px;
    height: 27px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    background: #f3f5f9;
    color: #78849c;
    font-size: 11px;
    font-weight: 700;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.step-dot label {
    overflow: hidden;
    color: inherit;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
}

.step-dot.active {
    color: var(--blue-600);
}

.step-dot.active span {
    border-color: var(--blue-600);
    background: var(--blue-600);
    color: #fff;
}

.step-dot.completed {
    color: var(--ink-2);
}

.step-dot.completed span {
    border-color: #a8baf0;
    background: var(--blue-100);
    color: var(--blue-700);
}

.step-dot.completed span::before {
    content: "✓";
}

.step-dot.completed span {
    font-size: 0;
}

.step-dot.completed span::before {
    font-size: 12px;
}

/* Form shell */
#onboardingForm {
    padding: 0 44px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: #fff;
}

.form-step {
    display: none;
    min-height: 480px;
    padding: 12px 0 24px;
}

.form-step.active {
    display: block;
    animation: step-in .24s ease both;
}

@keyframes step-in {
    from { opacity: .65; transform: translateY(7px); }
    to { opacity: 1; transform: none; }
}

.step-header {
    padding: 30px 0 22px;
    margin-bottom: 26px;
    border-bottom: 1px solid var(--line);
}

.step-header h2 {
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 25px;
    letter-spacing: -.035em;
    line-height: 1.15;
}

.step-header p {
    max-width: 640px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-group {
    margin-bottom: 21px;
}

.form-group > label {
    display: block;
    margin-bottom: 7px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
}

.required {
    color: var(--error);
}

.optional {
    color: var(--faint);
    font-size: 11px;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font-size: 15px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
select {
    min-height: 48px;
    padding: 0 13px;
}

textarea {
    min-height: 112px;
    padding: 13px;
    line-height: 1.55;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #99a2b4;
    opacity: 1;
}

select {
    cursor: pointer;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(30, 80, 229, .12);
}

/* Checkboxes and radios are native controls: they never receive the border /
   box-shadow treatment above, so clearing `outline` left them with no
   perceptible keyboard focus indicator at all. Restore a high-contrast ring
   (brand blue on white is ~6.5:1, well above the 3:1 required for indicators). */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid var(--blue-600);
    outline-offset: 2px;
}

input.error,
select.error,
textarea.error,
[aria-invalid="true"] {
    border-color: var(--error);
    background: #fffafa;
}

.error-msg {
    display: block;
    min-height: 17px;
    margin-top: 5px;
    color: var(--error);
    font-size: 11.5px;
    font-weight: 600;
}

.field-hint {
    display: block;
    margin-top: 6px;
    color: var(--faint);
    font-size: 11.5px;
}

/* Choice controls */
.checkbox-group {
    display: grid;
    gap: 9px;
}

.checkbox-group.horizontal {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checkbox-label {
    min-height: 44px;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-2);
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.checkbox-label:hover {
    border-color: #a9bdf2;
    background: #fbfcff;
}

.checkbox-label:has(input:checked) {
    border-color: #9db5f4;
    background: #f5f8ff;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin-top: 1px;
    accent-color: var(--blue-600);
}

.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.radio-card {
    min-height: 106px;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 17px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.radio-card:hover {
    border-color: #a9bdf2;
}

.radio-card:has(input:checked) {
    border-color: var(--blue-600);
    background: #f5f8ff;
    box-shadow: 0 0 0 2px rgba(30, 80, 229, .08);
}

.radio-card input[type="radio"] {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    margin-top: 2px;
    accent-color: var(--blue-600);
}

.radio-card-content strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
}

.radio-card-content p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12.5px;
}

/* Supporting panels */
.info-box,
.conditional-section,
.agreement-box {
    border: 1px solid var(--line);
    background: #f8faff;
}

.info-box {
    position: relative;
    padding: 17px 18px 17px 48px;
    margin-bottom: 24px;
    color: var(--ink-2);
    font-size: 13px;
}

.info-box::before {
    content: "i";
    position: absolute;
    left: 18px;
    top: 18px;
    width: 19px;
    height: 19px;
    display: grid;
    place-items: center;
    border: 1px solid #adc1f6;
    border-radius: 50%;
    color: var(--blue-600);
    font-family: Georgia, serif;
    font-size: 12px;
    font-weight: 700;
}

.info-box.secure {
    border-color: #cbd8f8;
    background: #f3f7ff;
}

.info-box strong {
    display: block;
    color: var(--ink);
    font-size: 13px;
}

.info-box p {
    margin-top: 3px;
    color: var(--muted);
}

.info-box.small {
    padding: 12px 14px 12px 42px;
    margin-bottom: 10px;
}

.info-box.small::before {
    top: 13px;
    left: 14px;
}

.conditional-section {
    padding: 20px;
    margin-bottom: 22px;
    animation: step-in .2s ease both;
}

.conditional-section h3 {
    margin-bottom: 17px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 15px;
    letter-spacing: -.02em;
}

.agreement-box {
    padding: 24px;
    margin-bottom: 22px;
}

.agreement-box h3 {
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 17px;
}

.agreement-box p {
    margin-top: 10px;
    color: var(--ink-2);
    font-size: 13px;
}

.agreement-box ul {
    margin-top: 13px;
    padding-left: 20px;
}

.agreement-box li {
    margin-bottom: 9px;
    color: var(--ink-2);
    font-size: 13px;
    line-height: 1.55;
}

.agreement-box .policy-notice {
    margin-top: 17px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.agreement-box .policy-notice a {
    color: var(--blue);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

/* Review-before-sign panel (Step 7) + draft-restore banner */
.review-panel {
    padding: 24px;
    margin-bottom: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper, #fff);
}

.review-panel h3 {
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 17px;
    margin-bottom: 12px;
}

.review-panel dl {
    display: grid;
    grid-template-columns: minmax(120px, 200px) 1fr;
    row-gap: 8px;
    column-gap: 14px;
    margin: 0;
}

.review-panel dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding-top: 2px;
}

.review-panel dd {
    margin: 0;
    color: var(--ink);
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.review-panel dd button {
    margin-left: 8px;
    border: none;
    background: none;
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
}

.draft-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 18px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--blue);
    border-radius: 12px;
    background: var(--paper, #fff);
    color: var(--ink-2);
    font-size: 13px;
}

.draft-banner button {
    flex-shrink: 0;
    border: 1px solid var(--line);
    background: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

.field-hint {
    display: block;
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--muted);
}

.field-hint.ok { color: var(--green, #067647); font-weight: 600; }
.field-hint.warn { color: #92580a; font-weight: 600; }

/* Conspicuous standalone risk acknowledgment panel (Step 6) */
.ack-panel {
    padding: 24px;
    margin-bottom: 16px;
    border: 2px solid var(--blue-600);
    border-radius: var(--radius);
    background: var(--blue-100);
}

.ack-panel h3 {
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 17px;
}

.ack-panel p {
    margin-top: 10px;
    color: var(--ink-2);
    font-size: 13.5px;
    line-height: 1.6;
}

.ack-disclosure-link {
    margin-bottom: 20px;
    font-size: 13px;
}

.ack-disclosure-link a {
    color: var(--blue-600);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.agreement-check {
    padding: 14px 15px;
    border-color: var(--line-strong);
    background: #fafbfe;
}

.signature-input {
    font-weight: 600;
}

/* Form navigation */
.form-error-banner {
    display: none;
    padding: 12px 14px;
    margin: 2px 0 14px;
    border: 1px solid #efc2c6;
    border-radius: 8px;
    background: var(--error-bg);
    color: var(--error);
    font-size: 13px;
    font-weight: 600;
}

.form-error-banner.visible {
    display: block;
}

.form-navigation {
    min-height: 86px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    background: #fff;
}

.btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

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

.btn-primary,
.btn-success {
    margin-left: auto;
    background: var(--blue-600);
    color: #fff;
    box-shadow: 0 14px 26px -18px rgba(30, 80, 229, .9);
}

.btn-primary:hover,
.btn-success:hover {
    background: var(--blue-700);
}

.btn-secondary {
    border-color: var(--line-strong);
    background: #fff;
    color: var(--ink-2);
}

.btn-secondary:hover {
    border-color: #9eabc0;
    background: #f8f9fc;
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin: -9px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .65s linear infinite;
}

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

/* Success */
.success-message {
    padding: 60px 52px;
    border: 1px solid var(--line);
    background: #fff;
    text-align: center;
    box-shadow: var(--shadow);
}

.success-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
    border: 1px solid #a8d9c2;
    background: var(--success-bg);
    color: var(--success);
    font-size: 28px;
}

.success-eyebrow {
    color: var(--success);
}

.success-message h2 {
    margin-top: 14px;
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 29px;
    letter-spacing: -.035em;
}

.success-message > p {
    max-width: 610px;
    margin: 10px auto 0;
    color: var(--muted);
    font-size: 14px;
}

.next-steps {
    max-width: 680px;
    margin: 30px auto 0;
    padding: 23px 26px;
    border: 1px solid var(--line);
    background: #f8faff;
    text-align: left;
}

.next-steps h3 {
    color: var(--ink);
    font-family: "Sora", "Inter", sans-serif;
    font-size: 16px;
}

.next-steps ol {
    margin-top: 13px;
    padding-left: 20px;
}

.next-steps li {
    margin-bottom: 8px;
    color: var(--ink-2);
    font-size: 13px;
}

.success-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 26px;
}

.success-actions .btn {
    margin-left: 0;
}

.footer {
    padding: 22px;
    color: #7b879f;
    font-size: 11.5px;
    text-align: center;
}

@media (max-width: 820px) {
    .container {
        width: min(100% - 24px, 960px);
        margin-top: 12px;
    }

    .header {
        padding-inline: 28px;
    }

    .header-top {
        min-height: 70px;
    }

    .header-copy {
        padding-top: 34px;
    }

    .progress-container,
    #onboardingForm {
        padding-inline: 28px;
    }

    .steps-indicator {
        grid-template-columns: repeat(7, auto);
        justify-content: space-between;
    }

    .step-dot label {
        display: none;
    }

    .form-step {
        min-height: 0;
    }

    .checkbox-group.horizontal {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    body {
        background: var(--paper);
    }

    .container {
        width: 100%;
        margin: 0;
    }

    .header {
        padding: 0 20px 34px;
    }

    .header-top {
        min-height: 64px;
    }

    .onboarding-brand img {
        height: 25px;
    }

    .return-link {
        font-size: 0;
    }

    .return-link span {
        font-size: 18px;
    }

    .header-copy {
        padding-top: 30px;
    }

    .header h1 {
        font-size: 31px;
    }

    .header-copy > p {
        font-size: 14px;
    }

    .header-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .progress-container {
        padding: 20px 18px 17px;
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .steps-indicator {
        gap: 6px;
    }

    .step-dot span {
        width: 25px;
        height: 25px;
        font-size: 10px;
    }

    #onboardingForm {
        padding: 0 18px;
        border: 0;
    }

    .step-header {
        padding-top: 25px;
        margin-bottom: 22px;
    }

    .step-header h2 {
        font-size: 21px;
    }

    .form-row,
    .radio-group,
    .checkbox-group.horizontal {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .radio-group {
        gap: 10px;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px;
    }

    .agreement-box,
    .ack-panel,
    .conditional-section {
        padding: 18px;
    }

    .form-navigation {
        min-height: 78px;
    }

    .btn {
        min-height: 48px;
        padding-inline: 18px;
    }

    .form-navigation .btn-primary,
    .form-navigation .btn-success {
        flex: 1;
    }

    .success-message {
        padding: 44px 20px;
        border-inline: 0;
    }

    .success-message h2 {
        font-size: 24px;
    }

    .success-actions {
        flex-direction: column;
    }

    .success-actions .btn {
        width: 100%;
    }
}

@media (max-width: 360px) {
    .header {
        padding-inline: 16px;
    }

    .progress-container,
    #onboardingForm {
        padding-inline: 14px;
    }

    .steps-indicator {
        gap: 3px;
    }

    .step-dot span {
        width: 23px;
        height: 23px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
