html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
}

.school-header {
    position: sticky;
    top: 0;
    z-index: 50;
}

.school-main {
    display: flex !important;
    align-items: flex-start !important;
    gap: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 12px 20px !important;
}

.school-sidebar {
    flex: 0 0 176px !important;
    width: 176px !important;
    min-width: 176px !important;
    position: sticky !important;
    top: 96px;
    max-height: calc(100vh - 108px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 14px !important;
    align-self: flex-start;
    z-index: 20;
}

.school-sidebar::-webkit-scrollbar {
    width: 6px;
}

.school-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.school-sidebar-item {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    line-height: 1.2;
    white-space: normal;
}

.school-content {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 10px !important;
}

.school-content > * {
    max-width: 100%;
}

.page-title,
.page-title-bar,
.content-section,
.exam-form-card,
.teachers-table,
.students-table,
.exams-table,
.table-container {
    max-width: 100%;
}

.teachers-table,
.students-table,
.exams-table,
.table-container {
    overflow-x: auto;
}

.form-row,
.stats-row,
.stats-circles,
.quick-access-grid,
.plans-grid,
.overview-grid,
.cards-grid {
    min-width: 0;
}

@media (max-width: 900px) {
    .school-header {
        position: relative;
    }

    .school-main {
        flex-direction: column !important;
        padding: 0 10px 18px !important;
    }

    .school-sidebar {
        position: relative !important;
        top: auto;
        width: 100% !important;
        min-width: 0 !important;
        flex: 0 0 auto !important;
        max-height: none;
        overflow: visible;
        padding-right: 0 !important;
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
        gap: 8px;
        margin-bottom: 12px;
    }

    .school-content {
        width: 100% !important;
        padding: 0 !important;
    }
}

@media (max-width: 640px) {
    .school-header {
        margin: 8px;
        padding: 14px 16px;
    }

    .school-name {
        font-size: 18px !important;
    }

    .form-row,
    .stats-row,
    .stats-circles {
        flex-direction: column !important;
        gap: 12px !important;
    }
}
