:root {
  color-scheme: light;
  --font-family: 'Inter', 'Roboto', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg-page: #f4f7fb;
  --bg-card: #ffffff;
  --bg-muted: #eef2ff;
  --bg-toolbar: #f1f5ff;
  --border-color: rgba(99, 102, 241, 0.12);
  --border-strong: rgba(99, 102, 241, 0.25);
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #94a3b8;
  --shadow-sm: 0 4px 16px -6px rgba(15, 23, 42, 0.18);
  --shadow-md: 0 18px 40px -24px rgba(45, 55, 72, 0.2);
  --shadow-lg: 0 32px 60px -28px rgba(30, 64, 175, 0.24);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --primary-strong: rgba(37, 99, 235, 0.25);
  --primary-text: #1d4ed8;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --nav-height: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(140deg, var(--bg-page) 0%, #e0e7ff 100%);
  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: 32px 16px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(28px, 6vw, 40px);
  border: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-badge {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  margin-inline: auto;
  box-shadow: 0 18px 30px -18px rgba(37, 99, 235, 0.6);
}

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

.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(148, 163, 184, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.9);
  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: 12px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  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 16px 24px -14px rgba(37, 99, 235, 0.75);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 22px 40px -18px rgba(37, 99, 235, 0.65);
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.24);
}

.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(16px, 5vw, 32px);
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

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

.topbar-brand .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 14px 22px -18px rgba(37, 99, 235, 0.8);
}

.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, 4vw, 40px);
  box-sizing: border-box;
  gap: 28px;
}

.sidebar {
  width: 230px;
  padding: 32px 20px;
  background: rgba(255, 255, 255, 0.75);
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.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: linear-gradient(120deg, rgba(37, 99, 235, 0.14) 0%, rgba(59, 130, 246, 0.22) 100%);
  color: var(--primary-text);
  box-shadow: var(--shadow-sm);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 36px) clamp(18px, 6vw, 40px) clamp(96px, 14vw, 140px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  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.6rem;
  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: clamp(20px, 4vw, 28px) clamp(20px, 4.5vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.card-footer {
  padding: clamp(16px, 4vw, 24px) clamp(20px, 4.5vw, 32px);
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.05) 0%, rgba(37, 99, 235, 0.03) 100%);
}

.card-title {
  font-size: 1.1rem;
  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 rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.82);
  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: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(59, 130, 246, 0.24));
  border-color: var(--primary-strong);
  color: var(--primary-text);
  box-shadow: 0 10px 18px -18px rgba(37, 99, 235, 0.6);
}

.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-md);
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(243, 244, 255, 0.9));
  transition: all 0.2s ease;
}

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

.student-card.absent {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.12);
}

.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(16, 185, 129, 0.15);
  color: #047857;
}

.status-toggle.absent {
  background: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
}

.status-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -18px rgba(15, 23, 42, 0.4);
}

.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: 40px 16px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 255, 0.6);
}

.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-md);
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 244, 255, 0.95));
  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: rgba(255, 255, 255, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  display: none;
  justify-content: space-around;
  align-items: center;
  padding: 0 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 -12px 32px -24px rgba(15, 23, 42, 0.35);
  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(15, 23, 42, 0.3);
  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.35rem;
  }
}

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