/* Keep intrinsic table/form widths inside the workspace, not the viewport. */
.app-shell,
.app-shell > *,
.dashboard-content > *,
.app-shell form,
.app-shell .table-card,
.app-shell .table-scroll,
.app-shell .form-card,
.app-shell .profile-card,
.app-shell .metric-card,
.app-shell .billing-card {
    min-width: 0;
}

.app-shell {
    width: 100%;
}

.app-shell .dashboard-content {
    grid-template-columns: minmax(0, 1fr);
}

.app-shell .table-scroll {
    /* Contain absolutely positioned screen-reader labels inside wide tables. */
    position: relative;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.mobile-menu-toggle,
.coach-mobile-attendance-shortcut {
    display: none;
}

.mobile-nav-panel {
    display: contents;
}

.attendance-contact > summary {
    display: none;
}

.attendance-contact strong,
.attendance-contact small {
    display: block;
    overflow-wrap: anywhere;
}

.attendance-contact small {
    margin-top: .25rem;
    color: var(--slate-500);
}

.attendance-toggle input:focus-visible + .attendance-button {
    outline: 3px solid var(--blue-600);
    outline-offset: 3px;
}

@media (max-width: 900px) {
    .member-application-list {
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    .member-application-list .data-table {
        display: block;
        min-width: 0;
    }

    .member-application-list thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .member-application-list tbody {
        display: grid;
        gap: 1rem;
    }

    .member-application-list tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .75rem;
        padding: 1rem;
        border: 1px solid var(--slate-200);
        border-radius: 1rem;
        background: var(--white);
    }

    .member-application-list .data-table td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .member-application-list td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: .2rem;
        color: var(--slate-500);
        font-size: .75rem;
        font-weight: 600;
    }

    .member-application-list .member-application-identity > strong {
        font-size: 1rem;
    }

    .member-application-list .data-table .member-application-actions {
        padding-top: .75rem;
        border-top: 1px solid var(--slate-200);
    }

    .member-application-list .table-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
        gap: .5rem;
    }

    .member-application-list .table-actions .button {
        width: 100%;
        min-height: 2.75rem;
        white-space: normal;
    }

    .member-application-list .status-badge {
        max-width: 100%;
        white-space: normal;
    }

    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        /* Keep short pages below the menu; leave spare viewport space at the bottom. */
        align-content: start;
        min-height: 100dvh;
    }

    .app-shell > .sidebar.mobile-navigation-ready {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        align-self: start;
        min-height: 0;
        gap: .75rem;
        padding: .75rem max(1rem, env(safe-area-inset-right)) .75rem max(1rem, env(safe-area-inset-left));
        position: sticky;
        top: 0;
        z-index: 80;
    }

    .mobile-navigation-ready > .wordmark {
        min-width: 0;
        width: fit-content;
    }

    .mobile-navigation-ready .brand-logo {
        width: min(9.5rem, 100%);
        max-width: 100%;
        height: auto;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .5rem;
        min-height: 44px;
        border: 1px solid rgb(255 255 255 / 30%);
        border-radius: .7rem;
        padding: .55rem .7rem;
        color: var(--white);
        background: rgb(255 255 255 / 8%);
        font-size: .875rem;
        font-weight: 700;
        cursor: pointer;
    }

    .mobile-menu-toggle:focus-visible {
        outline: 3px solid #8bd9ff;
        outline-offset: 3px;
    }

    .mobile-menu-toggle svg {
        width: 1.2rem;
        height: 1.2rem;
        flex: 0 0 auto;
    }

    .mobile-navigation-ready > .mobile-nav-panel {
        display: grid;
        position: absolute;
        top: 100%;
        inset-inline: 0;
        gap: 1rem;
        min-width: 0;
        background: var(--navy-950);
        border-bottom: 1px solid rgb(255 255 255 / 20%);
        box-shadow: 0 1rem 2rem rgb(7 22 47 / 20%);
        max-height: 70vh;
        max-height: min(70dvh, calc(100dvh - 6rem));
        overflow-y: auto;
        overscroll-behavior-y: contain;
        padding: .5rem max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left));
    }

    .mobile-nav-panel .nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .mobile-nav-panel .nav-item {
        min-width: 0;
        min-height: 44px;
        overflow-wrap: anywhere;
    }

    .mobile-nav-panel .user-menu {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .8rem;
        margin: 0;
        width: 100%;
        padding-top: 1rem;
        border-top: 1px solid rgb(255 255 255 / 20%);
        color: var(--white);
    }

    .mobile-nav-panel .user-menu > div {
        max-width: 100%;
        text-align: left;
    }

    .mobile-nav-panel .workspace-switcher label {
        color: #c9d6e6;
    }

    .mobile-nav-panel .workspace-switcher select {
        width: 100%;
        max-width: 100%;
    }

    .mobile-nav-panel .language-switcher {
        width: fit-content;
        max-width: 100%;
        margin-top: 0;
    }

    .app-shell .topbar {
        min-height: 0;
        padding: 1rem;
        gap: 1rem;
    }

    .app-shell .topbar h1 {
        margin: 0;
        font-size: 1.3rem;
        line-height: 1.3;
    }

    .app-shell .dashboard-content {
        gap: 1rem;
        padding: 1rem;
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

    .app-shell .page-actions,
    .app-shell .form-footer,
    .app-shell .pagination {
        flex-wrap: wrap;
        gap: .75rem;
    }

    .app-shell .button,
    .app-shell .billing-button,
    .app-shell .language-switcher__item,
    .app-shell .club-section-tabs > a {
        min-height: 44px;
    }

    .app-shell input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    .app-shell select,
    .app-shell textarea {
        min-width: 0;
        max-width: 100%;
        font-size: 16px;
    }

    .app-shell .field input:not([type="checkbox"]):not([type="radio"]),
    .app-shell select {
        min-height: 44px;
    }

    .app-shell .status-badge {
        max-width: 100%;
        white-space: normal;
    }

    .app-shell .profile-card > div,
    .app-shell .member-identity > div {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 620px) {
    .app-shell .filter-bar,
    .app-shell .form-grid,
    .app-shell .club-profile-grid,
    .app-shell .club-settings-grid,
    .app-shell .weekly-schedule__item,
    .app-shell .review-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-shell .form-card {
        padding: 1rem;
    }

    .app-shell .attendance-date-nav {
        width: 100%;
        max-width: 100%;
        min-height: 0;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
    }

    .attendance-date-nav .attendance-date-nav__arrow {
        min-width: 44px;
        width: 44px;
        min-height: 44px;
    }

    .attendance-date-nav .attendance-date-nav__date {
        min-width: 0;
        padding: .85rem .25rem;
        overflow-wrap: anywhere;
    }

    .attendance-date-nav .attendance-date-nav__date strong {
        font-size: clamp(1.05rem, 5vw, 1.4rem);
    }

    .table-card.attendance-card {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .attendance-card > .table-scroll {
        overflow: visible;
    }

    .attendance-table,
    .attendance-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .attendance-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .attendance-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "member" "controls" "contact";
        gap: .75rem;
        margin-bottom: .75rem;
        border: 1px solid var(--slate-200);
        border-radius: 1rem;
        padding: 1rem;
        background: var(--white);
    }

    .attendance-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .attendance-table tbody td {
        display: block;
        min-width: 0;
        width: 100%;
        padding: 0;
        border: 0;
    }

    .attendance-table .attendance-member { grid-area: member; }
    .attendance-table .attendance-controls { grid-area: controls; }
    .attendance-table .attendance-contact-cell { grid-area: contact; }

    .attendance-table .member-identity {
        min-width: 0;
        align-items: flex-start;
    }

    .attendance-table .member-identity .text-link {
        font-size: 1rem;
        line-height: 1.4;
    }

    .attendance-table .attendance-toggle {
        display: grid;
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
        margin: 0;
        padding: 0;
    }

    .attendance-table .attendance-option,
    .attendance-table .attendance-button {
        width: 100%;
        min-width: 0;
    }

    .attendance-table .attendance-button {
        min-height: 48px;
        padding: .65rem .4rem;
        font-size: .95rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .attendance-contact > summary {
        display: list-item;
        min-height: 44px;
        padding-block: .65rem;
        color: var(--blue-600);
        font-weight: 650;
        cursor: pointer;
    }

    .attendance-contact > summary:focus-visible {
        outline: 3px solid var(--blue-600);
        outline-offset: 2px;
    }
}

/* Keep the coach's daily actions reachable without horizontal table scrolling. */
@media (max-width: 900px) {
    .coach-mobile-attendance-shortcut {
        display: flex;
        width: 100%;
    }

    #coach-training-groups {
        scroll-margin-top: 5.5rem;
    }
}

@media (max-width: 620px) {
    .app-shell .coach-group-card {
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .app-shell .coach-group-table,
    .app-shell .coach-athlete-table,
    .coach-group-table tbody,
    .coach-athlete-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .coach-group-table thead,
    .coach-athlete-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .coach-group-table tbody tr,
    .coach-athlete-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .6rem;
        padding: 1rem;
        background: var(--white);
    }

    .coach-group-table tbody tr {
        border: 1px solid var(--slate-200);
        border-radius: 1rem;
        margin-bottom: .75rem;
    }

    .coach-group-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .coach-athlete-table tbody tr + tr {
        border-top: 1px solid var(--slate-200);
    }

    .coach-group-table tbody td,
    .coach-athlete-table tbody td {
        display: block;
        width: 100%;
        height: auto;
        min-width: 0;
        border: 0;
        padding: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .coach-group-table td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--slate-500);
    }

    .coach-group-table td:first-child strong,
    .coach-athlete-table .member-identity a {
        font-size: 1rem;
        line-height: 1.4;
    }

    .coach-athlete-table .member-identity,
    .coach-athlete-contact {
        min-width: 0;
    }

    .coach-athlete-table .member-identity a {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .coach-athlete-contact a {
        display: flex;
        align-items: center;
        min-height: 44px;
        overflow-wrap: anywhere;
    }

    .coach-group-table .table-actions .button,
    .coach-athlete-table .table-actions .button {
        width: 100%;
        min-height: 44px;
        margin: .25rem 0 0;
    }
}
