:root {
  --bg: #eef3f8;
  --panel: #fff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e1ec;
  --blue: #2477d4;
  --blue-dark: #1558a8;
  --nav: #1d2d47;
  --nav-2: #243854;
  --soft: #f7f9fc;
  --good: #158657;
  --warn: #b66a00;
  --bad: #c63d37;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  color: var(--ink);
  background: var(--bg);
  font: 13px/1.42 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, var(--nav) 0 42%, #f7f9fc 42% 100%);
}
.login-view.hidden { display: none; }
.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15,23,42,.24);
}
.login-brand, .brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong, .brand strong, .login-brand span, .brand span { display: block; }
.login-brand span, .brand span { color: #a9b7c8; font-size: 12px; }
.login-card h2 { margin: 24px 0 16px; font-size: 26px; }
.login-card input { margin-bottom: 12px; }
.login-card button { width: 100%; }
.login-card p { min-height: 20px; color: var(--bad); }

.sidebar {
  width: 218px;
  min-height: 100vh;
  color: #fff;
  background: var(--nav);
  border-right: 1px solid #172238;
}
.brand {
  height: 58px;
  padding: 0 16px;
  background: #16243a;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--blue);
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
}
nav { padding: 8px; }
.nav-btn {
  width: 100%;
  height: 36px;
  border: 0;
  border-radius: 4px;
  margin: 2px 0;
  padding: 0 12px;
  text-align: left;
  color: #d4deeb;
  background: transparent;
  cursor: pointer;
}
.nav-btn.active, .nav-btn:hover { background: var(--nav-2); color: #fff; }

.main { flex: 1; min-width: 0; }
.top-strip {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; align-items: center; gap: 4px; padding-left: 10px; overflow: auto; }
.tab {
  height: 30px;
  min-width: 90px;
  border: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  background: #f8fafc;
  color: #475467;
}
.tab.active { background: #fff; color: var(--blue); border-bottom-color: #fff; }
.user-tools { display: flex; gap: 8px; padding-right: 12px; }

.page-head {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0; font-size: 16px; }
p { margin: 4px 0 0; color: var(--muted); }
.actions, .user-tools, .toolbar-actions { display: flex; align-items: center; gap: 8px; }

input, select, textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 76px; resize: vertical; }
.actions input { width: 320px; }
button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
button.primary:hover { background: var(--blue-dark); }
button.link { border: 0; padding: 0 4px; background: transparent; color: var(--blue); }
button.danger { color: var(--bad); }
.icon-btn { border: 0; font-size: 22px; background: transparent; }

.dashboard, .content { padding: 12px 16px; }
.content { padding-top: 0; }
.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
}
.card, .panel, .student-card, .filter-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.card { padding: 14px; }
.card span { color: var(--muted); }
.card strong { display: block; margin-top: 6px; font-size: 24px; }

.filter-panel {
  padding: 12px;
  margin-bottom: 10px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
}
.filter-grid label { color: #475467; display: block; margin-bottom: 4px; }

.student-card {
  margin-bottom: 10px;
  padding: 12px;
}
.student-main {
  display: grid;
  grid-template-columns: 190px 1fr 360px;
  gap: 12px;
  align-items: stretch;
}
.student-name {
  display: flex;
  align-items: center;
  gap: 10px;
  border-right: 1px solid var(--line);
}
.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e8f1ff;
  color: var(--blue);
  font-weight: 700;
  font-size: 18px;
}
.student-name strong { display: block; font-size: 18px; }
.student-facts, .student-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 8px 14px;
}
.fact span, .metric span { color: var(--muted); display: block; }
.fact b, .metric b { display: block; margin-top: 2px; font-weight: 600; }
.student-metrics {
  grid-template-columns: repeat(3, 1fr);
  border-left: 1px solid var(--line);
  padding-left: 12px;
}
.metric b { font-size: 18px; color: var(--blue-dark); }

.detail-tabs {
  display: flex;
  gap: 4px;
  margin: 8px 0 0;
  border-bottom: 1px solid var(--line);
}
.detail-tab {
  height: 34px;
  border-bottom: 0;
  background: #f8fafc;
  border-radius: 4px 4px 0 0;
}
.detail-tab.active { background: #fff; color: var(--blue); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
table { width: 100%; border-collapse: collapse; min-width: 1050px; }
th, td {
  height: 38px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th { background: #f8fafc; color: #344054; font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #f5f9ff; }
td.actions-cell { display: flex; align-items: center; gap: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf4ff;
  color: var(--blue-dark);
}
.badge.warn { background: #fff3df; color: var(--warn); }
.badge.bad { background: #ffeceb; color: var(--bad); }
.badge.good { background: #e9f8f0; color: var(--good); }
.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

dialog {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 6px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15,23,42,.25);
}
dialog::backdrop { background: rgba(15,23,42,.45); }
.modal-card header, .modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-card footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; gap: 8px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}
.field.full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 5px; color: #344054; }

@media (max-width: 980px) {
  body { display: block; }
  .sidebar { width: 100%; min-height: auto; }
  nav { display: grid; grid-template-columns: repeat(2, 1fr); }
  .page-head { display: block; }
  .actions { margin-top: 10px; flex-wrap: wrap; }
  .actions input { width: 100%; }
  .cards, .filter-grid, .student-main, .student-facts, .student-metrics { grid-template-columns: 1fr; }
  .student-name, .student-metrics { border: 0; padding-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
