:root {
  /* Brand Palettes - Ultra-Refined Executive Palette */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.35);

  --secondary: #0ea5e9;
  --secondary-hover: #0284c7;
  --secondary-light: rgba(14, 165, 233, 0.12);

  --success: #10b981;
  --success-hover: #059669;
  --success-light: rgba(16, 185, 129, 0.12);
  --success-glow: rgba(16, 185, 129, 0.3);

  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);

  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-light: rgba(244, 63, 94, 0.12);
  --danger-glow: rgba(244, 63, 94, 0.3);

  --purple: #a855f7;
  --purple-light: rgba(168, 85, 247, 0.12);

  /* Modern Studio Dark Theme (Default) */
  --bg-main: #0b0f19;
  --bg-gradient: radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
                 radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.06) 0%, transparent 40%),
                 #0b0f19;
  --surface-1: #111726;
  --surface-2: #172033;
  --surface-3: #1f2b45;
  --surface-hover: #1c273e;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-hover: rgba(99, 102, 241, 0.45);

  --text-primary: #ffffff;
  --text-secondary: #cbd5e1;
  --text-muted: #7888a0;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 18px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.6), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
  --shadow-glow: 0 0 24px var(--primary-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --glass-blur: blur(12px);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-gradient: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 40%),
                 radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.03) 0%, transparent 40%),
                 #f8fafc;
  --surface-1: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --surface-hover: #e8eef6;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --border-hover: rgba(99, 102, 241, 0.4);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #8492a6;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 14px 32px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14.5px;
  scroll-behavior: smooth;
  box-sizing: border-box;
}

body {
  font-family: 'Cairo', 'Alexandria', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  letter-spacing: -0.15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  box-sizing: border-box;
}

/* Custom Ultra-Slim Clean Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Background Ambient Orbs - Hardware Accelerated without expensive CSS filter blur */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  transform: translateZ(0);
}
.ambient-orb-1 {
  width: 500px;
  height: 500px;
  top: -100px;
  right: -100px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.22) 0%, rgba(99, 102, 241, 0.04) 45%, transparent 70%);
}
.ambient-orb-2 {
  width: 450px;
  height: 450px;
  bottom: -80px;
  left: -80px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.18) 0%, rgba(6, 182, 212, 0.03) 45%, transparent 70%);
}

/* Layout Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Header & Nav */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 16px;
  z-index: 100;
  transition: var(--transition-normal);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
  position: relative;
}

.brand-logo svg {
  width: 28px;
  height: 28px;
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title .highlight {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--border-hover);
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  user-select: none;
}
.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-success:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.38);
}

.btn-danger-ghost {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.2);
}
.btn-danger-ghost:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-1px);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.btn-wa-status {
  background: rgba(37, 211, 102, 0.08);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #25d366;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-wa-status:hover {
  background: rgba(37, 211, 102, 0.16);
  border-color: #25d366;
  color: #25d366;
  transform: translateY(-1px);
}
.wa-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  display: inline-block;
  flex-shrink: 0;
}
.wa-status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.8);
  animation: pulseDot 2s infinite ease-in-out;
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-paid {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.badge-paid .badge-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.badge-overdue {
  background: rgba(244, 63, 94, 0.12);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.25);
}
.badge-overdue .badge-dot {
  background: #f43f5e;
  box-shadow: 0 0 6px #f43f5e;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.badge-pending .badge-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.badge-trial {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.badge-trial .badge-dot {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.badge-active {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.badge-suspended {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Toast Notifications */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.25s ease;
}
.toast.success { border-right: 4px solid var(--success); }
.toast.error { border-right: 4px solid var(--danger); }
.toast.info { border-right: 4px solid var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive Media Queries - Multi-device Precision */
@media (max-width: 1280px) {
  .app-container {
    padding: 20px 24px;
    gap: 22px;
  }
  .main-header {
    padding: 14px 22px;
  }
}

@media (max-width: 1080px) {
  .main-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 16px 20px;
    top: 8px;
  }
  .brand-section {
    justify-content: space-between;
    width: 100%;
  }
  .header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .header-actions .btn {
    flex: 1 1 auto;
    font-size: 0.84rem;
    padding: 8px 12px;
  }
  .header-actions .btn-icon-only {
    flex: 0 0 40px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  .app-container {
    padding: 12px 14px;
    gap: 16px;
  }

  .main-header {
    padding: 12px 14px;
    gap: 12px;
    border-radius: var(--radius-lg);
    top: 4px;
  }

  .brand-section {
    gap: 10px;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .brand-logo img {
    width: 26px !important;
    height: 26px !important;
  }

  .brand-title {
    font-size: 1.18rem;
    flex-wrap: wrap;
    gap: 6px;
  }

  .brand-badge {
    font-size: 0.68rem;
    padding: 2px 8px;
  }

  .brand-subtitle {
    font-size: 0.74rem;
    line-height: 1.35;
    margin-top: 2px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
  }

  /* Make Primary Add Teacher span full width on small screens */
  .header-actions #openAddTeacherBtn {
    grid-column: 1 / -1;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 800;
  }

  .header-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    padding: 8px 10px;
    min-height: 40px;
    white-space: normal;
    text-align: center;
  }

  .header-actions .btn-icon-only {
    width: 100%;
    min-width: 0;
  }

  #toastContainer {
    bottom: 20px;
    right: 12px;
    left: 12px;
    width: auto;
    align-items: stretch;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    padding: 12px 14px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 13.5px;
  }
  .app-container {
    padding: 10px 10px;
    gap: 12px;
  }
  .header-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .header-actions .btn {
    font-size: 0.76rem;
    padding: 7px 8px;
    gap: 6px;
  }
}
