@media (max-width: 1180px) {
  #site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
  }
  .header-wrapper {
    position: relative;
    width: 100%;
    background: #FFFFFF;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
  }
  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #FFFFFF;
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
    border-bottom: 4px solid var(--primary-gold, #ECB438);
    border-radius: 0 0 16px 16px;
    gap: 0.75rem;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  .nav-menu.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
  }
  .nav-link {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #F1F5F9;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0F172A;
  }
  .nav-link:hover, .nav-link.active {
    color: var(--primary-gold-dark, #C4911E);
    background: #F8FAFC;
    border-radius: 6px;
    padding-left: 0.75rem;
  }
  .nav-link.active::after {
    display: none;
  }
  .nav-actions {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  .nav-actions .btn {
    width: 100%;
    justify-content: center;
    font-weight: 700;
  }
  .mobile-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    color: var(--primary-navy, #0F172A);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .mobile-toggle:hover {
    background: var(--primary-navy, #0F172A);
    color: var(--primary-gold, #ECB438);
    border-color: var(--primary-navy, #0F172A);
  }
}
@media (max-width: 1024px) {
  .portal-layout, .admin-layout {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
  }
  .portal-sidebar, .admin-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 270px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 1050 !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.35) !important;
  }
  .portal-sidebar.active, .admin-sidebar.active,
  .portal-sidebar.mobile-open, .admin-sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .sidebar-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(11, 17, 32, 0.65) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 1040 !important;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .sidebar-overlay.active {
    display: block !important;
    opacity: 1 !important;
  }
  .portal-main, .admin-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    min-height: 100vh !important;
  }
}
@media (max-width: 720px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    font-size: 15px;
  }
  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }
  h1, .h1 { font-size: clamp(1.5rem, 5.5vw, 1.85rem) !important; line-height: 1.25 !important; }
  h2, .h2 { font-size: clamp(1.3rem, 4.8vw, 1.6rem) !important; line-height: 1.28 !important; }
  h3, .h3 { font-size: clamp(1.1rem, 4vw, 1.3rem) !important; }
  h4, .h4 { font-size: clamp(0.95rem, 3.5vw, 1.1rem) !important; }
  .top-bar {
    display: none !important;
  }
  .navbar {
    height: 64px !important;
    padding: 0 !important;
  }
  .brand-logo {
    height: 42px !important;
    max-height: 42px !important;
  }
  .brand-title {
    font-size: clamp(0.9rem, 4vw, 1.1rem) !important;
    white-space: nowrap !important;
  }
  .brand-tagline {
    font-size: 0.65rem !important;
    letter-spacing: 0.3px !important;
  }
  .hero {
    padding: 2rem 0 3rem 0 !important;
  }
  .hero-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    text-align: center !important;
    width: 100% !important;
  }
  .hero-content {
    max-width: 100% !important;
    width: 100% !important;
  }
  .hero-desc {
    font-size: 0.92rem !important;
    line-height: 1.5 !important;
    margin-bottom: 1.25rem !important;
  }
  .hero-actions {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.65rem !important;
    align-items: stretch !important;
    margin-bottom: 1.5rem !important;
  }
  .hero-actions .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.65rem 1rem !important;
    font-size: 0.88rem !important;
  }
  .hero-stats {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
    margin-top: 1.25rem !important;
    padding-top: 1.25rem !important;
  }
  .stat-number {
    font-size: 1.45rem !important;
  }
  .stat-label {
    font-size: 0.75rem !important;
  }
  .grid-2, .grid-3, .grid-4, .grid-5, .footer-grid,
  .stats-grid, .overview-grid, .category-grid,
  [style*="grid-template-columns:repeat(5"], [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns:repeat(4"], [style*="grid-template-columns: repeat(4"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    width: 100% !important;
  }
  .card, .feature-card, .stat-card, .event-card, .news-card, .testimonial-card {
    padding: 1.1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .admin-content, .portal-content {
    padding: 0.85rem !important;
    margin-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .admin-topbar, .portal-topbar, .topbar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 56px !important;
    padding: 0.65rem 0.85rem !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 90 !important;
    background: #FFFFFF !important;
    border-bottom: 1px solid #E2E8F0 !important;
    gap: 0.5rem !important;
  }
  .admin-topbar > div, .portal-topbar > div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  .admin-mobile-toggle, .portal-mobile-toggle, .mobile-menu-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.3rem !important;
    background: transparent !important;
    border: none !important;
    color: var(--primary-navy, #0B1120) !important;
    cursor: pointer !important;
    padding: 0.35rem !important;
    border-radius: var(--radius-sm, 6px) !important;
  }
  .students-action-bar, .teachers-action-bar, .staff-action-bar, .archives-search-bar, .attendance-mark-bar, .attendance-audit-bar, .salary-action-bar, .fees-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
  .students-filter-group, .teachers-filter-group, .attendance-filter-group, .attendance-audit-filters, .attendance-action-btns, .salary-filter-group, .salary-action-btns, .fees-filter-group, .fees-pills-group {
    flex-direction: column !important;
    max-width: 100% !important;
    width: 100% !important;
    gap: 0.65rem !important;
  }
  .students-filter-group input,
  .students-filter-group select,
  .students-add-btn,
  .teachers-filter-group input,
  .teachers-filter-group select,
  .teachers-add-btn,
  .archives-search-bar input,
  .archives-refresh-btn,
  .attendance-filter-group input,
  .attendance-filter-group select,
  .attendance-audit-filters input,
  .attendance-audit-filters select,
  .attendance-action-btns .btn,
  .attendance-refresh-btn,
  .salary-filter-group input,
  .salary-filter-group select,
  .salary-action-btns .btn,
  .salary-generate-btn,
  .fees-filter-group input,
  .fees-filter-group select,
  .fees-generate-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    justify-content: center !important;
  }
  .view-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  .view-tabs .tab-btn {
    flex: 1 1 100% !important;
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }
  .category-pills {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    margin-bottom: 1.25rem !important;
  }
  .category-pills .pill-btn {
    flex: 1 1 auto !important;
    text-align: center !important;
    justify-content: center !important;
  }
  .filter-bar, .table-toolbar, .search-bar, .header-actions, .action-bar {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.65rem !important;
    width: 100% !important;
  }
  .filter-bar select, .filter-bar input, .filter-bar .btn,
  .table-toolbar select, .table-toolbar input, .table-toolbar .btn,
  .custom-select-wrapper, .custom-select-trigger, .form-control,
  [style*="width:230px"]:not(.founder-dp-wrapper), [style*="width: 230px"]:not(.founder-dp-wrapper),
  [style*="width:220px"]:not(.founder-dp-wrapper), [style*="width: 220px"]:not(.founder-dp-wrapper),
  [style*="width:200px"]:not(.founder-dp-wrapper), [style*="width: 200px"]:not(.founder-dp-wrapper),
  [style*="width:190px"]:not(.founder-dp-wrapper), [style*="width: 190px"]:not(.founder-dp-wrapper),
  [style*="width:180px"]:not(.founder-dp-wrapper), [style*="width: 180px"]:not(.founder-dp-wrapper),
  [style*="width:160px"]:not(.founder-dp-wrapper), [style*="width: 160px"]:not(.founder-dp-wrapper),
  [style*="max-width:280px"]:not(.founder-dp-wrapper), [style*="max-width: 280px"]:not(.founder-dp-wrapper),
  [style*="max-width:400px"]:not(.founder-dp-wrapper), [style*="max-width: 400px"]:not(.founder-dp-wrapper) {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .founder-dp-wrapper {
    width: 200px !important;
    height: 200px !important;
    min-width: 200px !important;
    min-height: 200px !important;
    max-width: 200px !important;
    max-height: 200px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    margin: 0 auto 1.25rem auto !important;
    flex-shrink: 0 !important;
    display: block !important;
  }
  .founder-dp-wrapper.sm,
  .founder-dp-wrapper[style*="130px"] {
    width: 130px !important;
    height: 130px !important;
    min-width: 130px !important;
    min-height: 130px !important;
    max-width: 130px !important;
    max-height: 130px !important;
  }
  .founder-dp-wrapper img {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
  }
  .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  .table-responsive > table, table.table {
    display: table !important;
    min-width: 880px !important;
    width: 100% !important;
    border-collapse: collapse !important;
  }
  table th, table td {
    padding: 0.65rem 0.7rem !important;
    font-size: 0.82rem !important;
    vertical-align: middle !important;
  }
  table td .btn, table td .btn-sm, table td .action-btn {
    padding: 0.35rem 0.55rem !important;
    font-size: 0.76rem !important;
  }
  .modal-overlay {
    padding: 0.75rem !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-dialog, .modal-card, .campus-modal-content, .custom-dialog-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0.5rem auto !important;
    padding: 1.25rem !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
  }
  .modal-dialog .grid-2, .modal-card .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  #t_permissions_grid, #st_permissions_grid, [id$="_permissions_grid"], .permissions-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)) !important;
    gap: 0.5rem !important;
  }
  .staff-leave-grid, .staff-resignation-grid, .payslip-meta-grid {
    grid-template-columns: 1fr !important;
  }
  .modal-footer {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 0.65rem !important;
    margin-top: 1.25rem !important;
  }
  .footer-bottom {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    text-align: center !important;
  }
}
@media (max-width: 480px) {
  .modal-overlay {
    padding: 0.25rem !important;
  }
  .modal-card, .modal-dialog, .campus-modal-content {
    width: 98vw !important;
    padding: 0.9rem !important;
    border-radius: 12px !important;
  }
  #t_permissions_grid, #st_permissions_grid, [id$="_permissions_grid"], .permissions-grid {
    grid-template-columns: 1fr !important;
  }
  .hero-title, [style*="font-size:2.3rem"], [style*="font-size: 2.3rem"],
  [style*="font-size:2.5rem"], [style*="font-size: 2.5rem"] {
    font-size: 1.4rem !important;
    line-height: 1.25 !important;
  }
  .hero-badge, .section-subtitle {
    font-size: 0.72rem !important;
    padding: 0.25rem 0.65rem !important;
  }
  .section-title {
    font-size: 1.3rem !important;
  }
  table th, table td {
    padding: 0.5rem 0.55rem !important;
    font-size: 0.78rem !important;
  }
}
@media (max-width: 1024px), (pointer: coarse) {
  #custom-side-scrollbar {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
  }
  html, body, *, *::before, *::after {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  ::-webkit-scrollbar,
  *::-webkit-scrollbar,
  html::-webkit-scrollbar,
  body::-webkit-scrollbar,
  div::-webkit-scrollbar,
  section::-webkit-scrollbar,
  ul::-webkit-scrollbar,
  nav::-webkit-scrollbar,
  table::-webkit-scrollbar,
  .card ::-webkit-scrollbar,
  .admin-content ::-webkit-scrollbar,
  .grid-scroll-container::-webkit-scrollbar,
  .table-responsive::-webkit-scrollbar,
  .nav-menu::-webkit-scrollbar,
  .modal-content::-webkit-scrollbar,
  .custom-select-dropdown::-webkit-scrollbar {
    display: none !important;
    width: 0px !important;
    height: 0px !important;
    background: transparent !important;
  }
  ::-webkit-scrollbar-track,
  *::-webkit-scrollbar-track,
  ::-webkit-scrollbar-thumb,
  *::-webkit-scrollbar-thumb {
    display: none !important;
    background: transparent !important;
    border: none !important;
  }
}

/* Attendance Record Log & Leave Application Responsive Layout for Tablet & Mobile */
#psec-attendance,
#psec-attendance *,
#psec-attendance *::before,
#psec-attendance *::after {
  box-sizing: border-box !important;
}

#psec-attendance .card,
#psec-attendance > div,
#psec-attendance .grid > div {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

#psec-attendance .form-control,
#psec-attendance input,
#psec-attendance select,
#psec-attendance textarea,
#psec-attendance .form-group {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

#btnSubmitParentLeave,
#psec-attendance .btn {
  white-space: normal !important;
  word-wrap: break-word !important;
  text-align: center !important;
  padding: 0.75rem 0.75rem !important;
  font-size: 0.88rem !important;
  line-height: 1.3 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.4rem !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#psec-attendance .table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

@media (max-width: 1024px) {
  #psec-attendance .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
  #psec-attendance > div,
  #psec-attendance .grid > div,
  #psec-attendance .card {
    padding: 1.25rem !important;
    border-radius: 12px !important;
  }
  #psec-attendance table th,
  #psec-attendance table td {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.84rem !important;
    white-space: normal !important;
  }
}

@media (max-width: 640px) {
  #psec-attendance > div,
  #psec-attendance .grid > div,
  #psec-attendance .card {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
  }
  #psec-attendance h3 {
    font-size: 1.05rem !important;
    margin-bottom: 0.85rem !important;
  }
  #parentLeaveForm .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
  #parentLeaveForm .form-label {
    font-size: 0.82rem !important;
  }
  #parentLeaveForm input[type="date"],
  #parentLeaveForm select,
  #parentLeaveForm textarea {
    font-size: 0.88rem !important;
    padding: 0.55rem 0.75rem !important;
    min-height: 42px !important;
  }
  #btnSubmitParentLeave {
    font-size: 0.85rem !important;
    padding: 0.75rem 0.85rem !important;
    width: 100% !important;
  }
  #psec-attendance table {
    min-width: 100% !important;
    width: 100% !important;
  }
  #psec-attendance table th {
    font-size: 0.78rem !important;
  }
  #psec-attendance table td {
    font-size: 0.8rem !important;
  }
}

/* Teacher Dashboard Student Leave Approval Responsive Fixes */
#sec-student-leaves .card,
#studentLeaveApprovalContainer {
  box-sizing: border-box !important;
  max-width: 100% !important;
  width: 100% !important;
  overflow: hidden !important;
}

#sec-student-leaves .table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
  display: block !important;
}

@media (max-width: 768px) {
  #sec-student-leaves .card {
    padding: 1rem !important;
  }
}

/* Teacher Dashboard Today's Allocated Class Lectures Responsive Fixes */
#todayScheduleContainer,
#todayScheduleContainer > div {
  box-sizing: border-box !important;
  max-width: 100% !important;
  width: 100% !important;
}

@media (max-width: 600px) {
  #sec-dashboard .card {
    padding: 1.1rem !important;
  }
  #todayScheduleContainer > div {
    padding: 0.85rem 1rem !important;
  }
  #todayScheduleContainer .badge {
    font-size: 0.76rem !important;
  }
}

/* Staff Dashboard Attendance Responsive Fixes */
#tab-attendance .card,
#staffAttendanceLogBody {
  box-sizing: border-box !important;
  max-width: 100% !important;
  width: 100% !important;
}

#tab-attendance .table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
  display: block !important;
}

@media (max-width: 640px) {
  #tab-attendance .card {
    padding: 1rem !important;
  }
  #attMonthFilter {
    width: 100% !important;
  }
}

/* Staff Dashboard Leave Application & Topbar Responsive Fixes */
.portal-layout,
.portal-main,
.portal-content,
.tab-content,
.staff-leave-grid,
#tab-leave,
#tab-leave .card,
#staffLeaveForm,
#staffLeaveForm * {
  box-sizing: border-box !important;
  max-width: 100% !important;
}

#tab-leave .card,
.portal-content .card {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

#tab-leave .form-control,
#tab-leave input,
#tab-leave select,
#tab-leave textarea,
#staffLeaveForm .form-control {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

#staffLeaveForm .btn,
#tab-leave .btn,
#tab-leave button[type="submit"] {
  white-space: normal !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
  text-align: center !important;
  justify-content: center !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0.65rem 0.5rem !important;
  font-size: 0.88rem !important;
  line-height: 1.3 !important;
}

#tab-leave .table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  display: block !important;
}

@media (max-width: 1024px) {
  .staff-leave-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
}

@media (max-width: 768px) {
  .portal-topbar {
    height: auto !important;
    min-height: 60px !important;
    padding: 0.65rem 0.85rem !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  .portal-topbar > div:last-child {
    width: 100% !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }
  .portal-topbar .btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.78rem !important;
  }
  .portal-content {
    padding: 0.75rem !important;
  }
  #tab-leave .card,
  .portal-content .card {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
    border-radius: 12px !important;
  }
}
