/* =====================================================================
   教学管理系统 —— 全局样式（浅色主题）
   ===================================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 18px;
}

.login-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 600; }
.login-card .sub { margin: 0 0 26px; color: var(--muted); font-size: 13px; }

.demo-box {
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--primary-light);
  border-radius: 10px;
  font-size: 12.5px;
  color: #334155;
}
.demo-box b { font-weight: 600; }
.demo-box .demo-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

input, select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input::placeholder { color: var(--faint); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

.btn-block { width: 100%; height: 42px; font-size: 14.5px; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }

/* ---------------- 顶部导航 ---------------- */
.topbar {
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 15.5px; font-weight: 600; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 500;
}

.user-area { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.user-area .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-area .who { display: flex; flex-direction: column; line-height: 1.25; }
.user-area .who b { color: var(--text); font-weight: 600; font-size: 13.5px; }
.user-area .who span { font-size: 11.5px; color: var(--faint); }

/* ---------------- 布局 ---------------- */
.page { max-width: 1180px; margin: 0 auto; padding: 24px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.tab {
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* 卡片头下方的轻量提示条 */
.card-hint {
  padding: 10px 20px 0;
  font-size: 12.5px;
  color: var(--muted);
}
.card-hint:empty { display: none; }

/* ---------------- 统计卡片 ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.stat .value { font-size: 24px; font-weight: 600; line-height: 1.2; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }

.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 26px; }
.profile-grid .item { display: flex; flex-direction: column; gap: 2px; }
.profile-grid .item .k { font-size: 12.5px; color: var(--muted); }
.profile-grid .item .v { font-size: 14.5px; font-weight: 500; }

/* ---------------- 表格 ---------------- */
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  padding: 11px 16px;
  background: #fafbfc;
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}
.tag-gray { background: #f3f4f6; color: #4b5563; }
.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-amber { background: var(--warning-bg); color: var(--warning); }
.tag-red { background: var(--danger-bg); color: var(--danger); }

/* ---------------- 进度条 ---------------- */
.bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.bar-track { flex: 1; height: 6px; border-radius: 999px; background: #eef1f5; overflow: hidden; min-width: 54px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-fill.warn { background: var(--warning); }
.bar-fill.full { background: var(--danger); }
.bar-text { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar input, .toolbar select { width: auto; min-width: 180px; height: 36px; }

/* ---------------- 空状态与提示 ---------------- */
.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
}
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: 0.5; }

.loading { padding: 40px; text-align: center; color: var(--faint); font-size: 13.5px; }

.alert {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-ok { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }

/* ---------------- 成绩输入框 ---------------- */
.grade-input {
  width: 82px;
  height: 32px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
}
.grade-input.is-fail { border-color: #fca5a5; background: #fff8f8; }

/* ---------------- Toast ---------------- */
#toast-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.14);
  background: #fff;
  border: 1px solid var(--border);
  animation: toast-in 0.18s ease-out;
  max-width: 460px;
}
.toast.ok { background: var(--success-bg); border-color: #a7f3d0; color: #065f46; }
.toast.err { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow: auto;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.2);
}
.modal.modal-wide { max-width: 820px; }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 15.5px;
  font-weight: 600;
}
.modal-body { padding: 22px; }
.modal-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------------- 分页 ---------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pager .info { font-size: 12.5px; color: var(--muted); }
.pager .pages { display: flex; align-items: center; gap: 8px; }

/* ---------------- 文字按钮（表格内可点） ---------------- */
.link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}
.link:hover { text-decoration: underline; }

/* ---------------- 授权勾选chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip input { width: auto; height: auto; margin: 0; }
.chip.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

/* ---------------- 变更前后值 ---------------- */
.diff { font-size: 12px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.diff b { color: var(--text); font-weight: 600; }

@media (max-width: 720px) {
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .user-area .who { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1; }
  .pager { flex-direction: column; align-items: stretch; }
}


/* ---------------- 演示版标识 ---------------- */
.demo-badge {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.12);
  font-size: 12px;
  color: var(--muted);
  backdrop-filter: blur(6px);
}
.demo-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}
.demo-badge .btn { height: 26px; padding: 0 9px; font-size: 12px; }

.demo-note {
  margin-top: 16px;
  padding: 10px 13px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  font-size: 12px;
  line-height: 1.65;
  color: var(--muted);
}
.demo-note b { color: var(--text); font-weight: 600; }

@media (max-width: 720px) {
  .demo-badge { right: 10px; bottom: 10px; font-size: 11px; padding: 6px 10px; }
  .demo-badge span:nth-child(2) { display: none; }
}
