html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101318;
  --surface: #191d24;
  --surface-soft: #20252d;
  --text: #edf1f7;
  --muted: #a5adba;
  --accent: #6f9fff;
  --accent-dark: #8bb1ff;
  --border: #2c323c;
  --border-strong: #3a424e;
  --danger: #ef8c8c;
  --success: #78c49b;
  --warning: #dfb968;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .topbar {
  background: rgba(25, 29, 36, 0.92);
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .tabs,
html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] dialog,
html[data-theme="dark"] .login-dropdown,
html[data-theme="dark"] .student-card,
html[data-theme="dark"] .list-item,
html[data-theme="dark"] .invoice-customer {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  color-scheme: dark;
}

html[data-theme="dark"] .button-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

html[data-theme="dark"] .button-secondary:hover {
  background: #292f39;
  border-color: #4a5564;
}

html[data-theme="dark"] .student-card-footer,
html[data-theme="dark"] .student-modal-card > .form-actions,
html[data-theme="dark"] .student-edit-tabs,
html[data-theme="dark"] .statistics-content {
  background: var(--surface-soft);
  border-color: var(--border);
}

html[data-theme="dark"] .student-modal-card > .card-heading,
html[data-theme="dark"] .statistics-disclosure summary {
  background: linear-gradient(135deg, #20262e, #1b2027);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .student-edit-tab.active {
  background: #263140;
  color: var(--accent-dark);
}

html[data-theme="dark"] .schedule-student-card,
html[data-theme="dark"] .schedule-student-card.is-current,
html[data-theme="dark"] .schedule-student-card.is-upcoming,
html[data-theme="dark"] .schedule-empty {
  background: linear-gradient(145deg, #1c2129, #171b21);
  border-color: var(--border-strong);
}

html[data-theme="dark"] .schedule-focus,
html[data-theme="dark"] .schedule-progress-block {
  background: rgba(31, 37, 46, 0.9);
  border-color: var(--border);
}

html[data-theme="dark"] .schedule-focus li {
  background: #222c3d;
  color: #a9c5ff;
  border-color: #30415e;
}

html[data-theme="dark"] .is-current .schedule-focus li {
  background: #1e3328;
  color: #9bd6b3;
  border-color: #2d503c;
}

html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .meta,
html[data-theme="dark"] p,
html[data-theme="dark"] .schedule-status,
html[data-theme="dark"] .schedule-pill,
html[data-theme="dark"] .schedule-updated-at {
  color: var(--muted);
}

html[data-theme="dark"] .badge.muted {
  background: #2b313a;
  color: #c2c8d1;
}

html[data-theme="dark"] .badge.success {
  background: #1d392b;
  color: #91d4ae;
}

html[data-theme="dark"] .badge.warning {
  background: #40351f;
  color: #e8c77f;
}

html[data-theme="dark"] .button-danger {
  background: #2b2022;
  color: #f29a9a;
  border-color: #563538;
}

.theme-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  margin: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.theme-toggle {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.theme-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.theme-toggle-track {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #d8dde5;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.theme-toggle-track::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease;
}

.theme-toggle input:checked + .theme-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.theme-toggle input:checked + .theme-toggle-track::after {
  transform: translateX(20px);
}

.theme-toggle input:focus-visible + .theme-toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
