:root {
  color-scheme: dark;
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bg-page: #0b0b0f;
  --bg-page-gradient: #0b0b0f;
  --bg-card: #12161f;
  --bg-muted: #151a22;
  --bg-toolbar: #1b2230;
  --border-color: #262b36;
  --border-strong: #2b3240;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;
  --shadow-sm: 0 6px 24px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.25);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.18);
  --primary-strong: rgba(37, 99, 235, 0.28);
  --primary-text: #bfdbfe;
  --accent: #16a34a;
  --danger: #dc2626;
  --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);
  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;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: clamp(20px, 4vw, 24px);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.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 var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  min-height: 38px;
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-strong);
  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: 8px 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

.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);
  border: 1px solid var(--border-color);
  overflow: hidden;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.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.15s ease;
}

.pill-button:hover {
  border-color: var(--primary-strong);
  color: var(--primary-text);
}

.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;
  }
}
