/* ============================================
   QLHT v2 — "Warm Daylight" Dashboard
   Aesthetic: Luxury Minimal — Amber on Warm Cream
   Fonts: Space Grotesk (display) + DM Sans (body)
   ============================================ */

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Cool Light Backgrounds */
  --bg-void: #f5f7fa;
  --bg-primary: #eef1f6;
  --bg-secondary: #e8ecf2;
  --bg-tertiary: #dfe4ec;
  --bg-card: #ffffff;
  --bg-card-alt: #fafbfd;
  --bg-hover: #f0f3f8;
  --bg-active: #e8edf5;

  /* Text — warm-tinted darks */
  --text-primary: #1a1612;
  --text-secondary: #5c534a;
  --text-tertiary: #8a8078;
  --text-muted: #b5aca2;

  /* Blue Accent System */
  --accent: #4285f4;
  --accent-light: #669df6;
  --accent-lighter: #8ab4f8;
  --accent-dark: #1a73e8;
  --accent-glow: rgba(66, 133, 244, 0.12);
  --accent-bg: rgba(66, 133, 244, 0.07);

  /* Teal — secondary */
  --teal: #0d9488;
  --teal-light: #14b8a6;
  --teal-bg: rgba(13, 148, 136, 0.08);

  /* Status Colors */
  --success: #059669;
  --success-light: #10b981;
  --success-bg: rgba(5, 150, 105, 0.08);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.07);
  --info: #2563eb;
  --info-bg: rgba(37, 99, 235, 0.07);

  /* Subject Colors */
  --math: #c8850a;
  --physics: #2563eb;
  --chemistry: #059669;
  --english: #db2777;

  /* Card effects */
  --card-border: rgba(0, 0, 0, 0.06);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.03);
  --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.05);
  --card-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.06);

  /* Layout */
  --sidebar-width: 264px;
  --header-height: 72px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 0.15s ease;
  --t-base: 0.3s var(--ease-out);
  --t-slow: 0.5s var(--ease-out);
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle warm grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.015'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 999;
  opacity: 0.5;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--t-slow), width var(--t-slow);
  box-shadow: 1px 0 12px rgba(0, 0, 0, 0.03);
}

/* Left amber accent line */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg,
      var(--accent-light) 0%,
      rgba(66, 133, 244, 0.2) 50%,
      transparent 100%);
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--card-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.logo-text {
  min-width: 0;
}

.logo-text h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--accent);
  line-height: 1.2;
}

.logo-text span {
  display: block;
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  display: block;
  padding: 12px 12px 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--t-fast);
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item.active .material-symbols-rounded {
  color: var(--accent);
}

.nav-item .material-symbols-rounded {
  font-size: 20px;
  font-variation-settings: 'FILL' 0, 'wght' 400;
  transition: color var(--t-fast);
}

.nav-item.active .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 500;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 600;
  background: var(--bg-active);
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
}

.nav-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.nav-badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--card-border);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}

.user-profile:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-avatar .material-symbols-rounded {
  font-size: 18px;
  color: #fff;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  display: block;
  font-size: 0.67rem;
  color: var(--text-muted);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--t-slow);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 247, 250, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
}

.header-greeting h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.header-greeting p {
  font-size: 0.76rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  min-width: 250px;
  transition: all var(--t-base);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box .material-symbols-rounded {
  font-size: 18px;
  color: var(--text-muted);
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box kbd {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-active);
  border: 1px solid var(--card-border);
  font-size: 0.67rem;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-muted);
}

/* Dashboard-only placeholders for features that are not implemented yet. */
.search-box.feature-upcoming {
  background: var(--bg-card-alt);
  border-style: dashed;
  border-color: rgba(92, 83, 74, 0.28);
  box-shadow: none;
  cursor: not-allowed;
}

.search-box.feature-upcoming:focus-within {
  border-color: rgba(92, 83, 74, 0.28);
  box-shadow: none;
}

.search-box.feature-upcoming input:disabled {
  cursor: not-allowed;
  opacity: 1;
  color: #6f665e;
  -webkit-text-fill-color: #6f665e;
}

.search-box.feature-upcoming input:disabled::placeholder {
  color: #6f665e;
  opacity: 1;
}

.feature-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-active);
  color: #5c534a;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Button Icon */
.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: rgba(66, 133, 244, 0.2);
}

.btn-icon .material-symbols-rounded {
  font-size: 20px;
}

/* Modal close button — always red */
.btn-icon.modal-close {
  background: var(--danger);
  color: #fff;
  border: none;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}

.btn-icon.modal-close:hover {
  background: #b91c1c;
  color: #fff;
  border-color: transparent;
  transform: scale(1.05);
}

.notification-btn {
  position: relative;
}

.notification-btn.feature-upcoming:disabled {
  background: var(--bg-card-alt);
  color: #6f665e;
  cursor: not-allowed;
  opacity: 0.68;
  box-shadow: none;
}

.notification-btn.feature-upcoming:disabled:hover {
  background: var(--bg-card-alt);
  color: #6f665e;
  border-color: var(--card-border);
  transform: none;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-base);
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.2);
  border: 0;
  padding: 0;
  font: inherit;
}

.header-avatar:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(66, 133, 244, 0.28);
}

.header-avatar .material-symbols-rounded {
  font-size: 19px;
  color: #fff;
}

/* User Top-Right Account Dropdown Menu */
.user-dropdown-menu {
  position: fixed;
  top: 65px;
  right: 24px;
  width: 250px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.05);
  z-index: 10050;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.user-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.user-dropdown-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
}

.user-dropdown-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #1a73e8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.user-dropdown-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-dropdown-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-dropdown-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-role {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--card-border);
}

.user-dropdown-body,
.user-dropdown-footer {
  padding: 6px;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
}

.user-dropdown-item:hover {
  background: var(--bg-primary);
  color: var(--accent);
}

.user-dropdown-item .material-symbols-rounded {
  font-size: 19px;
  color: var(--text-secondary);
}

.user-dropdown-item:hover .material-symbols-rounded {
  color: var(--accent);
}

.user-dropdown-item.text-danger {
  color: var(--danger);
}

.user-dropdown-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.user-dropdown-item.text-danger .material-symbols-rounded {
  color: var(--danger);
}

/* ============================================
   DASHBOARD CONTENT
   ============================================ */
.dashboard-content {
  padding: 24px 30px 44px;
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  overflow: hidden;
  transition: all var(--t-base);
  cursor: pointer;
  box-shadow: var(--card-shadow);
  width: 100%;
  appearance: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

/* Left accent stripe */
.stat-card::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 0;
  width: 3px;
  height: calc(100% - 28px);
  border-radius: 0 3px 3px 0;
  transition: height var(--t-base);
}

.stat-card:hover::before {
  top: 8px;
  height: calc(100% - 16px);
}

.stat-card-students::before {
  background: var(--accent);
}

.stat-card-attendance::before {
  background: var(--warning);
}

.stat-card-classes::before {
  background: var(--chemistry);
}

.stat-card-tuition::before {
  background: var(--danger);
}

.stat-card-bg {
  position: absolute;
  top: -50px;
  right: -50px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  opacity: 0.04;
  transition: all var(--t-base);
  filter: blur(16px);
}

.stat-card:hover .stat-card-bg {
  opacity: 0.08;
  transform: scale(1.1);
}

.stat-card-students .stat-card-bg {
  background: var(--accent);
}

.stat-card-attendance .stat-card-bg {
  background: var(--warning);
}

.stat-card-classes .stat-card-bg {
  background: var(--chemistry);
}

.stat-card-tuition .stat-card-bg {
  background: var(--danger);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon .material-symbols-rounded {
  font-size: 21px;
  font-variation-settings: 'FILL' 1;
}

.stat-icon.students {
  background: var(--accent-bg);
}

.stat-icon.students .material-symbols-rounded {
  color: var(--accent);
}

.stat-icon.attendance {
  background: var(--warning-bg);
}

.stat-icon.attendance .material-symbols-rounded {
  color: var(--warning);
}

.stat-icon.classes {
  background: var(--success-bg);
}

.stat-icon.classes .material-symbols-rounded {
  color: var(--success);
}

.stat-icon.tuition {
  background: var(--danger-bg);
}

.stat-icon.tuition .material-symbols-rounded {
  color: var(--danger);
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

.stat-trend.up {
  background: var(--success-bg);
  color: var(--success);
}

.stat-trend.down {
  background: var(--danger-bg);
  color: var(--danger);
}

.stat-trend.neutral {
  background: var(--bg-active);
  color: #5c534a;
}

.stat-trend .material-symbols-rounded {
  font-size: 15px;
}

.stat-card-body {
  display: block;
  margin-bottom: 12px;
}

.stat-value {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.1;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-card-footer {
  display: block;
  border-top: 1px solid var(--card-border);
  padding-top: 12px;
}

.stat-detail {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* ---- Charts Grid ---- */
.charts-grid {
  display: grid;
  grid-template-columns: 5fr 3fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* Card Base */
.card {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--t-base);
  box-shadow: var(--card-shadow);
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 0;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.74rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

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

.card-actions {
  display: flex;
  gap: 8px;
}

.select-mini {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.76rem;
  cursor: pointer;
  outline: none;
  transition: all var(--t-fast);
}

.select-mini:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.select-mini option {
  background: var(--bg-card);
}

.btn-text {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
}

.btn-text:hover {
  background: var(--accent-bg);
  color: var(--accent-dark);
}

.btn-text .material-symbols-rounded {
  font-size: 16px;
}

/* Override btn-text color when inside btn-primary */
.btn-primary .btn-text {
  color: #fff;
  padding: 0;
  background: none;
}

/* Chart Containers */
.chart-container {
  height: 280px;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.donut-chart-container {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.donut-chart-container canvas {
  max-width: 180px;
  max-height: 180px;
}

/* Chart Legend */
.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.8rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  color: var(--text-secondary);
}

.legend-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Bottom Grid ---- */
.bottom-grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 16px;
}

/* Desktop: course progress left (order 1), schedule right (order 2) */
.bottom-grid .course-card {
  order: -1;
}

/* ============================================
   COURSE PROGRESS TRACKING CARD
   ============================================ */
.course-progress-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.course-progress-item {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.course-progress-item:hover {
  background: var(--bg-hover);
  border-color: var(--card-border);
}

.course-color-bar {
  width: 4px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: stretch;
}

.course-color-bar.math {
  background: var(--math);
}

.course-color-bar.physics {
  background: var(--physics);
}

.course-color-bar.chemistry {
  background: var(--chemistry);
}

.course-color-bar.english {
  background: var(--english);
}

.course-color-bar.other {
  background: var(--text-muted);
}

.course-progress-details {
  flex: 1;
  min-width: 0;
}

.course-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.course-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.course-sessions {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.course-sessions strong {
  color: var(--text-primary);
}

.course-teacher {
  font-size: 0.74rem;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.course-teacher .material-symbols-rounded {
  font-size: 13px;
}

/* Course period / semester dates */
.course-period {
  font-size: 0.73rem;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.course-period .material-symbols-rounded {
  font-size: 14px;
  color: var(--text-muted);
}

/* Progress bar — the visual signature */
.progress-track {
  width: 100%;
  height: 7px;
  background: var(--bg-active);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1.2s var(--ease-out);
  position: relative;
  width: 0;
}

.progress-fill.math {
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-light));
}

.progress-fill.physics {
  background: linear-gradient(90deg, #1d4ed8, #60a5fa);
}

.progress-fill.chemistry {
  background: linear-gradient(90deg, #047857, #34d399);
}

.progress-fill.english {
  background: linear-gradient(90deg, #be185d, #f472b6);
}

.progress-fill.other {
  background: linear-gradient(90deg, var(--text-muted), var(--text-tertiary));
}

/* Shimmer effect on progress fill */
.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.25) 50%,
      transparent 100%);
  animation: shimmer 2s ease-in-out infinite;
  border-radius: 10px;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(200%);
  }
}

/* Session dots — visual 10-dot indicator */
.session-dots {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-active);
  transition: all 0.4s var(--ease-out);
}

.session-dot.completed {
  transform: scale(1);
}

.session-dot.completed.math {
  background: var(--math);
}

.session-dot.completed.physics {
  background: var(--physics);
}

.session-dot.completed.chemistry {
  background: var(--chemistry);
}

.session-dot.completed.english {
  background: var(--english);
}

.session-dot.completed.other {
  background: var(--text-tertiary);
}

/* ---- Desktop / Mobile visibility utilities ---- */
.mobile-only {
  display: none;
}

/* ---- Mobile Reminder Cards ---- */
.dash-reminders {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.reminder-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  width: 100%;
  appearance: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.reminder-card:active {
  transform: scale(0.97);
}

.reminder-card.has-items {
  border-color: transparent;
}

.reminder-card.reminder-attendance.has-items {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(245, 158, 11, 0.12));
  border-color: rgba(245, 158, 11, 0.25);
}

.reminder-card.reminder-tuition.has-items {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), rgba(239, 68, 68, 0.12));
  border-color: rgba(239, 68, 68, 0.25);
}

.reminder-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.reminder-icon .material-symbols-rounded {
  font-size: 18px;
  font-variation-settings: 'FILL' 1;
}

.reminder-icon.attendance {
  background: var(--warning-bg);
}

.reminder-icon.attendance .material-symbols-rounded {
  color: var(--warning);
}

.reminder-icon.tuition {
  background: var(--danger-bg);
}

.reminder-icon.tuition .material-symbols-rounded {
  color: var(--danger);
}

.reminder-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.reminder-count {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.reminder-label {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-arrow {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---- Unpaid Tuition Modal ---- */
.unpaid-student-item {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.unpaid-student-item:hover {
  border-color: rgba(66, 133, 244, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.unpaid-student-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  gap: 8px;
}

.unpaid-student-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.unpaid-student-info .material-symbols-rounded {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.unpaid-student-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unpaid-student-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.unpaid-debt-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--danger);
}

.unpaid-course-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 6px;
}

.unpaid-chevron {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.unpaid-detail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-secondary);
}

.unpaid-course-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 40px;
  background: var(--bg-card);
  font-size: 0.78rem;
}

.unpaid-course-class {
  font-weight: 600;
  color: var(--accent);
  min-width: 60px;
  flex-shrink: 0;
}

.unpaid-course-name {
  flex: 1;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unpaid-course-debt {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--danger);
  flex-shrink: 0;
}

.btn-quick-collect {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px solid var(--success);
  background: var(--success-bg);
  color: var(--success);
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-quick-collect .material-symbols-rounded {
  font-size: 14px;
}

.btn-quick-collect:hover {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

/* ---- Schedule Card ---- */
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.schedule-list::before {
  content: '';
  position: absolute;
  left: 37px;
  top: 20px;
  bottom: 20px;
  width: 1px;
  background: linear-gradient(180deg,
      var(--accent) 0%,
      rgba(66, 133, 244, 0.15) 60%,
      transparent 100%);
}

.schedule-item {
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.schedule-item:hover {
  background: var(--bg-hover);
}

.schedule-item.active {
  background: var(--accent-bg);
  border: 1px solid rgba(66, 133, 244, 0.12);
}

.schedule-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  gap: 2px;
  position: relative;
  z-index: 2;
}

.time-start {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
}

.time-end {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.schedule-bar {
  width: 3px;
  border-radius: 3px;
  flex-shrink: 0;
}

.schedule-bar.math {
  background: var(--math);
}

.schedule-bar.physics {
  background: var(--physics);
}

.schedule-bar.chemistry {
  background: var(--chemistry);
}

.schedule-bar.english {
  background: var(--english);
}

.schedule-info {
  flex: 1;
}

.schedule-info h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.schedule-info p {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.schedule-info p .material-symbols-rounded {
  font-size: 13px;
  color: var(--text-muted);
}

.schedule-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--accent-bg);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.75);
  }
}

/* ---- Dashboard Schedule - Dynamic ---- */
.schedule-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 8px;
  color: var(--text-muted);
}

.schedule-empty .material-symbols-rounded {
  font-size: 36px;
  opacity: 0.5;
}

.schedule-empty p {
  font-size: 0.84rem;
  color: var(--text-tertiary);
}

.schedule-item.cancelled {
  opacity: 0.5;
}

.schedule-item.cancelled h4 {
  text-decoration: line-through;
  color: var(--text-muted);
}

.schedule-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.66rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.3px;
}

.schedule-status-tag .material-symbols-rounded {
  font-size: 13px;
}

.schedule-status-tag.completed {
  background: var(--success-bg);
  color: var(--success);
}

.schedule-status-tag.cancelled {
  background: var(--danger-bg);
  color: var(--danger);
  opacity: 1;
}

.schedule-att-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.schedule-att-info .material-symbols-rounded {
  font-size: 14px;
  color: var(--text-muted);
}

.schedule-att-info.pending {
  color: var(--warning);
}

.schedule-att-info.pending .material-symbols-rounded {
  color: var(--warning);
}

.att-status-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

.att-status-info .material-symbols-rounded {
  font-size: 18px;
}

/* ---- Dashboard accessibility ---- */
.dashboard-content .stat-card:focus-visible,
.dashboard-content .reminder-card:focus-visible,
.dashboard-content .btn-text:focus-visible,
#sidebar-toggle:focus-visible,
#notification-btn:focus-visible,
#header-avatar:focus-visible,
#dash-att-overlay button:focus-visible,
#dash-repeat-action-overlay button:focus-visible,
#dash-reason-overlay button:focus-visible,
#dash-att-overlay input:focus-visible,
#dash-att-overlay select:focus-visible,
#dash-reason-overlay textarea:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}

/* Keep compact dashboard copy above WCAG AA contrast on light cards. */
.dashboard-content .stat-detail,
.dashboard-content .card-subtitle,
.dashboard-content .reminder-label,
.dashboard-content .course-teacher,
.dashboard-content .course-period,
.dashboard-content .time-end,
.dashboard-content .schedule-info p,
.dashboard-content .schedule-att-info,
.dashboard-content .schedule-empty p,
.dashboard-content .course-period .material-symbols-rounded,
.dashboard-content .schedule-info p .material-symbols-rounded,
.dashboard-content .schedule-att-info .material-symbols-rounded {
  color: #6f665e;
}

.dashboard-content .schedule-item.cancelled {
  opacity: 0.72;
}

.dashboard-content .schedule-item.cancelled h4,
#dash-att-overlay .modal-subtitle,
#dash-repeat-action-overlay .repeat-choice-btn small,
#dash-reason-overlay label span {
  color: #6f665e !important;
}


/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stat-card {
  animation: rise 0.5s var(--ease-out) forwards;
  opacity: 0;
}

.stat-card:nth-child(1) {
  animation-delay: 0.04s;
}

.stat-card:nth-child(2) {
  animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
  animation-delay: 0.16s;
}

.stat-card:nth-child(4) {
  animation-delay: 0.22s;
}

.card {
  animation: rise 0.5s var(--ease-out) forwards;
  opacity: 0;
}

.bottom-grid .card:nth-child(1) {
  animation-delay: 0.28s;
}

.bottom-grid .card:nth-child(2) {
  animation-delay: 0.32s;
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-content *,
  .dashboard-content *::before,
  .dashboard-content *::after,
  #dash-att-overlay,
  #dash-att-overlay *,
  #dash-repeat-action-overlay,
  #dash-repeat-action-overlay *,
  #dash-reason-overlay,
  #dash-reason-overlay *,
  #dash-unattended-overlay,
  #dash-unattended-overlay *,
  #dash-unpaid-overlay,
  #dash-unpaid-overlay *,
  #search-box,
  #search-box *,
  #notification-btn,
  #header-avatar,
  #sidebar-toggle {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .dashboard-content .stat-card,
  .dashboard-content .card {
    opacity: 1 !important;
    transform: none !important;
  }

  .dashboard-content .stat-card:hover,
  .dashboard-content .reminder-card:active,
  #header-avatar:hover,
  #dash-att-overlay .modal-close:hover,
  #dash-repeat-action-overlay .modal-close:hover,
  #dash-reason-overlay .modal-close:hover {
    transform: none !important;
  }

  .dashboard-content .progress-fill::after {
    display: none;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .header {
    padding: 0 16px;
  }

  .header-greeting p {
    display: none;
  }

  .dashboard-content {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .search-box {
    display: none;
  }

  .header-greeting h2 {
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.8rem;
  }

  .session-dots {
    gap: 3px;
  }

  .session-dot {
    width: 6px;
    height: 6px;
  }

  /* Modal constraints for mobile */
  .modal-overlay .modal {
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal .modal-body {
    max-height: 60vh;
    overflow-y: auto;
  }
}

/* Tooltip */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 10px;
  background: var(--text-primary);
  color: var(--bg-card);
  font-size: 0.72rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--t-fast);
  box-shadow: var(--card-shadow);
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   SPA Page Transitions
   ============================================ */
@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pageOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.page-enter {
  animation: pageIn 0.25s ease-out both;
  /* Remove transform after animation to avoid creating a containing block
     which would trap position:fixed modals inside this element */
}

.page-exit {
  animation: pageOut 0.08s ease-in forwards;
}

/* ============================================
   LOGIN OVERLAY
   ============================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-void) 0%, var(--bg-primary) 50%, var(--bg-secondary) 100%);
}

.login-card {
  text-align: center;
  padding: 52px 44px 44px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow-hover);
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--card-border);
  animation: loginIn 0.5s var(--ease-out);
}

@keyframes loginIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(66, 133, 244, 0.25);
}

.login-logo .logo-icon .material-symbols-rounded {
  font-size: 36px;
  color: white;
}

.login-logo h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-logo p {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--t-fast);
}

.btn-google:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.btn-google:active {
  transform: translateY(0);
}

.login-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.login-error {
  font-size: 0.82rem;
  color: var(--danger);
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
}

/* ============================================
   SYNC STATUS INDICATOR
   ============================================ */

.sync-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  margin-top: 4px;
  cursor: default;
}

.sync-indicator .material-symbols-rounded {
  font-size: 18px;
  color: var(--text-muted);
  transition: color var(--t-fast);
}

.sync-indicator.synced .material-symbols-rounded {
  color: var(--success);
}

.sync-indicator.syncing .material-symbols-rounded {
  color: var(--info);
  animation: syncSpin 1.2s linear infinite;
}

.sync-indicator.offline .material-symbols-rounded {
  color: var(--text-muted);
}

.sync-indicator.error .material-symbols-rounded {
  color: var(--danger);
}

@keyframes syncSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Online exam — advanced settings */
.exam-settings-overlay {
  padding: 24px;
  background: rgba(27, 35, 48, 0.5) !important;
  backdrop-filter: blur(8px) saturate(120%);
}

.exam-settings-modal {
  width: min(660px, 100%) !important;
  max-width: 660px !important;
  max-height: min(90vh, 820px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.75) !important;
  border-radius: var(--radius-xl) !important;
  background: var(--bg-card) !important;
  box-shadow: 0 28px 80px rgba(19, 31, 49, 0.22) !important;
}

.exam-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--card-border);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.exam-settings-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.exam-settings-heading-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: var(--accent-bg);
  border: 1px solid rgba(66, 133, 244, 0.14);
  border-radius: 12px;
  font-size: 22px !important;
}

.exam-settings-heading h3 {
  margin: 0;
  color: var(--text-primary);
  font: 700 1.18rem/1.25 'Space Grotesk', 'DM Sans', sans-serif;
}

.exam-settings-heading p {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.exam-settings-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-tertiary);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--t-fast);
}

.exam-settings-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: rgba(66, 133, 244, 0.18);
}

.exam-settings-close .material-symbols-rounded { font-size: 19px; }

.exam-settings-body {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 22px;
  background: var(--bg-card-alt);
}

.exam-settings-section {
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
}

.exam-settings-section:last-child { margin-bottom: 0; }

.exam-settings-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}

.exam-settings-section-title > .material-symbols-rounded {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: var(--accent-bg);
  border-radius: 9px;
  font-size: 18px;
}

.exam-settings-section-title strong,
.exam-settings-section-title small {
  display: block;
}

.exam-settings-section-title strong {
  color: var(--text-primary);
  font-size: 0.9rem;
}

.exam-settings-section-title small {
  margin-top: 1px;
  color: var(--text-tertiary);
  font-size: 0.74rem;
  font-weight: 500;
}

.exam-settings-list {
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 11px;
}

.exam-settings-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 13px;
  cursor: pointer;
  background: var(--bg-card);
  transition: var(--t-fast);
}

.exam-settings-list .exam-settings-row + .exam-settings-row {
  border-top: 1px solid var(--card-border);
}

.exam-settings-row:hover { background: var(--bg-hover); }
.exam-settings-row.highlighted {
  min-height: 54px;
  border: 1px solid rgba(66, 133, 244, 0.13);
  border-radius: 11px;
  background: var(--accent-bg);
}

.exam-settings-row > span:first-child {
  min-width: 0;
}

.exam-settings-row strong,
.exam-settings-row small {
  display: block;
}

.exam-settings-row strong {
  color: var(--text-primary);
  font-size: 0.84rem;
  line-height: 1.35;
}

.exam-settings-row small {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 0.74rem;
  line-height: 1.35;
}

.exam-settings-switch {
  position: relative;
  width: 40px;
  height: 23px;
  flex: 0 0 40px;
}

.exam-settings-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.exam-settings-switch i {
  position: absolute;
  inset: 0;
  border: 1px solid #c8d0dc;
  border-radius: 999px;
  background: #dfe4ec;
  transition: var(--t-fast);
}

.exam-settings-switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.25);
  transition: var(--t-fast);
}

.exam-settings-switch input:checked + i {
  border-color: var(--accent);
  background: var(--accent);
}

.exam-settings-switch input:checked + i::after {
  transform: translateX(17px);
}

.exam-settings-switch input:focus-visible + i {
  outline: 3px solid var(--accent-glow);
  outline-offset: 2px;
}

.exam-settings-date-grid {
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) !important;
  align-items: end;
  gap: 10px !important;
  padding: 13px;
  margin-top: 10px;
  border: 1px solid var(--card-border);
  border-radius: 11px;
  background: var(--bg-card-alt);
}

.exam-settings-date-grid label > span,
.exam-settings-answer-grid label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 700;
}

.exam-settings-date-grid label,
.exam-settings-answer-grid label,
.exam-settings-answer-grid > div {
  min-width: 0;
}

.exam-settings-date-grid input,
.exam-settings-answer-grid select,
.exam-settings-score-input {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  width: 100%;
  height: 38px;
  border: 1px solid #d6dce5;
  border-radius: 9px;
  color: var(--text-primary);
  background: var(--bg-card);
  font: 600 0.8rem 'DM Sans', sans-serif;
  outline: none;
  transition: var(--t-fast);
}

.exam-settings-date-grid input { padding: 0 10px; }
.exam-settings-answer-grid select { padding: 0 34px 0 11px; }

.exam-settings-date-grid input:focus,
.exam-settings-answer-grid select:focus,
.exam-settings-score-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.exam-settings-date-arrow {
  align-self: center;
  color: var(--text-muted);
  font-size: 18px !important;
  text-align: center;
}

.exam-settings-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 0.72rem;
}

.exam-settings-hint .material-symbols-rounded { font-size: 15px; }

.exam-settings-answer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  align-items: end;
  gap: 10px;
}

.exam-settings-answer-grid:not(.threshold-active) { grid-template-columns: 1fr; }

.exam-settings-score-input {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.exam-settings-score-input input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 9px;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  background: transparent;
  font: 700 0.82rem 'DM Sans', sans-serif;
}

.exam-settings-score-input b {
  padding-right: 9px;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.exam-settings-security-note {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  margin-top: 11px;
  border: 1px solid rgba(5, 150, 105, 0.12);
  border-radius: 10px;
  color: var(--success);
  background: var(--success-bg);
}

.exam-settings-security-note > .material-symbols-rounded { font-size: 19px; }
.exam-settings-security-note span:last-child { font-size: 0.73rem; }
.exam-settings-security-note strong { display: block; margin-bottom: 1px; font-size: 0.77rem; }

.exam-settings-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 22px;
  border-top: 1px solid var(--card-border);
  background: var(--bg-card);
}

.exam-settings-footer .btn-secondary,
.exam-settings-footer .btn-primary {
  min-height: 38px;
  padding: 0 17px;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 700;
}

.exam-settings-apply {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 5px 14px var(--accent-glow);
}

.exam-settings-apply .material-symbols-rounded { font-size: 17px; }

@media (max-width: 640px) {
  .exam-settings-overlay { padding: 10px; }
  .exam-settings-modal { max-height: 94vh !important; border-radius: 16px !important; }
  .exam-settings-header { padding: 16px; }
  .exam-settings-body { padding: 12px; }
  .exam-settings-section { padding: 13px; }
  .exam-settings-heading p,
  .exam-settings-section-title small { display: none; }
  .exam-settings-date-grid {
    grid-template-columns: 1fr !important;
    width: 100%;
    overflow: hidden;
  }
  .exam-settings-date-grid label,
  .exam-settings-date-grid input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .exam-settings-date-arrow { transform: rotate(90deg); }
  .exam-settings-answer-grid { grid-template-columns: 1fr; }
  .exam-settings-footer { padding: 12px 16px; }
}

@media (max-width: 768px) {
  .azota-editor-workspace {
    display: block !important;
  }

  .azota-editor-code-pane {
    display: none !important;
  }

  .azota-editor-preview-pane {
    width: 100% !important;
    height: 100%;
    border-right: 0 !important;
    padding: 12px !important;
  }
}
/* ===== CHUẨN HÓA TOÀN CỤC KATEX (TRÁNH LỆCH DÒNG, LỆCH BASELINE) ===== */
.katex {
  font-size: 1.06em;
  line-height: normal;
  text-rendering: auto;
  white-space: normal;
}
.katex * {
  box-sizing: content-box !important;
}
.katex-html {
  vertical-align: -0.05em;
}
.katex-display {
  max-width: 100%;
  margin: 0.8em 0;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.azota-math-content .katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
/* Visually hidden labels remain available to screen readers and keyboard users. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Hộp thoại xác nhận dùng chung cho các thao tác có thể thay đổi dữ liệu. */
.modal-overlay.qlht-dialog-overlay.open {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10050 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 1 !important;
  visibility: visible !important;
}
.modal-overlay.qlht-dialog-overlay.open .qlht-dialog {
  transform: translateY(0) scale(1) !important;
}
.qlht-dialog {
  width: min(100%, 480px);
  max-height: calc(100vh - 40px);
  background: #ffffff;
  border-radius: 18px;
  padding: 24px 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  border: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.qlht-dialog .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 14px 0;
  margin: 0;
  border-bottom: 1px solid #f1f5f9;
}
.qlht-dialog .modal-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.01em;
}
.qlht-dialog-danger .modal-title {
  color: #dc2626;
}
.qlht-dialog .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.qlht-dialog .btn-icon:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}
.qlht-dialog .modal-body {
  padding: 16px 0 0 0;
}
.qlht-dialog-message {
  margin: 0;
  white-space: pre-line;
  color: #475569;
  font-size: 14.5px;
  line-height: 1.6;
}
.qlht-dialog-field {
  margin-top: 18px;
}
.qlht-dialog-field .form-label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: #334155;
  margin-bottom: 6px;
}
.qlht-dialog-field .form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.qlht-dialog-field .form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.qlht-dialog-error {
  margin: 10px 0 0;
  color: #dc2626;
  font-size: 13px;
  font-weight: 500;
}
.qlht-dialog-actions {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding-top: 4px;
}
.qlht-dialog-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s ease;
  min-width: 100px;
}
.qlht-dialog-actions .btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.qlht-dialog-actions .btn-secondary:hover {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #94a3b8;
}
.qlht-dialog-actions .btn-danger {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #dc2626;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}
.qlht-dialog-actions .btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.35);
}
.qlht-dialog-actions .btn-primary {
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.qlht-dialog-actions .btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}
@media (max-width: 640px) {
  .qlht-dialog-overlay {
    padding: 12px;
  }
  .qlht-dialog {
    max-height: calc(100vh - 24px);
    padding: 20px;
    border-radius: 14px;
  }
  .qlht-dialog-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .qlht-dialog-actions button {
    width: 100%;
  }
}
