/* ================================================================
   MOBILE.CSS  â€“  AMS Portal
   Responsive & Accessibility Overhaul
   Breakpoints: â‰¤768px (general mobile), â‰¤480px (small phone)
   WCAG AA/AAA: min 4.5:1 contrast, 48Ã—48px touch targets, 16px text
   ================================================================ */

/* â”€â”€ ALWAYS HIDDEN (shown only by mobile media queries) â”€â”€ */
.mobile-topbar          { display: none; }
.mobile-tabs            { display: none; }
.mobile-menu-overlay    { display: none; }
.mobile-slide-menu      { display: none; }
.table-scroll-hint      { display: none; }
.timetable-day-view     { display: none; }
.period-card-mobile     { display: none; }
.attendance-student-row-mobile { display: none; }
.day-selector           { display: none; }
.mobile-bottom-nav      { display: none; }

/* â”€â”€ ACTUAL DESKTOP SIDEBAR BECOMES SLIDE-IN ON MOBILE â”€â”€ */
@media (max-width: 990px) {
  body.principal-portal .sidebar,
  body.faculty-portal .sidebar,
  body.student-portal .sidebar,
  body.parent-portal .sidebar,
  .sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    width: 280px !important;
    border-radius: 0 20px 20px 0 !important; /* Elegant rounded corner */
    z-index: 2000 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    visibility: visible !important;
    margin: 0 !important;
  }
  
  body.principal-portal .sidebar.open,
  body.faculty-portal .sidebar.open,
  body.student-portal .sidebar.open,
  body.parent-portal .sidebar.open,
  .sidebar.open {
    transform: translateX(0) !important;
  }

  /* Force the logo to show on mobile (app.css hides it) */
  body.principal-portal .sidebar > div:first-child,
  body.faculty-portal .sidebar > div:first-child,
  body.student-portal .sidebar > div:first-child,
  body.parent-portal .sidebar > div:first-child,
  .sidebar-logo-container {
    display: flex !important;
  }
}

/* ================================================================
   BREAKPOINT: â‰¤768px  (tablets and large phones)
   ================================================================ */
@media (max-width: 990px) {

  /* â”€â”€ BASE TYPOGRAPHY â”€â”€ */
  html {
    font-size: 16px;
    overflow: auto;
  }

  body {
    font-size: 16px !important;
    height: auto !important;
    overflow: auto !important;
    overflow-x: hidden !important;
  }

  /* â”€â”€ SIDEBAR SLIDE OVERRIDE â”€â”€ */
  .sidebar {
    display: flex !important;
  }

  /* â”€â”€ TOPBAR (desktop) HIDE â”€â”€ */
  .topbar {
    display: none !important;
  }

  /* â”€â”€ MAIN CONTENT FULL WIDTH â”€â”€ */
  body.principal-portal .main,
  body.faculty-portal .main,
  body.student-portal .main,
  body.parent-portal .main,
  body .layout .main,
  .main-content,
  .main {
    margin-left: 0 !important;
    padding: 0 !important;
    padding-top: 64px !important;
    padding-bottom: 80px !important;
    width: 100% !important;
    height: auto !important;
    overflow: auto !important;
    overflow-x: hidden !important;
    min-height: calc(100vh - 64px);
  }

  /* â”€â”€ MOBILE TOP NAVBAR â”€â”€ */
  .mobile-topbar {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #9164f3 !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  }

  .mobile-topbar-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: Poppins, sans-serif;
    letter-spacing: 0.3px;
  }

  .mobile-topbar-icons {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  /* 48Ã—48px touch targets on topbar icons */
  .mobile-topbar-icons i {
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-topbar-icons i:active {
    background: rgba(255,255,255,0.15);
  }

  /* â”€â”€ BOTTOM NAVIGATION BAR â”€â”€ */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
    justify-content: space-around;
    align-items: center;
    z-index: 1100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 56px;
    padding: 6px 8px;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 500;
    font-family: Poppins, sans-serif;
    text-decoration: none;
    border-radius: 10px;
    transition: color 0.2s, background 0.2s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    gap: 2px;
  }

  .mobile-bottom-nav-item i {
    font-size: 1.15rem;
    margin-bottom: 2px;
  }

  .mobile-bottom-nav-item.active {
    color: #4f46e5;
    background: #eef2ff;
    font-weight: 700;
  }

  .mobile-bottom-nav-item:active {
    background: #f1f5f9;
  }

  /* â”€â”€ MOBILE SLIDE MENU â”€â”€ */
  .mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 1200;
    backdrop-filter: blur(2px);
  }

  .mobile-menu-overlay.open {
    display: block;
  }

  /* Override the global display:none â€” hidden via transform instead */
  .mobile-slide-menu {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 82% !important;
    max-width: 300px !important;
    height: 100vh !important;
    background: linear-gradient(180deg, #0f2545 0%, #1a3a6b 100%) !important;
    z-index: 1300 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-y: auto !important;
    padding: 24px 0 !important;
    scrollbar-width: none !important;
    /* Portal-specific colours */
    visibility: visible !important;
  }

  .mobile-slide-menu::-webkit-scrollbar {
    display: none;
  }

  /* Only slides in when .open is added by JS */
  .mobile-slide-menu.open {
    transform: translateX(0) !important;
  }

  .mobile-menu-school-name {
    color: #c9a227;
    font-size: 1rem;
    font-weight: 700;
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 8px;
    font-family: Poppins, sans-serif;
  }

  /* 48px minimum touch targets on menu items */
  .mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    min-height: 48px;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    font-family: Poppins, sans-serif;
    cursor: pointer;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-item:hover,
  .mobile-menu-item.active {
    background: rgba(255,255,255,0.08);
    color: #c9a227;
    border-left-color: #c9a227;
  }

  .mobile-menu-item i {
    width: 22px;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
  }

  /* â”€â”€ HORIZONTAL SCROLL TABS (secondary) â”€â”€ */
  .mobile-tabs {
    display: flex !important;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    height: 44px;
    background: white;
    border-bottom: 2px solid #f0f4f8;
    overflow-x: auto;
    z-index: 1090;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-tabs::-webkit-scrollbar {
    display: none;
  }

  /* 48px touch target: height + padding */
  .mobile-tab-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    min-height: 44px;
    padding: 0 16px;
    height: 44px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-family: Poppins, sans-serif;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab-item.active {
    color: #1e293b;
    border-bottom-color: #4f46e5;
    font-weight: 700;
  }

  /* â”€â”€ FORM ROWS STACK â”€â”€ */
  .form-row-2,
  .form-row-3,
  .form-row-4 {
    grid-template-columns: 1fr !important;
  }

  .upload-grid {
    display: flex !important;
    flex-direction: column !important;
  }

  /* â”€â”€ INPUTS â€“ Sleeker height and text size â”€â”€ */
  .form-control,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  select,
  textarea {
    height: 40px !important;
    font-size: 0.85rem !important;
    border-radius: 8px !important;
  }

  textarea {
    height: auto !important;
    min-height: 100px !important;
  }

  /* â”€â”€ BUTTONS â€“ full WCAG touch target â”€â”€ */
  button,
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-outline-primary {
    min-height: 48px !important;
    font-size: 0.95rem !important;
    border-radius: 10px !important;
    -webkit-tap-highlight-color: transparent;
  }

  /* â”€â”€ COMPACT FILTER BUTTONS â€“ override 48px rule â”€â”€ */
  #marksTermFilter .btn,
  .term-tabs .btn {
    min-height: 32px !important;
    height: auto !important;
    font-size: 0.72rem !important;
    padding: 3px 6px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
    overflow: visible !important;
  }

  /* â”€â”€ ACTION BUTTONS STACK â”€â”€ */
  .form-actions {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .form-actions button,
  .form-actions .btn-primary-ams,
  .form-actions .btn-success-ams,
  .form-actions .btn-gold-ams {
    width: 100% !important;
    justify-content: center !important;
    min-height: 48px !important;
  }

  /* â”€â”€ DOWNLOAD BUTTONS WRAP â”€â”€ */
  .download-buttons-group {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  .download-buttons-group button {
    flex: 1 1 calc(50% - 5px) !important;
    justify-content: center !important;
    font-size: 0.82rem !important;
    min-height: 44px !important;
    padding: 10px !important;
  }

  .dl-btn:active, .dl-btn:focus, .dl-btn:hover {
    background: transparent !important;
    box-shadow: none !important;
  }

  .btn-outline-danger:active,
  .btn-outline-danger:focus,
  .btn-outline-danger:hover {
    background: transparent !important;
    color: #dc3545 !important;
  }

  /* â”€â”€ TABLES HORIZONTAL SCROLL â”€â”€ */
  .ams-card {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .ams-table {
    min-width: 580px;
  }

  .table-scroll-hint {
    display: block !important;
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 8px;
    padding: 4px 0;
  }

  /* â”€â”€ AMS CARD â”€â”€ */
  .ams-card {
    padding: 16px !important;
    border-radius: 14px !important;
  }

  /* â”€â”€ STAT CARDS 2 PER ROW â”€â”€ */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .stat-card {
    padding: 14px 12px !important;
  }

  .stat-card .stat-number {
    font-size: 1.5rem !important;
  }

  .stat-card .stat-label {
    font-size: 0.65rem !important;
  }

  /* â”€â”€ PAGE HEADER â”€â”€ */
  .page-header h4 {
    font-size: 1.1rem !important;
  }

  /* â”€â”€ FACULTY CARD GRID 1 COLUMN â”€â”€ */
  .faculty-card-grid {
    grid-template-columns: 1fr !important;
  }

  /* â”€â”€ MODALS â†’ BOTTOM SHEET â”€â”€ */
  .modal-dialog {
    margin: 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .modal-content {
    border-radius: 20px 20px 0 0 !important;
    border: none !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* â”€â”€ TOUCH IMPROVEMENTS â”€â”€ */
  button,
  a,
  .nav-link,
  .mobile-menu-item,
  .mobile-tab-item,
  .mobile-bottom-nav-item {
    -webkit-tap-highlight-color: transparent;
  }

  /* â”€â”€ LOGIN PAGE â”€â”€ */
  .login-wrapper {
    min-height: 100vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
  }

  .login-left {
    display: none !important;
  }

  .login-right {
    width: 100% !important;
    padding: 20px 16px !important;
  }

  .login-card {
    padding: 28px 20px !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px !important;
  }

  #login-page {
    flex-direction: column !important;
    min-height: 100vh;
    padding: 0 !important;
  }

  /* â”€â”€ TIMETABLE DAY VIEW â”€â”€ */
  .timetable-weekly-grid {
    display: none !important;
  }

  .timetable-day-view {
    display: block !important;
  }

  .day-selector {
    display: flex !important;
    overflow-x: auto;
    gap: 8px;
    padding: 8px 0;
    scrollbar-width: none;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .day-selector::-webkit-scrollbar {
    display: none;
  }

  /* 48px touch targets on day buttons */
  .day-btn {
    min-width: 52px;
    min-height: 44px;
    border-radius: 22px;
    border: 1.5px solid #e2e8f0;
    background: white;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    padding: 0 14px;
    font-family: Poppins, sans-serif;
    -webkit-tap-highlight-color: transparent;
  }

  .day-btn.active {
    background: #0f2545;
    color: white;
    border-color: #0f2545;
  }

  .period-card-mobile {
    display: flex !important;
    align-items: center;
    gap: 12px;
    background: white;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #f0f4f8;
  }

  .period-badge-mobile {
    background: #0f2545;
    color: white;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
    flex-shrink: 0;
  }

  .period-details-mobile { flex: 1; }

  .period-subject-mobile {
    font-weight: 700;
    color: #0f2545;
    font-size: 0.92rem;
    margin-bottom: 2px;
  }

  .period-teacher-mobile {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 2px;
  }

  .period-time-mobile {
    font-size: 0.74rem;
    color: #94a3b8;
  }

  /* â”€â”€ ATTENDANCE CARDS â”€â”€ */
  .attendance-student-row-mobile {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }

  .attendance-student-name-mobile {
    font-weight: 700;
    font-size: 0.9rem;
    color: #0f2545;
  }

  .attendance-student-id-mobile {
    font-size: 0.76rem;
    color: #64748b;
  }

  .attendance-buttons-mobile {
    display: flex;
    gap: 6px;
  }

  /* 48px touch on attendance buttons */
  .att-btn-mobile {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
    min-width: 40px;
    font-family: Poppins, sans-serif;
    background: white;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .att-btn-present  { border-color: #1a7a4a; color: #1a7a4a; }
  .att-btn-present.selected { background: #1a7a4a; color: white; }
  .att-btn-absent   { border-color: #c0392b; color: #c0392b; }
  .att-btn-absent.selected  { background: #c0392b; color: white; }
  .att-btn-late     { border-color: #b8860b; color: #b8860b; }
  .att-btn-late.selected    { background: #b8860b; color: white; }

} /* end @media 990px */

/* ================================================================
   BREAKPOINT: â‰¤480px  (phones â€“ primary mobile target)
   Full WCAG AA, thumb-zone UX, progressive disclosure
   ================================================================ */
@media (max-width: 480px) {

  /* â”€â”€ GLOBAL SPACING â”€â”€ */
  .main-content {
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-top: 68px !important;
    padding-bottom: 80px !important;
  }

  /* â”€â”€ TYPOGRAPHY â€“ prevent zoom, ensure readability â”€â”€ */
  body,
  p, span, div, li, td, th,
  .stat-label, .qa-title, .qa-desc,
  .notice-item-text {
    font-size: 15px;
    line-height: 1.6;
  }

  h1 { font-size: 1.4rem !important; }
  h2 { font-size: 1.2rem !important; }
  h3 { font-size: 1.05rem !important; }
  h4 { font-size: 0.95rem !important; }

  /* â”€â”€ WCAG AA: inputs must be â‰¥16px to prevent iOS zoom â”€â”€ */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* â”€â”€ DASHBOARD â€“ Quick Access 2 columns â”€â”€ */
  .quick-access-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: auto !important;
    gap: 10px !important;
  }

  .qa-card {
    border-radius: 14px !important;
    padding: 14px 8px !important;
    min-height: 90px !important;
  }

  .qa-icon-circle {
    width: 46px !important;
    height: 46px !important;
    font-size: 1.15rem !important;
    margin-bottom: 6px !important;
  }

  .qa-title {
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    white-space: normal !important;
    text-align: center;
  }

  .qa-desc {
    font-size: 0.7rem !important;
    text-align: center;
    white-space: normal !important;
  }

  /* â”€â”€ DASHBOARD â€“ Banner â”€â”€ */
  .banner-section,
  .student-banner,
  .welcome-banner {
    border-radius: 16px !important;
    padding: 16px !important;
  }

  .banner-character-wrapper {
    display: none !important;
  }

  .banner-pill {
    font-size: 0.72rem !important;
    padding: 4px 10px !important;
    border-radius: 20px !important;
  }

  /* â”€â”€ DASHBOARD â€“ Extra Cards (teacher/AI) stack â”€â”€ */
  .extra-panel {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .extra-card {
    padding: 14px !important;
  }

  .btn-outline {
    min-height: 48px !important;
    font-size: 0.9rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* â”€â”€ DASHBOARD â€“ Stats grid â”€â”€ */
  .stats-notices-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .stats-group > div {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .stat-card {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .stat-label {
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    color: #475569 !important; /* WCAG AA */
  }

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

  /* â”€â”€ DASHBOARD â€“ Notices â”€â”€ */
  .notice-item-title {
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    color: #1e293b !important;
  }

  .notice-item-text {
    font-size: 0.7rem !important;
    color: #475569 !important; /* WCAG AA */
  }

  /* â”€â”€ TABLE WRAPPER â”€â”€ */
  .modern-table,
  .ams-table,
  table {
    min-width: 540px;
    font-size: 0.82rem !important;
  }

  /* â”€â”€ ACADEMIC PROGRESS â”€â”€ */
  .chart-tab {
    min-height: 40px !important;
    font-size: 0.82rem !important;
    padding: 8px 14px !important;
  }

  /* â”€â”€ CARD HEADERS â”€â”€ */
  .card-header, .card-header-compact {
    padding: 12px 14px !important;
    font-size: 0.9rem !important;
    min-height: auto !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important; 
    gap: 8px !important;
    overflow-x: auto; 
  }
  
  /* Give the title room to breathe and reduce size slightly */
  .card-header-compact > div:first-child,
  .card-header-compact > div:first-child span,
  .card-header-compact > div:first-child i {
    font-size: 0.7rem !important;
    white-space: nowrap !important;
    font-weight: 600 !important;
  }
  
  /* Force inner button wrappers to stay on same line */
  .card-header-compact > div:nth-child(2),
  .card-header-compact #exportBtnsHost {
    flex-wrap: nowrap !important;
    height: auto !important;
    gap: 6px !important;
    justify-content: flex-end !important;
  }
  
  /* Convert buttons to compact size on mobile but keep text visible */
  .card-header-compact .ams-btn-export,
  .card-header-compact button,
  .ams-btn-export {
    min-height: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    padding: 0 10px !important;
  }
  
  /* Keep icons visible and correctly sized */
  .card-header-compact button i,
  .ams-btn-export i {
    font-size: 1rem !important; /* Icon size */
    margin-right: 4px !important; /* Spacing between icon and text */
  }

  /* â”€â”€ FILTER BUTTONS â”€â”€ */
  .filter-btn,
  [id^="btn"],
  .btn-sm {
    min-height: 40px !important;
    font-size: 0.7rem !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
  }

  /* â”€â”€ MARKS / SCORECARD FILTERS â”€â”€ */
  #marksTermFilter,
  #marksTermFilter .btn {
    min-height: 32px !important;
    font-size: 0.72rem !important;
  }

  /* â”€â”€ FEES PAGE â”€â”€ */
  .fees-summary-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* â”€â”€ PAGINATION â”€â”€ */
  .pagination .page-link {
    min-width: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.85rem !important;
  }

  /* â”€â”€ MODAL BOTTOM SHEET â”€â”€ */
  .modal-content {
    padding: 20px 16px !important;
  }

  /* â”€â”€ NOTICES PAGE â”€â”€ */
  .notice-card,
  .notice-list-item {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  /* â”€â”€ TIMETABLE â”€â”€ */
  .period-card-mobile {
    min-height: 64px;
  }

  /* â”€â”€ EXAM SCHEDULE â”€â”€ */
  .exam-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  /* â”€â”€ PROFILE / PERSONAL DETAILS â”€â”€ */
  .profile-avatar-area {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  /* â”€â”€ PROGRESS CIRCLES â”€â”€ */
  .progress-circle {
    width: 56px !important;
    height: 56px !important;
  }

  /* â”€â”€ LAYOUT CONTAINERS â”€â”€ */
  .layout, .main-layout {
    flex-direction: column !important;
  }

  /* â”€â”€ SUMMARY STATS (overview cards) â”€â”€ */
  .overview-stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .overview-stat-card {
    padding: 14px 12px !important;
    border-radius: 14px !important;
  }

  .overview-stat-val {
    font-size: 1.4rem !important;
    font-weight: 900 !important;
    color: #1e293b !important;
  }

  .overview-stat-label {
    font-size: 0.65rem !important;
    color: #475569 !important;
  }

  /* â”€â”€ ATTENDANCE TRACKER HEATMAP â”€â”€ */
  .heatmap-cell {
    width: 7px !important;
    height: 7px !important;
  }

  /* â”€â”€ SCROLL CONTAINERS â”€â”€ */
  .heatmap-wrapper,
  .scroll-x-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .heatmap-wrapper::-webkit-scrollbar,
  .scroll-x-wrap::-webkit-scrollbar {
    display: none;
  }

  /* â”€â”€ TOP HEADER COMPACT â”€â”€ */
  .top-header {
    padding: 0 12px !important;
    height: 56px !important;
  }

  .top-header .page-title {
    font-size: 1rem !important;
  }

  /* â”€â”€ USER AVATAR (topbar) â”€â”€ */
  .user-avatar-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }

  /* â”€â”€ BREADCRUMB â”€â”€ */
  .breadcrumb {
    font-size: 0.65rem !important;
    padding: 6px 0 !important;
  }

  /* â”€â”€ PANEL/CARD TITLES â”€â”€ */
  .panel-title, .card-title, .section-title {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
  }

  /* â”€â”€ FULL-WIDTH BUTTONS â”€â”€ */
  .btn-block-mobile {
    width: 100% !important;
    min-height: 48px !important;
    justify-content: center !important;
  }

  /* â”€â”€ FOOTER â”€â”€ */
  .app-footer, .footerSchool {
    font-size: 0.72rem !important;
    padding: 12px !important;
    text-align: center !important;
    flex-direction: column !important;
    gap: 2px !important;
  }

} /* end @media 480px */

/* ================================================================
   BREAKPOINT: â‰¤360px  (very small phones like Galaxy A series)
   ================================================================ */
@media (max-width: 360px) {

  .quick-access-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .qa-card {
    padding: 10px 6px !important;
    min-height: 80px !important;
  }

  .qa-icon-circle {
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem !important;
  }

  .qa-title {
    font-size: 0.72rem !important;
  }

  .mobile-bottom-nav-item {
    min-width: 44px !important;
    font-size: 0.6rem !important;
    padding: 4px !important;
  }

  .mobile-bottom-nav-item i {
    font-size: 1rem !important;
  }

} /* end @media 360px */

/* ================================================================
   ACCESSIBILITY HELPERS (global, not media-query-scoped)
   ================================================================ */

/* Focus-visible ring for keyboard navigation */
:focus-visible {
  outline: 3px solid #4f46e5;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip to main content link */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  background: #4f46e5;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-to-content:focus {
  top: 8px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ================================================================
   TABLE RESPONSIVENESS FIXES
   ================================================================ */
@media (max-width: 990px) {
  .table-responsive {
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Force text not to wrap in small cells */
  .modern-table th,
  .modern-table td {
    white-space: nowrap !important;
  }

  /* Make tables scrollable even if missing the wrapper */
  table.modern-table {
    display: table !important;
    width: max-content !important;
    min-width: 100% !important;
  }
}

/* ================================================================
   ACCESSIBILITY & USABILITY FIXES
   ================================================================ */
@media (max-width: 990px) {
  /* Enforce 48px min touch target on main interactive elements */
  select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  .form-control,
  .form-select,
  .btn-primary,
  .btn-secondary,
  .ams-btn-export,
  .ams-btn-save {
    min-height: 48px !important;
    font-size: 16px !important; /* Prevents iOS auto-zoom */
  }

  /* Modals should take up most of screen on mobile */
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100% - 1rem) !important;
  }
}

/* --- COMPACT ACTION BUTTONS (Datatables & Headers) --- */
@media (max-width: 990px) {
  .ams-btn-export,
  #exportBtnsHost .dt-button,
  .dt-buttons .btn,
  .dt-buttons .dt-button,
  #openAddStuBtn,
  #openAddFacBtn,
  .ams-action-btn {
    padding: 0 !important;
    width: 34px !important;
    height: 34px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
  }
  
  #exportBtnsHost .btn i,
  #exportBtnsHost .dt-button i,
  .ams-btn-export i,
  .dt-buttons .btn i,
  .dt-buttons .dt-button i,
  #openAddStuBtn i,
  #openAddFacBtn i,
  .ams-action-btn i {
    font-size: 1.15rem !important;
    margin: 0 !important;
  }

  .btn-text {
    display: none !important;
  }
}