/* ============================================================
   MOBILE.CSS — Authoritative responsive overrides
   Load this LAST in every page's <head>
   ============================================================ */

/* ════════════════════════════════════════════
   0. GLOBAL MOBILE FOUNDATIONS
   ════════════════════════════════════════════ */

/* Prevent elastic overscroll on iOS pulling the page accidentally */
html {
    overscroll-behavior-y: contain;
}

/* Momentum-based scroll for iOS in scrollable containers */
.sidebar-nav,
.split-view,
.table-wrapper,
.fee-table-wrap,
.marksheet-wrapper,
.admitcard-wrapper,
.monthly-table-wrap,
.history-table-wrap {
    -webkit-overflow-scrolling: touch;
}

/* Remove 300ms tap delay on all interactive elements */
a, button, [role="button"], input, select, textarea, label {
    touch-action: manipulation;
}

/* ════════════════════════════════════════════
   1. SIDEBAR + HAMBURGER (all pages)
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%) !important;
        box-shadow: none !important;
    }
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 6px 0 32px rgba(0,0,0,0.2) !important;
    }

    /* Smooth momentum scroll inside sidebar nav */
    .sidebar-nav {
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }

    .main-wrapper { margin-left: 0 !important; }

    .btn-hamburger {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: fixed !important;
        top: 8px !important; left: 8px !important;
        /* Respect iOS safe area left (notch landscape) */
        left: max(8px, calc(8px + env(safe-area-inset-left))) !important;
        top: max(8px, calc(8px + env(safe-area-inset-top))) !important;
        z-index: 1101 !important;
        width: 42px !important; height: 42px !important;
        font-size: 20px !important;
        background: white !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
        /* KEY FIX: always clickable even when parent has pointer-events:none */
        pointer-events: auto !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
        /* Active tap feedback */
        transition: background 0.1s, transform 0.1s !important;
    }
    .btn-hamburger:active {
        background: #f1f5f9 !important;
        transform: scale(0.93) !important;
    }

    .btn-close-sidebar {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 8px !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
        transition: background 0.1s !important;
    }
    .btn-close-sidebar:active {
        background: rgba(255,255,255,0.12) !important;
    }

    .topbar { padding: 0 16px 0 62px !important; }
    /* Respect iOS notch for topbar */
    .topbar {
        padding-top: env(safe-area-inset-top) !important;
        padding-left: max(62px, calc(54px + env(safe-area-inset-left))) !important;
    }

    /* Overlay: A real <div> injected by shared.js covers the content area
       when the sidebar is open. It dims the background and — critically —
       clicking it closes the sidebar. The hamburger (z-index 1101) stays
       above the overlay (z-index 999) and remains fully clickable at all
       times because we no longer set pointer-events:none on main-wrapper. */
    .main-wrapper.sidebar-open {
        filter: none !important;  /* Override any inline filter on individual pages */
    }
    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.18);
        z-index: 999; /* Below sidebar (1000) and hamburger (1101) */
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    .mobile-sidebar-overlay.active {
        display: block;
        animation: _fadeInOverlay 0.25s ease;
    }
    @keyframes _fadeInOverlay {
        from { opacity: 0; }
        to   { opacity: 1; }
    }

    /* Body scroll lock — class toggled by shared.js */
    body.sidebar-body-lock {
        overflow: hidden !important;
        /* Prevent content jump when scrollbar disappears */
        padding-right: 0 !important;
    }

    .page-body { padding: 14px !important; gap: 14px !important; }

    /* Active tap state for nav links */
    .nav-link:active {
        background: rgba(255,255,255,0.1) !important;
    }
    .nav-link.active:active {
        background: rgba(59,130,246,0.25) !important;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 82% !important;
        max-width: 280px !important;
        /* Include iOS safe area on left side */
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
    .topbar  { height: 52px !important; }
    .btn-hamburger { top: 6px !important; left: 6px !important; width: 38px !important; height: 38px !important; }
}

/* Bottom navigation bar removed */

/* ════════════════════════════════════════════
   3. HORIZONTAL SCROLL FADE HINTS
   Shows gradient when table overflows right
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Wrap is positioned relative; the fade is a pseudo-element overlay */
    .table-wrapper,
    .fee-table-wrap,
    .marksheet-wrapper,
    .admitcard-wrapper,
    .monthly-table-wrap,
    .history-table-wrap,
    .tt-wrap,
    .entry-table-container {
        position: relative !important;
    }

    /* Right-side fade — shows there's more content to scroll */
    .table-wrapper::after,
    .fee-table-wrap::after,
    .marksheet-wrapper::after,
    .monthly-table-wrap::after,
    .tt-wrap::after,
    .entry-table-container::after {
        content: '' !important;
        position: sticky !important;
        right: 0 !important;
        top: 0 !important;
        width: 32px !important;
        min-height: 100% !important;
        background: linear-gradient(to left, rgba(255,255,255,0.9), transparent) !important;
        pointer-events: none !important;
        float: right !important;
        display: block !important;
        z-index: 2 !important;
    }
}

/* ════════════════════════════════════════════
   4. TOPBAR CONTENT
   ════════════════════════════════════════════ */
@media (max-width: 600px) {
    .topbar-title { font-size: 13px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
    .topbar-right { flex-shrink: 0; }
    .ctx-bar-label { display: none !important; }
    .ctx-bar-info  { padding: 6px 8px !important; gap: 4px !important; }
    .ctx-bar-sep   { margin: 0 5px !important; }
    .ctx-bar-edit  { padding: 0 9px !important; min-height: 32px !important; }
    .ctx-dropdown  { right: -8px !important; min-width: 260px !important; }
}

/* ════════════════════════════════════════════
   5. DASHBOARD
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .stats-row     { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .features-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
    .hero       { padding: 20px 16px !important; border-radius: 12px !important; }
    .hero h1    { font-size: 20px !important; }
    .hero p     { font-size: 13px !important; }
    .stat-card  { padding: 14px !important; gap: 10px !important; }
    .stat-value { font-size: 22px !important; }
    .stat-icon  { width: 36px !important; height: 36px !important; font-size: 18px !important; }
    .feature-card { padding: 16px 14px !important; gap: 12px !important; }
    .feature-card-arrow { display: none !important; }
}

/* ════════════════════════════════════════════
   6. ADMIN PAGE
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
    .admin-layout, .page-body.admin-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
    .form-grid-2  { grid-template-columns: 1fr !important; }
    .form-grid-4  { grid-template-columns: 1fr 1fr !important; }
    .item-actions { flex-wrap: wrap !important; gap: 6px !important; }
    .item-actions .btn { flex: 1; min-width: 80px; justify-content: center; }
}
@media (max-width: 480px) {
    .form-grid-4 { grid-template-columns: 1fr !important; }
}

/* ════════════════════════════════════════════
   7. STUDENTS PAGE
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
    .split-view    { flex-direction: column !important; height: auto !important; }
    .class-panel   { width: 100% !important; height: auto !important; max-height: 200px !important; border-right: none !important; border-bottom: 1px solid #e2e8f0 !important; flex-shrink: 0 !important; }
    .student-panel { height: auto !important; flex: 1 !important; }
    .student-panel-toolbar { padding: 10px 14px !important; flex-wrap: wrap !important; gap: 8px !important; }
    .search-box    { flex: 1 !important; min-width: 0 !important; }
    .search-box input { width: 100% !important; }
}
@media (max-width: 520px) {
    .class-panel  { max-height: 150px !important; }
    .class-item   { padding: 8px 10px !important; font-size: 12.5px !important; }
    .srp-name     { font-size: 13px !important; }
    .srp-meta     { font-size: 11px !important; }
    .table-wrapper{ padding: 10px !important; }
    .col-section  { display: none !important; }
}

/* ════════════════════════════════════════════
   8. MARKS ENTRY PAGE
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
    .filter-row, .toolbar-row { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
    .toolbar-group { width: 100% !important; }
    .field         { flex: 1 1 100% !important; }
    .grid-header   { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
    .entry-table-container { margin: 0 !important; border-radius: 8px !important; }
    .quick-actions-toolbar { padding: 10px !important; gap: 8px !important; }
    .nav-hint      { display: none !important; }
}
@media (max-width: 768px) {
    .entry-table th, .entry-table td { padding: 5px 3px !important; font-size: 12px !important; }
    .student-cell  { min-width: 90px !important; max-width: 90px !important; }
    .roll-cell     { width: 34px !important; min-width: 34px !important; }
    .mark-input    { width: 46px !important; font-size: 11px !important; padding: 3px 2px !important; }
    .subject-header{ min-width: 74px !important; font-size: 10.5px !important; }
    .copy-btn      { display: none !important; }
    .att-input     { width: 46px !important; }
}
@media (max-width: 480px) {
    .entry-table th, .entry-table td { padding: 4px 2px !important; font-size: 10.5px !important; }
    .student-cell  { min-width: 72px !important; max-width: 72px !important; }
    .roll-cell     { width: 28px !important; min-width: 28px !important; }
    .mark-input    { width: 38px !important; font-size: 10px !important; }
}

/* ════════════════════════════════════════════
   9. MARKSHEET PAGE
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
    .control-panel  { padding: 0 14px !important; }
    .cp-row         { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
    .cp-group       { width: 100% !important; }
    .cp-group select, .cp-group input { width: 100% !important; }
    .cp-actions     { margin-left: 0 !important; width: 100% !important; display: flex !important; gap: 8px !important; }
    .cp-actions .btn{ flex: 1 !important; justify-content: center !important; }
    .preview-area   { padding: 14px !important; }
}
@media (max-width: 680px) {
    .marksheet-wrapper { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .marksheet         { min-width: 580px !important; }
}

/* ════════════════════════════════════════════
   10. ADMIT CARD PAGE
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
    .admitcard-layout, .admit-layout { flex-direction: column !important; }
    .admit-controls { width: 100% !important; max-width: none !important; }
    .admit-preview  { width: 100% !important; }
    .cp-row         { flex-wrap: wrap !important; gap: 10px !important; }
    .cp-group       { flex: 1 1 45% !important; }
    .cp-group select, .cp-group input { width: 100% !important; }
}
@media (max-width: 520px) {
    .cp-group      { flex: 1 1 100% !important; }
    .admitcard-wrapper { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .admitcard     { min-width: 460px !important; }
}

/* ════════════════════════════════════════════
   11. BILLING PAGE
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
    .billing-layout { grid-template-columns: 1fr !important; }
    .filter-bar     { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
    .filter-group   { width: 100% !important; }
    .filter-input, .filter-select { width: 100% !important; }
}
@media (max-width: 768px) {
    .summary-row    { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .fee-table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .fee-table      { min-width: 560px !important; }
    .fee-table th, .fee-table td { padding: 8px 9px !important; font-size: 12.5px !important; }
    .receipt-actions { flex-direction: column !important; }
    .receipt-actions .btn { width: 100% !important; justify-content: center !important; }
}
@media (max-width: 480px) {
    .summary-row { grid-template-columns: 1fr 1fr !important; }
    .sum-card    { padding: 12px !important; }
    .sum-val     { font-size: 18px !important; }
    .fee-table   { min-width: 480px !important; }
    .fee-table th, .fee-table td { padding: 6px 7px !important; font-size: 11.5px !important; }
}

/* ════════════════════════════════════════════
   12. CALENDAR PAGE
   ════════════════════════════════════════════ */
@media (max-width: 1100px) {
    .cal-layout    { grid-template-columns: 1fr !important; }
    .event-sidebar { display: none !important; }
}
@media (max-width: 768px) {
    .cal-header    { flex-wrap: wrap !important; gap: 8px !important; padding: 12px 14px !important; }
    .cal-nav       { width: 100% !important; justify-content: center !important; order: 2 !important; }
    .cal-today-btn { margin-left: auto !important; }
    .cal-month-label { font-size: 15px !important; min-width: 150px !important; }
    .cal-nav-btn   { width: 38px !important; height: 38px !important; }
    .cal-day       { min-height: 56px !important; padding: 5px 2px 3px !important; }
    .day-num       { font-size: 12px !important; width: 22px !important; height: 22px !important; }
    .day-ad        { display: none !important; }
    .cal-event     { font-size: 9px !important; padding: 1px 3px !important; }
}
@media (max-width: 480px) {
    .cal-header    { padding: 10px !important; }
    .cal-month-label { font-size: 14px !important; min-width: 130px !important; }
    .cal-weekday   { font-size: 9px !important; padding: 6px 1px !important; letter-spacing: 0 !important; }
    .cal-day       { min-height: 46px !important; padding: 4px 2px 2px !important; }
    .day-num       { font-size: 11px !important; width: 20px !important; height: 20px !important; }
    .day-event-chip, .cal-event { display: none !important; }
    .day-more      { font-size: 9px !important; }
    .cal-nav-btn   { width: 34px !important; height: 34px !important; }
}

/* ════════════════════════════════════════════
   13. SCHOOL INFO PAGE
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
    .info-layout   { grid-template-columns: 1fr !important; flex-direction: column !important; }
}
@media (max-width: 768px) {
    .logo-upload   { flex-direction: row !important; align-items: flex-start !important; gap: 14px !important; }
    .logo-preview  { width: 80px !important; height: 80px !important; flex-shrink: 0 !important; }
    .info-section  { padding: 16px !important; }
}

/* ════════════════════════════════════════════
   14. PROFILE PAGE
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
    .section-grid  { grid-template-columns: 1fr !important; }
    .detail-grid   { grid-template-columns: 1fr !important; }
    .hero-stats    { display: none !important; }
    .hero-actions  { gap: 8px !important; flex-wrap: wrap !important; }
    .hero-actions .btn { flex: 1 !important; justify-content: center !important; min-width: 120px !important; }
}
@media (max-width: 600px) {
    .hero-card     { flex-direction: column !important; align-items: flex-start !important; gap: 14px !important; padding: 16px !important; }
    .form-row      { grid-template-columns: 1fr !important; }
    .history-table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .history-table { min-width: 480px !important; }
}

/* ════════════════════════════════════════════
   15. MODALS
   ════════════════════════════════════════════ */
@media (max-width: 600px) {
    .modal-content  { width: 96% !important; max-height: 88vh !important; margin: 0 !important; }
    .modal-footer   { flex-direction: column-reverse !important; }
    .modal-footer .btn { width: 100% !important; justify-content: center !important; }
    .cm-box         { width: 96% !important; }
    .cm-footer      { flex-direction: column-reverse !important; }
    .cm-btn         { width: 100% !important; text-align: center !important; }
    #appModalBox    { width: 95% !important; padding: 20px !important; }
    #appModalActions { flex-direction: column-reverse !important; }
    #appModalActions button { width: 100% !important; }
    .modal-box      { max-height: 88vh !important; overflow-y: auto !important; }
    .form-grid      { grid-template-columns: 1fr !important; }
    .form-group.full { grid-column: 1 !important; }
}

/* ════════════════════════════════════════════
   16. GENERIC TABLES
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .table          { font-size: 13px !important; }
    .table th, .table td { padding: 9px 10px !important; }
    .table-actions  { gap: 5px !important; }
    .table-actions .btn-sm { padding: 5px 9px !important; font-size: 12px !important; }
}

/* ════════════════════════════════════════════
   17. GENERIC FORMS
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .form-actions   { flex-direction: column !important; }
    .form-actions .btn { width: 100% !important; justify-content: center !important; }
    .form-row       { grid-template-columns: 1fr !important; }
    .content        { padding: 16px !important; }
    .content-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
    .content-header h1 { font-size: 22px !important; }
}

/* ════════════════════════════════════════════
   18. TOUCH DEVICE IMPROVEMENTS
   ════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    .btn            { min-height: 44px !important; }
    .btn-sm         { min-height: 38px !important; }
    .nav-link       { min-height: 44px !important; }
    /* 16px prevents iOS auto-zoom on input focus */
    .form-control, select.form-control,
    input[type="text"], input[type="number"],
    input[type="email"], input[type="tel"],
    input[type="date"], textarea,
    .filter-input, .filter-select { font-size: 16px !important; }
    /* Disable hover transforms on touch — they stick after tap */
    .btn:hover, .feature-card:hover, .stat-card:hover { transform: none !important; }
    /* Instead, use active state for tap feedback */
    .btn:active     { transform: scale(0.97) !important; }
    .feature-card:active { transform: scale(0.99) !important; box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important; }
}

/* ════════════════════════════════════════════
   19. LANDSCAPE PHONE
   ════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar-nav  { padding: 6px 8px !important; }
    .nav-link     { padding: 6px 10px !important; font-size: 12px !important; min-height: 36px !important; }
    .topbar       { height: 46px !important; }
    .sidebar-header { padding: 12px 14px !important; }
    /* Smaller bottom nav in landscape */
    .main-wrapper { padding-bottom: 0 !important; }
}

/* ════════════════════════════════════════════
   20. PRINT SAFETY
   ════════════════════════════════════════════ */
@media print {
    .sidebar, .btn-hamburger, .topbar, .ctx-widget, .no-print,
    .main-wrapper { margin-left: 0 !important; padding-bottom: 0 !important; }
}

/* ════════════════════════════════════════════
   21. TIMETABLE PAGE
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
    .filter-card   { flex-wrap: wrap !important; gap: 8px !important; }
    .filter-group  { flex: 1 1 45% !important; min-width: 120px !important; }
    .tt-header     { flex-direction: column !important; align-items: flex-start !important; }
    .periods-row   { flex-wrap: wrap !important; }
}
@media (max-width: 768px) {
    .toolbar .filter-group { flex: 1 1 100% !important; min-width: 0 !important; }
    .day-tabs  { flex-wrap: wrap !important; }
    .day-tab   { flex: 1 1 auto !important; text-align: center !important; padding: 6px 8px !important; font-size: 12px !important; }
    .period-config-head { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
    .tt-wrap   { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .tt-table  { min-width: 520px !important; }
    .slot-subject { font-size: 11px !important; }
    .slot-teacher { font-size: 10px !important; }
    .slot-meta    { display: none !important; }
}
@media (max-width: 680px) {
    .tt-wrap       { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .tt-table      { min-width: 560px !important; }
    .filter-group  { flex: 1 1 100% !important; }
    .period-controls { padding: 12px 14px !important; }
}
@media (max-width: 480px) {
    .day-tab   { padding: 5px 6px !important; font-size: 11px !important; }
    .tt-table  { min-width: 440px !important; }
    .tt-table thead th.class-hdr { min-width: 80px !important; width: 80px !important; }
    .class-cell-name  { font-size: 11.5px !important; }
    .period-hdr-time  { display: none !important; }
    .tt-table th, .tt-table td { padding: 4px !important; }
    .tt-cell       { min-height: 54px !important; padding: 4px 6px !important; }
    .tt-cell-subject { font-size: 11.5px !important; }
    .tt-cell-teacher { font-size: 10px !important; }
    .tt-cell-time  { display: none !important; }
}

/* ════════════════════════════════════════════
   22. ATTENDANCE PAGE
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
    .register-table-wrap { display: none !important; }
    .student-cards       { display: flex !important; }
    .att-summary         { gap: 6px !important; }
    .register-header     { flex-direction: column !important; align-items: flex-start !important; }
}
@media (max-width: 992px) {
    .filter-card   { padding: 12px 14px !important; }
    .filter-row    { flex-wrap: wrap !important; gap: 8px !important; }
    .filter-group  { flex: 1 1 45% !important; min-width: 120px !important; }
    .filter-group.grow { flex: 1 1 100% !important; }
    .tab-bar       { width: 100% !important; }
    .tab-btn       { flex: 1 !important; padding: 8px 10px !important; font-size: 12px !important; }
}
@media (max-width: 768px) {
    .tab-bar   { width: 100% !important; }
    .tab-btn   { flex: 1 !important; padding: 8px 6px !important; font-size: 12px !important; text-align: center !important; }
    .filter-row { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
    .filter-group { width: 100% !important; }
    .filter-group input, .filter-group select { width: 100% !important; box-sizing: border-box !important; }
    .register-date-nav { flex-wrap: wrap !important; gap: 6px !important; }
    .att-summary { flex-wrap: wrap !important; }
}
@media (max-width: 480px) {
    .filter-group  { flex: 1 1 100% !important; }
    .stu-card      { padding: 10px 12px !important; }
    .stu-card-name { font-size: 13px !important; }
    .status-btn    { width: 32px !important; height: 32px !important; font-size: 14px !important; }
    .att-badge     { font-size: 11px !important; padding: 3px 9px !important; }
    .monthly-table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .monthly-table      { min-width: 480px !important; }
    .tab-btn   { font-size: 11px !important; padding: 7px 4px !important; }
}

/* ════════════════════════════════════════════
   23. BILLING PAGE (additional)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .filter-bar     { flex-direction: column !important; align-items: stretch !important; }
    .filter-bar .filter-group { width: 100% !important; }
    .filter-bar .filter-input,
    .filter-bar .filter-select { width: 100% !important; box-sizing: border-box !important; }
    .billing-panel-toolbar { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
    .toolbar-actions { width: 100% !important; flex-wrap: wrap !important; }
    .toolbar-actions .btn { flex: 1 1 auto !important; justify-content: center !important; min-width: 0 !important; }
    .student-search-wrap { width: 100% !important; }
    .student-search-input { width: 100% !important; box-sizing: border-box !important; }
    .btn-generate { width: 100% !important; justify-content: center !important; }
}
@media (max-width: 480px) {
    .summary-row { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
    .sum-value   { font-size: 17px !important; }
    .sum-label   { font-size: 11px !important; }
    .sum-card    { padding: 12px 14px !important; }
}

/* ════════════════════════════════════════════
   24. SUBJECTS PAGE
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .toolbar   { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
    .toolbar .filter-group { width: 100% !important; }
    .toolbar .filter-group select { width: 100% !important; }
    .toolbar-right { margin-left: 0 !important; width: 100% !important; display: flex !important; }
    .toolbar-right .btn { flex: 1 !important; justify-content: center !important; }
}
@media (max-width: 600px) {
    .card { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .table { min-width: 400px !important; }
    .table th:nth-child(4),
    .table td:nth-child(4),
    .table th:nth-child(5),
    .table td:nth-child(5) { display: none !important; }
}

/* ════════════════════════════════════════════
   25. TEACHERS PAGE
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .teacher-grid  { grid-template-columns: 1fr !important; }
    .stats-row     { grid-template-columns: repeat(3, 1fr) !important; }
    .toolbar     { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
    .search-box  { max-width: none !important; width: 100% !important; }
    .search-box input { width: 100% !important; }
    .toolbar-right { justify-content: flex-start !important; flex-wrap: wrap !important; gap: 6px !important; }
    .toolbar-right .btn { flex: 1 1 auto !important; justify-content: center !important; }
}
@media (max-width: 480px) {
    .stats-row     { grid-template-columns: 1fr 1fr !important; }
    .tc-header     { gap: 10px !important; }
    .tc-avatar     { width: 44px !important; height: 44px !important; font-size: 18px !important; }
    .tc-name       { font-size: 13.5px !important; }
    .tc-actions    { gap: 4px !important; }
    .toolbar       { flex-direction: column !important; align-items: stretch !important; }
    .search-box    { max-width: none !important; }
    .toolbar-right { justify-content: flex-end !important; }
}

/* ════════════════════════════════════════════
   26. ADMIN PAGE (additional)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .panel-stats { grid-template-columns: repeat(2,1fr) !important; }
}
@media (max-width: 480px) {
    .panel-stats { grid-template-columns: 1fr 1fr !important; }
    .item-actions .btn { font-size: 11px !important; padding: 5px 8px !important; }
    .inline-form { flex-direction: column !important; align-items: stretch !important; }
}

/* ════════════════════════════════════════════
   27. MARKSHEET & ENTRY (additional)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
    .cp-row     { flex-wrap: wrap !important; gap: 8px !important; }
    .cp-group   { flex: 1 1 45% !important; min-width: 0 !important; }
    .cp-group.lg select, .cp-group.lg input,
    .cp-group.md select, .cp-group.md input,
    .cp-group.sm select, .cp-group.sm input { width: 100% !important; }
    .cp-actions { margin-left: 0 !important; width: 100% !important; display: flex !important; gap: 8px !important; }
    .cp-actions .btn { flex: 1 !important; justify-content: center !important; }
    .card-action-bar { flex-wrap: wrap !important; gap: 6px !important; }
    .card-action-bar .btn { flex: 1 1 auto !important; justify-content: center !important; min-width: 0 !important; }
    .filter-row  { flex-wrap: wrap !important; gap: 8px !important; }
    .field       { flex: 1 1 45% !important; min-width: 0 !important; }
    .quick-actions-toolbar { flex-wrap: wrap !important; gap: 8px !important; padding: 10px 12px !important; }
    .quick-actions-toolbar .btn { flex: 1 1 auto !important; justify-content: center !important; }
    .toolbar-row { flex-wrap: wrap !important; gap: 8px !important; }
}
@media (max-width: 480px) {
    .cp-group   { flex: 1 1 100% !important; }
    .preview-area { padding: 12px !important; }
    .field       { flex: 1 1 100% !important; }
    .grid-header { flex-direction: column !important; align-items: flex-start !important; gap: 6px !important; }
    .preview-area { padding: 12px 8px !important; overflow-x: auto !important; align-items: flex-start !important; }
    .card-wrapper { max-width: 100% !important; overflow-x: auto !important; }
}

/* ════════════════════════════════════════════
   28. PROFILE HERO (additional)
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
    .hero-actions { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; width: 100% !important; }
    .btn-hero     { flex: 1 !important; justify-content: center !important; min-width: 120px !important; }
}
@media (max-width: 480px) {
    .hero-card  { padding: 16px !important; gap: 12px !important; }
    .hero-avatar { width: 64px !important; height: 64px !important; font-size: 28px !important; }
    .hero-name  { font-size: 18px !important; }
    .hero-meta  { font-size: 12px !important; gap: 8px !important; }
    .section-card { padding: 14px !important; }
    .detail-label { font-size: 10px !important; }
    .detail-value { font-size: 13px !important; }
}

/* ════════════════════════════════════════════
   29. SCHOOL INFO (additional)
   ════════════════════════════════════════════ */
@media (max-width: 600px) {
    .logo-upload-area { flex-direction: column !important; align-items: flex-start !important; gap: 12px !important; }
    .info-section  { padding: 14px 12px !important; }
    .info-section h2 { font-size: 14px !important; }
    .preview-panel { padding: 14px !important; }
}

/* ════════════════════════════════════════════
   30. STUDENTS (very small screens)
   ════════════════════════════════════════════ */
@media (max-width: 400px) {
    .class-panel   { max-height: 130px !important; }
    .student-panel-toolbar .btn span { display: none !important; }
}

/* ════════════════════════════════════════════
   31. VERY SMALL SCREENS
   ════════════════════════════════════════════ */
@media (max-width: 360px) {
    .topbar { padding: 0 8px 0 52px !important; height: 50px !important; }
    .topbar-title { font-size: 12px !important; }
    .ctx-bar-info { padding: 5px 8px !important; }
    .ctx-bar-value { font-size: 11.5px !important; }
    .ctx-bar-edit  { padding: 0 8px !important; font-size: 11px !important; }
    .page-body { padding: 10px 8px !important; gap: 10px !important; }
}
@media (max-width: 480px) {
    .page-body { padding: 10px 8px !important; gap: 10px !important; }
}