:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(0,0,0,0.1);
}


* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  background: linear-gradient(180deg, var(--bg), #f1f5f9);
  color: var(--text);
}

/* Login */
.login-body { display: grid; place-items: center; padding: 32px; position: relative; }
.login-wrapper { width: 100%; max-width: 420px; }

.login-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand { text-align: center; margin-bottom: 18px; }
.logo-circle {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: radial-gradient(120% 120% at 20% 20%, var(--accent), var(--primary));
  color: white;
  margin: 0 auto 8px;
}
.logo-circle.small { width: 36px; height: 36px; font-size: 12px; }
.brand-title { font-size: 20px; font-weight: 700; }
.brand-subtitle { color: var(--muted); font-size: 13px; }

.login-form { display: grid; gap: 10px; margin-top: 10px; }
.input-label { font-size: 13px; color: var(--muted); }
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
.input::-webkit-calendar-picker-indicator {
  filter: invert(0);
  cursor: pointer;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 14px; color: var(--text); text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--panel-2); border: 1px solid var(--border); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.demo-note { margin-top: 12px; color: var(--muted); font-size: 12px; text-align: center; }

/* App shell */
.app-shell { 
  display: grid; 
  grid-template-columns: 260px 1fr; 
  min-height: 100vh; 
  transition: grid-template-columns 0.2s ease;
}
.app-shell.sidebar-collapsed { grid-template-columns: 72px 1fr; }
.sidebar {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-right: 1px solid var(--border);
  padding: 18px 14px;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-text .brand-title { font-weight: 700; font-size: 14px; }
.brand-text .brand-subtitle { font-size: 11px; color: var(--muted); }
.menu { display: grid; gap: 4px; margin-top: 8px; }
.menu-item { color: var(--text); text-decoration: none; padding: 10px 10px; border-radius: 10px; display: flex; align-items: center; gap: 10px; }
.menu-item .icon { width: 18px; height: 18px; display:inline-flex; align-items:center; justify-content:center; color: var(--muted); }
.menu-item .label { flex: 1; }
.menu-item:hover { background: var(--panel-2); }
.has-children { display: grid; }
.has-children > span, .has-children > .icon, .has-children > .label { display: inline-flex; }
.has-children > .label, .has-children > span { padding: 10px; color: var(--muted); font-weight: 600; }
.submenu { display: grid; gap: 2px; padding-left: 12px; }
.submenu-item { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; gap: 8px; }
.submenu-item:hover { background: var(--panel-2); }
.submenu-item .icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.submenu-item .label { flex: 1; }

.main { padding: 18px; background: var(--bg); }
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-bottom: 12px; }
.page-title { margin: 0; font-size: 20px; }
.dashboard { display: grid; grid-template-columns: 1fr; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
/* Topbar controls */
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 6px; display: inline-flex; align-items: center; justify-content: center; }
.profile { position: relative; }
.profile-btn { display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; color: var(--text); cursor: pointer; }
.profile-btn:hover { background: var(--panel-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: radial-gradient(120% 120% at 20% 20%, var(--accent), var(--primary)); color: white; }
.avatar-text { font-size: 14px; font-weight: 600; }
.profile-info { display: flex; flex-direction: column; align-items: flex-start; }
.profile-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.profile-role { font-size: 12px; color: var(--muted); text-transform: capitalize; line-height: 1.2; }
.profile-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 0; display: none; z-index: 1000; }
.profile.open .profile-dropdown { display: block; }
.dropdown-header { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dropdown-name { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.2; }
.dropdown-email { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.2; }
.dropdown-divider { margin: 0; border: none; border-top: 1px solid var(--border); }
.dropdown-item { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; padding: 10px 16px; border-radius: 0; font-size: 14px; transition: background-color 0.2s ease; }
.dropdown-item:hover { background: var(--panel-2); }
.dropdown-item:last-child { border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }


/* Collapsible sidebar */
.app-shell { transition: all .2s ease; }
.sidebar { transition: width .2s ease; }
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .menu-item .label { display: none; }
.sidebar.collapsed .menu-item { justify-content: center; }
.sidebar.collapsed .submenu { display: none; }
/* Forms / Table helpers */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
.form-field { display: grid; gap: 6px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; }
.table th { color: var(--muted); font-weight: 600; }
.btn-small { padding: 6px 10px; border-radius: 8px; }
.status { padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.status.success { background: #10b981; color: white; }
.status.warning { background: #f59e0b; color: white; }
.status.danger { background: #ef4444; color: white; }
.extra-time { color: #ef4444; font-weight: 700; background: rgba(239, 68, 68, 0.1); padding: 4px 8px; border-radius: 4px; }
.extra-time-row { background: rgba(239, 68, 68, 0.05); border-left: 4px solid #ef4444; color: #ef4444; }
.extra-time-row td { color: #ef4444; }

/* KPI */
.kpi { display: flex; align-items: center; gap: 16px; padding: 20px; }
.kpi-icon { color: var(--accent); }
.kpi-content { flex: 1; }
.kpi-label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.kpi-value { font-size: 32px; font-weight: 700; color: var(--accent); }

/* Switch Component */
.switch-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-input {
  display: none;
}

.switch-label {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
  cursor: pointer;
}

.switch-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: all 0.3s ease;
}

.switch-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.switch-input:checked + .switch-label .switch-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.switch-input:checked + .switch-label .switch-slider:before {
  transform: translateX(24px);
  background: white;
}

.switch-input:focus + .switch-label .switch-slider {
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.2);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--panel-2);
  color: var(--text);
}

.modal-body {
  padding: 0 20px;
}

.modal-body p {
  margin: 0 0 16px;
  color: var(--text);
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* Calendar */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar-title { font-weight: 600; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-cell { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.day-name { font-size: 12px; color: var(--muted); }
.day-date { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.event { font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); margin-top: 6px; }

/* Schedule Layout */
.schedule-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.day-schedule {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-height: 200px;
}

.classroom-type-header {
  background: var(--primary);
  color: white;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 12px;
  border-radius: 6px;
  margin: 8px 0 6px 0;
  text-align: center;
}

.date-header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.date-header .day-name {
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
}

.date-header .day-date {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.schedule-item {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.schedule-item:last-child {
  margin-bottom: 0;
}

.schedule-student {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.schedule-time {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.schedule-subject {
  color: var(--muted);
  font-size: 12px;
}

.no-schedule {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 20px;
  font-size: 13px;
}

@media (max-width: 768px) {
  .schedule-container {
    grid-template-columns: 1fr;
  }
  
  .schedule-item {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 1200px) {
  .schedule-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .schedule-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 80px 1fr; }
  .brand-text { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .dashboard { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}


