/* ===== Sections Grid ===== */
.sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
    width: 100%;
    min-height: 0;
}

/* Let data-module wrappers inside the grid stretch to fill the cell.
   min-height: 0 overrides the grid default (min-height: auto), otherwise
   the cell refuses to shrink below table content and overflow is clipped. */
.sections-grid > [data-module] {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Two-column grid collapses at ≤900px (see responsive.css) */

/* ===== Section ===== */
.section {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-height: 0;
}

.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.section__title {
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

/* Collapsible title: looks like plain text on desktop, becomes an
   expand/collapse switch inside the H5 media query (see responsive.css) */
.section-toggle {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    color: inherit;
    text-align: left;
    cursor: default;
    pointer-events: none;
}

.section-toggle__arrow {
    display: none;
}

.section__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.section__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem 0;
    margin-bottom: 0.625rem;
    align-items: center;
    flex-shrink: 0;
}

.section__filters .chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1;
}

.section__filters .search-wrapper {
    margin-left: auto;
}

/* Overall stats in progress filters */
.progress-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.progress-stat {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.progress-stat strong {
    color: var(--color-text);
    font-weight: 600;
    margin-left: 0.25rem;
}

@media (max-width: 640px) {
    .section__filters .search-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .section__filters .search-input {
        width: 100%;
    }
}

/* ===== H5: page-scroll layout, sections keep internal table scroll ===== */
@media (max-width: 768px) {
    .sections-grid {
        grid-template-rows: none;
        gap: 0.75rem;
        flex: none;
        overflow: visible;
    }

    .sections-grid > [data-module] {
        height: auto;
        overflow: visible;
    }

    .section {
        height: auto;
    }

    .section .table-wrap {
        max-height: 52dvh;
    }

    .section__header {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .section__actions {
        margin-left: auto;
        gap: 0.375rem;
    }

    .section__filters {
        padding: 0.5rem 0.75rem 0;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }
}

/* Full width section */
.section--full {
    width: 100%;
    margin-bottom: 1rem;
}
