@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f7f8fa;
  --border: #e4e7ed;
  --border2: #d0d5dd;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent2: #7c3aed;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; min-height: 100vh; }

/* ===== AUTH ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 40%, #2563eb 100%);
  padding: 20px;
}
.auth-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.auth-logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.2rem;
}
.auth-logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.auth-sub { color: var(--muted); font-size: .82rem; margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.form-group input, .form-group select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  padding: 10px 13px;
  outline: none;
  transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--accent-hover); }
.auth-msg { margin-top: 10px; font-size: .8rem; text-align: center; min-height: 18px; }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: var(--success); }

/* ===== LAYOUT ===== */
.app-wrap { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.sidebar-logo span { font-weight: 700; font-size: .9rem; }
.sidebar-school {
  padding: 12px 16px;
  font-size: .72rem;
  color: rgba(255,255,255,.4);
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sidebar-nav { padding: 10px 8px; flex: 1; }
.nav-section { margin-bottom: 20px; }
.nav-section-title {
  font-size: .65rem;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 4px 8px;
  margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: rgba(255,255,255,.65);
  font-size: .84rem;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ni { font-size: 1rem; min-width: 20px; }
.sidebar-bottom {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}
.user-avatar {
  width: 30px; height: 30px;
  background: var(--accent2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .65rem; color: rgba(255,255,255,.4); }
.btn-logout-small {
  background: none; border: none; color: rgba(255,255,255,.4);
  cursor: pointer; font-size: .9rem; padding: 4px;
  transition: color .15s;
}
.btn-logout-small:hover { color: var(--danger); }

/* ===== MAIN CONTENT ===== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-weight: 700; font-size: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .8rem;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}
.content { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
}
.card-header h2 { font-size: .92rem; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.card-body { padding: 20px; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
@media(max-width:900px){ .stats-grid { grid-template-columns: repeat(2,1fr); } }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.blue::before { background: var(--accent); }
.stat-card.purple::before { background: var(--accent2); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-num { font-size: 1.9rem; font-weight: 700; font-family: 'DM Mono', monospace; line-height: 1; margin-bottom: 4px; }
.stat-lbl { font-size: .75rem; color: var(--muted); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--border); background: var(--surface2); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 7px; font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: .8rem; cursor: pointer; transition: all .15s; border: 1px solid transparent; }
.btn-blue { background: var(--accent); color: #fff; }
.btn-blue:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border-color: var(--border2); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: .74rem; }

/* ===== BADGE ===== */
.badge { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: .7rem; font-weight: 600; }
.badge-blue { background: #dbeafe; color: var(--accent); }
.badge-purple { background: #ede9fe; color: var(--accent2); }
.badge-green { background: #dcfce7; color: var(--success); }
.badge-orange { background: #fef3c7; color: var(--warning); }
.badge-red { background: #fee2e2; color: var(--danger); }
.badge-gray { background: #f3f4f6; color: var(--muted); }

/* ===== MODAL ===== */
.mo { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; padding: 28px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal h3 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }

/* ===== MISC ===== */
.empty { text-align: center; color: var(--muted); padding: 40px; font-size: .85rem; }
.loading { text-align: center; color: var(--muted); padding: 30px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.page-sub { color: var(--muted); font-size: .82rem; margin-bottom: 24px; }
