.epay-w7-generator {
    --w7-navy: #023047;
    --w7-teal: #0097b2;
    --w7-teal-dark: #158793;
    --w7-border: #d9e3e8;
    --w7-surface: #f6f9fb;
    --w7-muted: #627783;
    overflow-x: clip;
    background: #ffffff;
    color: var(--w7-navy);
}

.epay-w7-generator,
.epay-w7-generator *,
.epay-w7-generator *::before,
.epay-w7-generator *::after {
    box-sizing: border-box;
}

.epay-w7-generator input,
.epay-w7-generator select,
.epay-w7-generator textarea,
.epay-w7-generator button {
    font-family: inherit;
}

.epay-w7-generator > .container,
.epay-w7-generator .epay-w7__hero > .container {
    width: 100%;
    max-width: 1220px;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* Create-page header: same centered hierarchy used by the 1099 master. */
.epay-w7-generator .epay-w7__hero {
    min-height: 0;
    padding: 40px 0 34px;
    border: 0;
    background: #f3fafc;
}

.epay-w7-generator .epay-w7-hero__content {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 0;
    text-align: center;
}

.epay-w7-generator .epay-w7-hero__title {
    width: 100%;
    margin: 0 0 10px;
    color: #062b45;
    font-family: "Open Sans", sans-serif;
    font-size: clamp(28px, 3.5vw, 40px);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.8px;
    text-align: center;
}

.epay-w7-generator .w-create-intro-guide {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    color: #17384d;
    text-align: left;
}

.epay-w7-generator .w-create-intro-guide h2 {
    margin: 0 0 8px;
    color: var(--w7-navy);
    font-size: 13px;
    font-weight: 700;
    line-height: 18px;
}

.epay-w7-generator .w-create-intro-guide ol {
    margin: 0;
    padding-left: 19px;
}

.epay-w7-generator .w-create-intro-guide li {
    margin: 0 0 4px;
    color: #17384d;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
}

/* Keep the preview prominent while giving W-7's three-field rows enough room. */
.epay-w7-generator .epay-w7__layout-container {
    padding-top: 40px;
    padding-bottom: 64px;
    width: 100%;
    max-width: 1220px;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

.epay-w7-generator .epay-w7__layout-row {
    overflow: visible;
}

.epay-w7-generator .epay-w7__layout-row > [class*="col-"] {
    min-width: 0;
    padding: 0;
}

@media (min-width: 1200px) {
    .epay-w7-generator .epay-w7__layout-row {
    }

    .epay-w7-generator .epay-w7__layout-row > [class*="col-"] {
        width: 100%;
        max-width: none;
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .epay-w7-generator .epay-w7__layout-row {
    }

    .epay-w7-generator .epay-w7__layout-row > [class*="col-"] {
        width: 100%;
        max-width: none;
    }
}

#w7form {
    display: grid;
    gap: 24px;
    width: 100%;
}

/* Section cards and the W-7-specific twelve-column field grid. */
#w7form .w7-form-card {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 18px;
    width: 100%;
    margin: 0;
    padding: 24px;
    overflow: visible;
    border: 1px solid var(--w7-border);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(2, 48, 71, .07);
}

/* Grid row-gap owns field spacing; Bootstrap's mt-3 must not add a second gap. */
#w7form .w7-form-card > .mt-3 {
    margin-top: 0 !important;
}

#w7form .form-section-title {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    min-height: 0;
    margin: 0;
    padding: 0 0 14px;
    border-bottom: 2px solid #e8eef1;
    color: var(--w7-navy);
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.35;
}

#w7form .w7-form-card > .form-main {
    grid-column: span 6;
}

#w7form .w7-form-card > .w7-span-full,
#w7form .w7-form-card > .w7-application-type,
#w7form .w7-form-card > .note_point,
#w7form .w7-form-card > .w7-reason-options,
#w7form .w7-form-card > .reason_box,
#w7form .w7-form-card > .w7-treaty-fields,
#w7form .w7-form-card > .w7-us-person-fields,
#w7form .w7-form-card > .w7-birth-name-choice,
#w7form .w7-form-card > .birth_name_div,
#w7form .w7-form-card > .w7-subsection-title,
#w7form .w7-form-card > .w7-compact-question,
#w7form .w7-form-card > .w7-compact-choice-row,
#w7form .w7-form-card > .w7-citizenship-question,
#w7form .w7-form-card > .w7-citizenship-choice-row,
#w7form .w7-form-card > .citizenship_box,
#w7form .w7-form-card > .w7-identification-block,
#w7form .w7-form-card > .w7-previous-itin-question,
#w7form .w7-form-card > .w7-previous-itin-fields,
#w7form .w7-form-card > .w7-perjury-copy,
#w7form .w7-form-card > .w7-signature-pair,
#w7form .w7-form-card > .delegateDiv,
#w7form .w7-form-card > .delegateRelationshipDiv,
#w7form .w7-form-card > .Acceptance_agentDiv,
#w7form .w7-form-card > .eminfo,
#w7form .w7-form-card > .other_id_submit_box {
    grid-column: 1 / -1;
}

#w7form .w7-form-card > .w7-name-field,
#w7form .w7-birth-card > .form-main {
    grid-column: span 4;
}

#w7form .w7-address-card > .form-main,
#w7form .w7-other-card > .form-main,
#w7form .w7-tax-card > .form-main {
    grid-column: span 6;
}

#w7form .w7-other-card > .w7-visa-field {
    grid-column: span 4;
}

#w7form .w7-email-card > .form-main {
    grid-column: 1 / -1;
}

/* Nested conditional field panels. */
#w7form .birth_name_div,
#w7form .citizenship_box,
#w7form .Acceptance_agentDiv,
#w7form .w7-treaty-fields,
#w7form .w7-us-person-fields,
#w7form .w7-previous-itin-fields {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--w7-border);
    border-radius: 12px;
    background: #f8fbfc;
}

#w7form .birth_name_div > .form-main,
#w7form .w7-us-person-fields > .form-main {
    grid-column: span 4;
}

#w7form .birth_name_div > .form-main:first-child,
#w7form .w7-us-person-fields > .w7-us-relationship-field,
#w7form .citizenship_box > .w7-compact-question,
#w7form .citizenship_box > .w7-compact-choice-row,
#w7form .citizenship_box > .more_citizenshipDiv,
#w7form .Acceptance_agentDiv > .w7-signature-pair {
    grid-column: 1 / -1;
}

#w7form .citizenship_box > .form-main,
#w7form .Acceptance_agentDiv > .form-main,
#w7form .w7-treaty-fields > .form-main,
#w7form .w7-previous-itin-fields > .form-main {
    grid-column: span 6;
}

#w7form .w7-subsection-title {
    margin: 2px 0 0;
    padding: 14px 0 0;
    border-top: 1px solid #e8eef1;
    color: var(--w7-navy);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

#w7form .w7-subsection-title span {
    color: var(--w7-muted);
    font-size: 13px;
    font-weight: 400;
}

/* Master form typography and control treatment. */
#w7form .form-main,
#w7form .form-main-checkbox {
    width: 100%;
    min-width: 0;
}

#w7form .form-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    align-content: start;
    height: auto;
    margin: 0 !important;
    padding: 0;
}

#w7form label,
#w7form .w7-group-label {
    display: block;
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    color: var(--w7-navy);
    font-size: 15px;
    font-weight: 500;
    line-height: 18px;
    text-align: left;
}

#w7form .required::after {
    position: static;
    display: inline;
    float: none !important;
    flex: 0 0 auto;
    margin-left: 2px;
    color: #e34a3b;
    content: " *";
}

#w7form .form-control,
#w7form .form-select {
    display: block;
    width: 100%;
    min-width: 0;
    height: 46px;
    min-height: 46px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #cfdbe1;
    border-radius: 9px;
    outline: 0;
    background: var(--w7-surface);
    color: var(--w7-navy);
    font-size: 15px;
    font-weight: 400;
    line-height: 20px;
    text-align: left;
    box-shadow: none;
}

#w7form .form-control::placeholder {
    color: #667f8e;
    opacity: 1;
}

#w7form .form-control:focus,
#w7form .form-select:focus {
    border-color: var(--w7-teal);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 151, 178, .14);
}

#w7form .form-control:invalid:not(:placeholder-shown),
#w7form .form-select:invalid:not(:focus) {
    box-shadow: none;
}

#w7form .position-relative,
#w7form .icon-input,
#w7form .icon-select,
#w7form .input-group {
    position: relative;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
}

#w7form .icon-select::after,
#w7form .icon-select > i,
#w7form .icon-input > i {
    display: none !important;
}

#w7form input[type="date"]::-webkit-datetime-edit {
    text-transform: uppercase;
}

/* Choice and checkbox cards. */
#w7form input[type="radio"],
#w7form input[type="checkbox"] {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--w7-teal);
}

#w7form .w7-application-type > .position-relative,
#w7form .w7-birth-name-choice > .position-relative,
#w7form .w7-compact-choice-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

#w7form .w7-reason-options > .position-relative {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

#w7form .position-relative > .d-flex,
#w7form .checkbox_sty {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0 !important;
    padding: 10px 12px;
    border: 1px solid #dce5e9;
    border-radius: 10px;
    background: #fbfdfe;
}

#w7form .position-relative > .d-flex:hover,
#w7form .checkbox_sty:hover {
    border-color: #b9cdd6;
    background: #f7fbfc;
}

#w7form .position-relative > .d-flex label,
#w7form .checkbox_sty label {
    min-width: 0;
    margin: 0 !important;
    overflow-wrap: anywhere;
}

#w7form .w7-form-card > .w7-compact-question,
#w7form .citizenship_box > .w7-compact-question {
    display: block;
    width: 100%;
    margin: 0;
}

#w7form .w7-form-card > .w7-compact-choice-row,
#w7form .citizenship_box > .w7-compact-choice-row {
    margin: 0 !important;
}

#w7form .w7-identification-block,
#w7form .delegateRelationshipDiv {
    margin: 0 !important;
}

#w7form .w7-identification-block > .w7-group-label,
#w7form .delegateRelationshipDiv > .w7-group-label {
    margin: 0 0 8px;
}

#w7form .w7-identification-block .form-main-checkbox {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 !important;
}

#w7form .delegateRelationshipDiv .form-main-checkbox {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin: 0 !important;
}

#w7form .w7-previous-itin-question > .d-flex {
    display: flex;
    align-items: center;
    gap: 14px !important;
    margin: 0 !important;
}

#w7form .w7-previous-itin-question > .d-flex > label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

/* Informational surfaces. */
#w7form .note_point {
    margin: 0 !important;
    padding: 12px 14px;
    border: 1px solid #cde4e9;
    border-left: 4px solid var(--w7-teal);
    border-radius: 10px;
    background: #f2fafb;
}

#w7form .w7-itin-note {
    margin: 0;
    padding-left: 18px;
}

#w7form .w7-itin-note li {
    margin: 0 0 5px;
    color: #31566a;
    font-size: 12px;
    font-weight: 400;
    line-height: 18px;
}

#w7form .w7-itin-note li:last-child {
    margin-bottom: 0;
}

#w7form .w7-itin-note strong {
    font-weight: 600;
}

#w7form .eminfo {
    margin: -4px 0 0;
    color: var(--w7-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 18px;
}

#w7form .w7-perjury-copy {
    margin: 0;
    padding: 13px 14px;
    border: 1px solid #dce5e9;
    border-radius: 10px;
    background: #f8fbfc;
    color: var(--w7-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 19px;
}

/* Applicant and acceptance-agent signatures. */
#w7form .w7-signature-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
    margin: 0;
}

#w7form .w7-signature-main {
    display: grid;
    grid-template-rows: auto 160px auto;
    gap: 7px;
    min-width: 0;
}

#w7form .w7-signature-main > .icon-input {
    height: 160px;
}

#w7form .signaturePad {
    display: block;
    width: 100%;
    height: 160px;
    min-height: 160px;
    border: 1px solid #cfdbe1;
    border-radius: 10px;
    background: var(--w7-surface);
    touch-action: none;
}

#w7form .clear-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #f2b9b2;
    border-radius: 9px;
    background: #fffafa;
    color: #a7281d;
    font-size: 14px;
    cursor: pointer;
}

#w7form .w7-signature-main small {
    margin: 0;
    color: var(--w7-muted) !important;
    font-size: 12px;
    line-height: 18px;
}

#w7form .w7-signature-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-content: start;
    min-width: 0;
}

#w7form .Acceptance_agentDiv {
    margin: 0;
}

#w7form .w7-hidden {
    display: none !important;
}

/* Preview shell and controls match the 1099-MISC master. */
.epay-w7-generator .epay-w7__preview-column {
    position: sticky;
    top: 96px;
    align-self: start;
    height: fit-content;
}

.epay-w7-generator .pdfv {
    position: relative;
    width: 100%;
    min-width: 0;
    padding: 12px;
    overflow: visible;
    border: 1px solid var(--w7-border);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 14px 36px rgba(2, 48, 71, .1);
}

.epay-w7-generator .pdfv > h2 {
    margin: 2px 0 14px;
    color: var(--w7-navy);
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.35;
    text-align: center;
}

.epay-w7-generator #iframeWrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding: 0;
    border: 1px solid #cfdbe1;
    border-radius: 10px;
    background: #e9eef1;
}

.epay-w7-generator #pdfPreview {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.epay-w7-generator #pdfPreview[hidden] {
    display: none !important;
}

.epay-w7-generator .w7-inline-pages {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #e9eef1;
}

.epay-w7-generator .w7-inline-page {
    box-sizing: content-box;
    max-width: none;
    margin: 0 auto;
    overflow: hidden;
    background: #ffffff;
}

.epay-w7-generator .w7-inline-page canvas {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
}

.epay-w7-generator #iframeWrapper.w7-native-fallback {
    aspect-ratio: 612 / 792;
    overflow: hidden;
}

.epay-w7-generator #iframeWrapper.w7-native-fallback #pdfPreview {
    width: 100%;
    height: 100%;
}

.epay-w7-generator .w7-preview-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100%;
    max-width: 580px;
    margin: 30px auto 8px !important;
}

.epay-w7-generator #previewBtn,
.epay-w7-generator #save_w7formdata {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    text-align: center !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    transform: none !important;
}

.epay-w7-generator #previewBtn {
    border: 1px solid #7895a8 !important;
    background: #eaf2f6 !important;
    color: var(--w7-navy) !important;
    box-shadow: 0 1px 3px rgba(15, 50, 71, .14) !important;
}

.epay-w7-generator #previewBtn:hover,
.epay-w7-generator #previewBtn:focus-visible {
    border-color: var(--w7-navy) !important;
    background: #dceaf1 !important;
}

.epay-w7-generator #save_w7formdata {
    border: 1px solid #168894 !important;
    background: #1a9ba8 !important;
    color: #ffffff !important;
    box-shadow: 0 1px 3px rgba(15, 50, 71, .18) !important;
}

.epay-w7-generator #save_w7formdata:hover,
.epay-w7-generator #save_w7formdata:focus-visible {
    background: var(--w7-teal-dark) !important;
}

.epay-w7-generator .loader-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    background: rgba(255, 255, 255, .8);
}

.epay-w7-generator .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5edf0;
    border-top-color: var(--w7-teal);
    border-radius: 50%;
    animation: w7-spin .8s linear infinite;
}

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

/* Full preview modal keeps the existing W-7 PDF and iframe behavior. */
.epay-w7-generator #pdfModal {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: auto;
    background: rgba(6, 43, 69, .42);
}

.epay-w7-generator #pdfModal .modal-content {
    display: flex;
    flex-direction: column;
    width: min(820px, calc(100vw - 24px));
    max-width: none;
    height: calc(100dvh - 24px);
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #d6e1e6;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 18, 27, .16);
}

.epay-w7-generator #pdfModal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 8px 10px 8px 16px;
    border-bottom: 1px solid #dce5e9;
}

.epay-w7-generator #pdfModal .modal-header h3 {
    margin: 0;
    color: var(--w7-navy);
    font-size: 17px;
    font-weight: 700;
}

.epay-w7-generator #pdfModal .close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid #d6e1e6;
    border-radius: 7px;
    background: #ffffff;
    color: #17384d;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.epay-w7-generator #pdfModal .close-btn:hover,
.epay-w7-generator #pdfModal .close-btn:focus-visible {
    border-color: #9fb5c1;
    background: #f4f8fa;
    outline: 2px solid rgba(0, 155, 181, .22);
    outline-offset: 1px;
}

.epay-w7-generator #pdfModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
}

.epay-w7-generator #pdfModal .modal-body iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.epay-w7-generator #modalPdf[hidden] {
    display: none !important;
}

.epay-w7-generator .w7-modal-pages {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #e9eef1;
}

.epay-w7-generator .w7-modal-page {
    box-sizing: content-box;
    max-width: none;
    margin: 0 auto;
    overflow: hidden;
    background: #ffffff;
}

.epay-w7-generator .w7-modal-page canvas {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
}

.epay-w7-generator #pdfModal .modal-body.w7-modal-native-fallback {
    aspect-ratio: 612 / 792;
}

@media (max-width: 991.98px) {
    .epay-w7-generator .epay-w7__preview-column {
        position: static;
        top: auto;
        align-self: auto;
        height: auto;
        margin-top: 24px;
    }

}

@media (max-width: 767.98px) {
    .epay-w7-generator .epay-w7__layout-container {
        padding-top: 28px;
        padding-bottom: 44px;
        width: 100%;
        max-width: 1220px;
        min-width: 0;
        padding-left: 12px;
        padding-right: 12px;
        box-sizing: border-box;
        margin-left: auto;
        margin-right: auto;
    }

    #w7form .w7-form-card {
        padding: 16px;
        border-radius: 14px;
    }

    #w7form .form-section-title {
        font-size: 1.18rem;
    }

    .epay-w7-generator .pdfv {
        padding: 10px;
        border-radius: 14px;
    }

}

@media (max-width: 575.98px) {
    /* Match W-9's 12px mobile outer card margin; keep card padding. */
    .epay-w7-generator .epay-w7__layout-container {
        width: 100%;
        max-width: 1220px;
        min-width: 0;
        padding-left: 12px;
        padding-right: 12px;
        box-sizing: border-box;
        margin-left: auto;
        margin-right: auto;
    }

    .epay-w7-generator .epay-w7__hero {
        padding: 28px 0 24px;
    }

    .epay-w7-generator .epay-w7-hero__title {
        font-size: 20px;
        line-height: 1.18;
        letter-spacing: -.2px;
        text-align: left;
    }

    .epay-w7-generator .w-create-intro-guide h2,
    .epay-w7-generator .w-create-intro-guide li {
        font-size: 11px;
        line-height: 1.45;
    }

    #w7form .w7-form-card,
    #w7form .birth_name_div,
    #w7form .citizenship_box,
    #w7form .Acceptance_agentDiv,
    #w7form .w7-treaty-fields,
    #w7form .w7-us-person-fields,
    #w7form .w7-previous-itin-fields {
        grid-template-columns: minmax(0, 1fr);
        column-gap: 0;
        row-gap: 18px;
    }

    #w7form .w7-form-card > *,
    #w7form .birth_name_div > *,
    #w7form .citizenship_box > *,
    #w7form .Acceptance_agentDiv > *,
    #w7form .w7-treaty-fields > *,
    #w7form .w7-us-person-fields > *,
    #w7form .w7-previous-itin-fields > * {
        grid-column: 1 / -1 !important;
    }

    #w7form .w7-identification-block .form-main-checkbox,
    #w7form .w7-application-type > .position-relative,
    #w7form .w7-signature-pair {
        grid-template-columns: minmax(0, 1fr);
    }

    #w7form .w7-form-card > .w7-compact-choice-row,
    #w7form .citizenship_box > .w7-compact-choice-row {
        margin-top: 0 !important;
    }

    #w7form .w7-signature-main {
        grid-template-rows: auto 150px auto;
    }

    #w7form .w7-signature-main > .icon-input,
    #w7form .signaturePad {
        height: 150px;
        min-height: 150px;
    }

    .epay-w7-generator .pdfv {
        padding: 8px;
    }

}

@media (max-width: 479.98px) {
    .epay-w7-generator .w7-preview-actions {
        grid-template-columns: minmax(0, 1fr) !important;
        max-width: 100%;
    }

    .epay-w7-generator #previewBtn,
    .epay-w7-generator #save_w7formdata {
        white-space: normal !important;
    }
}

/* Dedicated zoom tools for W-7's existing PDF iframe previews. */
.epay-w7-generator .w7-zoom-controls {
    display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:7px;
    min-height:44px; margin:8px 0; padding:5px 8px;
    border:1px solid #d7e4ea; border-radius:9px; background:#f5f9fb;
    color:#062b45; font:600 13px/1.25 "Open Sans",sans-serif;
}
.epay-w7-generator .w7-zoom-controls button {
    min-width:40px; min-height:40px; padding:0 9px; cursor:pointer;
    border:1px solid #b9cfd9; border-radius:8px; background:#fff; color:#062b45;
    font:inherit;
}
.epay-w7-generator .w7-zoom-value {min-width:48px;text-align:center;font-variant-numeric:tabular-nums;}
.epay-w7-generator .w7-zoom-controls button:focus-visible {outline:2px solid #0097b2;outline-offset:2px;}
.epay-w7-generator #pdfModal .w7-zoom-controls {
    flex:0 0 auto; margin:0; border:0; border-bottom:1px solid #d7e4ea; border-radius:0;
}
@media(max-width:575px) {
    .epay-w7-generator .w7-zoom-controls {gap:4px;padding:4px;}
    .epay-w7-generator .w7-zoom-controls button {min-width:36px;padding:0 5px;}
}

/* Approved create-form visual tokens. W-7 validation and conditional fields stay intact. */
.epay-w7-generator,
.epay-w7-generator :is(input,select,textarea,button){font-family:"Poppins",sans-serif}
.epay-w7-generator .epay-w7-hero__title{font-size:32px;line-height:40px;font-weight:700;letter-spacing:-.8px}
#w7form .w7-form-card{margin-bottom:24px;padding:24px 26px;border:1px solid #d9e3e8;border-radius:16px;box-shadow:0 10px 30px rgba(2,48,71,.07)}
#w7form .form-section-title{padding-bottom:14px;border-bottom:2px solid #e8eef1;color:#023047;font-size:21.6px;font-weight:800;line-height:29.16px}
#w7form .form-main{gap:8px}
#w7form label,#w7form .w7-group-label{color:#023047;font-size:14px;font-weight:400;line-height:20px}
#w7form :is(.form-control,.form-select){box-sizing:border-box;width:100%;height:46px;min-height:46px;padding:9px 12px;border:1px solid #cfdbe1;border-radius:9px;background:#f6f9fb;color:#023047;font-size:12.5px;font-weight:400;line-height:1.35}
#w7form .form-select{padding-right:36px}
#w7form .form-control::placeholder{color:#667f8e;font-size:12.5px;font-weight:400;opacity:1}
#w7form textarea.form-control{height:auto;min-height:94px;line-height:1.55;resize:vertical}
#w7form :is(.position-relative>.d-flex,.checkbox_sty){display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;align-items:center!important;gap:10px;padding:12px 13px;border:1px solid #dce5e9;border-radius:10px;background:#fbfdfe;font-size:14px;font-weight:400;line-height:20px}
#w7form :is(.position-relative>.d-flex,.checkbox_sty)>:is(input[type="radio"],input[type="checkbox"]){flex:0 0 18px;width:18px;height:18px;margin:0!important;align-self:center}
#w7form :is(.position-relative>.d-flex,.checkbox_sty)>label{display:flex!important;align-items:center;flex:1 1 auto;min-width:0;min-height:20px;margin:0!important;line-height:20px}
.epay-w7-generator :is(#previewBtn,#save_w7formdata){font-family:"Poppins",sans-serif!important;font-size:14px!important;font-weight:800!important;line-height:20px!important}
@media(min-width:768px) and (max-width:1023.98px){.epay-w7-generator .epay-w7-hero__title{font-size:30.72px;line-height:38.4px}}
@media(max-width:767.98px){.epay-w7-generator .epay-w7-hero__title{font-size:28px;line-height:35px;text-align:center}#w7form .w7-form-card{padding:24px 26px}}
.epay-w7-generator .w-create-hero-standard[data-w-create-standard="1"] #w7HeroTitle{font-family:"Poppins",sans-serif!important;font-size:32px!important;line-height:40px!important}
@media(min-width:768px) and (max-width:1023.98px){.epay-w7-generator .w-create-hero-standard[data-w-create-standard="1"] #w7HeroTitle{font-size:30.72px!important;line-height:38.4px!important}}
@media(max-width:767.98px){.epay-w7-generator .w-create-hero-standard[data-w-create-standard="1"] #w7HeroTitle{font-size:28px!important;line-height:35px!important}}
.epay-w7-generator #w7form .form-section-title{font-size:21.6px!important;font-weight:800!important;line-height:29.16px!important}
/* Container layout verified against Form 941; page-scoped, 2026-11-01. */
.epay-w7-generator .epay-w7__layout-row{display:grid;grid-template-columns:minmax(0,7fr) minmax(0,13fr);gap:24px;margin:0;width:100%;min-width:0;align-items:start;box-sizing:border-box}
.epay-w7-generator .epay-w7__layout-row > *{width:100%;max-width:none;min-width:0;padding-left:0;padding-right:0;margin:0;box-sizing:border-box}
@media(min-width:992px) and (max-width:1199.98px){.epay-w7-generator .epay-w7__layout-row{grid-template-columns:minmax(0,2fr) minmax(0,3fr);gap:22px}}
@media(max-width:991.98px){.epay-w7-generator .epay-w7__layout-row{grid-template-columns:minmax(0,1fr);gap:24px}}
/* W-7 reason options: restored rounded borders, improved line-height (2026-11-02). */
#w7form .w7-reason-options > .form-main .w7-group-label {
    line-height: 21px !important;
    margin-bottom: 10px !important;
}
#w7form .w7-reason-options > .position-relative {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-top: 0 !important;
}
#w7form .w7-reason-options > .position-relative > .d-flex {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: flex-start !important;
    gap: 10px !important;
    width: 100%;
    min-height: 48px !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    border: 1px solid #dce5e9 !important;
    border-radius: 10px !important;
    background: #fbfdfe !important;
    box-shadow: none !important;
}
#w7form .w7-reason-options > .position-relative > .d-flex:hover {
    border-color: #b9cdd6 !important;
    background: #f7fbfc !important;
}
#w7form .w7-reason-options > .position-relative > .d-flex > input[type="checkbox"] {
    flex: 0 0 18px !important;
    width: 18px;
    height: 18px;
    margin: 1px 0 0 !important;
    align-self: flex-start !important;
}
#w7form .w7-reason-options > .position-relative > .d-flex > label {
    display: block !important;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0 !important;
    margin: 0 !important;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px !important;
    text-align: justify;
    text-align-last: left;
    overflow-wrap: break-word;
}


/* W-7 spacing audit: parity with approved Form 941 (2026-11-02).
   Only W-7 Create-page labels and section spacing; no preview/checkout/PDF rules. */
#w7form .w7-form-card { row-gap: 18px; }
#w7form .form-main { row-gap: 8px; }
#w7form .form-main > label:not(.security_no),
#w7form .form-main > .w7-group-label,
#w7form .w7-identification-block > .w7-group-label,
#w7form .delegateRelationshipDiv > .w7-group-label {
    margin-top: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-size: 14px;
    font-weight: 400;
    line-height: 14px !important;
}
#w7form .form-main > .epay-w7-wrap-multiline,
#w7form .w7-identification-block > .epay-w7-wrap-multiline,
#w7form .delegateRelationshipDiv > .epay-w7-wrap-multiline {
    line-height: 23px !important;
}
#w7form .epay-w7-wrap-justify {
    text-align: justify !important;
    text-align-last: left;
}
/* Special question groups use the same 8px heading-to-options gap. */
#w7form .w7-reason-options > .form-main > .w7-group-label {
    margin-bottom: 8px !important;
}
#w7form .w7-birth-name-choice > .position-relative {
    margin-top: 8px !important;
}
#w7form .w7-compact-question + .w7-compact-choice-row {
    margin-top: -10px !important; /* 18px parent grid gap -> 8px question gap */
}
/* Remove stray offsets; the card grid already supplies 18px field spacing. */
#w7form .w7-subsection-title { margin-top: 0 !important; }
#w7form .eminfo { margin-top: 0 !important; }
/* The two long question labels have legacy, more-specific line-height rules. */
#w7form .w7-reason-options > .form-main > .w7-group-label {
    line-height: 14px !important;
}
#w7form .w7-reason-options > .form-main > .w7-group-label.epay-w7-wrap-multiline,
#w7form .w7-previous-itin-question > label.w7-inline-required.epay-w7-wrap-multiline {
    line-height: 23px !important;
}


/* W-7 action alignment and Form 941 full-preview shell; W-7 scoped only. */
.epay-w7-generator .pdfv > .w7-preview-actions.epay-create-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    justify-items: stretch !important;
    justify-content: center !important;
    width: min(100%, 580px) !important;
    max-width: 580px !important;
    margin: 18px auto 8px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    gap: 12px !important;
}
.epay-w7-generator .w7-preview-actions > :is(#previewBtn, #save_w7formdata) {
    display: flex !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
    height: 46px !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    text-align: center !important;
}
@media (max-width: 479.98px) {
    .epay-w7-generator .pdfv > .w7-preview-actions.epay-create-actions {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
    }
}

/* The modal is moved to body just as in the Form 941 Create page.
   These selectors work outside the preview column without global overrides. */
body > #pdfModal.epay-w7-body-preview-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    box-sizing: border-box !important;
    width: 100vw !important;
    height: 100dvh !important;
    padding: clamp(16px, 4vw, 40px) !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: auto !important;
    background: rgba(2,48,71,.72) !important;
}
body > #pdfModal.epay-w7-body-preview-modal > .modal-content {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    width: min(960px, 75vw, calc((100dvh - 64px) * 17 / 11)) !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: calc(100dvh - 32px) !important;
    aspect-ratio: 17 / 11 !important;
    margin: auto !important;
    padding: 6px !important;
    overflow: hidden !important;
    border: 1px solid #cfdbe1 !important;
    border-radius: 12px !important;
    background: #edf2f5 !important;
    box-shadow: 0 16px 42px rgba(0,18,27,.24) !important;
}
body > #pdfModal.epay-w7-body-preview-modal .modal-header {
    position: absolute !important;
    inset: 0 0 auto !important;
    z-index: 25 !important;
    width: 100% !important;
    height: 52px !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    pointer-events: none !important;
}
body > #pdfModal.epay-w7-body-preview-modal .modal-header h3 {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
}
body > #pdfModal.epay-w7-body-preview-modal .modal-header .close-btn {
    position: absolute !important;
    top: 9px !important;
    right: 22px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    height: 38px !important;
    padding: 0 !important;
    border: 1px solid #b9ccd5 !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #023047 !important;
    font: 700 22px/1 "Open Sans", Arial, sans-serif !important;
    pointer-events: auto !important;
}
body > #pdfModal.epay-w7-body-preview-modal > .modal-content > .w7-zoom-controls {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 7px !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 5px 58px 5px 10px !important;
    border: 0 !important;
    border-bottom: 1px solid #d7e4ea !important;
    border-radius: 0 !important;
    background: #fff !important;
}
body > #pdfModal.epay-w7-body-preview-modal .w7-zoom-controls button {
    flex: 0 0 auto !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 8px !important;
    border: 1px solid #b9cfd9 !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #062b45 !important;
    font: 600 12px/1.2 "Open Sans", sans-serif !important;
    cursor: pointer !important;
}
body > #pdfModal.epay-w7-body-preview-modal .w7-zoom-controls .w7-zoom-value {
    min-width: 48px !important;
    text-align: center !important;
}
body > #pdfModal.epay-w7-body-preview-modal .modal-body {
    position: relative !important;
    display: block !important;
    flex: 1 1 auto !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: auto !important;
    border: 1px solid #cfdbe1 !important;
    border-radius: 8px !important;
    background: #fff !important;
}
body > #pdfModal.epay-w7-body-preview-modal .w7-modal-pages {
    min-width: 100%;
    width: max-content;
    margin: 0;
    padding: 0;
    background: #edf2f5;
}
body > #pdfModal.epay-w7-body-preview-modal .w7-modal-page {
    box-sizing: content-box;
    max-width: none;
    margin: 0 auto;
    background: #fff;
}
body > #pdfModal.epay-w7-body-preview-modal .w7-modal-page canvas {
    display: block;
    max-width: none;
    height: auto;
    margin: 0 auto;
}
body > #pdfModal.epay-w7-body-preview-modal .modal-body[aria-busy="true"] .w7-modal-pages:empty::before {
    content: "Preparing your W-7 PDF preview…";
    display: flex;
    min-height: 180px;
    align-items: center;
    justify-content: center;
    color: #31566a;
    font: 500 13px/1.4 "Poppins", sans-serif;
}
body > #pdfModal.epay-w7-body-preview-modal #modalPdf:not([hidden]) {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}
body > #pdfModal.epay-w7-body-preview-modal #modalPdf[hidden] {
    display: none !important;
}
@media (max-width: 991.98px) {
    body > #pdfModal.epay-w7-body-preview-modal {
        padding: 16px !important;
    }
    body > #pdfModal.epay-w7-body-preview-modal > .modal-content {
        width: min(720px, calc(100vw - 32px)) !important;
        height: calc(100dvh - 32px) !important;
        max-height: 900px !important;
        aspect-ratio: auto !important;
    }
}
@media (max-width: 767.98px) {
    body > #pdfModal.epay-w7-body-preview-modal {
        padding: 12px !important;
    }
    body > #pdfModal.epay-w7-body-preview-modal > .modal-content {
        width: 100% !important;
        height: calc(100dvh - 24px) !important;
        max-height: none !important;
        padding: 4px !important;
        border-radius: 10px !important;
    }
    body > #pdfModal.epay-w7-body-preview-modal > .modal-content > .w7-zoom-controls {
        gap: 5px !important;
        padding: 5px 48px 5px 7px !important;
    }
    body > #pdfModal.epay-w7-body-preview-modal .w7-zoom-controls button {
        min-width: 34px !important;
        padding: 0 5px !important;
    }
    body > #pdfModal.epay-w7-body-preview-modal .modal-header .close-btn {
        top: 9px !important;
        right: 8px !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 20px !important;
    }
}
/* Do not expose an aria-hidden preview before W-7 initialization completes. */
body > #pdfModal.epay-w7-body-preview-modal[aria-hidden="true"] {
    display: none !important;
}
body > #pdfModal.epay-w7-body-preview-modal[aria-hidden="false"] {
    display: flex !important;
}
