.modal-layer {
    /* position: fixed; Changed from absolute to fixed to anchor beautifully on scroll */
    position: absolute; /* Changed from absolute to fixed to anchor beautifully on scroll */

    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999; /* Boosted to ensure it stays above any background tab rules */

    /* 🔑 THE CENTERING MATRIX: Forces both containers to lock onto dead-center coordinates */
    display: none;
    align-items: center;
    justify-content: center;

    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.modal-layer {
    display: none;
}

/* Open backdrop active state alignment */
.modal-layer.active {
    display: flex !important;
}

#globalUiModalBody {
    padding: 23px;
    /* border: 1px solid red; */
}

/* 🔑 THE WIDTH CONSTRAINT FOR ALERTS */
/* If the backdrop overlay carries the alert-scale-modifier class, clamp the alert box size tightly */
.modal-layer.alert-scale-modifier #globalUIModalContainer {
    width: 100% !important;
    max-width: 450px !important; /* Forces the box to shrink to match the size in your clean design layout */
    height: auto !important;
}

.modal-layer.spinner #globalUIModalContainer {
    width: 100% !important;
    max-width: 350px !important; /* Forces the box to shrink to match the size in your clean design layout */
    height: auto !important;
}

.modal-layer.spinner #globalUiModalActions {
    display: none;
}

.modal-layer.spinner #globalUiModalBody {
    padding: 10px 20px;
}

.ui-lookup-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    color: var(--gray-90);
    background-color: #ffffff;
    table-layout: fixed;
}

.ui-lookup-table thead {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--gray-15);
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.ui-lookup-table thead th {
    padding: 8px 5px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-80);
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-right: 1px solid var(--gray-30);
}

.ui-lookup-table thead th:nth-last-child {
    border-right: none;
}

.ui-lookup-table tbody .ui-lookup-data-row {
    cursor: pointer;
}

.ui-lookup-table tbody td {
    padding: 5px;
    vertical-align: middle;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
}

.ui-lookup-table tbody .ui-lookup-data-row:nth-child(even) {
    background-color: var(--blue-10);
    border-bottom: 1px solid var(--blue-50);
}
.ui-lookup-table tbody .ui-lookup-data-row:nth-child(even) td:not(:last-child) {
    border-right: 1px solid var(--blue-50);
}

.ui-lookup-table tbody .ui-lookup-data-row:nth-child(odd) td {
    border-bottom: 1px solid var(--gray-30);
}
.ui-lookup-table tbody .ui-lookup-data-row:nth-child(odd) td:not(:last-child) {
    border-right: 1px solid var(--gray-30);
}

.ui-lookup-table tbody .ui-lookup-data-row:hover {
    background-color: var(--green-30);
}

.ui-lookup-table .table-status-message {
    text-align: center;
    padding: 32px 16px;
    font-style: italic;
    background-color: #ffffff;
    color: var(--gray-50);
}

.ui-lookup-table tr.error-state .table-status-message {
    color: var(--red-90);
    font-weight: 500;
}

.ui-spinner-canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    padding: 10px 0;
    text-align: center;
}

.ui-spinner-circle {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #0288d1;
    border-radius: 50%;
    animation: uiSpinInfinite 0.8s linear infinite;
}

.ui-spinner-text {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: #475569;
}

#curr-date-range {
    width: 100%;
    display: flex;
    padding: 8px 20px;
    align-items: center;
    justify-content: start;
    font-size: 14px;
    font-weight: 600;
    background-color: var(--gray-10);
    border-bottom: 1px solid var(--gray-30);
    color: var(--gray-70);
    margin-bottom: 10px;
}

#actionbar {
    display: flex;
    justify-content: center;
    column-gap: 10px;
    width: 100%;
    display: flex;
    padding: 8px 20px;
    background-color: var(--gray-10);
    border-top: 1px solid var(--gray-30);
    color: var(--gray-70);
    margin-top: 10px;
}

@keyframes uiSpinInfinite {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.ui-modal-box {
    background: #ffffff;
    border-radius: 8px;
    width: 100%;
    max-width: 750px;
    height: auto;
    max-height: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.alert-scale-modifier .ui-modal-box {
    max-width: 450px;
    height: auto;
}

.modal-layer:not(.alert-scale-modifier) .ui-modal-box:has(.ui-lookup-container) {
    height: 100%;
    max-height: 100%;
}

.ui-modal-header {
    padding: 10px 15px;
    font-size: 1rem;
    font-weight: 600;
    background: #0288d1;
    color: #ffffff;
    cursor: move;
    cursor: grab;
    user-select: none;
}

.ui-modal-header:active {
    cursor: grabbing;
}

.ui-modal-body {
    padding: 0px 15px;
    font-size: 0.95rem;
    color: #333333;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ui-modal-footer {
    padding: 12px 20px;
    background: var(--gray-20);
    border-top: 1px var(--gray-40);
    display: flex;
    justify-content: center;
    gap: 10px;
    /* border-top: 1px solid #eeeeee; */
}

.alert-status-canvas {
    display: flex;
    align-items: center;
    gap: 14px;
}
.alert-status-icon {
    font-size: 1.8rem;
    line-height: 1;
}
.alert-status-text {
    margin: 0;
    font-weight: 500;
}

.ui-dialog-form div {
    margin-bottom: 12px;
}
.ui-dialog-label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
.ui-dialog-input {
    width: 100%;
    padding: 8px 12px;
    /* border: 1px solid #999999; */
    border: 2px solid var(--gray-50);
    outline: none;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 14px;
}

.ui-dialog-input:focus {
    border-color: black;
    box-shadow: var(--form-input-focus-ring);
}

.btn-std-primary,
.btn-std-secondary {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-weight: 500;
    cursor: pointer;
}
.btn-std-primary {
    background: #222222;
    color: #ffffff;
}
.btn-std-secondary {
    background: #e2e8f0;
    color: #333333;
}

.ui-modal-box {
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.ui-modal-box.is-dragging {
    transition: none !important;
}

.ui-modal-box {
    display: none;
}

#globalUIModalContainer {
    max-width: 750px;
    height: auto;
}

#globalUIModalContainer.ui-modal-body {
    min-height: 125px;
}

#globalUiLookupContainer {
    max-width: 95vw;
    max-height: 90vh;
}

.matching-row td {
    color: red !important;
    font-weight: 600;
}

/* Core Modal Wrapper Box */
.date-filter-modal {
    position: absolute;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    width: 80%;
    max-width: 350px;
    background-color: #ffffff;
    font-family: inherit;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    border-radius: 8px;
}
date-filter-modal.active {
    display: flex;
}
/* Gradient Header Strip */
.date-filter-modal .modal-header {
    background: #0288d1;
    color: #ffffff;
    padding: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    cursor: grab;
}

/* Component Body Layout */
.date-modal-body {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 5px 20px;
    row-gap: 8px;
    /* border: 1px solid red; */
}

.date-filter-modal .date-modal-body .action-bar .btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    /* Reset layout box metrics */
    box-sizing: border-box !important;
    line-height: 1 !important;

    /* FORCE RESET PADDING & HEIGHT SYMMETRY */
    height: 30px !important; /* Forces a consistent, clean button thickness */
    padding-top: 0 !important; /* Strips away unequal top padding */
    padding-bottom: 0 !important; /* Strips away unequal bottom padding */
}

@media (max-width: 850px) {
    .ui-modal-box {
        max-width: 1000px !important;
        width: 100% !important;
        height: 100% !important;
        /* max-height: 100%; */
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }

    /* 1. Strip the structural table behavior from the table itself */
    table#ui-lookuptable.ui-lookup-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    /* 2. Hide the header row since the columns are now stacked vertically */
    #ui-lookup-table-thead,
    #uiLookupTheadRow {
        display: none !important;
    }

    /* 3. Turn the tbody wrapper into a block layout */
    #ui-lookup-table-tbody {
        display: block !important;
        width: 100% !important;
    }

    /* 4. Transform rows into individual block cards */
    #ui-lookup-table-tbody tr {
        display: block !important;
        background: var(--gray-10);
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 6px 9px;
        width: 99%;
    }

    .ui-lookup-table tbody .ui-lookup-data-row:hover {
        background-color: gray(--gray-10) !important;
    }

    #ui-lookup-table-tbody tr.redrow {
        background-color: gray(--gray-10) !important;
    }

    /* 5. Force the cells to stack vertically at full width */
    #ui-lookup-table-tbody tr td {
        background-color: white;
        border-radius: 5px;
        margin: 5px 0;
        display: flex;
        /* flex-direction: column; */
        /* align-items: start; */
        justify-content: space-between;
        flex-wrap: wrap;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        padding: 5px 10px !important; /* Replaces 0 padding so text doesn't hug the edge */
        border-bottom: 1px solid var(--gray-25) !important;
        border-right: 1px solid var(--gray-25) !important;

        font-size: 16px;
        font-weight: 600;
        color: var(--gray-80);
        overflow: auto;
        scrollbar-width: thin;
    }

    #ui-lookup-table-tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-60) !important;
        font-size: 13px;
        letter-spacing: 0.5px;
    }

    /* Remove the bottom border from the very last cell inside the card block */
    #ui-lookup-table-tbody tr td:last-child {
        border-bottom: none !important;
    }
}

@media (max-width: 520px) {
    .ui-lookup-data-row {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    .ui-lookup-data-row td:first-child {
        grid-column: span 1;
        border-bottom: 1px dashed #e2e8f0 !important;
    }
}
