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

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

body {
  font-family: 'Tajawal', sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  color: #1e293b;
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.logo-section {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  display: inline-block;
  margin-bottom: 16px;
}

.logo-section h1 {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.subtitle {
  color: #64748b;
  font-size: 15px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 14px;
  color: #374151;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  font-family: 'Tajawal', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8fafc;
  direction: rtl;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: #ffffff;
}

.form-group input::placeholder {
  color: #94a3b8;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: #94a3b8;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Tajawal', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  background: var(--primary, #2563eb);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid #e2e8f0;
  color: #64748b;
}

.btn-outline:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

.alert-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.footer-link {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: #64748b;
}

.footer-link a {
  color: var(--primary, #2563eb);
  text-decoration: none;
  font-weight: 500;
}

.footer-link a:hover {
  text-decoration: underline;
}

.navbar {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}

.nav-top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo {
  display: flex;
}

.nav-links-desktop {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 24px 10px;
  overflow: visible;
}

.nav-links-mobile {
  display: none;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.nav-link.active {
  background: #eff6ff;
  color: var(--primary, #2563eb);
  font-weight: 600;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: var(--card-bg, white);
  border: 1.5px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 1000;
  animation: navDropFade 0.15s ease;
}

@keyframes navDropFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-dropdown-item:hover {
  background: var(--hover-bg, #f1f5f9);
}

.nav-dropdown-item.active {
  background: #eff6ff;
  color: var(--primary, #2563eb);
  font-weight: 600;
}

.nav-mobile-section {
  border-bottom: 1px solid var(--border-color, #f1f5f9);
}

.nav-mobile-section-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  transition: background 0.15s;
}

.nav-mobile-section-toggle:hover {
  background: var(--hover-bg, #f8fafc);
}

.nav-mobile-chevron {
  margin-right: auto;
  transition: transform 0.2s;
}

.nav-mobile-section.open .nav-mobile-chevron {
  transform: rotate(180deg);
}

.nav-mobile-section-items {
  display: none;
  padding: 0 8px 8px 20px;
}

.nav-mobile-section.open .nav-mobile-section-items {
  display: block;
}

.nav-mobile-link.sub-link {
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 8px;
  margin-bottom: 2px;
}

.nav-support-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary, #2563eb);
  background: #eff6ff;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  border: 1.5px solid transparent;
}
.nav-support-btn:hover {
  background: #dbeafe;
  border-color: var(--primary, #2563eb);
}
.nav-support-btn svg { flex-shrink: 0; }

.nav-avatar-link { text-decoration: none; }
.nav-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; overflow: hidden; transition: all 0.2s; border: 2px solid transparent; }
.nav-avatar:hover { border-color: rgba(255,255,255,0.5); transform: scale(1.05); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar-emoji { font-size: 18px; line-height: 1; }
.nav-avatar-initials { font-size: 13px; font-weight: 700; }

.nav-user {
  font-size: 14px;
  font-weight: 500;
  color: #475569;
}

.nav-mobile-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: all 0.2s;
  border-radius: 0;
}
.nav-mobile-link:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.nav-mobile-link.active {
  background: #eff6ff;
  color: var(--primary, #2563eb);
  font-weight: 600;
}
.nav-mobile-link svg {
  flex-shrink: 0;
}
.nav-mobile-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 8px 0;
}
.nav-mobile-logout {
  color: #dc2626;
}
.nav-mobile-logout:hover {
  background: #fef2f2;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #64748b;
  border-radius: 8px;
  transition: background 0.2s;
}
.mobile-menu-btn:hover {
  background: #f1f5f9;
}

.subscription-expired-banner {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: linear-gradient(135deg, #fef2f2, #fff1f2);
  border: 2px solid #fecaca;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 28px;
}
.sub-expired-icon { flex-shrink: 0; }
.sub-expired-text h3 { font-size: 20px; font-weight: 700; color: #dc2626; margin-bottom: 8px; }
.sub-expired-text p { font-size: 15px; color: #7f1d1d; line-height: 1.7; }

.dark-theme .subscription-expired-banner {
  background: linear-gradient(135deg, #450a0a, #1e293b);
  border-color: #7f1d1d;
}
.dark-theme .sub-expired-text h3 { color: #f87171; }
.dark-theme .sub-expired-text p { color: #fca5a5; }

.dashboard-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.welcome-banner {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
  border-radius: 16px;
  padding: 32px;
  color: white;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.welcome-text h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-text p {
  font-size: 15px;
  opacity: 0.85;
}

.promo-slider {
  position: relative;
  min-height: 80px;
}

.promo-slide {
  display: none;
  animation: promoFadeIn 0.5s ease;
}

.promo-slide.active {
  display: block;
}

.promo-slide h3 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.promo-slide-icon {
  font-size: 26px;
  flex-shrink: 0;
}

.promo-slide p {
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.6;
}

.promo-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.promo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: all 0.3s;
}

.promo-dot.active {
  background: #fff;
  width: 20px;
  border-radius: 4px;
}

@keyframes promoFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-stats {
  display: flex;
  gap: 24px;
}

.stat-item {
  text-align: center;
  background: rgba(255,255,255,0.15);
  padding: 16px 24px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.stat-number {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

.stat-label {
  font-size: 13px;
  opacity: 0.85;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 20px;
  margin-top: 8px;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.service-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: all 0.25s;
  display: block;
  border: 1.5px solid transparent;
}

.service-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  border-color: var(--primary, #2563eb);
}

.service-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.service-card h4 {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 6px;
}

.service-card p {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
}

.main-categories {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.category-card {
  position: relative;
  padding: 28px 20px 22px;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
}

.category-card .service-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.category-card h4 {
  font-size: 17px;
  margin-bottom: 6px;
}

.category-card:hover {
  border-color: var(--primary, #2563eb);
}

.category-count {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.dark-theme .category-count {
  background: #334155;
  color: #94a3b8;
}

.category-page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid #e2e8f0;
}

.category-page-header .cat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.category-page-header h2 {
  font-size: 1.4rem;
  color: var(--text-primary, #1e293b);
  margin: 0;
}

.category-page-header .cat-back {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary, #64748b);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 10px;
  background: #f1f5f9;
  transition: background 0.2s;
}

.category-page-header .cat-back:hover {
  background: #e2e8f0;
}

.dark-theme .category-page-header {
  border-bottom-color: #334155;
}

.dark-theme .category-page-header .cat-back {
  background: #1e293b;
  color: #94a3b8;
}

.subjects-preview {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.subject-card-mini {
  background: #ffffff;
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
  flex: 1;
  min-width: 160px;
}

.subject-color-bar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: var(--primary, #2563eb);
}

.subject-card-mini:nth-child(2) .subject-color-bar { background: #16a34a; }
.subject-card-mini:nth-child(3) .subject-color-bar { background: #d97706; }

.subject-card-mini h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  padding-top: 4px;
}

.subject-grade {
  font-size: 12px;
  color: #94a3b8;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.page-header p {
  font-size: 15px;
  color: #64748b;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.subject-card {
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s;
}

.subject-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.subject-header {
  padding: 20px 24px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subject-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.subject-grade-tag {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
}

.subject-body {
  padding: 20px 24px;
}

.subject-desc {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 16px;
}

.subject-resources {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
  color: #475569;
  transition: background 0.2s;
  cursor: pointer;
}

.resource-item:hover {
  background: #eff6ff;
  color: var(--primary, #2563eb);
}

.schedule-table-wrapper {
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: #f8fafc;
}

.data-table th {
  padding: 14px 20px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 20px;
  font-size: 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #475569;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

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

.day-badge {
  display: inline-block;
  padding: 4px 12px;
  background: #eff6ff;
  color: var(--primary, #2563eb);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.progress-bar {
  width: 80px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-fill.high { background: #16a34a; }
.progress-fill.medium { background: #d97706; }
.progress-fill.low { background: #dc2626; }

.pct-text {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.status-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.status-present {
  background: #dcfce7;
  color: #16a34a;
}

.status-absent {
  background: #fef2f2;
  color: #dc2626;
}

.attendance-summary {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.summary-card {
  flex: 1;
  min-width: 120px;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
}

.summary-total {
  background: #eff6ff;
}

.summary-present {
  background: #dcfce7;
}

.summary-absent {
  background: #fef2f2;
}

.summary-number {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 4px;
}

.summary-label {
  font-size: 14px;
  color: #64748b;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.plan-card {
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.plan-header {
  background: #f8fafc;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
}

.plan-week {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary, #2563eb);
  background: #eff6ff;
  padding: 4px 12px;
  border-radius: 6px;
}

.plan-subject {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.plan-body {
  padding: 20px;
}

.plan-topic {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
}

.plan-detail {
  margin-bottom: 14px;
}

.plan-detail:last-child {
  margin-bottom: 0;
}

.plan-detail-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.plan-detail p {
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
  padding-right: 22px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.empty-state svg {
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

@media (max-width: 1024px) {
  .nav-links-desktop {
    gap: 2px;
  }
  .nav-link {
    padding: 8px 10px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .nav-top-row {
    padding: 10px 16px;
  }

  .nav-links-desktop {
    display: none;
  }

  .nav-links-mobile {
    display: none;
    flex-direction: column;
    border-top: 1px solid #e2e8f0;
    padding: 8px 0;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .nav-links-mobile.show {
    display: flex;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-user {
    display: none;
  }

  .nav-logout-btn {
    display: none;
  }

  .nav-support-btn {
    display: none;
  }

  .nav-desktop-auth {
    display: none;
  }

  .nav-top-actions {
    gap: 8px;
  }

  .nav-brand span {
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  .welcome-banner {
    flex-direction: column;
    text-align: center;
    padding: 24px;
  }

  .welcome-stats {
    width: 100%;
    justify-content: center;
  }

  .stat-item {
    padding: 12px 16px;
  }

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

  .subjects-grid {
    grid-template-columns: 1fr;
  }

  .plans-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 28px 24px;
  }

  .dashboard-container {
    padding: 20px 16px;
  }

  .subject-resources {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .page-header h2 {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .services-grid {
    grid-template-columns: 1fr;
  }

  .welcome-stats {
    flex-direction: column;
    gap: 8px;
  }

  .stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h3 {
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: #1e293b;
}

.modal-content .form-group {
  margin-bottom: 16px;
}

.modal-content label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #475569;
  font-size: 0.9rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  direction: rtl;
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  border-color: var(--primary, #2563eb);
  outline: none;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn-primary {
  background: var(--primary, #2563eb);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark, #1d4ed8);
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-small {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
}

.btn-edit {
  background: #dbeafe;
  color: var(--primary-dark, #1d4ed8);
}

.btn-edit:hover {
  background: #bfdbfe;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
}

.btn-danger:hover {
  background: #fecaca;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

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

.alert {
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 500;
}

.alert-success {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.page-header .btn-primary {
  margin-right: auto;
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .modal-content {
    padding: 20px;
  }
  .actions-cell {
    flex-direction: column;
    gap: 4px;
  }
}

/* =====================================================================
   GLOBAL MOBILE / TABLET RESPONSIVE LAYER
   Applies to legacy views (login, register, dashboard, schedule, etc.)
   ===================================================================== */

/* Prevent horizontal page overflow */
html, body { max-width: 100vw; overflow-x: hidden; }

/* iPad / tablet portrait & smaller */
@media (max-width: 1024px) {
  .dashboard-container { max-width: 100%; padding: 22px 16px; }
}

/* Mobile (≤768px) — already partial above, augment here */
@media (max-width: 768px) {
  .dashboard-container { padding: 16px 12px 70px; }

  /* Page header stacks */
  .page-header h2 { font-size: 1.15rem; line-height: 1.4; }
  .page-header p { font-size: .88rem; }

  /* Tables: enable horizontal scroll instead of breaking layout */
  .schedule-table-wrapper, .data-table-wrapper, .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 12px; white-space: nowrap; }

  /* Buttons: comfortable tap targets */
  .btn-primary, .btn-secondary, .btn-outline, .btn,
  .btn-sm, .btn-small, .btn-danger, .btn-edit {
    min-height: 42px; padding: 10px 14px; font-size: .88rem;
  }
  .btn-sm, .btn-small { min-height: 36px; padding: 7px 12px; font-size: .8rem; }

  /* Form inputs: 16px font prevents iOS zoom on focus */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="tel"], input[type="search"],
  input[type="date"], input[type="time"], input[type="url"],
  select, textarea, .form-control, .form-select, .form-input {
    font-size: 16px !important;
  }

  /* Modals */
  .modal { padding: 12px; }
  .modal-content { max-width: calc(100vw - 24px); max-height: 90vh; overflow-y: auto; }

  /* Cards/grids stack */
  .card-grid, .stats-grid, .features-grid, .resources-grid {
    grid-template-columns: 1fr !important; gap: 12px;
  }

  /* Schedule timetable horizontal scroll */
  .schedule-grid, .timetable, .week-grid {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }

  /* Action cells stack vertically with small gaps */
  .actions-cell { gap: 6px; }
  .actions-cell .btn, .actions-cell button, .actions-cell a {
    width: 100%; justify-content: center; text-align: center;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .dashboard-container { padding: 12px 10px 70px; }
  .page-header { gap: 8px; margin-bottom: 16px; }
  .page-header h2 { font-size: 1.05rem; }
  .card { padding: 18px 16px !important; }
  .btn-primary, .btn-secondary, .btn-outline, .btn { width: auto; }

  /* Login/register card full width */
  .auth-card, .login-card, .register-card { max-width: 100%; padding: 24px 18px !important; }

  /* Navbar brand text smaller */
  .nav-brand span { font-size: 13px; }
  .nav-logo svg, .nav-logo img { width: 28px !important; height: 28px !important; }
}

/* Extra-small (≤360px) */
@media (max-width: 360px) {
  .nav-brand span { display: none; }
}

/* Touch-friendly scrolling everywhere */
* { -webkit-tap-highlight-color: rgba(0,0,0,0.05); }

/* =====================================================================
   COCKPIT / DASHBOARD / SCHEDULE / EXAM-GENERATOR / DIRECT-CLASSROOM
   Covers views that don't include ck-theme.ejs partial
   ===================================================================== */

/* iPad / tablet (≤1024px) */
@media (max-width: 1024px) {
  .cockpit { padding: 22px 14px 40px; }
  .cockpit-wrap { max-width: 100%; gap: 18px; }
  .gen-container { padding: 16px; }
  .a4-page, .page-wrapper { max-width: 100%; padding: 18px 14px; }
}

/* Tablet portrait (≤900px) */
@media (max-width: 900px) {
  .ck-cols { grid-template-columns: 1fr !important; gap: 14px !important; }
  .ck-qa-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .grid-2 { grid-template-columns: 1fr !important; }
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
  /* Dashboard cockpit */
  .cockpit { padding: 14px 10px 70px; }
  .cockpit-wrap { gap: 14px; }
  .ck-qa-grid { grid-template-columns: 1fr !important; }
  .ck-qa { padding: 14px !important; }
  .ck-next-card { flex-direction: column !important; align-items: stretch !important; text-align: center; gap: 12px !important; }
  .ck-next-left { flex-direction: column; text-align: center; gap: 10px; }
  .ck-next-cta { width: 100%; justify-content: center; }
  .ck-att-item, .ck-sched-row { flex-wrap: wrap; gap: 10px !important; }
  .ck-att-cta { width: 100%; justify-content: center; }
  .ck-section-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .label-long { display: none; }

  /* Schedule timetable: keep horizontally scrollable */
  .timetable-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; }
  .timetable { min-width: 720px; }
  .timetable th, .timetable td { padding: 6px 4px !important; font-size: .72rem !important; }
  .timetable td { min-width: 96px !important; height: 64px !important; }

  /* Exam generator */
  .gen-container { padding: 12px 10px; }
  .gen-header { flex-direction: column; text-align: center; padding: 20px 16px !important; gap: 10px !important; }
  .gen-header h2 { font-size: 1.1rem !important; }
  .gen-header-icon { width: 44px !important; height: 44px !important; }
  .grid-2 { grid-template-columns: 1fr !important; }

  /* Exam preview (A4) */
  .a4-page { padding: 16px 12px !important; box-shadow: none !important; }
  .exam-header { flex-direction: column; gap: 10px; text-align: center; }
  .exam-block { padding: 12px !important; }
  .mcq-options { gap: 6px !important; }
  .mcq-option { padding: 8px 10px !important; font-size: .9rem !important; }
  .match-table { font-size: .85rem; }

  /* Direct-classroom & form cards */
  .form-card { padding: 16px !important; }
  .form-row { flex-direction: column !important; gap: 10px !important; }
  .form-row > * { width: 100% !important; }
  .info-grid { grid-template-columns: 1fr !important; }
  .header-compact { flex-direction: column; align-items: flex-start !important; gap: 8px; }
  .att-summary { flex-wrap: wrap; gap: 8px !important; }
  .att-date-nav { flex-wrap: wrap; gap: 8px !important; }
  .att-date-nav > * { flex: 1 1 auto; }

  /* Modal overlays everywhere */
  .modal-overlay, .modal { padding: 10px; }
  .modal-content { max-width: calc(100vw - 20px) !important; max-height: 90vh !important; padding: 18px !important; }
  .modal-actions { flex-direction: column; gap: 8px; }
  .modal-actions .btn, .modal-actions button { width: 100%; justify-content: center; }
}

/* Tiny phones (≤400px) */
@media (max-width: 400px) {
  .cockpit-wrap { gap: 12px; }
  .timetable { min-width: 640px; }
}

/* Print: undo all mobile overrides */
@media print {
  html, body { overflow-x: visible !important; }
  .timetable-wrapper { overflow: visible !important; }
  .timetable { min-width: 0 !important; }
}


body.dark-theme {
  background: #0f172a;
  color: #e2e8f0;
}
.dark-theme .navbar {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.dark-theme .nav-brand, .dark-theme .nav-user {
  color: #e2e8f0;
}
.dark-theme .nav-link {
  color: #94a3b8;
}
.dark-theme .nav-link:hover {
  background: #334155;
  color: #e2e8f0;
}
.dark-theme .nav-link.active {
  background: rgba(37,99,235,0.15);
  color: #60a5fa;
}
.dark-theme .nav-links-mobile {
  border-top-color: #334155;
}
.dark-theme .nav-dropdown-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.dark-theme .nav-dropdown-item {
  color: #cbd5e1;
}
.dark-theme .nav-dropdown-item:hover {
  background: #334155;
  color: #f1f5f9;
}
.dark-theme .nav-dropdown-item.active {
  background: rgba(37,99,235,0.15);
  color: #60a5fa;
}
.dark-theme .nav-mobile-section {
  border-bottom-color: #334155;
}
.dark-theme .nav-mobile-section-toggle {
  color: #e2e8f0;
}
.dark-theme .nav-mobile-section-toggle:hover {
  background: #334155;
}
.dark-theme .nav-mobile-link {
  color: #cbd5e1;
}
.dark-theme .nav-mobile-link:hover {
  background: #334155;
  color: #f1f5f9;
}
.dark-theme .nav-mobile-link.active {
  background: rgba(37,99,235,0.15);
  color: #60a5fa;
}
.dark-theme .nav-mobile-divider {
  background: #334155;
}
.dark-theme .nav-mobile-logout {
  color: #f87171;
}
.dark-theme .nav-mobile-logout:hover {
  background: #450a0a;
}
.dark-theme .mobile-menu-btn {
  color: #94a3b8;
}
.dark-theme .mobile-menu-btn:hover {
  background: #334155;
}
.dark-theme .dashboard-container {
  color: #e2e8f0;
}
.dark-theme .welcome-banner {
  background: linear-gradient(135deg, var(--primary, #2563eb) 0%, #1e293b 100%);
}
.dark-theme .service-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .service-card:hover {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.dark-theme .service-card h4 {
  color: #e2e8f0;
}
.dark-theme .service-card p {
  color: #94a3b8;
}
.dark-theme .section-title {
  color: #e2e8f0;
}
.dark-theme .card {
  background: #1e293b;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.dark-theme .form-group input, .dark-theme .form-group select, .dark-theme .form-group textarea {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .form-group input:focus, .dark-theme .form-group select:focus {
  background: #1e293b;
  border-color: var(--primary, #2563eb);
}
.dark-theme .form-group label {
  color: #cbd5e1;
}
.dark-theme .subject-card-mini {
  background: #1e293b;
  border-color: #334155;
}
.dark-theme table {
  background: #1e293b;
}
.dark-theme th {
  background: #334155;
  color: #e2e8f0;
}
.dark-theme td {
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .empty-state {
  color: #94a3b8;
}
.dark-theme .empty-state h3 {
  color: #cbd5e1;
}
.dark-theme .btn-outline {
  border-color: #475569;
  color: #94a3b8;
}
.dark-theme .btn-outline:hover {
  border-color: #64748b;
  background: #334155;
  color: #e2e8f0;
}
.dark-theme .page-header h2 {
  color: #e2e8f0;
}
.dark-theme .page-header p {
  color: #94a3b8;
}
.dark-theme .stat-card {
  background: #1e293b;
  border-color: #334155;
}
.dark-theme .modal-content {
  background: #1e293b;
}
.dark-theme .schedule-table-wrapper {
  background: #1e293b;
}
.dark-theme .student-item {
  background: #0f172a;
  border-color: #334155;
}
.dark-theme .classroom-card {
  background: #1e293b;
  border-color: #334155;
}
.dark-theme .week-card {
  background: #1e293b;
  border-color: #334155;
}
.dark-theme .plan-section-header {
  background: linear-gradient(135deg, var(--primary, #2563eb) 0%, #1e293b 100%);
}
.dark-theme .alert {
  border-width: 1px;
}
.dark-theme .alert-success {
  background: #052e16;
  color: #86efac;
  border-color: #166534;
}
.dark-theme .alert-error {
  background: #450a0a;
  color: #fca5a5;
  border-color: #7f1d1d;
}
.dark-theme .btn-secondary {
  background: #334155;
  color: #cbd5e1;
}
.dark-theme .btn-secondary:hover {
  background: #475569;
}
.dark-theme .btn-primary {
  color: white;
}
.dark-theme .subject-card,
.dark-theme .subjects-grid .subject-card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.dark-theme .subject-body {
  background: #1e293b;
}
.dark-theme .subject-body p,
.dark-theme .subject-desc {
  color: #94a3b8;
}
.dark-theme .card-actions a,
.dark-theme .card-actions button {
  color: #cbd5e1;
}
.dark-theme input[type="date"],
.dark-theme input[type="number"],
.dark-theme input[type="text"],
.dark-theme select,
.dark-theme textarea {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .grade-input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .grade-input:focus {
  border-color: var(--primary, #2563eb);
}
.dark-theme .status-label {
  border-color: #334155;
  color: #cbd5e1;
}
.dark-theme .form-select {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .modal-overlay {
  background: rgba(0,0,0,0.6);
}
.dark-theme .modal-content h3,
.dark-theme .modal-content h4 {
  color: #f1f5f9;
}
.dark-theme .modal-content label {
  color: #cbd5e1;
}
.dark-theme .modal-content input,
.dark-theme .modal-content select,
.dark-theme .modal-content textarea {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.grades-form-box {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}
.grades-form-box h4 {
  color: #1e293b;
}
.dark-theme .grades-form-box {
  background: #1e293b;
  border-color: #334155;
}
.dark-theme .grades-form-box h4 {
  color: #f1f5f9;
}
.dark-theme .date-nav input[type="date"] {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.dark-theme .status-toggle label,
.dark-theme .status-toggle .status-label {
  border-color: #334155;
  color: #cbd5e1;
}
.dark-theme .nav-support-btn { background: #1e293b; color: #60a5fa; }
.dark-theme .nav-support-btn:hover { background: #334155; border-color: #60a5fa; }
.dark-theme a:not(.nav-link):not(.nav-mobile-link):not(.nav-brand):not(.nav-avatar-link):not(.nav-support-btn) { color: #60a5fa; }
.dark-theme a:not(.nav-link):not(.nav-mobile-link):not(.nav-brand):not(.nav-avatar-link):not(.nav-support-btn):hover { color: #93bbfd; }

.floating-help-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Tajawal', sans-serif;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.floating-help-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.45);
  color: #fff;
}
.floating-help-btn svg { flex-shrink: 0; }
.dark-theme .floating-help-btn {
  background: linear-gradient(135deg, #5b21b6, #4c1d95);
  box-shadow: 0 4px 16px rgba(91, 33, 182, 0.4);
}
.dark-theme .floating-help-btn:hover {
  box-shadow: 0 6px 24px rgba(91, 33, 182, 0.55);
  color: #fff;
}

/* ============================================================
   COMPREHENSIVE DARK-MODE COVERAGE
   Catches inline styles + shared class names so no page or
   component appears white when body.dark-theme is active.
   Scoped to body.dark-theme; excludes admin (.admin-body) and
   print contexts (handled by their own @media print rules).
   ============================================================ */

/* --- White backgrounds in inline styles --- */
body.dark-theme [style*="background:white"],
body.dark-theme [style*="background: white"],
body.dark-theme [style*="background:#fff;"],
body.dark-theme [style*="background: #fff;"],
body.dark-theme [style*="background:#fff "],
body.dark-theme [style*="background: #fff "],
body.dark-theme [style*="background:#ffffff"],
body.dark-theme [style*="background: #ffffff"],
body.dark-theme [style*="background-color:white"],
body.dark-theme [style*="background-color: white"],
body.dark-theme [style*="background-color:#fff"],
body.dark-theme [style*="background-color: #fff"],
body.dark-theme [style*="background-color:#ffffff"],
body.dark-theme [style*="background-color: #ffffff"] {
  background: var(--ck-card, #111a2e) !important;
  border-color: var(--ck-border, #1f2a44) !important;
}

/* --- Very-light surface tints --- */
body.dark-theme [style*="background:#f8fafc"],
body.dark-theme [style*="background: #f8fafc"],
body.dark-theme [style*="background:#f1f5f9"],
body.dark-theme [style*="background: #f1f5f9"],
body.dark-theme [style*="background:#f9fafb"],
body.dark-theme [style*="background: #f9fafb"],
body.dark-theme [style*="background:#f3f4f6"],
body.dark-theme [style*="background: #f3f4f6"] {
  background: #0f172a !important;
  border-color: var(--ck-border, #1f2a44) !important;
}

/* --- Dark text colors (would be invisible on dark surfaces) --- */
body.dark-theme [style*="color:#0f172a"],
body.dark-theme [style*="color: #0f172a"],
body.dark-theme [style*="color:#1e293b"],
body.dark-theme [style*="color: #1e293b"],
body.dark-theme [style*="color:#0b1220"],
body.dark-theme [style*="color: #0b1220"] {
  color: var(--ck-text, #e8eef9) !important;
}
body.dark-theme [style*="color:#334155"],
body.dark-theme [style*="color: #334155"],
body.dark-theme [style*="color:#475569"],
body.dark-theme [style*="color: #475569"],
body.dark-theme [style*="color:#64748b"],
body.dark-theme [style*="color: #64748b"] {
  color: var(--ck-muted, #94a3b8) !important;
}

/* --- Light borders in inline styles --- */
body.dark-theme [style*="border:1px solid #e2e8f0"],
body.dark-theme [style*="border: 1px solid #e2e8f0"],
body.dark-theme [style*="border:1.5px solid #e2e8f0"],
body.dark-theme [style*="border: 1.5px solid #e2e8f0"],
body.dark-theme [style*="border:1px solid #e5e7eb"],
body.dark-theme [style*="border: 1px solid #e5e7eb"],
body.dark-theme [style*="border:1.5px solid #e5e7eb"],
body.dark-theme [style*="border: 1.5px solid #e5e7eb"],
body.dark-theme [style*="border-color:#e2e8f0"],
body.dark-theme [style*="border-color: #e2e8f0"] {
  border-color: var(--ck-border, #1f2a44) !important;
}

/* --- Shared class names with hardcoded light backgrounds --- */
body.dark-theme .form-card,
body.dark-theme .q-card,
body.dark-theme .answer-card,
body.dark-theme .source-tab,
body.dark-theme .q-type-check,
body.dark-theme .cur-card,
body.dark-theme .cur-add-section,
body.dark-theme .cur-empty-state,
body.dark-theme .modal-box,
body.dark-theme .st-card,
body.dark-theme .st-class-card,
body.dark-theme .unit-card,
body.dark-theme .my-product-card,
body.dark-theme .review-card,
body.dark-theme .st-modal,
body.dark-theme .st-empty-state,
body.dark-theme .content-item,
body.dark-theme .option-row,
body.dark-theme .ed-row,
body.dark-theme .review-form-box,
body.dark-theme .nav,
body.dark-theme .static-page .card {
  background: var(--ck-card, #111a2e) !important;
  border-color: var(--ck-border, #1f2a44) !important;
  color: var(--ck-text, #e8eef9);
}

/* iframes that embed external PDFs/files keep white (those are real document content),
   but stop the bordering wrapper from looking out of place */
body.dark-theme iframe[style*="background:white"],
body.dark-theme iframe[style*="background: white"] {
  background: #ffffff !important; /* PDFs need a white surface */
  border-color: var(--ck-border, #1f2a44) !important;
}

/* Auth pages (login/register) — already use cards via .card class.
   Catch any stray standalone <body> backgrounds left light. */
body.dark-theme.auth-bg,
body.dark-theme .auth-card {
  background: var(--ck-card, #111a2e);
  color: var(--ck-text, #e8eef9);
}

/* Tables: lighten zebra rows + make light-yellow/red row tints readable */
body.dark-theme tr[style*="background:#fffdf4"],
body.dark-theme tr[style*="background: #fffdf4"],
body.dark-theme tr[style*="background:#fffbeb"],
body.dark-theme tr[style*="background: #fffbeb"],
body.dark-theme thead[style*="background:#fffbeb"],
body.dark-theme thead[style*="background: #fffbeb"] {
  background: rgba(217,119,6,0.10) !important;
}
body.dark-theme tr[style*="background:#fff5f5"],
body.dark-theme tr[style*="background: #fff5f5"] {
  background: rgba(220,38,38,0.10) !important;
}

/* Schedule print fallback (study-plan/schedule/grades-analysis explicitly
   force white inside @media print — those rules win at print time). */

/* ============================================================
   EXTENDED DARK-MODE COVERAGE — pastel surfaces + dark text on
   them. Covers direct-classroom/* tabs (settings, attendance,
   chat, assignments, exam library) and anywhere else that uses
   light pastel inline backgrounds.
   ============================================================ */

/* Pastel backgrounds → dark surface. Property-qualified to avoid
   false positives on border/color usage of the same hex. */
body.dark-theme [style*="background:#ecfdf5"], body.dark-theme [style*="background: #ecfdf5"], body.dark-theme [style*="background-color:#ecfdf5"], body.dark-theme [style*="background-color: #ecfdf5"],
body.dark-theme [style*="background:#d1fae5"], body.dark-theme [style*="background: #d1fae5"], body.dark-theme [style*="background-color:#d1fae5"], body.dark-theme [style*="background-color: #d1fae5"],
body.dark-theme [style*="background:#f0fdf4"], body.dark-theme [style*="background: #f0fdf4"], body.dark-theme [style*="background-color:#f0fdf4"], body.dark-theme [style*="background-color: #f0fdf4"],
body.dark-theme [style*="background:#dcfce7"], body.dark-theme [style*="background: #dcfce7"], body.dark-theme [style*="background-color:#dcfce7"], body.dark-theme [style*="background-color: #dcfce7"],
body.dark-theme [style*="background:#f5f3ff"], body.dark-theme [style*="background: #f5f3ff"], body.dark-theme [style*="background-color:#f5f3ff"], body.dark-theme [style*="background-color: #f5f3ff"],
body.dark-theme [style*="background:#ede9fe"], body.dark-theme [style*="background: #ede9fe"], body.dark-theme [style*="background-color:#ede9fe"], body.dark-theme [style*="background-color: #ede9fe"],
body.dark-theme [style*="background:#faf5ff"], body.dark-theme [style*="background: #faf5ff"], body.dark-theme [style*="background-color:#faf5ff"], body.dark-theme [style*="background-color: #faf5ff"],
body.dark-theme [style*="background:#fff7ed"], body.dark-theme [style*="background: #fff7ed"], body.dark-theme [style*="background-color:#fff7ed"], body.dark-theme [style*="background-color: #fff7ed"],
body.dark-theme [style*="background:#fed7aa"], body.dark-theme [style*="background: #fed7aa"], body.dark-theme [style*="background-color:#fed7aa"], body.dark-theme [style*="background-color: #fed7aa"],
body.dark-theme [style*="background:#fef3c7"], body.dark-theme [style*="background: #fef3c7"], body.dark-theme [style*="background-color:#fef3c7"], body.dark-theme [style*="background-color: #fef3c7"],
body.dark-theme [style*="background:#fef2f2"], body.dark-theme [style*="background: #fef2f2"], body.dark-theme [style*="background-color:#fef2f2"], body.dark-theme [style*="background-color: #fef2f2"],
body.dark-theme [style*="background:#fee2e2"], body.dark-theme [style*="background: #fee2e2"], body.dark-theme [style*="background-color:#fee2e2"], body.dark-theme [style*="background-color: #fee2e2"],
body.dark-theme [style*="background:#eff6ff"], body.dark-theme [style*="background: #eff6ff"], body.dark-theme [style*="background-color:#eff6ff"], body.dark-theme [style*="background-color: #eff6ff"],
body.dark-theme [style*="background:#dbeafe"], body.dark-theme [style*="background: #dbeafe"], body.dark-theme [style*="background-color:#dbeafe"], body.dark-theme [style*="background-color: #dbeafe"],
body.dark-theme [style*="background:#f0f9ff"], body.dark-theme [style*="background: #f0f9ff"], body.dark-theme [style*="background-color:#f0f9ff"], body.dark-theme [style*="background-color: #f0f9ff"] {
  background: var(--ck-card, #111a2e) !important;
  background-image: none !important;
  border-color: var(--ck-border, #1f2a44) !important;
}

/* Dark accent text colors used inside pastel boxes — invisible on
   dark surfaces. Force to light accents (keeps semantic hue). */
body.dark-theme [style*="color:#065f46"],
body.dark-theme [style*="color: #065f46"],
body.dark-theme [style*="color:#047857"],
body.dark-theme [style*="color: #047857"],
body.dark-theme [style*="color:#166534"],
body.dark-theme [style*="color: #166534"],
body.dark-theme [style*="color:#14532d"],
body.dark-theme [style*="color: #14532d"],
body.dark-theme [style*="color:#16a34a"],
body.dark-theme [style*="color: #16a34a"] { color: #86efac !important; }

body.dark-theme [style*="color:#7c2d12"],
body.dark-theme [style*="color: #7c2d12"],
body.dark-theme [style*="color:#9a3412"],
body.dark-theme [style*="color: #9a3412"],
body.dark-theme [style*="color:#c2410c"],
body.dark-theme [style*="color: #c2410c"],
body.dark-theme [style*="color:#92400e"],
body.dark-theme [style*="color: #92400e"],
body.dark-theme [style*="color:#a16207"],
body.dark-theme [style*="color: #a16207"],
body.dark-theme [style*="color:#d97706"],
body.dark-theme [style*="color: #d97706"] { color: #fcd34d !important; }

body.dark-theme [style*="color:#991b1b"],
body.dark-theme [style*="color: #991b1b"],
body.dark-theme [style*="color:#dc2626"],
body.dark-theme [style*="color: #dc2626"],
body.dark-theme [style*="color:#ef4444"],
body.dark-theme [style*="color: #ef4444"] { color: #fca5a5 !important; }

body.dark-theme [style*="color:#5b21b6"],
body.dark-theme [style*="color: #5b21b6"],
body.dark-theme [style*="color:#7c3aed"],
body.dark-theme [style*="color: #7c3aed"] { color: #c4b5fd !important; }

body.dark-theme [style*="color:#1e40af"],
body.dark-theme [style*="color: #1e40af"],
body.dark-theme [style*="color:#1d4ed8"],
body.dark-theme [style*="color: #1d4ed8"],
body.dark-theme [style*="color:#1e3a8a"],
body.dark-theme [style*="color: #1e3a8a"],
body.dark-theme [style*="color:#0369a1"],
body.dark-theme [style*="color: #0369a1"] { color: #93c5fd !important; }

/* Gradients with light pastel stops — flatten to dark surface */
body.dark-theme [style*="linear-gradient(135deg,#ecfdf5"],
body.dark-theme [style*="linear-gradient(135deg, #ecfdf5"],
body.dark-theme [style*="linear-gradient(135deg, #f5f3ff"],
body.dark-theme [style*="linear-gradient(135deg,#f5f3ff"],
body.dark-theme [style*="linear-gradient(135deg, #f0fdf4"],
body.dark-theme [style*="linear-gradient(135deg,#f0fdf4"],
body.dark-theme [style*="linear-gradient(135deg, #fff7ed"],
body.dark-theme [style*="linear-gradient(135deg,#fff7ed"] {
  background: var(--ck-card, #111a2e) !important;
  background-image: none !important;
  border-color: var(--ck-border, #1f2a44) !important;
}

/* End comprehensive dark-mode coverage */
