.esf-form-shell,
.esf-form-shell * {
    box-sizing: border-box;
    font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.esf-form-shell {
    width: 100%;
    margin: 24px 0;
    color: #111827;
}

.esf-form {
    --esf-front-primary: #6d5dfc;
    --esf-front-primary-dark: #5546e8;
    --esf-front-text: #111827;
    --esf-front-muted: #6b7280;
    --esf-front-border: #dfe3ea;
    --esf-front-bg: #ffffff;
    --esf-front-danger: #dc2626;
    --esf-front-success: #15803d;
    position: relative;
    width: 100%;
    padding: clamp(22px, 4vw, 38px);
    background: var(--esf-front-bg);
    border: 1px solid #e8eaf0;
    border-radius: 22px;
    box-shadow: 0 20px 55px rgba(17, 24, 39, 0.08);
}

.esf-form-grid {
    display: flex;
    flex-wrap: wrap;
    margin: -9px;
}

.esf-field {
    width: 100%;
    padding: 9px;
}

.esf-field.esf-width-25 { width: 25%; }
.esf-field.esf-width-33 { width: 33.3333%; }
.esf-field.esf-width-50 { width: 50%; }
.esf-field.esf-width-66 { width: 66.6667%; }
.esf-field.esf-width-75 { width: 75%; }

.esf-field-label {
    display: block;
    margin: 0 0 8px;
    color: var(--esf-front-text);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 600;
}

.esf-required {
    margin-left: 4px;
    color: var(--esf-front-danger);
}

.esf-control-wrap input[type="text"],
.esf-control-wrap input[type="email"],
.esf-control-wrap input[type="tel"],
.esf-control-wrap input[type="number"],
.esf-control-wrap input[type="url"],
.esf-control-wrap input[type="date"],
.esf-control-wrap textarea,
.esf-control-wrap select {
    display: block;
    width: 100%;
    min-height: 50px;
    margin: 0;
    padding: 12px 14px;
    color: var(--esf-front-text);
    background: #fbfcfe;
    border: 1px solid var(--esf-front-border);
    border-radius: 12px;
    outline: 0;
    box-shadow: none;
    font-size: 15px;
    line-height: 1.5;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.esf-control-wrap textarea {
    min-height: 132px;
    resize: vertical;
}

.esf-control-wrap select {
    cursor: pointer;
}

.esf-control-wrap input:focus,
.esf-control-wrap textarea:focus,
.esf-control-wrap select:focus {
    background: #ffffff;
    border-color: var(--esf-front-primary);
    box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.12);
}

.esf-control-wrap input::placeholder,
.esf-control-wrap textarea::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.esf-field-help {
    margin-top: 7px;
    color: var(--esf-front-muted);
    font-size: 12px;
    line-height: 1.55;
}

.esf-field-error {
    min-height: 0;
    margin-top: 6px;
    color: var(--esf-front-danger);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
}

.esf-field.has-error .esf-control-wrap input,
.esf-field.has-error .esf-control-wrap textarea,
.esf-field.has-error .esf-control-wrap select {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.esf-choice-group {
    display: grid;
    gap: 9px;
}

.esf-choice,
.esf-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 12px 13px;
    color: #273244;
    background: #fbfcfe;
    border: 1px solid var(--esf-front-border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
}

.esf-choice input,
.esf-consent input {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    margin: 2px 0 0;
    accent-color: var(--esf-front-primary);
}

.esf-choice:has(input:checked),
.esf-consent:has(input:checked) {
    background: #f5f3ff;
    border-color: rgba(109, 93, 252, .45);
}

.esf-file-locked {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    color: #475569;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
}

.esf-file-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: var(--esf-front-primary);
    background: #ede9fe;
    border-radius: 9px;
    font-size: 18px;
    font-weight: 700;
}

.esf-file-locked strong,
.esf-file-locked span {
    display: block;
}

.esf-file-locked strong {
    color: #1e293b;
    font-size: 13px;
}

.esf-file-locked div > span {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

.esf-form-actions {
    margin-top: 22px;
}

.esf-submit-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 150px;
    min-height: 50px;
    padding: 12px 22px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--esf-front-primary), #806cf8);
    border: 0;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(109, 93, 252, 0.22);
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 700;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.esf-submit-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(109, 93, 252, 0.28);
}

.esf-submit-button:focus-visible {
    outline: 3px solid rgba(109, 93, 252, 0.28);
    outline-offset: 3px;
}

.esf-submit-button:disabled {
    opacity: .72;
    cursor: wait;
    transform: none;
}

.esf-submit-spinner {
    display: none;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: esf-spin .7s linear infinite;
}

.esf-form.is-submitting .esf-submit-spinner {
    display: inline-block;
}

.esf-form-status {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 11px;
    font-size: 13px;
    line-height: 1.55;
    font-weight: 600;
}

.esf-form-status.is-success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.esf-form-status.is-error,
.esf-form-notice-error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.esf-form-notice {
    padding: 12px 14px;
    border-radius: 10px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 13px;
}

.esf-honeypot {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

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

@media (max-width: 700px) {
    .esf-form {
        padding: 20px;
        border-radius: 16px;
    }

    .esf-field.esf-width-25,
    .esf-field.esf-width-33,
    .esf-field.esf-width-50,
    .esf-field.esf-width-66,
    .esf-field.esf-width-75 { width: 100%; }

    .esf-submit-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .esf-control-wrap input,
    .esf-control-wrap textarea,
    .esf-control-wrap select,
    .esf-submit-button {
        transition: none;
    }

    .esf-submit-spinner {
        animation-duration: 1.4s;
    }
}

/* Step 6: hardened upload field */
.esf-secure-upload {
    display: grid;
    gap: 9px;
}

.esf-file-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

.esf-upload-dropzone {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 78px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff, #fbfcff);
    border: 1px dashed #b9c3d4;
    border-radius: 14px;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.esf-upload-dropzone:hover,
.esf-secure-upload:focus-within .esf-upload-dropzone {
    border-color: var(--esf-front-primary);
    background: #faf9ff;
    box-shadow: 0 0 0 3px rgba(109, 93, 252, .08);
}

.esf-upload-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.esf-upload-copy strong {
    color: #1e293b;
    font-size: 13px;
    font-weight: 700;
}

.esf-upload-copy small {
    color: #64748b;
    font-size: 11px;
    line-height: 1.45;
}

.esf-upload-button {
    flex: 0 0 auto;
    padding: 8px 12px;
    color: #4c3bd4;
    background: #f0edff;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 700;
}

.esf-upload-selection {
    min-height: 18px;
    color: #64748b;
    font-size: 11px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.esf-upload-selection.has-files {
    color: #334155;
    font-weight: 600;
}

.esf-upload-security {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: #64748b;
    font-size: 10px;
    line-height: 1.45;
}

.esf-upload-security > span {
    color: #16a34a;
    font-weight: 800;
}

@media (max-width: 520px) {
    .esf-upload-dropzone {
        align-items: flex-start;
        flex-wrap: wrap;
    }
    .esf-upload-button {
        margin-left: 46px;
    }
}

/* Step 8 — Design controls, conditional logic and multi-step experience */
.esf-form {
    --esf-front-primary: var(--esf-accent, #6d5dfc);
    --esf-front-text: var(--esf-text, #172033);
    --esf-front-border: var(--esf-border, #d9e0ea);
    color: var(--esf-front-text);
    border-radius: calc(var(--esf-radius, 14px) + 8px);
}

.esf-form.esf-preset-soft {
    background: #f8f9ff;
    border-color: transparent;
    box-shadow: 0 24px 65px rgba(17, 24, 39, .09);
}

.esf-form.esf-preset-minimal {
    padding: 8px 0;
    border-color: transparent;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.esf-form .esf-control-wrap input[type="text"],
.esf-form .esf-control-wrap input[type="email"],
.esf-form .esf-control-wrap input[type="tel"],
.esf-form .esf-control-wrap input[type="number"],
.esf-form .esf-control-wrap input[type="url"],
.esf-form .esf-control-wrap input[type="date"],
.esf-form .esf-control-wrap textarea,
.esf-form .esf-control-wrap select,
.esf-form .esf-choice,
.esf-form .esf-consent {
    background: var(--esf-field-bg, #fff);
    border-color: var(--esf-front-border);
    border-radius: var(--esf-radius, 14px);
}

.esf-form .esf-control-wrap input:focus,
.esf-form .esf-control-wrap textarea:focus,
.esf-form .esf-control-wrap select:focus {
    border-color: var(--esf-front-primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--esf-front-primary) 14%, transparent);
}

.esf-form .esf-choice:has(input:checked),
.esf-form .esf-consent:has(input:checked) {
    border-color: var(--esf-front-primary);
    background: color-mix(in srgb, var(--esf-front-primary) 6%, var(--esf-field-bg, #fff));
}

.esf-form .esf-submit-button,
.esf-form .esf-next-button {
    background: var(--esf-front-primary);
    border-radius: var(--esf-radius, 14px);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--esf-front-primary) 28%, transparent);
}

.esf-form.esf-button-full .esf-submit-button,
.esf-form.esf-button-full .esf-next-button {
    width: 100%;
}

.esf-step[hidden],
.esf-field[hidden],
.esf-field.is-condition-hidden {
    display: none !important;
}

.esf-step {
    animation: esf-step-in .24s ease both;
}

.esf-step-heading {
    margin: 0 0 18px;
    padding: 0 9px;
}

.esf-step-heading h3 {
    margin: 0;
    color: var(--esf-front-text);
    font-size: clamp(20px, 3vw, 28px);
    line-height: 1.15;
    letter-spacing: -.025em;
}

.esf-step-heading p {
    max-width: 680px;
    margin: 7px 0 0;
    color: var(--esf-front-muted);
    font-size: 13px;
    line-height: 1.65;
}

.esf-step-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 9px;
}

.esf-next-button,
.esf-back-button-front {
    display: inline-flex;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 22px;
    border-radius: var(--esf-radius, 14px);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.esf-next-button {
    color: #fff;
    border: 0;
}

.esf-back-button-front {
    color: var(--esf-front-text);
    background: transparent;
    border: 1px solid var(--esf-front-border);
}

.esf-next-button:hover,
.esf-back-button-front:hover {
    transform: translateY(-1px);
}

.esf-progress {
    margin: 0 9px 26px;
}

.esf-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 9px;
    color: var(--esf-front-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
}

.esf-progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef1f6;
}

.esf-progress-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--esf-front-primary);
    transition: width .25s ease;
}

.esf-progress-numbers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
}

.esf-progress-numbers > span {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    color: #98a2b3;
    font-size: 10px;
    font-weight: 700;
}

.esf-progress-numbers i {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    border: 1px solid var(--esf-front-border);
    border-radius: 50%;
    background: #fff;
    font-style: normal;
}

.esf-progress-numbers span.is-active,
.esf-progress-numbers span.is-complete {
    color: var(--esf-front-text);
}

.esf-progress-numbers span.is-active i,
.esf-progress-numbers span.is-complete i {
    color: #fff;
    border-color: var(--esf-front-primary);
    background: var(--esf-front-primary);
}

@keyframes esf-step-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
    .esf-step-actions { align-items: stretch; flex-direction: column-reverse; }
    .esf-next-button,
    .esf-back-button-front,
    .esf-submit-button { width: 100%; }
    .esf-progress-numbers small { display: none; }
}

/* v1.1.0 — country-aware phone validation and strict message feedback. */
.esf-phone-input {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.esf-phone-prefix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 0 14px;
    color: var(--esf-front-text);
    background: #f3f5f9;
    border: 1px solid var(--esf-front-border);
    border-right: 0;
    border-radius: 12px 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .02em;
}

.esf-control-wrap .esf-phone-input input[type="tel"] {
    border-radius: 0 12px 12px 0;
}

.esf-field.has-error .esf-phone-prefix {
    border-color: #ef4444;
}

.esf-phone-rule,
.esf-character-counter {
    margin-top: 7px;
    color: var(--esf-front-muted);
    font-size: 11px;
    line-height: 1.45;
}

.esf-phone-rule {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.esf-phone-rule [data-esf-phone-counter] {
    flex: 0 0 auto;
    color: var(--esf-front-text);
    font-weight: 700;
    white-space: nowrap;
}

.esf-character-counter {
    text-align: right;
}

.esf-form-status.is-warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

/* v1.3.0 — compact mailbox verification */
.esf-form [hidden] {
    display: none !important;
}

.esf-email-input-shell {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.esf-email-input-shell > input[type="email"] {
    flex: 1 1 auto;
    min-width: 0;
}

.esf-email-inline-verify,
.esf-email-verify-button {
    appearance: none;
    border: 1px solid color-mix(in srgb, var(--esf-front-primary) 34%, #d9e0ea);
    border-radius: calc(var(--esf-front-radius) - 3px);
    background: #fff;
    color: var(--esf-front-primary);
    cursor: pointer;
    font-family: "Space Grotesk", sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.esf-email-inline-verify {
    flex: 0 0 auto;
    min-width: 104px;
    padding: 0 13px;
    white-space: nowrap;
}

.esf-email-inline-verify:hover,
.esf-email-verify-button:hover {
    border-color: var(--esf-front-primary);
    background: color-mix(in srgb, var(--esf-front-primary) 7%, #fff);
}

.esf-email-inline-verify:focus-visible,
.esf-email-verify-button:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--esf-front-primary) 16%, transparent);
}

.esf-email-inline-verify:disabled,
.esf-email-verify-button:disabled {
    opacity: .6;
    cursor: wait;
}

.esf-email-verification {
    margin-top: 6px;
}

.esf-email-verification-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 18px;
}

.esf-email-status-icon {
    display: inline-grid;
    place-items: center;
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: transparent;
    font-size: 9px;
    font-weight: 800;
}

.esf-email-verification-status {
    color: #667085;
    font-size: 11px;
    line-height: 1.35;
}

.esf-email-verification.is-verified .esf-email-status-icon {
    border-color: #86efac;
    background: #ecfdf3;
    color: #15803d;
}

.esf-email-verification-status.is-verified {
    color: #15803d;
    font-weight: 700;
}

.esf-email-code-row {
    display: grid;
    grid-template-columns: minmax(110px, 150px) auto;
    align-items: center;
    justify-content: start;
    gap: 8px;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid #e3e7f0;
    border-radius: 10px;
    background: #f8f9ff;
}

.esf-email-code-row[hidden] {
    display: none !important;
}

.esf-email-code-row input[data-esf-email-code] {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 7px 10px;
    text-align: center;
    letter-spacing: .24em;
    font-size: 14px;
    font-weight: 700;
}

.esf-email-verify-button {
    min-height: 38px;
    padding: 0 13px;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .esf-email-input-shell {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .esf-email-code-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

@media (max-width: 420px) {
    .esf-email-input-shell,
    .esf-email-code-row {
        grid-template-columns: 1fr;
    }

    .esf-email-inline-verify,
    .esf-email-verify-button {
        width: 100%;
        min-height: 40px;
    }
}

.esf-phone-rule {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 7px;
    color: #667085;
    font-size: 11px;
    line-height: 1.45;
}

.esf-phone-rule strong {
    flex: 0 0 auto;
    color: var(--esf-front-primary);
}

