@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-dark: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #334155;
    --danger: #ef4444;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

/* ========================================= */
/* ============ DESKTOP SIDEBAR ============ */
/* ========================================= */

.sidebar {
    width: 280px;
    min-width: 280px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.nav-links a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-links a:hover, .nav-links a.active {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

/* ========================================= */
/* ============= MAIN CONTENT ============== */
/* ========================================= */

.main-content {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    min-width: 0;
}

.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
}

/* ========================================= */
/* ============= CARDS & FORMS ============= */
/* ========================================= */

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

/* ========================================= */
/* ================ TABLES ================= */
/* ========================================= */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* Table wrapper with horizontal scroll */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    border-radius: 0.5rem;
}

.table-responsive table {
    margin-top: 0;
    min-width: 600px;
}

/* ========================================= */
/* ============= GRID UTILITIES ============ */
/* ========================================= */

.grid-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.grid-cols-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-cols-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }

@media (max-width: 1024px) {
    .grid-container { grid-template-columns: 1fr; }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-2-1 { grid-template-columns: 1fr; }
}

/* ========================================= */
/* ================ MODALS ================= */
/* ========================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-overlay.open {
    display: flex;
}

.payment-modal {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

/* ========================================= */
/* ===== MOBILE HAMBURGER / DRAWER ========= */
/* ========================================= */

/* Hidden on desktop — only shown via media query */
.mobile-topbar {
    display: none;
}

/* Drawer hidden on desktop entirely */
.sidebar-drawer {
    display: none;
}

/* Overlay hidden on desktop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1200;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Hamburger button — hidden on desktop */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    border-radius: 0.4rem;
    transition: background 0.2s;
    flex-shrink: 0;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.28s ease, opacity 0.2s ease;
}

/* ========================================= */
/* ============= MOBILE STYLES ============= */
/* ========================================= */

@media (max-width: 768px) {

    /* --- Reset layout --- */
    html, body {
        height: auto !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        min-height: 100vh;
        max-width: 100vw;
    }

    body {
        display: block !important;
        flex-direction: unset !important;
    }

    .app-wrapper {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* --- Hide desktop sidebar --- */
    .sidebar {
        display: none !important;
    }

    /* --- Show mobile top bar --- */
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.85rem 1rem;
        background-color: var(--surface);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 900;
        width: 100%;
    }

    .mobile-topbar .brand {
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--primary);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0;
    }

    /* --- Show hamburger button --- */
    .hamburger-btn {
        display: flex;
    }

    .hamburger-btn:hover {
        background: rgba(255, 255, 255, 0.07);
    }

    /* Animate to X when open */
    .hamburger-btn.open span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .hamburger-btn.open span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    .hamburger-btn.open span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* --- Overlay --- */
    .sidebar-overlay.visible {
        display: block;
    }

    /* --- Slide-in drawer --- */
    .sidebar-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: -290px;
        width: 270px;
        height: 100%;
        height: 100dvh;
        background-color: var(--surface);
        border-right: 1px solid var(--border);
        padding: 1.5rem 1.25rem;
        z-index: 1300;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }

    .sidebar-drawer.open {
        left: 0;
    }

    .sidebar-drawer .brand {
        font-size: 1.2rem;
        font-weight: 700;
        color: var(--primary);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 1.75rem;
        padding-left: 0.25rem;
    }

    .sidebar-drawer .nav-links {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
    }

    .sidebar-drawer .nav-links a {
        display: block;
        color: var(--text-secondary);
        text-decoration: none;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        margin-bottom: 0;
        font-weight: 500;
        font-size: 0.95rem;
        transition: all 0.2s;
    }

    .sidebar-drawer .nav-links a:hover,
    .sidebar-drawer .nav-links a.active {
        background-color: rgba(79, 70, 229, 0.12);
        color: var(--primary);
    }

    /* --- Main content on mobile --- */
    .main-content {
        display: block !important;
        padding: 1rem !important;
        height: auto !important;
        min-height: unset !important;
        overflow: visible !important;
        flex-direction: unset !important;
        width: 100% !important;
    }

    /* --- Scrollable areas on mobile (attendance, rooms etc.) --- */
    .att-scroll,
    .rooms-scroll-wrapper {
        overflow: visible !important;
        height: auto !important;
        min-height: unset !important;
        padding: 0 1rem 1rem !important;
        flex: unset !important;
    }

    .att-top,
    .rooms-top {
        padding: 1rem !important;
        flex-shrink: unset !important;
    }

    /* --- Page header --- */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .page-header button,
    .page-header a {
        width: auto;
    }

    .header-logout-btn {
        align-self: flex-start;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .card {
        padding: 1.25rem;
    }

    /* --- Tables: card layout on mobile (no horizontal scroll) --- */
    .table-responsive {
        overflow-x: visible !important;
        overflow: visible !important;
        width: 100% !important;
        margin-top: 0.5rem;
    }

    .table-responsive table {
        min-width: 0 !important;
        width: 100% !important;
    }

    /* Kill any inline overflow-x:auto wrappers */
    div[style*="overflow-x: auto"],
    div[style*="overflow-x:auto"] {
        overflow-x: visible !important;
        overflow: visible !important;
    }

    table {
        width: 100%;
    }

    thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 0.75rem;
        margin-bottom: 1rem;
        padding: 0.25rem;
        position: relative;
    }

    td {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        position: relative;
        padding: 0.75rem 1rem 0.75rem 45% !important;
        text-align: right !important;
        min-height: 2.5rem;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        word-break: break-word;
    }

    td:last-child {
        border-bottom: none !important;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        color: var(--text-secondary);
        text-align: left;
        max-width: 40%;
        white-space: nowrap;
    }

    /* --- Grids collapse to single column on mobile --- */
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2,
    .grid-cols-2-1,
    .grid-container {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Override inline grid styles */
    div[style*="grid-template-columns: repeat(4"] { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }
    div[style*="grid-template-columns: repeat(3"] { grid-template-columns: 1fr !important; gap: 1rem !important; }
    div[style*="grid-template-columns: 2fr 1fr"]  { grid-template-columns: 1fr !important; gap: 1rem !important; }
    div[style*="grid-template-columns: repeat(2"] { grid-template-columns: 1fr 1fr !important; gap: 0.75rem !important; }
    div[style*="grid-template-columns: 1fr 1fr"]  { grid-template-columns: 1fr 1fr !important; }
    div[style*="grid-template-columns: 1fr 1fr 1fr"] { grid-template-columns: 1fr !important; gap: 1rem !important; }

    /* --- Fee table specific --- */
    .fee-table-container {
        max-height: none !important;
        overflow: visible !important;
        overflow-x: auto !important;
    }

    /* --- Attendance pill buttons --- */
    .pill-group {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .pill-btn {
        flex: 1 1 calc(33.33% - 0.5rem);
        padding: 0.75rem 0.5rem !important;
        justify-content: center;
        font-size: 0.8rem !important;
    }

    .student-cell {
        justify-content: flex-end;
    }

    /* --- Student item grid --- */
    .student-item {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
        position: relative;
    }

    .student-item > div:last-child {
        justify-content: flex-start !important;
        margin-top: 0.5rem;
    }

    /* --- Report header hidden on mobile print preview --- */
    .report-header {
        display: none !important;
    }

    /* --- Stat grids on attendance/fees --- */
    .stat-cards,
    .stat-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    /* --- Controls row on attendance --- */
    .controls-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .controls-row .form-group {
        max-width: 100% !important;
    }

    .controls-row > div:last-child {
        margin-left: 0 !important;
        flex-wrap: wrap;
    }

    /* --- Attendance grid --- */
    .att-grid {
        grid-template-columns: 1fr !important;
    }

    /* --- Filter bar on fees --- */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .filter-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .search-box-wrap {
        max-width: 100% !important;
    }

    /* --- Modal padding on mobile --- */
    .payment-modal {
        padding: 1.5rem;
        border-radius: 1rem;
    }
}

@media (max-width: 480px) {
    .grid-cols-4 { grid-template-columns: 1fr 1fr !important; }
    div[style*="grid-template-columns: repeat(4"] { grid-template-columns: 1fr 1fr !important; }

    .stat-cards,
    .stat-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    .page-title {
        font-size: 1.2rem;
    }
}

/* =========================================================
   GLOBAL MOBILE TABLE → CARD LAYOUT
   Applies to ALL pages. No horizontal scrollbar anywhere.
   ========================================================= */
@media (max-width: 768px) {

    /* 1. Kill any inline overflow-x: auto wrapper divs */
    div[style*="overflow-x: auto"],
    div[style*="overflow-x:auto"] {
        overflow: visible !important;
        overflow-x: visible !important;
    }

    /* 2. Table wrapper: no scroll */
    .table-responsive {
        overflow: visible !important;
        overflow-x: visible !important;
        width: 100% !important;
    }

    /* 3. Table itself: block, full width, no min-width */
    .table-responsive table,
    .table-responsive table[style],
    table {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        border: none !important;
    }

    /* 4. thead hidden (labels come from data-label) */
    thead, thead tr {
        display: none !important;
        position: static !important;
    }

    /* 5. tbody, tr, td all block */
    tbody {
        display: block !important;
        width: 100% !important;
    }

    tr {
        display: block !important;
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        border-radius: 0.85rem !important;
        margin-bottom: 0.85rem !important;
        padding: 0 !important;
        overflow: hidden !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    tr:hover td {
        background: transparent !important;
    }

    td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.6rem 1rem !important;
        border-bottom: 1px solid rgba(255,255,255,0.05) !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        text-align: right !important;
        font-size: 0.875rem !important;
        min-height: unset !important;
        position: static !important;
        width: 100% !important;
        box-sizing: border-box !important;
        word-break: break-word !important;
    }

    td:last-child {
        border-bottom: none !important;
        padding-bottom: 0.75rem !important;
    }

    /* data-label pseudo-element as left label */
    td::before {
        content: attr(data-label) !important;
        font-size: 0.7rem !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        color: var(--text-secondary) !important;
        letter-spacing: 0.05em !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        margin-right: 0.75rem !important;
        position: static !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        max-width: none !important;
        text-align: left !important;
    }

    /* Action / button cells: centred, no label */
    td[data-label="Action"],
    td[data-label="Actions"] {
        justify-content: center !important;
        padding: 0.75rem 1rem !important;
        background: rgba(255,255,255,0.015) !important;
    }

    td[data-label="Action"]::before,
    td[data-label="Actions"]::before {
        display: none !important;
    }

    /* Row number cell — hidden on mobile */
    td[data-label="#"] {
        display: none !important;
    }

    /* Buttons inside action cells — full width */
    td[data-label="Action"] button,
    td[data-label="Actions"] button,
    td[data-label="Action"] a,
    td[data-label="Actions"] a {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
    }

    /* Student cell stays left-aligned flex */
    .student-cell,
    td[data-label="Student"] .student-cell {
        justify-content: flex-start !important;
        text-align: left !important;
    }

    /* Student name cell: full-width header style */
    td[data-label="Student"] {
        justify-content: flex-start !important;
        text-align: left !important;
        background: rgba(79,70,229,0.05) !important;
        border-bottom: 1px solid rgba(255,255,255,0.06) !important;
        padding: 0.85rem 1rem !important;
        gap: 0.75rem !important;
    }

    td[data-label="Student"]::before {
        display: none !important;
    }
}

/* =====================================================
   GLOBAL MOBILE OVERFLOW FIX — No horizontal scroll
   ===================================================== */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

@media (max-width: 768px) {

    /* Guarantee nothing exceeds viewport width */
    *, *::before, *::after {
        max-width: 100vw;
        box-sizing: border-box;
    }

    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    /* Main content: full width, no side overflow */
    .main-content {
        width: 100% !important;
        padding: 0.85rem !important;
        overflow-x: hidden !important;
    }

    /* Page header: stack on small screens */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    /* ── Reports page: stack grid vertically ── */
    .reports-grid {
        display: block !important;
    }

    .student-selector-card {
        height: auto !important;
        max-height: 260px !important;
        position: static !important;
        margin-bottom: 1rem !important;
        width: 100% !important;
    }

    .report-content {
        width: 100% !important;
    }

    /* Report controls: stack vertically */
    .report-controls {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: flex-start !important;
    }

    .range-controls {
        width: 100% !important;
        justify-content: space-between !important;
    }

    /* Summary grid: 2×2 */
    .summary-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.6rem !important;
    }

    .summary-card {
        padding: 0.85rem !important;
    }

    /* Calendar: fit 7 columns in viewport */
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 0.2rem !important;
        overflow-x: hidden !important;
    }

    .calendar-day {
        font-size: 0.65rem !important;
        border-radius: 0.25rem !important;
        aspect-ratio: 1/1;
    }

    .calendar-day-label {
        font-size: 0.6rem !important;
        padding-bottom: 0.25rem !important;
    }

    /* ── System Insights: single column ── */
    .stats-report-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Report section full width */
    .report-section {
        width: 100% !important;
    }

    /* chart-card full width */
    .chart-card {
        padding: 1rem !important;
        border-radius: 0.75rem !important;
    }
}

/* ╔═══════════════════════════════════════════════════╗
   ║  GLOBAL MOBILE FIX — ALL PAGES                   ║
   ║  No horizontal scroll. Full-width content.        ║
   ╚═══════════════════════════════════════════════════╝ */

html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

@media (max-width: 768px) {

    /* ── Core layout ── */
    html, body {
        width: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .app-wrapper {
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .main-content {
        width: 100% !important;
        padding: 0.85rem !important;
        overflow-x: hidden !important;
        min-width: 0 !important;
    }

    /* ── Page header: stack vertically ── */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.6rem !important;
        margin-bottom: 1rem !important;
        flex-wrap: wrap !important;
    }

    .page-header > * {
        width: 100% !important;
    }

    /* ── Inline flex controls in header: wrap ── */
    div[style*="display: flex"][style*="gap: 1rem"] {
        flex-wrap: wrap;
    }

    /* ── Fee page stat grid: 2×2 ── */
    .stat-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.6rem !important;
        margin-bottom: 1rem !important;
    }

    .stat-card-premium {
        padding: 0.9rem !important;
        border-radius: 0.85rem !important;
    }

    .stat-value-large {
        font-size: 1.3rem !important;
    }

    /* ── Filter bar: stack ── */
    .filter-bar {
        flex-direction: column !important;
        gap: 0.6rem !important;
        padding: 0.75rem !important;
    }

    .filter-tabs {
        width: 100% !important;
        flex-wrap: wrap !important;
        overflow-x: visible !important;
    }

    .filter-tab {
        flex: 1 1 auto !important;
        text-align: center !important;
        font-size: 0.78rem !important;
        padding: 0.45rem 0.5rem !important;
    }

    .search-box-wrap {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* ── Fee table: full height, no scroll ── */
    .fee-table-container {
        max-height: none !important;
        overflow: visible !important;
    }

    /* ── System insights grid: 1 column ── */
    .stats-report-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    /* ── Reports: stack vertically ── */
    .reports-grid {
        display: block !important;
    }

    .student-selector-card {
        height: auto !important;
        max-height: 240px !important;
        position: static !important;
        width: 100% !important;
        margin-bottom: 0.85rem !important;
    }

    /* ── Report controls: stack ── */
    .report-controls {
        flex-direction: column !important;
        gap: 0.6rem !important;
        align-items: flex-start !important;
        padding: 0.85rem !important;
    }

    .range-controls {
        width: 100% !important;
        justify-content: space-between !important;
    }

    /* ── Summary stats: 2×2 ── */
    .summary-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.6rem !important;
    }

    .summary-val {
        font-size: 1.4rem !important;
    }

    /* ── Calendar: no overflow ── */
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 0.18rem !important;
        overflow: hidden !important;
    }

    .calendar-day {
        font-size: 0.6rem !important;
        border-radius: 0.2rem !important;
    }

    .calendar-day-label {
        font-size: 0.55rem !important;
    }

    /* ── Rooms & Allocations: single column ── */
    .rooms-grid,
    .allocations-grid {
        grid-template-columns: 1fr !important;
    }

    /* ── Modals: full-width on mobile ── */
    .payment-modal,
    .profile-modal,
    .modal-box {
        width: calc(100vw - 2rem) !important;
        max-width: calc(100vw - 2rem) !important;
        margin: 1rem auto !important;
        padding: 1.25rem !important;
        border-radius: 1rem !important;
    }

    /* ── Form controls: full width ── */
    .form-group,
    .form-control,
    select.form-control {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* ── Buttons in header: full width ── */
    .page-header .btn {
        width: 100% !important;
        justify-content: center !important;
    }
}
