/* CSCS SMS Responsive Overrides
   Scope: Landing (/), Auth (/login, /register), Admin Dashboard
   Rule: Desktop styles remain untouched. All overrides scoped to mobile/tablet breakpoints.
*/

/* Safe global: fluid media only */
img, svg, canvas, video { max-width: 100%; height: auto; }

/* Prevent horizontal scrollbars across dashboards */
html, body { max-width: 100%; overflow-x: hidden; }
body.dashboard-app {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.dashboard-app,
.dashboard-app .page-content,
.dashboard-app .container-fluid,
.dashboard-app .dashboard-page-container {
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Table row actions — compact toolbar on desktop */
.dashboard-app .table-actions-grid {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  vertical-align: middle;
}
.dashboard-app .table-action-label {
  display: none;
}

/* Desktop: color-coded action buttons with visible text labels */
@media (min-width: 769px) {
  .dashboard-app table.table-sections-list th:last-child,
  .dashboard-app table.table-sections-list td:last-child {
    min-width: 30rem;
    width: auto;
    vertical-align: middle;
  }

  .dashboard-app .table-actions-grid {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    max-width: none;
  }

  .dashboard-app .table-actions-grid .table-action-btn {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.4rem !important;
    min-width: 0;
    min-height: 2.5rem;
    height: auto;
    padding: 0.45rem 0.7rem !important;
    border-width: 1.5px;
    border-radius: 8px;
    font-size: 0.8125rem !important;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  }

  .dashboard-app .table-actions-grid .table-action-btn .bi {
    font-size: 1.05rem;
    line-height: 1;
    flex-shrink: 0;
  }

  .dashboard-app .table-actions-grid .table-action-label {
    display: inline !important;
    font-size: 0.8125rem !important;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
  }

  .dashboard-app .table-actions-grid .table-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
    filter: brightness(0.97);
  }

  .dashboard-app .table-actions-grid .table-action-btn--adviser {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #93c5fd;
  }
  .dashboard-app .table-actions-grid .table-action-btn--adviser .bi { color: #2563eb; }

  .dashboard-app .table-actions-grid .table-action-btn--teachers {
    color: #0e7490;
    background: #ecfeff;
    border-color: #67e8f9;
  }
  .dashboard-app .table-actions-grid .table-action-btn--teachers .bi { color: #0891b2; }

  .dashboard-app .table-actions-grid .table-action-btn--students {
    color: #047857;
    background: #ecfdf5;
    border-color: #6ee7b7;
  }
  .dashboard-app .table-actions-grid .table-action-btn--students .bi { color: #059669; }

  .dashboard-app .table-actions-grid .table-action-btn--enroll {
    color: #b45309;
    background: #fffbeb;
    border-color: #fcd34d;
  }
  .dashboard-app .table-actions-grid .table-action-btn--enroll .bi { color: #d97706; }

  .dashboard-app .table-actions-grid .table-action-btn--subjects {
    color: #6d28d9;
    background: #f5f3ff;
    border-color: #c4b5fd;
  }
  .dashboard-app .table-actions-grid .table-action-btn--subjects .bi { color: #7c3aed; }

  .dashboard-app .table-actions-grid .table-action-btn--edit {
    color: #334155;
    background: #f8fafc;
    border-color: #cbd5e1;
  }
  .dashboard-app .table-actions-grid .table-action-btn--edit .bi { color: #475569; }

  .dashboard-app .table-actions-grid .table-action-btn--delete {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fca5a5;
  }
  .dashboard-app .table-actions-grid .table-action-btn--delete .bi { color: #dc2626; }
}

/* ================ Up to 992px (tablets and below) ================ */
@media (max-width: 992px) {
  /* Landing Analytics columns stack */
  #landing .analytics-section .row { gap: 1rem !important; }
  #landing .analytics-section .col-6 { width: 100% !important; flex: 0 0 100% !important; }

  /* Principal section: comfortable padding */
  #landing .principal-section .principal-content { padding: 1.5rem !important; }

  /* Login/Register cards fit nicely on tablets */
  .login-container { height: auto !important; margin: 0 !important; padding: 2rem 1.25rem !important; }
  .login-card { max-width: 600px !important; }

  .register-container { min-height: auto !important; margin: 0 !important; padding: 1.5rem 1.25rem !important; }
  .register-card { max-width: 100% !important; }

  /* Footer stacks into single column on tablets */
  footer .footer-container > div { grid-template-columns: 1fr !important; text-align: left !important; display: grid !important; }
  footer .footer-container > div > div:last-child { text-align: left !important; }

  /* ADMIN: Dashboard charts and cards stack vertically */
  .dashboard-app .row[style*="flex-wrap: nowrap"],
  .dashboard-app .row[style*="flex-wrap:nowrap"] { flex-wrap: wrap !important; }
  .dashboard-app .row .col-6[style*="flex: 1"], 
  .dashboard-app .row .col-4[style*="flex: 1"],
  .dashboard-app .row .col-3[style*="flex: 1"] { flex: 0 0 100% !important; width: 100% !important; max-width: 100% !important; margin-bottom: 1rem !important; }
  
  .dashboard-app .dashboard-header { flex-direction: column !important; align-items: stretch !important; gap: 1rem !important; }
  .dashboard-app .dashboard-header .btn-group { flex-wrap: wrap; gap: 0.5rem; }
  .dashboard-app .dashboard-header .btn-group .btn { flex: 1 1 calc(50% - 0.25rem); min-width: 140px; }
  
  .dashboard-app .chart-container { height: 280px !important; }
  .dashboard-app .card-body[style*="max-height"] { max-height: 400px !important; }

  /* Tablet: keep main content full width (no sidebar gutter) */
  body.dashboard-app .main-content,
  body.dashboard-app .app-sidebar-wrapper.collapsed ~ .main-content,
  body.dashboard-app .app-sidebar-wrapper.show ~ .main-content {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-left: none !important;
  }

  body.dashboard-app .page-content .container-fluid,
  body.dashboard-app .page-content .dashboard-page-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
}

/* ================ Up to 768px (phones, large phones) ================ */
@media (max-width: 768px) {
  /* Header/nav */
  .site-header .container-fluid { gap: .75rem; padding-left: .75rem !important; padding-right: .75rem !important; }
  .nav-toggle { display: block; }
  .site-nav { width: 100%; }
  .site-nav a { width: 100%; text-align: left; padding: .75rem !important; }

  /* Brand scale down on small screens */
  .site-brand img { width: 40px; height: 40px; }
  .site-brand span { font-size: 1.05rem !important; white-space: normal !important; }

  /* Landing hero text */
  #landing .hero { min-height: 420px; }
  #landing .hero .hero-title { font-size: 2.2rem !important; line-height: 1.15 !important; }
  #landing .hero .hero-subtitle { font-size: 1.1rem !important; }
  #landing .hero .hero-description { font-size: 1rem !important; margin-bottom: 1.25rem !important; }
  #landing .hero .hero-banners { display: grid; grid-template-columns: 1fr; gap: .5rem; }

  /* Reposition floating badges into flow to avoid overlap */
  .hero-badge-top-right, .hero-badge-small { position: static !important; margin: .75rem 0 !important; display: inline-flex !important; }

  /* Principal section stacking */
  #landing .principal-section .row { display: flex; flex-wrap: wrap; }
  #landing .principal-image img { height: auto !important; max-height: 380px; }

  /* Vision/Mission safe paddings */
  #vision-mission-section .row { padding-left: 1rem !important; padding-right: 1rem !important; }

  /* Features/Analytics stacking */
  #landing .features-horizontal { grid-template-columns: 1fr !important; }

  /* Charts height */
  #landing .chart-container { height: 280px !important; }

  /* Enrollment process cards */
  .enrollment-process-steps, #landing .process-steps, #landing .process-timeline { display: grid !important; grid-template-columns: 1fr !important; gap: 1rem !important; }
  #landing .process-item { max-width: 100% !important; }

  /* Login page */
  .login-title { font-size: 1.6rem !important; }
  .login-subtitle { font-size: .95rem !important; }
  .remember-section { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .login-btn { padding: .9rem !important; font-size: 1rem !important; }
  #togglePassword { right: 6px !important; top: 50% !important; transform: translateY(-50%) !important; }

  /* Register page */
  .register-title { font-size: 1.4rem !important; }
  .register-subtitle { font-size: .95rem !important; }
  .register-form { padding: 1rem !important; }
  .register-form .row { --bs-gutter-x: .75rem; --bs-gutter-y: .75rem; }
  .section-title { font-size: 1.05rem !important; }
  .form-label { font-size: .85rem !important; }
  .form-control, .form-select { font-size: .9rem !important; }

  .step-navigation { flex-direction: column; align-items: stretch; gap: .75rem; }
  .step-navigation .right-buttons { width: 100%; justify-content: space-between; }
  .btn-step, .register-btn { width: 100%; }

  /* ===== ADMIN DASHBOARD MOBILE ===== */
  /* Top bar: one row — menu | title (ellipsis) | actions. Do NOT target nested .d-flex (was breaking layout). */
  .dashboard-app .top-bar { padding: 0.75rem 1rem !important; }
  .dashboard-app .top-bar > .d-flex {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  .dashboard-app .top-bar > .d-flex > .d-flex.align-items-center {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
  .dashboard-app .top-bar .app-sidebar-toggle {
    flex-shrink: 0 !important;
    margin-right: 0.5rem !important;
    align-self: center !important;
  }
  .dashboard-app .top-bar .top-bar-title-wrap {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    margin-left: 0 !important;
  }
  .dashboard-app .top-bar .top-bar-title {
    font-size: 1rem !important;
    line-height: 1.25 !important;
    margin: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .dashboard-app .top-bar .title-sub { display: none !important; }
  .dashboard-app .top-bar .top-bar-actions {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
  }
  .dashboard-app .top-bar .top-bar-icon-btn { width: 38px; height: 38px; }
  .dashboard-app .top-bar .top-bar-icon-btn i { font-size: 1.2rem; }
  .dashboard-app .app-desktop-collapse { display: none !important; }

  /* Full-width main column on phones — cancel desktop sidebar offset */
  body.dashboard-app .main-content,
  body.dashboard-app .app-sidebar-wrapper.collapsed ~ .main-content,
  body.dashboard-app .app-sidebar-wrapper.show ~ .main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-left: none !important;
    box-sizing: border-box !important;
  }

  body.dashboard-app .page-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  body.dashboard-app .page-content .container-fluid,
  body.dashboard-app .page-content .dashboard-page-container,
  body.dashboard-app .main-content .container-fluid,
  body.dashboard-app .main-content .container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 1rem !important;
    box-sizing: border-box !important;
  }

  .dashboard-app .main-content > .top-bar {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .dashboard-app .main-content > .page-content {
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  .dashboard-app .main-content footer,
  .dashboard-app .main-content > div[style*="linear-gradient"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    box-sizing: border-box !important;
  }
  
  .dashboard-app .dashboard-header { padding: 1rem !important; }
  .dashboard-app .dashboard-header h2 { font-size: 1.25rem !important; margin-bottom: 0.5rem !important; }
  .dashboard-app .dashboard-header small { font-size: 0.85rem !important; }
  .dashboard-app .dashboard-header .btn-group .btn { font-size: 0.85rem !important; padding: 0.6rem 0.8rem !important; }
  
  .dashboard-app .card { margin-bottom: 1.5rem !important; }
  .dashboard-app .card-header { padding: 1rem !important; }
  .dashboard-app .card-header h6 { font-size: 1rem !important; }
  .dashboard-app .card-body { padding: 1rem !important; }
  
  .dashboard-app .chart-container { height: 260px !important; }

  /* Teacher dashboard: stats + featured responsive */
  .dashboard-app .teacher-stats-row { flex-wrap: wrap !important; }
  .dashboard-app .teacher-stats-row .teacher-stat-col { flex: 0 0 100% !important; width: 100% !important; max-width: 100% !important; }
  .dashboard-app .featured-poster,
  .dashboard-app .featured-poster-banner {
    height: 200px !important;
    min-height: 200px !important;
    max-height: 200px !important;
  }
  
  /*
   * Mobile tables → card rows (all roles using dashboard_layout).
   * Opt out: add class `table-mobile-static` on <table>.
   * Labels come from <thead> via public/js/mobile-tables.js (data-label).
   * Scoped with `table > tbody` so nested tables inside cells still work.
   */
  .dashboard-app .table-responsive {
    overflow: visible !important;
  }
  .dashboard-app table:not(.table-mobile-static) {
    display: block !important;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }
  .dashboard-app table:not(.table-mobile-static) > thead {
    display: none !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody,
  .dashboard-app table:not(.table-mobile-static) > tfoot {
    display: block !important;
    width: 100% !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr {
    display: block !important;
    width: 100% !important;
    background: #ffffff !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 14px !important;
    padding: 0 !important;
    margin-bottom: 1rem !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08) !important;
    overflow: hidden !important;
    position: relative !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr::before,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr::before {
    content: '' !important;
    display: block !important;
    height: 4px !important;
    width: 100% !important;
    background: linear-gradient(90deg, #1e40af 0%, #3b82f6 50%, #f59e0b 100%) !important;
    opacity: 0.95 !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.75rem !important;
    width: 100% !important;
    border: none !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 0.65rem 1rem !important;
    text-align: right !important;
    background: #f8fafc !important;
    box-sizing: border-box !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child {
    border-bottom: none !important;
    background: #f8fafc !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.35rem !important;
    align-items: stretch !important;
    justify-items: stretch !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child:has(> .btn-group:not(.table-actions-grid)),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child:has(> .btn-group:not(.table-actions-grid)) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td[data-label]:before,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td[data-label]:before {
    content: attr(data-label) !important;
    font-weight: 700 !important;
    font-size: 0.78rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    color: #475569 !important;
    text-align: left !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
    max-width: 46% !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-label]:before,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-label]:before {
    grid-column: 1 / -1 !important;
    max-width: none !important;
    width: 100% !important;
    padding-bottom: 0.5rem !important;
    margin-bottom: 0.35rem !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td > *:not(table):not(.table-responsive),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td > *:not(table):not(.table-responsive) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: right !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > *:not(table):not(.table-responsive),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > *:not(table):not(.table-responsive) {
    text-align: center !important;
    width: 100% !important;
  }
  /*
   * Action buttons (mobile card tables).
   * .table-actions-grid → 2-column grid; odd counts end with one full-width row (2×2×1 style).
   * .btn-group → compact 2-column grid (legacy tables).
   */
  .dashboard-app table:not(.table-mobile-static) .btn-group {
    display: grid !important;
    gap: 0.4rem !important;
    width: 100% !important;
    align-items: stretch !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid {
    display: grid !important;
    gap: 0.35rem !important;
    width: 100% !important;
    align-items: stretch !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid[data-mobile-action-count="1"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid[data-mobile-action-count="3"] > .btn:nth-child(3),
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid[data-mobile-action-count="5"] > .btn:nth-child(5),
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid[data-mobile-action-count="7"] > .btn:nth-child(7),
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid[data-mobile-action-count="9"] > .btn:nth-child(9) {
    grid-column: 1 / -1 !important;
  }
  .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count="1"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="3"]):not([data-mobile-action-count="4"]) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* Detach Bootstrap btn-group joined corners */
  .dashboard-app table:not(.table-mobile-static) .btn-group > .btn {
    width: 100% !important;
    min-height: auto !important;
    margin: 0 !important;
    margin-left: 0 !important;
    border-radius: 6px !important;
    float: none !important;
    position: relative !important;
    flex: none !important;
  }
  .dashboard-app table:not(.table-mobile-static) .btn-group .btn {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.2rem !important;
    padding: 0.45rem 0.35rem !important;
    min-height: 2.75rem !important;
    font-size: 0.68rem !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    box-shadow: none !important;
  }
  /* Formal row actions: white surface, icon + label, no loud fills */
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid > .btn {
    width: 100% !important;
    min-height: 2.5rem !important;
    margin: 0 !important;
    margin-left: 0 !important;
    border-radius: 6px !important;
    float: none !important;
    position: relative !important;
    flex: none !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.2rem !important;
    padding: 0.4rem 0.3rem !important;
    min-height: 2.65rem !important;
    font-size: 0.68rem !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    text-align: center !important;
    background: #ffffff !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn .bi {
    font-size: 1rem !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    width: 1.25rem !important;
    text-align: center !important;
    color: #64748b !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-action-label {
    display: inline !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    max-width: 100% !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--delete {
    color: #b91c1c !important;
    border-color: #fecaca !important;
    background: #fef2f2 !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--delete .bi {
    color: #dc2626 !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--adviser {
    color: #1d4ed8 !important;
    border-color: #bfdbfe !important;
    background: #eff6ff !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--adviser .bi { color: #2563eb !important; }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--teachers {
    color: #0e7490 !important;
    border-color: #a5f3fc !important;
    background: #ecfeff !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--teachers .bi { color: #0891b2 !important; }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--students {
    color: #047857 !important;
    border-color: #a7f3d0 !important;
    background: #ecfdf5 !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--students .bi { color: #059669 !important; }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--enroll {
    color: #b45309 !important;
    border-color: #fde68a !important;
    background: #fffbeb !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--enroll .bi { color: #d97706 !important; }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--subjects {
    color: #6d28d9 !important;
    border-color: #ddd6fe !important;
    background: #f5f3ff !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--subjects .bi { color: #7c3aed !important; }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--edit {
    color: #334155 !important;
    border-color: #cbd5e1 !important;
    background: #f8fafc !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn--edit .bi { color: #475569 !important; }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn:hover,
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn:focus {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #1e293b !important;
    box-shadow: none !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn:active {
    background: #f1f5f9 !important;
  }
  .dashboard-app table:not(.table-mobile-static) .table-actions-grid .table-action-btn:focus-visible {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 1px !important;
  }
  /* Legacy btn-group tinting (not used by sections grid) */
  .dashboard-app table:not(.table-mobile-static) :is(tbody, tfoot) tr > td:last-child .btn-group .btn.btn-outline-primary {
    background-color: #eff6ff !important;
    color: #1d4ed8 !important;
    border-color: #bfdbfe !important;
  }
  .dashboard-app table:not(.table-mobile-static) :is(tbody, tfoot) tr > td:last-child .btn-group .btn.btn-outline-secondary {
    background-color: #f8fafc !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
  }
  .dashboard-app table:not(.table-mobile-static) :is(tbody, tfoot) tr > td:last-child .btn-group .btn.btn-outline-success {
    background-color: #ecfdf5 !important;
    color: #047857 !important;
    border-color: #a7f3d0 !important;
  }
  .dashboard-app table:not(.table-mobile-static) :is(tbody, tfoot) tr > td:last-child .btn-group .btn.btn-outline-danger {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    border-color: #fecaca !important;
  }
  .dashboard-app table:not(.table-mobile-static) :is(tbody, tfoot) tr > td:last-child .btn-group .btn.btn-outline-warning {
    background-color: #fffbeb !important;
    color: #b45309 !important;
    border-color: #fde68a !important;
  }
  .dashboard-app table:not(.table-mobile-static) :is(tbody, tfoot) tr > td:last-child .btn-group .btn.btn-outline-info {
    background-color: #ecfeff !important;
    color: #0e7490 !important;
    border-color: #a5f3fc !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child .btn:not(.btn-group .btn):not(.table-actions-grid .btn),
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child a.btn:not(.table-actions-grid .btn),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child .btn:not(.btn-group .btn):not(.table-actions-grid .btn),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child a.btn:not(.table-actions-grid .btn) {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    width: 100% !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > .btn-group,
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > .table-actions-grid,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > .btn-group,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > .table-actions-grid {
    grid-column: 1 / -1 !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > .table-actions-grid,
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child {
    grid-column: 1 / -1 !important;
    display: grid !important;
    gap: 0.35rem !important;
    width: 100% !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > .table-actions-grid[data-mobile-action-count="1"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > .table-actions-grid[data-mobile-action-count="1"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > .btn-group:not(.table-actions-grid),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > .btn-group:not(.table-actions-grid) {
    grid-column: 1 / -1 !important;
    display: grid !important;
    gap: 0.5rem !important;
    width: 100% !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count="1"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count="1"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count="2"],
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count="4"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count="2"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count="3"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count="3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="3"]):not([data-mobile-action-count="4"]),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="3"]):not([data-mobile-action-count="4"]) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count="1"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count="1"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count="2"],
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count="4"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count="2"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count="3"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count="3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="3"]):not([data-mobile-action-count="4"]),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="3"]):not([data-mobile-action-count="4"]) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child .btn,
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child button[type="submit"],
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child .btn,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child button[type="submit"] {
    width: 100% !important;
    min-height: 44px !important;
    margin: 0 !important;
  }
  /* One full-width action when it’s the only control */
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > a.btn:only-child,
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > .btn:only-child,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > a.btn:only-child,
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > .btn:only-child {
    grid-column: 1 / -1 !important;
  }
  @media (min-width: 400px) {
    .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count="3"] {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count="4"] {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .dashboard-app table:not(.table-mobile-static) .btn-group[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="3"]):not([data-mobile-action-count="4"]) {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count="3"],
    .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="4"]),
    .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count="3"],
    .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="4"]) {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child[data-mobile-action-count="4"],
    .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child[data-mobile-action-count="4"] {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count="3"],
    .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="4"]),
    .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count="3"],
    .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count]:not([data-mobile-action-count="1"]):not([data-mobile-action-count="2"]):not([data-mobile-action-count="4"]) {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child > form:only-child[data-mobile-action-count="4"],
    .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child > form:only-child[data-mobile-action-count="4"] {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td:last-child form:not(:only-child),
  .dashboard-app table:not(.table-mobile-static) > tfoot > tr > td:last-child form:not(:only-child) {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }
  .dashboard-app table:not(.table-mobile-static) > tbody > tr > td .badge {
    flex-shrink: 0 !important;
  }
  
  /* Filter forms */
  .dashboard-app form.row { display: flex !important; flex-direction: column !important; gap: 1rem !important; }
  .dashboard-app form .col-auto { width: 100% !important; }
  .dashboard-app form .col-auto .form-label { font-size: 0.9rem !important; font-weight: 600 !important; }
  .dashboard-app form .col-auto .form-select, .dashboard-app form .col-auto .form-control { font-size: 0.9rem !important; padding: 0.6rem !important; }
  .dashboard-app form .col-auto .btn { width: 100% !important; padding: 0.7rem !important; }
  
  .dashboard-app .pagination { font-size: 0.85rem !important; justify-content: center !important; }
  
  /* Modals */
  .dashboard-app .custom-modal-container { width: 96% !important; max-width: 96% !important; margin: 0.5rem !important; }
  .dashboard-app .custom-modal-header { padding: 1.25rem !important; }
  .dashboard-app .custom-modal-title { font-size: 1.15rem !important; }
  .dashboard-app .custom-modal-body { padding: 1.25rem !important; max-height: 65vh !important; }
  .dashboard-app .custom-modal-footer { padding: 1rem !important; flex-direction: column !important; gap: 0.75rem !important; }
  .dashboard-app .custom-modal-footer .btn { width: 100% !important; }
  
  .dashboard-app .custom-modal-body .row { display: flex !important; flex-direction: column !important; }
  .dashboard-app .custom-modal-body .col-md-6, 
  .dashboard-app .custom-modal-body .col-md-4, 
  .dashboard-app .custom-modal-body .col-md-3 { 
    width: 100% !important; 
    flex: 0 0 100% !important; 
    max-width: 100% !important; 
  }
  .dashboard-app .custom-modal-body .form-label { font-size: 0.9rem !important; font-weight: 600 !important; }
  .dashboard-app .custom-modal-body .form-control, .dashboard-app .custom-modal-body .form-select { font-size: 0.9rem !important; padding: 0.6rem !important; }
  
  .dashboard-app .student-info-section { padding: 1.25rem !important; }
  .dashboard-app .student-info-table td { padding: 0.6rem 0 !important; font-size: 0.9rem !important; }
  
  /* Stack split toolbars on mobile — never apply to .top-bar (needs one horizontal row). */
  .dashboard-app .d-flex.justify-content-between:not(.top-bar .d-flex) {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  .dashboard-app .d-flex.justify-content-between:not(.top-bar .d-flex) > div {
    width: 100% !important;
  }
  .dashboard-app .d-flex.justify-content-between:not(.top-bar .d-flex) .btn {
    width: 100% !important;
  }
  
  .dashboard-app .kpi-card .kpi-value { font-size: 1.5rem !important; }
  
  .dashboard-app footer .footer-container > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; text-align: center !important; }
}

/* ================ Up to 576px (small phones) ================ */
@media (max-width: 576px) {
  .container, .container-fluid { padding-left: 1rem; padding-right: 1rem; }
  #landing .chart-container { height: 240px !important; }
  
  .dashboard-app .page-content .container-fluid { padding: 1rem !important; }
  .dashboard-app .dashboard-header { padding: 0.75rem !important; }
  .dashboard-app .dashboard-header h2 { font-size: 1.1rem !important; }
  .dashboard-app .chart-container { height: 240px !important; }
  .dashboard-app .table tr { padding: 0.85rem !important; }
  .dashboard-app .custom-modal-container { width: 98% !important; }
}

/* ================ Very small devices ================ */
@media (max-width: 380px) {
  #landing .chart-container { height: 220px !important; }
  .dashboard-app .chart-container { height: 220px !important; }
}

/* ================ Dashboard mobile shell (loads after dashboard.css) ================ */
@media (max-width: 991.98px) {
  html body.dashboard-app {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  html body.dashboard-app .app-sidebar-wrapper {
    transform: translateX(-100%) !important;
  }

  html body.dashboard-app .app-sidebar-wrapper.show {
    transform: translateX(0) !important;
  }

  html body.dashboard-app .main-content,
  html body.dashboard-app div.main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    left: auto !important;
    right: auto !important;
    border-left: none !important;
    box-sizing: border-box !important;
    float: none !important;
  }

  html body.dashboard-app .main-content > .top-bar,
  html body.dashboard-app .main-content > .page-content,
  html body.dashboard-app .main-content > footer.dashboard-footer {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
  }

  html body.dashboard-app .main-content .dashboard-page-container {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    box-sizing: border-box !important;
  }

  /* Nested Bootstrap containers inside page body only */
  html body.dashboard-app .dashboard-page-container > .container,
  html body.dashboard-app .dashboard-page-container > .container-fluid,
  html body.dashboard-app .dashboard-page-container > .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  html body.dashboard-app footer.dashboard-footer {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

