/* ============================================================
   EduManager v3.0 — Main Stylesheet
   Premium dark/light theme system with smooth transitions
   ============================================================ */

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

/* ── CSS Custom Properties (Theme Tokens) ────────────────── */
:root {
  /* Typography */
  --font-display: 'Syne', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Spacing scale */
  --sp-1:  4px;  --sp-2:  8px;  --sp-3:  12px;
  --sp-4:  16px; --sp-5:  20px; --sp-6:  24px;
  --sp-8:  32px; --sp-10: 40px; --sp-12: 48px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px;

  /* Transitions */
  --trans: all .2s cubic-bezier(.4,0,.2,1);
  --trans-slow: all .35s cubic-bezier(.4,0,.2,1);

  /* Brand accent */
  --accent:       #6C63FF;
  --accent-hover: #5A52E0;
  --accent-glow:  rgba(108,99,255,.25);
  --accent-soft:  rgba(108,99,255,.12);

  /* Status colours */
  --green:  #22c55e; --green-soft:  rgba(34,197,94,.15);
  --red:    #ef4444; --red-soft:    rgba(239,68,68,.15);
  --amber:  #f59e0b; --amber-soft:  rgba(245,158,11,.15);
  --blue:   #3b82f6; --blue-soft:   rgba(59,130,246,.15);
  --purple: #a855f7; --purple-soft: rgba(168,85,247,.15);

  /* Sidebar width */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 64px;
}

/* ── DARK THEME (default) ────────────────────────────────── */
[data-theme="dark"], :root {
  --bg:          #0D0F14;
  --bg-card:     #161922;
  --bg-input:    #1E2230;
  --bg-hover:    #1E2230;
  --bg-modal:    #1A1E2A;
  --bg-sidebar:  #111318;
  --border:      rgba(255,255,255,.07);
  --border-focus:rgba(108,99,255,.6);
  --text:        #E8EAED;
  --text-muted:  #7B8196;
  --text-soft:   #ADB3C9;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --shadow-lg:   0 12px 48px rgba(0,0,0,.5);
  --scrollbar-bg:#1E2230;
  --scrollbar-th:#3A3F54;
}

/* ── LIGHT THEME ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #F5F6FA;
  --bg-card:     #FFFFFF;
  --bg-input:    #F0F2F8;
  --bg-hover:    #EEF0F8;
  --bg-modal:    #FFFFFF;
  --bg-sidebar:  #1A1E2A;  /* sidebar stays dark in light mode for contrast */
  --border:      rgba(0,0,0,.08);
  --border-focus:rgba(108,99,255,.5);
  --text:        #1A1E2A;
  --text-muted:  #7B8196;
  --text-soft:   #4A5068;
  --shadow:      0 4px 24px rgba(0,0,0,.08);
  --shadow-lg:   0 12px 48px rgba(0,0,0,.14);
  --scrollbar-bg:#E8EAED;
  --scrollbar-th:#C4C8D8;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .3s ease, color .3s ease;
  overflow-x: hidden;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-th); border-radius: 99px; }

/* ── Typography ──────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.25rem; }
p  { color: var(--text-soft); }
a  { color: var(--accent); text-decoration: none; transition: var(--trans); }
a:hover { color: var(--accent-hover); }
small { font-size: .8rem; }

/* ── Layout Skeleton ─────────────────────────────────────── */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width .3s cubic-bezier(.4,0,.2,1), transform .3s ease;
  overflow: hidden;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-5);
  border-bottom: 1px solid var(--border);
  min-height: 72px;
}

.sidebar-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), #8B78FF);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  transition: opacity .2s;
}

.sidebar.collapsed .sidebar-title { opacity: 0; pointer-events: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  white-space: nowrap;
  transition: opacity .2s;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--trans);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.nav-label { transition: opacity .2s; }
.sidebar.collapsed .nav-label { opacity: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
  transition: opacity .2s;
}
.sidebar.collapsed .nav-badge { opacity: 0; }

.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s cubic-bezier(.4,0,.2,1);
}

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

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  position: sticky;
  top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-toggle {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: var(--trans);
  flex-shrink: 0;
}
.topbar-toggle:hover { color: var(--text); border-color: var(--accent); }

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

/* Search box */
.topbar-search {
  position: relative;
  display: flex; align-items: center;
}

.topbar-search input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px 7px 36px;
  border-radius: var(--r-md);
  font-size: .875rem;
  font-family: var(--font-body);
  width: 220px;
  transition: var(--trans);
  outline: none;
}

.topbar-search input:focus {
  border-color: var(--border-focus);
  width: 280px;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar-search .search-icon {
  position: absolute; left: 10px;
  color: var(--text-muted);
  font-size: .85rem;
}

/* Icon button */
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: var(--trans);
  position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

/* Theme toggle */
.theme-toggle {
  width: 56px; height: 28px;
  border-radius: 99px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  display: flex; align-items: center;
  padding: 2px;
  transition: var(--trans);
}
.theme-toggle::after {
  content: '';
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  transform: translateX(0);
  box-shadow: 0 0 10px var(--accent-glow);
}
[data-theme="light"] .theme-toggle::after { transform: translateX(28px); }
.theme-toggle .sun-icon, .theme-toggle .moon-icon {
  position: absolute; font-size: .75rem;
  transition: opacity .2s;
}
.theme-toggle .moon-icon { left: 5px; }
.theme-toggle .sun-icon  { right: 5px; }

/* User avatar chip */
.user-chip {
  display: flex; align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px 4px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: var(--trans);
}
.user-chip:hover { border-color: var(--accent); }
.user-chip .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8B78FF);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
}
.user-chip .user-name { font-size: .8rem; font-weight: 600; }

/* ── Page Content ────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: var(--sp-8) var(--sp-8);
  max-width: 1400px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-header h1 { margin-bottom: 4px; }
.page-header p  { font-size: .9rem; }

.page-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  transition: box-shadow .2s, border-color .2s;
}

.card:hover { box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); }
.card-title  { font-size: 1rem; font-weight: 700; font-family: var(--font-display); }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  position: relative;
  overflow: hidden;
  transition: var(--trans);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: .06;
  transform: translate(20px,-20px);
}

.stat-card.accent::before  { background: var(--accent); }
.stat-card.green::before   { background: var(--green); }
.stat-card.amber::before   { background: var(--amber); }
.stat-card.red::before     { background: var(--red); }
.stat-card.purple::before  { background: var(--purple); }

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

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}

.stat-icon.accent  { background: var(--accent-soft);  color: var(--accent); }
.stat-icon.green   { background: var(--green-soft);   color: var(--green); }
.stat-icon.amber   { background: var(--amber-soft);   color: var(--amber); }
.stat-icon.red     { background: var(--red-soft);     color: var(--red); }
.stat-icon.purple  { background: var(--purple-soft);  color: var(--purple); }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-trend {
  font-size: .75rem; display: flex; align-items: center; gap: 4px;
  margin-top: auto;
}
.stat-trend.up   { color: var(--green); }
.stat-trend.down { color: var(--red); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 9px 18px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--trans);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

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

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(239,68,68,.2);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(34,197,94,.2);
}
.btn-success:hover { background: var(--green); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 9px; width: 38px; height: 38px; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text-soft); }
.form-label .req { color: var(--red); margin-left: 3px; }

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: .9rem;
  outline: none;
  transition: var(--trans);
  width: 100%;
}
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: .75rem; color: var(--text-muted); }
.form-error { font-size: .75rem; color: var(--red); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}

/* Input group */
.input-group { position: relative; }
.input-group .input-prefix,
.input-group .input-suffix {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .9rem;
}
.input-group .input-prefix { left: 12px; }
.input-group .input-suffix { right: 12px; }
.input-group .form-control.has-prefix { padding-left: 32px; }
.input-group .form-control.has-suffix { padding-right: 32px; }

/* Checkbox / radio */
.form-check {
  display: flex; align-items: center; gap: var(--sp-2); cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

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

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

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }

.td-muted { color: var(--text-muted); font-size: .8rem; }

/* ── Badges / Chips ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-green   { background: var(--green-soft);  color: var(--green); }
.badge-red     { background: var(--red-soft);    color: var(--red); }
.badge-amber   { background: var(--amber-soft);  color: var(--amber); }
.badge-accent  { background: var(--accent-soft); color: var(--accent); }
.badge-purple  { background: var(--purple-soft); color: var(--purple); }
.badge-muted   { background: var(--bg-input);    color: var(--text-muted); }

/* ── Progress Bars ───────────────────────────────────────── */
.progress { height: 6px; background: var(--bg-input); border-radius: 99px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 99px;
  background: var(--accent);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.progress-bar.green  { background: var(--green); }
.progress-bar.amber  { background: var(--amber); }
.progress-bar.red    { background: var(--red); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  padding: var(--sp-8);
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-6);
}
.modal-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: var(--trans);
}
.modal-close:hover { color: var(--red); border-color: var(--red); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  font-size: .875rem;
  border: 1px solid;
}
.alert-danger  { background: var(--red-soft);   border-color: rgba(239,68,68,.2);  color: var(--red); }
.alert-warn    { background: var(--amber-soft);  border-color: rgba(245,158,11,.2); color: var(--amber); }
.alert-success { background: var(--green-soft);  border-color: rgba(34,197,94,.2);  color: var(--green); }
.alert-info    { background: var(--blue-soft);   border-color: rgba(59,130,246,.2); color: var(--blue); }

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6);
  z-index: 9999;
  display: flex; flex-direction: column-reverse; gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-3);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  min-width: 280px; max-width: 380px;
  pointer-events: all;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
}
.toast.out { animation: toastOut .25s ease forwards; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warn    { border-left: 3px solid var(--amber); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }

@keyframes toastIn  { from { opacity:0; transform:translateX(60px) scale(.9); } to { opacity:1; transform:none; } }
@keyframes toastOut { to   { opacity:0; transform:translateX(60px) scale(.9); } }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-6); }
.tab-btn {
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--trans);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Search & Filter Bar ─────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.search-box {
  position: relative; flex: 1; min-width: 200px;
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 38px;
}
.search-box .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .9rem;
}

/* ── Dropdown Menu ───────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  overflow: hidden;
  opacity: 0; transform: translateY(-8px) scale(.97);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.dropdown-menu.open { opacity: 1; transform: none; pointer-events: all; }
.dropdown-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 16px;
  font-size: .875rem; color: var(--text);
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  transition: var(--trans);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--accent); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-soft); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Avatar / Profile Photo ──────────────────────────────── */
.avatar-lg {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8B78FF);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 24px var(--accent-glow);
  overflow: hidden;
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: var(--sp-12) var(--sp-8);
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--sp-4); opacity: .5; }
.empty-state h3 { margin-bottom: var(--sp-2); color: var(--text-soft); }
.empty-state p  { font-size: .875rem; margin-bottom: var(--sp-5); }

/* ── Loading States ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Charts container ────────────────────────────────────── */
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }

/* ── Payment Timeline ────────────────────────────────────── */
.payment-timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: var(--sp-4); position: relative;
  padding-bottom: var(--sp-5);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute; left: 15px; top: 30px;
  width: 1px; bottom: 0;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  z-index: 1;
}
.timeline-dot.paid    { background: var(--green-soft);  color: var(--green); }
.timeline-dot.partial { background: var(--amber-soft);  color: var(--amber); }
.timeline-dot.pending { background: var(--red-soft);    color: var(--red); }

/* ── Attendance Grid (calendar) ──────────────────────────── */
.att-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-2);
}
.att-day {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 600;
  cursor: default;
}
.att-day.present { background: var(--green-soft);  color: var(--green); }
.att-day.absent  { background: var(--red-soft);    color: var(--red); }
.att-day.holiday { background: var(--amber-soft);  color: var(--amber); }
.att-day.empty   { opacity: .2; background: var(--bg-input); }

/* ── Notification Panel ──────────────────────────────────── */
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 12px);
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  opacity: 0; transform: translateY(-8px);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.notif-panel.open { opacity: 1; transform: none; pointer-events: all; }
.notif-header { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex; gap: var(--sp-3); font-size: .8rem;
  transition: var(--trans);
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 5px; }

/* ── Utility Classes ─────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: var(--sp-5); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.ml-auto { margin-left: auto; }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-amber   { color: var(--amber); }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.font-bold { font-weight: 700; }
.font-display { font-family: var(--font-display); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0; }

/* ── Divider ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--sp-5) 0; }

/* ── Page loader ─────────────────────────────────────────── */
#page-loader {
  position: fixed; inset: 0; background: var(--bg); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: var(--sp-4);
  transition: opacity .3s;
}
#page-loader.done { opacity: 0; pointer-events: none; }
#page-loader .logo-pulse {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #8B78FF);
  border-radius: var(--r-lg);
  animation: pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 40px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
}
@keyframes pulse { 0%,100%{ transform:scale(1); } 50%{ transform:scale(1.1); } }

/* ── Print styles ────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-actions, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .page-content { padding: var(--sp-6); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }

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

  .page-content { padding: var(--sp-5) var(--sp-4); }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .page-header { flex-direction: column; }
  .page-actions { flex-wrap: wrap; }

  .filter-bar { flex-direction: column; }
  .search-box { width: 100%; }

  .modal { max-width: 100%; border-radius: var(--r-lg); padding: var(--sp-6); }
  .modal-xl, .modal-lg { max-width: 100%; }

  table { font-size: .8rem; }
  thead th, tbody td { padding: 10px 12px; }

  /* Mobile overlay when sidebar open */
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 99; display: none;
  }
  .sidebar-overlay.visible { display: block; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .topbar { padding: 0 var(--sp-4); }
  .form-row { grid-template-columns: 1fr; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}
