:root {
  --brand: #4F46E5;
  --brand-dark: #3730A3;
  --brand-light: #EEF2FF;
  --accent: #F59E0B;
  --ink: #1E1B2E;
  --muted: #6B7280;
  --border: #ECECF2;
  --surface: #F7F7FB;
  --sidebar-bg: #FFFFFF;
  --success: #10B981;
  --danger: #EF4444;
}

* { box-sizing: border-box; }

body {
  background-color: var(--surface);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ============== APP SHELL ============== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 18px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #818CF8);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 14px;
  overflow-y: auto;
}

.nav-section-label {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #A1A1AA;
  font-weight: 700;
  margin: 18px 10px 8px;
}
.nav-section-label:first-child { margin-top: 6px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: .92rem;
  margin-bottom: 2px;
  transition: background .15s ease, color .15s ease;
}
.side-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.side-link:hover { background: var(--brand-light); color: var(--brand-dark); }
.side-link.active { background: var(--brand); color: #fff; }
.side-link.active i { color: #fff; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}
.logout-link:hover { background: #FEF2F2; color: var(--danger); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 30, .45);
  z-index: 1035;
}

/* ---- Main area ---- */
.main-wrapper {
  margin-left: 252px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--ink);
  padding: 4px 6px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.user-chip::after { margin-left: 6px; }
.user-meta { flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: .87rem; color: var(--ink); }
.user-role { font-size: .74rem; color: var(--muted); }

.content-area {
  padding: 28px;
}

/* ============== COMPONENTS ============== */
.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header {
  background-color: #fff;
  border-bottom: 1px solid var(--border);
  border-radius: 16px 16px 0 0 !important;
  font-weight: 700;
  font-size: .95rem;
  padding: 16px 20px;
}
.card-body { padding: 20px; }

.btn {
  border-radius: 10px;
  font-weight: 600;
  font-size: .88rem;
  padding: 9px 16px;
}
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 8px; }

.btn-primary {
  background-color: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
}
.btn-outline-primary {
  color: var(--brand);
  border-color: var(--brand);
}
.btn-outline-primary:hover {
  background-color: var(--brand);
  border-color: var(--brand);
}

.btn-accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.form-control, .form-select {
  border-radius: 10px;
  border-color: #DDE0E6;
  padding: 9px 12px;
  font-size: .9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.form-label { font-weight: 600; font-size: .84rem; color: #374151; margin-bottom: 6px; }

.alert { border-radius: 12px; border: none; font-size: .9rem; }
.alert-success { background: #ECFDF5; color: #065F46; }
.alert-danger { background: #FEF2F2; color: #991B1B; }
.alert-warning { background: #FFFBEB; color: #92400E; }
.alert-info { background: var(--brand-light); color: var(--brand-dark); }

.badge { font-weight: 600; font-size: .72rem; padding: 5px 10px; border-radius: 7px; }

/* Stat cards */
.stat-card {
  border-radius: 16px;
  padding: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.stat-card i.bg-icon {
  position: absolute;
  right: -10px; bottom: -14px;
  font-size: 4.2rem;
  opacity: .18;
}
.stat-card p { opacity: 0.92; margin-bottom: 6px; font-size: .84rem; font-weight: 600; }
.stat-card h2 { font-weight: 800; margin-bottom: 0; font-size: 2rem; }
.stat-card.c1 { background: linear-gradient(135deg,#4F46E5,#818CF8); }
.stat-card.c2 { background: linear-gradient(135deg,#0EA5E9,#38BDF8); }
.stat-card.c3 { background: linear-gradient(135deg,#F59E0B,#FBBF24); }
.stat-card.c4 { background: linear-gradient(135deg,#10B981,#34D399); }

/* Class tiles */
.class-tile { text-decoration: none; display: block; transition: transform .15s ease, box-shadow .15s ease; }
.class-tile:hover { transform: translateY(-3px); }
.class-tile:hover .card { box-shadow: 0 8px 24px rgba(79,70,229,.14); }

.avatar-circle {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}

table.table { font-size: .89rem; margin-bottom: 0; }
table.table thead th {
  background-color: var(--surface);
  color: var(--muted);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  border-bottom: none;
  padding: 12px 14px;
}
table.table td { padding: 13px 14px; vertical-align: middle; border-color: var(--border); }
table.table tbody tr:hover { background-color: var(--surface); }

/* Modal */
.modal-content { border-radius: 16px; border: none; }
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 22px; }
.modal-title { font-weight: 700; font-size: 1.02rem; }

.assign-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  transition: border-color .15s ease, background .15s ease;
}
.assign-check:hover { border-color: var(--brand); background: var(--brand-light); }
.assign-check input { flex-shrink: 0; }

/* ============== PARENT APP (simple top nav, no sidebar) ============== */
.parent-topbar {
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.parent-topbar .brand { font-weight: 700; font-size: 1.02rem; }
.parent-topbar a { color: #fff; }

.child-card {
  text-decoration: none;
}
.child-card .card:hover { box-shadow: 0 8px 24px rgba(79,70,229,.14); transform: translateY(-2px); }
.child-card .card { transition: transform .15s ease, box-shadow .15s ease; }

/* ============== AUTH PAGES ============== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #6366F1, #3730A3 55%, #1E1B4B);
  font-family: 'Inter', system-ui, sans-serif;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  border-radius: 20px;
  padding: 42px 36px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-card .logo {
  width: 62px; height: 62px;
  border-radius: 16px;
  background: var(--brand-light);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 18px;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-wrapper { margin-left: 0; }
  .content-area { padding: 18px; }
  .topbar { padding: 0 16px; }
}
