:root {
  color-scheme: dark;
  --font-family: "Space Grotesk", "Cairo", "Segoe UI", sans-serif;
  --bg-page: #030712;
  --bg-page-gradient: radial-gradient(circle at top left, rgba(34, 197, 94, 0.08) 0%, transparent 40%),
    radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.1) 0%, transparent 40%),
    #030712;
  --bg-card: #1f2937;
  --bg-muted: #111827;
  --bg-toolbar: #374151;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.15);
  --primary-strong: #3b82f6;
  --primary-text: #eff6ff;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;
  --nav-height: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-page-gradient);
  font-family: var(--font-family);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
}

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

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

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

.w-100 {
  width: 100%;
}

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

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

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
}

.auth-screen::before,
.auth-screen::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.22), transparent 70%);
  filter: blur(6px);
  opacity: 0.8;
  z-index: 0;
}

.auth-screen::before {
  top: -10vh;
  left: -10vw;
}

.auth-screen::after {
  bottom: -10vh;
  right: -10vw;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15), transparent 70%);
}

.auth-card {
  width: min(460px, 100%);
  background: rgba(31, 41, 55, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.05);
  padding: clamp(32px, 5vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 1;
}

.auth-kicker {
  align-self: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(29, 78, 216, 0.14);
  color: var(--primary-text);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.brand-badge {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1d4ed8, #2563eb 50%, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  margin-inline: auto;
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.35);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-height: 48px;
  font-size: 1rem;
  background: rgba(17, 24, 39, 0.6);
  color: var(--text-primary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus {
  outline: none;
  background: rgba(17, 24, 39, 0.9);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.auth-alert {
  border-radius: var(--radius-md);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-left: 3px solid var(--danger);
  background: rgba(220, 38, 38, 0.12);
  color: #fecaca;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.btn {
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2), 0 2px 4px -1px rgba(37, 99, 235, 0.1);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3), 0 4px 6px -2px rgba(37, 99, 235, 0.15);
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

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

.btn-secondary:hover {
  background: var(--bg-toolbar);
}

.btn-secondary.active {
  background: var(--primary);
  color: #ffffff;
}

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

.teacher-app {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(var(--space-3), 4vw, var(--space-5));
  backdrop-filter: blur(12px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 1200px;
  margin: 16px auto 0;
  box-sizing: border-box;
  border-radius: var(--radius-lg);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-brand .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.08);
}

.brand-name {
  display: block;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.topbar-meta button {
  flex-shrink: 0;
}

.teacher-name {
  font-weight: 600;
  color: var(--text-primary);
  max-width: clamp(140px, 32vw, 260px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.teacher-shell {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-height));
  padding: clamp(16px, 3vw, 24px);
  box-sizing: border-box;
  gap: 24px;
}

.sidebar {
  width: 230px;
  padding: var(--space-5) var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.sidebar-link {
  border: none;
  background: transparent;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}

.sidebar-link i {
  font-size: 1.05rem;
}

.sidebar-link:hover {
  background: var(--primary-soft);
  color: var(--primary-text);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: var(--primary-soft);
  color: var(--primary-text);
  box-shadow: var(--shadow-sm);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(var(--space-3), 4vw, var(--space-5)) clamp(var(--space-3), 5vw, var(--space-5)) calc(var(--space-5) * 4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-sizing: border-box;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.section-header h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.section-header p {
  max-width: 540px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  width: 100%;
  justify-content: flex-start;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  overflow: hidden;
  width: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.card-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg-muted);
}

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

.button-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.button-toolbar.small .pill-button {
  padding: 6px 16px;
  font-size: 0.85rem;
}

.button-toolbar.compact .pill-button {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.pill-button {
  border: 1px solid var(--border-color);
  background: var(--bg-muted);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pill-button:hover {
  border-color: var(--primary-strong);
  color: var(--primary-text);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.pill-button.active {
  background: var(--primary-soft);
  border-color: var(--primary-strong);
  color: var(--primary-text);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.button-toolbar.pill-duo {
  width: 100%;
}

.button-toolbar.pill-duo .pill-button {
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.form-inline .form-control {
  flex: 1;
  min-width: 160px;
}

.form-inline .btn {
  flex-shrink: 0;
}

.student-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
  .student-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

.student-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all 0.2s ease;
}

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

.student-card.absent {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.08);
}

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

.student-meta {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.status-toggle {
  border-radius: 999px;
  border: none;
  padding: 8px 18px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.status-toggle.present {
  background: rgba(22, 163, 74, 0.16);
  color: #bbf7d0;
}

.status-toggle.absent {
  background: rgba(220, 38, 38, 0.16);
  color: #fecaca;
}

.status-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.08);
}

.layout-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.layout-split {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

@media (min-width: 1024px) {
  .layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout-split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.loading-state,
.empty-state {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
  background: var(--bg-muted);
}

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

.sessions-list, .recent-list, .alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-card, .recent-card, .alerts-list .alert-row {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
}

.session-card:hover, .recent-card:hover, .alerts-list .alert-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.session-card.active {
  border-color: var(--primary-strong);
  background: rgba(37, 99, 235, 0.12);
}

.session-detail .absence-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.session-detail .absence-item:last-child {
  border-bottom: 0;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: none;
  justify-content: space-around;
  align-items: center;
  padding: 0 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 -4px 12px rgba(17, 24, 39, 0.08);
  z-index: 1200;
}

.nav-button {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.nav-button i {
  font-size: 1.1rem;
}

.nav-button.active {
  color: var(--primary);
}

.toast-container .toast {
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: var(--shadow-md);
}

.global-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  backdrop-filter: blur(6px);
  z-index: 3000;
}

@media (max-width: 1024px) {
  .teacher-shell {
    flex-direction: column;
    padding: 18px;
    gap: 20px;
    max-width: 100%;
  }

  .sidebar {
    display: none;
  }

  .content {
    max-width: 100%;
    padding: 24px 16px 120px;
  }

  .bottom-nav {
    display: flex;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
    padding: 16px 20px;
    height: auto;
  }

  .topbar-meta {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .content {
    padding: 20px 16px 120px;
  }

  .card-body {
    padding: 22px 18px;
  }

  .section-header h2 {
    font-size: 1.3rem;
  }
}

@media (max-width: 600px) {
  .student-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .status-toggle {
    width: 100%;
    justify-content: center;
  }

  .session-card,
  .recent-card,
  .alerts-list .alert-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline .btn {
    width: 100%;
    justify-content: center;
  }

  .topbar-meta button {
    width: auto;
  }
}
