/* ============================================================
   SCSLAI — UNIVERSAL FILL-OUT-ON-IMAGE FORM MODAL
   ============================================================
   Works with:
   - SC Loan Application
   - SC Membership Application
   - Other SCSLAI forms

   The official PNG is the actual form.
   HTML inputs are positioned ON TOP of the PNG.

   IMPORTANT:
   The JavaScript configuration controls the actual
   x / y / w / h coordinates.

   This CSS only controls:
   - modal
   - scaling
   - scrolling
   - preview
   - blue-ink text
   - checkboxes
   - buttons
   ============================================================ */


/* ============================================================
   GLOBAL RESET
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body.loan-modal-open {
    overflow: hidden !important;
}


/* ============================================================
   MAIN MODAL OVERLAY
   ============================================================ */

#loanModal {
    position: fixed;

    inset: 0;

    width: 100%;
    height: 100%;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.68);

    z-index: 99999;

    overflow: hidden;

    isolation: isolate;
}

#loanModal.active {
    display: flex;
}


/* ============================================================
   MODAL WINDOW
   ============================================================ */

.loan-modal-content,
.loan-modal .loan-modal-content.loan-form-modal {
    position: relative;

    width: min(1150px, 96vw);

    height: min(94vh, 1100px);

    max-width: 1150px;
    max-height: 94vh;

    margin: 0;

    padding: 0;

    background: #ffffff;

    border-radius: 12px;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.35);

    z-index: 1;
}


/* ============================================================
   MODAL HEADER
   ============================================================ */

.loan-modal-header,
.loan-form-modal .loan-modal-header {
    flex: 0 0 auto;

    min-height: 62px;

    padding: 14px 22px;

    background: #176b3a;

    color: #ffffff;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 15px;
}

.loan-modal-header h2,
.loan-form-modal .loan-modal-header h2 {
    margin: 0;

    padding: 0;

    color: #ffffff;

    font-size: 20px;

    font-weight: 700;

    line-height: 1.2;

    letter-spacing: 0.2px;
}


/* ============================================================
   CLOSE MODAL BUTTON
   ============================================================ */

#closeLoanModal,
.close-loan-modal {
    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    margin: 0;
    padding: 0;

    border: none;

    border-radius: 50%;

    background: rgba(255, 255, 255, 0.15);

    color: #ffffff;

    font-size: 27px;

    line-height: 1;

    cursor: pointer;

    display: flex;

    align-items: center;
    justify-content: center;

    transition:
        background 0.2s ease,
        transform 0.15s ease;
}

#closeLoanModal:hover,
.close-loan-modal:hover {
    background: rgba(255, 255, 255, 0.28);

    transform: scale(1.04);
}


/* ============================================================
   MODAL BODY
   ============================================================ */

.loan-modal-body {
    flex: 1 1 auto;

    min-height: 0;

    width: 100%;

    padding: 0;

    background: #e9eceb;

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;
}


/* ============================================================
   FORM
   ============================================================ */

#loanApplicationForm {
    width: 100%;

    margin: 0;
    padding: 0;

    display: block;
}


/* ============================================================
   IMAGE FORM CANVAS
   ============================================================

   IMPORTANT:

   Do NOT give the canvas a fixed height.

   The height MUST follow the PNG's natural aspect ratio.
   This prevents stretching/compression.
   ============================================================ */

.loan-form-canvas {
    position: relative;

    width: min(100%, 1150px);

    height: auto;

    margin: 0 auto 25px;

    padding: 0;

    background: #ffffff;

    overflow: hidden;

    box-shadow:
        0 5px 20px rgba(0, 0, 0, 0.18);

    /*
       Keep the coordinate system tied to the image.
    */
    aspect-ratio: auto;
}


/* ============================================================
   FORM BACKGROUND IMAGE
   ============================================================ */

.loan-form-background {
    position: relative;

    display: block;

    width: 100%;

    height: auto;

    max-width: 100%;

    margin: 0;

    /*
       The image itself is decorative — never let it
       swallow clicks or text selection that belong
       to the inputs layered on top of it.
    */
    user-select: none;

    -webkit-user-select: none;

    pointer-events: none;
}


/* ============================================================
   DESKTOP FILL-ON-IMAGE MODE
   (inputs are positioned by JS; this just styles the page)
   ============================================================ */

.loan-image-page {
    padding: 20px 20px 8px;
    background: #e9eceb;
}

.loan-form-canvas {
    /*
        JS sets aspect-ratio inline from the PNG's
        design dimensions (dims.w / dims.h) and
        caps the width at the design width, so
        the form is never stretched beyond the
        scale the preview / print uses. Center
        it when it is narrower than the modal.
    */
    margin-bottom: 0;
    margin-left: auto;
    margin-right: auto;
}

.loan-form-canvas .form-input {
    font-size: 12px; /* overridden per-input by JS (f.fs) */
}


/* ============================================================
   FORM PAGE
   ============================================================ */

.loan-form-page {
    padding: 0;

    object-fit: contain;
}


/* ============================================================
   IMPORTANT:

   Overlay elements must be positioned relative to
   .loan-form-canvas.

   DO NOT add padding or borders that change its size.
   ============================================================ */

.loan-form-canvas > .form-input,
.loan-form-canvas > .form-checkbox,
.loan-form-canvas > .form-photo-canvas-slot {
    position: absolute;
}


/* ============================================================
   ATTACHED 2x2 PHOTO UPLOADER
   Desktop: absolutely positioned over the form's photo box.
   Mobile/stacked: shown as a normal section above the fields.
   ============================================================ */

.form-photo-canvas-slot {
    pointer-events: auto;
}

.form-photo-widget {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: Arial, Helvetica, sans-serif;
}

.form-photo-frame {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    background: #ffffff;
    border: 2px dashed rgba(0, 63, 145, 0.55);
    border-radius: 4px;
    cursor: pointer;
}

.form-photo-widget.has-photo .form-photo-frame {
    border-style: solid;
    border-color: rgba(0, 63, 145, 0.603);
}

.form-photo-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px;
    text-align: center;
    color: #003f91;
}

.form-photo-icon {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.form-photo-empty-title {
    font-size: 11px;
    font-weight: 700;
}

.form-photo-empty-sub {
    font-size: 9px;
    font-weight: 400;
    color: rgba(0, 63, 145, 0.75);
}

.form-photo-preview-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.form-photo-controls {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.form-photo-btn {
    flex: 1 1 auto;
    min-height: 26px;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: #18a854;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.form-photo-btn:hover {
    background: #0c6e35;
}


.form-photo-remove {
    background: #7a7878;
}

.form-photo-remove:hover {
    background: #c0170b;
}

.form-photo-name {
    font-size: 9px;
    color: #333;
    text-align: center;
    word-break: break-all;
    max-height: 24px;
    overflow: hidden;
}

.form-photo-stacked {
    height: auto;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid #d9dfdb;
    border-radius: 8px;
    background: #f6f8f7;
}

.form-photo-stacked .form-photo-frame {
    height: 220px;
    flex: none;
}

.form-photo-stacked .form-photo-btn {
    min-height: 38px;
    font-size: 13px;
}

.form-photo-stacked .form-photo-name {
    font-size: 12px;
    max-height: none;
}

.form-photo-canvas .form-photo-controls {
    flex: none;
}

.form-photo-canvas .form-photo-btn {
    font-size: 10px;
    min-height: 22px;
    padding: 2px 6px;
}

.form-photo-canvas .form-photo-name {
    display: none;
}


/* ============================================================
   TEXT INPUTS ON FORM
   ============================================================ */

.form-input {
    position: absolute;

    z-index: 10;

    display: block;

    margin: 0;

    padding: 0 3px;

    border: 1px solid transparent;

    outline: none;

    border-radius: 0;

    background: transparent;

    box-shadow: none;

    box-sizing: border-box;

    /*
       BLUE INK
    */
    color: #003f91;

    /*
       Match the preview / printed output exactly:
       Arial, BOLD and CENTERED (the preview values
       and the printed PDF are bold + centered too).
       Actual size is scaled by JS per field (f.fs).
    */
    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-weight: 700;

    line-height: 1;

    text-align: center;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: clip;

    -webkit-appearance: none;

    appearance: none;

    cursor: text;
}


/* ============================================================
   INPUT HOVER
   ============================================================ */

.form-input:hover {
    background: transparent;

    border-color: rgba(0, 63, 145, 0.25);
}


/* ============================================================
   INPUT FOCUS
   ============================================================ */

.form-input:focus {
    background: transparent;

    border: 1px solid rgba(0, 63, 145, 0.45);

    outline: none;

    box-shadow:
        0 0 0 2px rgba(0, 63, 145, 0.10);
}


/* ============================================================
   AUTO-GENERATED (READ-ONLY) INPUTS
   "Amount in Words" and "Payable Years in Words" are filled
   in by the engine. They are shown on the desktop fill-on-
   image view but must not look like editable boxes or react
   to hover / focus.
   ============================================================ */

.form-input[readonly] {
    cursor: default;

    background: transparent;

    border-color: transparent;
}

.form-input[readonly]:hover,
.form-input[readonly]:focus {
    background: transparent;

    border-color: transparent;

    box-shadow: none;
}


/* ============================================================
   PLACEHOLDER
   ============================================================ */

.form-input::placeholder {
    color: rgba(0, 63, 145, 0.35);

    font-weight: 400;

    opacity: 1;
}


/* ============================================================
   MOBILE STACKED INPUTS — centered + bold, same as the
   desktop fill view, the preview and the printed form.
   ============================================================ */

.loan-input {
    text-align: center;

    font-weight: 700;
}


/* ============================================================
   AUTOFILL NEUTRALIZER
   Chrome / Edge paint autofilled inputs light blue
   (#e8f0fe) and force their own text color. Force it back:
   transparent background + blue ink on the fill-on-image
   view, and the normal white box on the stacked view.
   ============================================================ */

.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px transparent inset;
    box-shadow: 0 0 0 1000px transparent inset;
    -webkit-text-fill-color: #003f91;
    caret-color: #003f91;
    /*
        The 99999s transition stops Chrome from ever
        painting its blue autofill background.
    */
    transition: background-color 99999s ease-in-out 0s;
}

.loan-input:-webkit-autofill,
.loan-input:-webkit-autofill:hover,
.loan-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
    box-shadow: 0 0 0 1000px #ffffff inset;
    -webkit-text-fill-color: #222222;
    caret-color: #222222;
    transition: background-color 99999s ease-in-out 0s;
}


/* ============================================================
   UPPERCASE
   ============================================================ */

.form-input.form-upper {
    text-transform: uppercase;
}


/* ============================================================
   SELECT
   ============================================================ */

.form-input.form-select {
    cursor: pointer;

    -webkit-appearance: auto;

    appearance: auto;

    background: transparent;
}


/* ============================================================
   DATE / NUMBER INPUTS
   ============================================================ */

.form-input[type="date"],
.form-input[type="number"] {
    background: transparent;
}


/* ============================================================
   CHECKBOXES
   ============================================================ */

.loan-form-canvas .form-checkbox {
    position: absolute;

    z-index: 20;

    display: block;

    margin: 0;
    padding: 0;

    width: 15px;
    height: 15px;

    border: none;

    outline: none;

    background: transparent;

    -webkit-appearance: none;

    appearance: none;

    cursor: pointer;
}


/* ============================================================
   CHECKBOX CLICK AREA
   ============================================================ */

.loan-form-canvas .form-checkbox::before {
    content: "";

    position: absolute;

    inset: -7px;

    background: transparent;

    cursor: pointer;
}


/* ============================================================
   CHECKMARK
   ============================================================ */

.loan-form-canvas .form-checkbox::after {
    content: "";

    position: absolute;

    left: 50%;
    top: 50%;

    width: 65%;
    height: 65%;

    transform:
        translate(-50%, -58%)
        rotate(45deg);

    border-right: 2px solid #003f91;

    border-bottom: 2px solid #003f91;

    opacity: 0;

    pointer-events: none;
}

.loan-form-canvas .form-checkbox:checked::after {
    opacity: 1;
}


/* ============================================================
   CHECKBOX HOVER
   ============================================================ */

.loan-form-canvas .form-checkbox:hover {
    background: rgba(0, 63, 145, 0.08);
}


/* ============================================================
   CHECKBOX FOCUS
   ============================================================ */

.loan-form-canvas .form-checkbox:focus-visible {
    outline: 2px dashed rgba(0, 63, 145, 0.6);

    outline-offset: 2px;
}


/* ============================================================
   FORM PAGE
   ============================================================ */

.loan-form-page {
    width: 100%;

    margin: 0;

    padding: 20px;

    background: #ffffff;

    border: none;

    border-radius: 0;
}

/* ============================================================
   NORMAL HTML FORM FIELDS
   ============================================================ */

.loan-form-fields {
    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 16px 20px;
}

.loan-field {
    width: 100%;

    display: flex;

    flex-direction: column;

    gap: 6px;
}

.loan-field label {
    font-size: 13px;

    font-weight: 600;

    color: #333333;
}

.loan-input {
    width: 100%;

    min-height: 42px;

    padding: 9px 12px;

    border: 1px solid #cbd5cf;

    border-radius: 6px;

    background: #ffffff;

    color: #222222;

    font-family: inherit;

    font-size: 14px;

    outline: none;
}

.loan-input:focus {
    border-color: #176b3a;

    box-shadow:
        0 0 0 3px rgba(23, 107, 58, 0.12);
}


/* ============================================================
   CHECKBOX LIST
   ============================================================ */

.modal-checkbox-section {
    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 18px;

    margin-bottom: 25px;
}

.modal-checkbox-group {
    padding: 15px;

    background: #f8faf9;

    border: 1px solid #dce5df;

    border-radius: 8px;
}

.modal-checkbox-group h3 {
    margin: 0 0 12px;

    color: #176b3a;

    font-size: 15px;
}

.loan-checkbox-list {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 8px 15px;
}

.modal-checkbox-item {
    display: flex;

    align-items: center;

    gap: 8px;

    padding: 6px 4px;

    font-size: 13px;

    color: #333333;

    cursor: pointer;
}


/* ============================================================
   MODAL ACTIONS
   ============================================================ */

.modal-actions {
    flex: 0 0 auto;

    width: 100%;

    display: flex;

    align-items: center;

    justify-content: flex-end;

    gap: 12px;

    padding: 12px 20px;

    background: #ffffff;

    border-top: 1px solid #d9dfdb;
}

.modal-actions button {
    min-width: 120px;

    min-height: 42px;

    padding: 10px 18px;

    border: none;

    border-radius: 6px;

    font-family: inherit;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        background 0.2s ease;
}

.modal-actions button:hover {
    transform: translateY(-1px);
}

#cancelLoanModal {
    background: #e8ece9;

    color: #333333;
}

#cancelLoanModal:hover {
    background: #dce2de;
}

.modal-actions button[type="submit"] {
    background: #176b3a;

    color: #ffffff;
}

.modal-actions button[type="submit"]:hover {
    background: #12572f;
}


/* ============================================================
   ============================================================
   PRINT PREVIEW
   ============================================================
   ============================================================ */

.loan-preview-overlay {
    position: fixed;

    inset: 0;

    width: 100%;
    height: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 15px;

    background: rgba(0, 0, 0, 0.72);

    z-index: 100000;

    overflow: hidden;

    isolation: isolate;
}


/* ============================================================
   PREVIEW WINDOW
   ============================================================ */

.loan-preview-window {
    position: relative;

    width: min(1200px, 96vw);

    height: min(94vh, 1100px);

    max-width: 1200px;

    max-height: 94vh;

    margin: 0;

    padding: 0;

    background: #ffffff;

    border-radius: 12px;

    display: flex;

    flex-direction: column;

    overflow: hidden;

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.40);

    z-index: 1;
}


/* ============================================================
   PREVIEW HEADER
   ============================================================ */

.loan-preview-header {
    flex: 0 0 auto;

    min-height: 60px;

    padding: 12px 20px;

    background: #176b3a;

    color: #ffffff;

    display: flex;

    align-items: center;

    justify-content: space-between;
}

.loan-preview-header h2 {
    margin: 0;

    color: #ffffff;

    font-size: 20px;

    font-weight: 700;
}


/* ============================================================
   CLOSE PREVIEW
   ============================================================ */

#closePreview {
    width: 40px;
    height: 40px;

    margin: 0;
    padding: 0;

    border: none;

    border-radius: 50%;

    background: rgba(255, 255, 255, 0.15);

    color: #ffffff;

    font-size: 27px;

    cursor: pointer;

    display: flex;

    align-items: center;
    justify-content: center;
}

#closePreview:hover {
    background: rgba(255, 255, 255, 0.28);
}


/* ============================================================
   PREVIEW BODY
   ============================================================ */

.loan-preview-body {
    flex: 1 1 auto;

    min-height: 0;

    width: 100%;

    padding: 25px;

    background: #e9eceb;

    overflow-y: auto;

    overflow-x: auto;

    display: flex;

    flex-direction: column;

    align-items: center;

    gap: 30px;

    overscroll-behavior: contain;
}


/* ============================================================
   PREVIEW PAGE
   ============================================================

   IMPORTANT:
   Do not force a fixed height.

   The image determines the page height.

   This prevents:
   - compressed forms
   - stretched forms
   - distorted text
   - wrong proportions
   ============================================================ */

.preview-page {
    position: relative;

    flex: 0 0 auto;

    margin: 0;

    padding: 0;

    background: #ffffff;

    overflow: hidden;

    box-shadow:
        0 5px 20px rgba(0, 0, 0, 0.20);
}


/* ============================================================
   PREVIEW BACKGROUND
   ============================================================ */

.preview-background {
    position: absolute;

    top: 0;
    left: 0;

    width: 100%;
    height: 100%;

    display: block;

    object-fit: fill;

    user-select: none;
    pointer-events: none;
}


/* ============================================================
   PREVIEW VALUES
   ============================================================

   BLUE INK

   These are the actual values that appear in the
   Print / Download preview.
   ============================================================ */

.preview-value {
    position: absolute;

    z-index: 10;

    margin: 0;

    padding: 0;

    /*
       BLUE INK
    */
    color: #1a58aa;

    font-family:
        "Times New Roman",
        Times,
        Georgia,
        serif;

    font-weight: 500;

    line-height: 1;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: clip;

    pointer-events: none;

    display: block;

    text-align: left;

    box-sizing: border-box;
}


/* ============================================================
   PREVIEW CHECK MARK
   ============================================================ */

.preview-check {
    position: absolute;

    z-index: 20;

    color: #003f91;

    font-family:
        Arial,
        sans-serif;

    font-size: 18px;

    font-weight: 700;

    line-height: 1;

    display: flex;

    align-items: center;

    justify-content: center;

    pointer-events: none;
}


/* ============================================================
   PREVIEW FOOTER
   ============================================================ */

.loan-preview-footer {
    flex: 0 0 auto;

    min-height: 68px;

    padding: 12px 20px;

    background: #ffffff;

    border-top: 1px solid #d9dfdb;

    display: flex;

    align-items: center;

    justify-content: flex-end;

    gap: 12px;
}


/* ============================================================
   PREVIEW FOOTER BUTTONS
   ============================================================ */

.loan-preview-footer button {
    min-height: 42px;

    padding: 10px 18px;

    border: none;

    border-radius: 6px;

    font-family: inherit;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        background 0.2s ease;
}

.loan-preview-footer button:hover {
    transform: translateY(-1px);
}


/* ============================================================
   EDIT BUTTON
   ============================================================ */

#editLoanForm {
    background: #e8ece9;

    color: #333333;
}

#editLoanForm:hover {
    background: #dce2de;
}


/* ============================================================
   DOWNLOAD BUTTON
   ============================================================ */

#downloadLoanPDF {
    background: #176b3a;

    color: #ffffff;
}

#downloadLoanPDF:hover {
    background: #12572f;
}


/* ============================================================
   SCROLLBAR
   ============================================================ */

.loan-modal-body::-webkit-scrollbar,
.loan-preview-body::-webkit-scrollbar {
    width: 10px;

    height: 10px;
}

.loan-modal-body::-webkit-scrollbar-track,
.loan-preview-body::-webkit-scrollbar-track {
    background: #e5e9e7;
}

.loan-modal-body::-webkit-scrollbar-thumb,
.loan-preview-body::-webkit-scrollbar-thumb {
    background: #9aaa9f;

    border-radius: 10px;
}

.loan-modal-body::-webkit-scrollbar-thumb:hover,
.loan-preview-body::-webkit-scrollbar-thumb:hover {
    background: #75877b;
}


/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 768px) {

    #loanModal {
        padding: 10px;
    }

    .loan-modal-content,
    .loan-modal .loan-modal-content.loan-form-modal {
        width: 100%;

        max-width: 100%;

        height: 96vh;
        height: 96dvh;

        max-height: 96vh;
        max-height: 96dvh;
    }

    .loan-preview-window {
        width: 100%;

        max-width: 100%;

        height: 96vh;
        height: 96dvh;

        max-height: 96vh;
        max-height: 96dvh;
    }

    .loan-preview-body {
        padding: 15px;
    }


    .loan-form-canvas {
        width: 100%;

        max-width: 100%;
    }

    .loan-form-fields {
        grid-template-columns: 1fr;
    }

    .modal-checkbox-section {
        grid-template-columns: 1fr;
    }
}


/* ============================================================
   MOBILE / SMALL TABLET
   ============================================================ */

@media (max-width: 768px) {

    #loanModal {
        padding: 0;
    }

    .loan-modal-content,
    .loan-modal .loan-modal-content.loan-form-modal {
        width: 100vw;

        height: 100vh;
        height: 100dvh;

        max-width: 100vw;

        max-height: 100vh;
        max-height: 100dvh;

        border-radius: 0;
    }

    .loan-modal-header {
        min-height: 56px;

        padding: 10px 14px;
    }

    .loan-modal-header h2 {
        font-size: 18px;
    }

    /* Prevent iOS Safari from auto-zooming when a field is focused,
       which pushes the modal contents off-screen while filling out. */
    .loan-input {
        font-size: 16px;
    }

    #closeLoanModal,
    .close-loan-modal {
        width: 36px;

        height: 36px;

        flex-basis: 36px;

        font-size: 24px;
    }

    .loan-preview-window {
        width: 100vw;

        height: 100vh;
        height: 100dvh;

        max-width: 100vw;

        max-height: 100vh;
        max-height: 100dvh;

        border-radius: 0;
    }

    .loan-preview-header {
        min-height: 56px;

        padding: 10px 14px;
    }

    .loan-preview-header h2 {
        font-size: 18px;
    }

    #closePreview {
        width: 36px;

        height: 36px;

        font-size: 24px;
    }

    .loan-preview-body {
        padding: 8px;

        align-items: flex-start;

        overflow-x: auto;
    }

    /*
       IMPORTANT:
       On phones, do NOT force the form to shrink too much.

       Let the user scroll horizontally if needed.
       This keeps the coordinate system accurate.
    */


    .loan-form-canvas {
        width: 100%;

        max-width: none;
    }

    .loan-preview-footer {
        padding: 10px;

        flex-direction: column;

        gap: 8px;
    }

    .loan-preview-footer button {
        width: 100%;
    }

    .modal-actions {
        flex-direction: column-reverse;

        align-items: stretch;
    }

    .modal-actions button {
        width: 100%;
    }
}


/* ============================================================
   SMALL PHONES
   ============================================================ */

@media (max-width: 480px) {

    .loan-preview-body {
        padding: 5px;
    }

    .loan-modal-body {
        padding: 0;
    }

    .loan-form-page {
        padding: 10px;
    }

    .modal-checkbox-group {
        padding: 10px;
    }

    .loan-input {
        min-height: 40px;

        font-size: 16px;
    }
}


/* ============================================================
   VERY SMALL PHONES
   ============================================================ */

@media (max-width: 360px) {

    .loan-modal-header h2 {
        font-size: 16px;
    }

    .loan-preview-header h2 {
        font-size: 16px;
    }
}


/* ============================================================
   PRINT
   ============================================================ */

@media print {

    html,
    body {
        width: 100% !important;

        height: auto !important;

        margin: 0 !important;

        padding: 0 !important;

        overflow: visible !important;
    }

    #loanModal {
        display: none !important;
    }

    .loan-preview-overlay {
        position: static !important;

        display: block !important;

        width: 100% !important;

        height: auto !important;

        min-height: 0 !important;

        padding: 0 !important;

        margin: 0 !important;

        background: transparent !important;
    }

    .loan-preview-window {
        width: 100% !important;

        height: auto !important;

        max-width: none !important;

        max-height: none !important;

        margin: 0 !important;

        padding: 0 !important;

        border-radius: 0 !important;

        box-shadow: none !important;

        overflow: visible !important;
    }

    .loan-preview-header,
    .loan-preview-footer {
        display: none !important;
    }

    .loan-preview-body {
        display: block !important;

        width: 100% !important;

        height: auto !important;

        max-height: none !important;

        padding: 0 !important;

        margin: 0 !important;

        background: transparent !important;

        overflow: visible !important;
    }

    .preview-page {
        position: relative !important;

        width: 100% !important;

        height: auto !important;

        max-width: none !important;

        margin: 0 !important;

        padding: 0 !important;

        box-shadow: none !important;

        overflow: visible !important;

        page-break-inside: avoid;

        page-break-after: always;

        break-after: page;
    }

    .preview-page:last-child {
        page-break-after: auto;

        break-after: auto;
    }

    .preview-background {
        position: static !important;

        display: block !important;

        width: 100% !important;

        height: auto !important;

        max-width: 100% !important;

        object-fit: contain !important;
    }

    .preview-value {
        color: #003f91 !important;
    }

    .preview-check {
        color: #003f91 !important;
    }
}


/* ============================================================
   ACCESSIBILITY
   ============================================================ */

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #176b3a;

    outline-offset: 2px;
}


/* ============================================================
   FINAL Z-INDEX / OVERLAY PROTECTION
   ============================================================ */

#loanModal.active,
.loan-preview-overlay {
    isolation: isolate;
}

.loan-modal-content,
.loan-preview-window {
    position: relative;

    z-index: 1;
}


/* ============================================================
   PREVENT MODAL FROM GOING BELOW PAGE
   ============================================================ */

#loanModal,
.loan-preview-overlay {
    top: 0 !important;

    right: 0 !important;

    bottom: 0 !important;

    left: 0 !important;

    margin: 0 !important;

    padding: 0 !important;
}