/* ============================================================
   DotLinks School Management System — Global Design System
   Brand: Dark Brown (#1a0a00), Green (#39d353), Red (#e63939)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@400;500;600;700;800&display=swap');

/* ─── CSS Variables (Light Mode) ──────────────────────────── */
:root {
  /* Brand Colors */
  --brand-primary: #2d8a3e;
  /* Rich green */
  --brand-primary-h: #1f6b2e;
  --brand-accent: #e63939;
  /* Red accent */
  --brand-accent-h: #c42929;
  --brand-dark: #1a0a00;
  /* Logo dark brown */
  --brand-orange: #f05a28;
  /* Supplementary */

  /* UI Colors — Light Mode */
  --bg-base: #f4f6fc;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8f9fd;
  --bg-sidebar: #0f1b2d;
  --bg-sidebar-item: rgba(255, 255, 255, 0.06);
  --bg-sidebar-active: rgba(45, 138, 62, 0.85);
  --border: #e2e8f0;
  --border-light: #eef1f6;

  /* Text */
  --text-primary: #0f1b2d;
  --text-secondary: #4a5568;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .08), 0 2px 6px rgba(0, 0, 0, .04);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .12), 0 4px 12px rgba(0, 0, 0, .06);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, .16);

  /* Sizing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --header-height: 60px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow: 0.4s ease;
}

/* ─── Dark Mode ──────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-base: #0a0f1a;
  --bg-surface: #111827;
  --bg-surface-2: #1c2536;
  --bg-sidebar: #060c16;
  --border: #1e2d42;
  --border-light: #162030;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #4a5568;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .4);
}

/* ─── Reset & Base ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--t-normal), color var(--t-normal);
  overflow-x: hidden;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Typography ────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1rem;
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--brand-primary-h);
}

/* ─── Layout Wrapper ────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transition: width var(--t-normal), transform var(--t-normal);
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(0, 0, 0, .3);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-section-label {
  opacity: 0;
  pointer-events: none;
}

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 76px;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  transition: opacity var(--t-normal);
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.sidebar-brand-text .brand-name {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-text .brand-sub {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-text .brand-slogan {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 400;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User Profile in Sidebar */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.sidebar-user .user-info {
  overflow: hidden;
  transition: opacity var(--t-normal);
}

.sidebar-user .user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  margin-top: 1px;
}

.sidebar-user .role-badge {
  display: inline-block;
  background: rgba(45, 138, 62, 0.3);
  color: #4ade80;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 600;
  margin-top: 2px;
  border: 1px solid rgba(74, 222, 128, 0.2);
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
}

.sidebar-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  padding: 14px 20px 6px;
  white-space: nowrap;
  transition: opacity var(--t-normal);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--t-fast);
  position: relative;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item .nav-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  transition: transform var(--t-fast);
}

.nav-item .nav-label {
  transition: opacity var(--t-normal);
}

.nav-item:hover {
  background: var(--bg-sidebar-item);
  color: #fff;
}

.nav-item:hover .nav-icon {
  transform: scale(1.1);
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: #fff;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--brand-primary);
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--brand-accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* Collapsible Nav Group */
.nav-group {
  margin: 2px 0;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: rgba(255, 255, 255, 0.45);
  transition: all var(--t-fast);
}

.nav-group-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-section-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.nav-group-header .chevron {
  transition: transform var(--t-fast);
  font-size: 0.9rem;
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  height: 0;
  overflow: hidden;
  transition: height var(--t-normal);
}

.nav-group.open .nav-submenu {
  height: auto;
}
.nav-group.open .nav-group-header {
  color: #fff;
  background: rgba(255, 255, 255, 0.02);
}
.nav-group.open .chevron {
  transform: rotate(180deg);
}

.nav-submenu .nav-item {
  padding-left: 20px;
}

.nav-quicklink-mang {
  color: rgba(255, 255, 255, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}
.nav-quicklink-mang:hover {
  color: #fff;
  background: var(--brand-primary);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 8px;
}

.sidebar-footer .nav-item.logout {
  color: rgba(239, 68, 68, 0.8);
}

.sidebar-footer .nav-item.logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

/* Toggle button */
.sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 80px;
  width: 24px;
  height: 24px;
  background: var(--brand-primary);
  border: 2px solid var(--bg-sidebar);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1001;
  color: #fff;
  font-size: 0.6rem;
  transition: all var(--t-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
  transform: scale(1.1);
}

.sidebar-toggle.rotated {
  transform: rotate(180deg);
}

.sidebar-toggle.rotated:hover {
  transform: rotate(180deg) scale(1.1);
}

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--t-normal);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed);
}

/* ─── Top Header ────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  flex: 1;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--brand-primary);
}

.breadcrumb .sep {
  color: var(--border);
}

.breadcrumb .current {
  color: var(--text-primary);
  font-weight: 600;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  width: 220px;
  transition: all var(--t-fast);
}

.header-search:focus-within {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(45, 138, 62, 0.1);
  width: 280px;
}

.header-search input {
  background: none;
  border: none;
  outline: none;
  font-size: 0.8rem;
  color: var(--text-primary);
  width: 100%;
}

.header-search .search-icon {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-base);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  position: relative;
  transition: all var(--t-fast);
  font-size: 1rem;
}

.header-btn:hover {
  background: var(--bg-surface-2);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--brand-accent);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* School switcher dropdown */
.school-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
}

.school-switcher:hover {
  border-color: var(--brand-primary);
}

/* ─── Page Content ──────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─── Stats / KPI Cards ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--card-accent, var(--brand-primary));
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--icon-bg, rgba(45, 138, 62, 0.1));
  color: var(--card-accent, var(--brand-primary));
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: 'Poppins', sans-serif;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-change {
  font-size: 0.72rem;
  margin-top: 6px;
  font-weight: 600;
}

.stat-change.up {
  color: var(--success);
}

.stat-change.down {
  color: var(--danger);
}

/* Color variants */
.stat-card.green {
  --card-accent: #10b981;
  --icon-bg: rgba(16, 185, 129, 0.1);
}

.stat-card.blue {
  --card-accent: #3b82f6;
  --icon-bg: rgba(59, 130, 246, 0.1);
}

.stat-card.orange {
  --card-accent: #f59e0b;
  --icon-bg: rgba(245, 158, 11, 0.1);
}

.stat-card.red {
  --card-accent: #ef4444;
  --icon-bg: rgba(239, 68, 68, 0.1);
}

.stat-card.purple {
  --card-accent: #8b5cf6;
  --icon-bg: rgba(139, 92, 246, 0.1);
}

.stat-card.teal {
  --card-accent: #14b8a6;
  --icon-bg: rgba(20, 184, 166, 0.1);
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--t-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface-2);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

.btn-primary:hover {
  background: var(--brand-primary-h);
  border-color: var(--brand-primary-h);
  box-shadow: 0 4px 12px rgba(45, 138, 62, 0.35);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}

.btn-info {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-base);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-base);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 0.92rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon-sm {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* Loading spinner in btn */
.btn .spinner {
  animation: spin 0.7s linear infinite;
}

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.badge-primary {
  background: rgba(45, 138, 62, 0.12);
  color: #16a34a;
}

.badge-gray {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

.badge-purple {
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
}

/* ─── Forms ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-label .req {
  color: var(--danger);
  margin-left: 2px;
}

.form-control,
.form-select {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  font-family: inherit;
  color: var(--text-primary);
  transition: all var(--t-fast);
  outline: none;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(45, 138, 62, 0.12);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--t-fast);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-surface-2);
}

.data-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
}

.data-table .actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.table-checkbox {
  width: 36px;
}

.table-checkbox input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--brand-primary);
}

/* Student/Person row */
.person-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.person-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--brand-primary), #065f46);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.person-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.person-name {
  font-weight: 600;
  color: var(--text-primary);
}

.person-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ─── Alerts & Toasts ────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  border: 1px solid;
  margin-bottom: 16px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #065f46;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #991b1b;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: #92400e;
}

.alert-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
  color: #1e3a5f;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  animation: slideInRight 0.3s ease;
}

.toast.removing {
  animation: slideOutRight 0.3s ease forwards;
}

.toast-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast.info .toast-icon {
  color: var(--info);
}

.toast-close {
  margin-left: auto;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ─── Filters & Search Bar ─────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-control,
.filter-bar .form-select {
  width: auto;
  min-width: 140px;
}

/* ─── Tabs ──────────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-item {
  padding: 9px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* ─── Pagination ────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 16px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}

.page-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.page-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Spinner / Loading ─────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(17, 24, 39, 0.7);
}

/* ─── Chart containers ──────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 260px;
}

/* ─── Progress bars ─────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-base);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* ─── Timeline ──────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--bg-surface);
}

.timeline-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.timeline-content {
  font-size: 0.82rem;
}

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--t-normal);
}

.modal-backdrop.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-close {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

.modal-close:hover {
  color: var(--danger);
}

/* ─── Dropdown ──────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--t-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: all;
  transform: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--bg-base);
  color: var(--text-primary);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.06);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px;
}

/* ─── Footer ─────────────────────────────────────────────── */
.app-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

.animate-slide-up {
  animation: slideUp 0.4s ease;
}

/* ─── Utility ────────────────────────────────────────────── */
.d-flex {
  display: flex;
}

.d-grid {
  display: grid;
}

.d-none {
  display: none;
}

.flex-1 {
  flex: 1;
}

.gap-1 {
  gap: 4px;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.gap-6 {
  gap: 24px;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-sm {
  font-size: 0.78rem;
}

.text-xs {
  font-size: 0.68rem;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-primary-color {
  color: var(--brand-primary);
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.p-4 {
  padding: 16px;
}

.p-6 {
  padding: 24px;
}

.rounded {
  border-radius: var(--radius-md);
}

.rounded-lg {
  border-radius: var(--radius-lg);
}

.rounded-full {
  border-radius: var(--radius-full);
}

.w-full {
  width: 100%;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Grid helpers */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ─── Table Responsive Wrapper ────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Responsive: Tablet (max 1024px) ────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
  }

  .mobile-overlay.visible {
    display: block;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr 1fr;
  }

  .header-search {
    display: none;
  }

  /* Wrap table containers */
  .table-wrapper,
  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Fee structure rows */
  .fee-row > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ─── Responsive: Mobile (max 640px) ─────────────────────── */
@media (max-width: 640px) {
  /* Page Headers */
  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .page-header > .btn,
  .page-header > a {
    align-self: stretch;
    text-align: center;
  }

  /* Stats grid: always 2-col on mobile */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* All grids stack on mobile */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  /* Form rows stack on mobile */
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4,
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Stat values */
  .stat-value {
    font-size: 1.3rem;
  }

  /* Card body padding */
  .card-body {
    padding: 14px;
  }

  .card-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Tables always scroll on mobile */
  .table-wrapper,
  .data-table-wrapper,
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Override any inline grid columns to single column on mobile */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Buttons: full width in action areas */
  .card-footer,
  .form-actions {
    flex-direction: column;
  }

  /* Hide less-critical table columns on mobile */
  .data-table th.hide-mobile,
  .data-table td.hide-mobile {
    display: none;
  }

  /* Fee structure rows: fully stacked */
  .fee-row > div {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Content padding */
  .main-content {
    padding: 12px !important;
  }

  /* Page content area */
  .page-content {
    padding: 12px;
  }

  /* Breadcrumb shrink */
  .breadcrumb {
    font-size: 0.78rem;
  }

  /* Prevent horizontal overflow globally */
  body {
    overflow-x: hidden;
  }
}