/* Responsive Breakpoints — Mobile-First Ergonomics & Zero Horizontal Overflow */

@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-grid,
  .dashboard-grid-equal {
    grid-template-columns: 1fr;
  }
  .report-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    width: var(--sidebar-width);
  }
  .main-wrapper,
  .sidebar.collapsed + .main-wrapper {
    margin-left: 0;
  }
  .mobile-only-toggle {
    display: inline-flex;
  }
  .desktop-only-toggle {
    display: none;
  }
  .topbar {
    padding: 0 14px;
  }
  .main-content {
    padding: 18px 14px 32px;
  }
  .global-search-wrap {
    width: 180px;
  }
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-brand-panel {
    display: none;
  }
  .login-form-panel {
    padding: 24px 16px;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 16px;
  }
  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .role-switcher-grid {
    grid-template-columns: 1fr;
  }
  .global-search-wrap {
    display: none;
  }
  .academic-year-wrap {
    display: none;
  }

  /* Page Header & Action Buttons */
  .page-header {
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-title {
    font-size: 19px;
  }
  .page-actions {
    width: 100%;
  }
  .page-actions .btn,
  .page-actions .form-control {
    flex: 1 1 auto;
    min-width: 0 !important;
  }

  /* Swipeable Single-Line Tabs */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 2px;
    margin-bottom: 16px;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Prevent Select & Input Overflow Inside Toolbars & Cards */
  .table-toolbar {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
  }
  .table-filters {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .table-filters .form-control,
  .card-body .form-control,
  .card-header .form-control {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .card-header {
    padding: 14px 16px;
  }
  .card-body {
    padding: 16px;
  }
  .summary-strip {
    padding: 10px 14px;
    gap: 8px 14px;
  }

  /* Report Card Mobile Layout */
  .report-card {
    padding: 16px;
  }
  .report-card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .report-card-head > div:last-child {
    text-align: left !important;
  }
  .report-meta-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .report-signatures {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Modals on Mobile */
  .modal-backdrop {
    padding: 12px;
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 14px 16px;
  }

  /* Responsive Table -> Stacked Card List on Mobile */
  .data-table thead {
    display: none;
  }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }
  .data-table tr {
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }
  .data-table tr:last-child {
    border-bottom: none;
  }
  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: none;
    text-align: right;
    word-break: break-word;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  .data-table .num-col {
    text-align: right;
  }
  .table-footer {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
  }
  .pagination {
    justify-content: space-between;
  }

  /* Touch-friendly controls, long UUID wrapping & compact charts */
  .app-shell,
  .main-wrapper {
    max-width: 100%;
    overflow-x: hidden;
  }
  .page-subtitle {
    word-break: break-word;
  }
  .btn {
    min-height: 38px;
  }
  .btn-sm {
    min-height: 34px;
  }
  .form-control {
    min-height: 38px;
  }
  .mark-input {
    width: 84px !important;
    height: 36px;
  }
  .att-btn {
    padding: 7px 11px;
  }
  .chart-box {
    height: 220px;
  }
  .dropdown-menu {
    max-width: calc(100vw - 24px);
  }
  .id-card-body {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  #topbarUserName {
    display: none;
  }
}
