/* Shared mobile layout: keep data readable, scroll tables instead of clipping.
   Desktop layouts and collection/business rules are unchanged. */
@media (max-width: 1199.98px) {
    .account-overview .row > div { flex: 0 0 100%; width: 100%; }
    .account-overview .justify-content-end {
        justify-content: flex-start !important;
        flex-wrap: wrap; gap: .75rem; text-align: left;
    }
    .account-overview .account-subtitle { overflow-wrap: anywhere; }
}
@media (max-width: 767.98px) {
    body .norman-chat-bubble {
        top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
        bottom: auto !important;
        right: 12px !important;
        width: 44px !important;
        height: 44px !important;
        z-index: 1040;
        animation: none;
    }
    .main-content {
        min-width: 0;
        padding-top: 5rem !important;
    }
    .main-content .container-fluid,
    .main-content .row > *,
    .main-content .card,
    .main-content .glass-card,
    .main-content details {
        min-width: 0;
        max-width: 100%;
    }
    .main-content :is(.table-responsive, .afs-table-wrap, .programs-scroll, .table-container) {
        min-width: 0;
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }
    .main-content .debt-table {
        width: max-content;
        min-width: 100%;
    }
    .main-content .debt-table :is(th, td) {
        max-width: none;
        overflow: visible;
        text-overflow: clip;
        white-space: nowrap;
        font-size: .875rem;
        padding: .65rem .75rem;
        letter-spacing: normal;
    }
    .main-content .debt-table td:first-child {
        white-space: normal;
        min-width: 5rem;
        max-width: 18rem;
    }
    .main-content table.mobile-stack-ready { display: block; width: 100%; }
    .main-content .mobile-stack-ready thead {
        position: absolute; width: 1px; height: 1px;
        overflow: hidden; clip-path: inset(50%);
    }
    .main-content .mobile-stack-ready tbody { display: block; }
    .main-content .mobile-stack-ready tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .75rem;
        padding: .85rem .25rem;
        border-bottom: 1px solid var(--afs-border, #ddd);
    }
    .main-content .mobile-stack-ready td,
    .main-content .mobile-stack-ready td:first-child {
        display: block; min-width: 0; max-width: none;
        padding: 0; border: 0;
        text-align: left; white-space: normal;
        overflow-wrap: anywhere;
        font-family: inherit;
    }
    .main-content .mobile-stack-ready td::before {
        content: attr(data-label);
        display: block; font-size: .75rem; font-weight: 500;
        color: var(--afs-text-muted, #64748b);
        margin-bottom: .2rem;
    }
    .main-content :is(.debt-info-notice, .debt-summary-card) {
        padding: 1rem !important;
        min-width: 0;
    }
    .main-content #keao-arrangements {
        padding-inline: 0 !important;
    }
    .main-content .keao-arrangement {
        padding: .75rem !important;
    }
    .main-content :is(code, summary, .modal-title) {
        overflow-wrap: anywhere;
    }
    .main-content .mof-debt-card__head {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }
    .main-content .mof-debt-badge { justify-self: start; }
    .main-content h3.mof-debt-card__title {
        font-size: 1rem !important;
        line-height: 1.45 !important;
        overflow-wrap: anywhere;
    }
    .main-content .mof-debt-card__actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }
    .main-content .mof-debt-card__actions .afs-btn {
        min-height: 44px;
        white-space: normal;
        word-break: normal;
        overflow-wrap: normal;
    }
    .modal-dialog { max-width: calc(100% - 1rem); }
    .modal-content { max-height: calc(100dvh - 1rem); }
    .modal-body { overflow: auto; min-width: 0; }
    .modal-footer { flex-wrap: wrap; }
    .main-content :is(input, select, textarea) { max-width: 100%; }
    .ft-wrap { padding-inline: 0; min-width: 0; }
    .ft-wrap .filters { grid-template-columns: minmax(0, 1fr); }
    .ft-wrap .programs-card-header { flex-wrap: wrap; gap: .75rem; }
    /* On phones the funding row becomes a complete card, including columns
       hidden by the older tablet rules. No eligibility actions are removed. */
    .ft-wrap table.programs-table { display: block; min-width: 0; width: 100%; }
    .ft-wrap .programs-table thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
    .ft-wrap .programs-table tbody { display: block; }
    .ft-wrap .programs-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        padding: 1rem;
        border-bottom: 1px solid var(--afs-border, #ddd);
    }
    .ft-wrap .programs-table td {
        display: block;
        max-width: none;
        padding: .4rem 0;
        border: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .ft-wrap .programs-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--afs-text-muted, #64748b);
    }
    .ft-wrap .programs-table .actions-cell {
        position: static;
        box-shadow: none;
    }
    .ft-wrap .actions-cell button { min-height: 44px; width: 100%; white-space: normal; }
}
