/* portal 控制台 · 与主站管理端保持同一套视觉语言（蓝主色 + 浅灰底 + 白色卡片） */
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --line: #e2e8f0;
  --line-2: #d7dee9;
  --bg: #f5f7fb;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================= 登录页（唯一登录入口 /login） ================= */
/* 视觉对齐设计稿：浅蓝灰底 + 白色圆角卡片 + 整幅 logo + 两个无标签输入框 + 蓝色通栏按钮 */
.login-body { background: #eef2f9; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background: #eef2f9;
}

.login-card {
  width: 100%;
  max-width: 430px;
  margin: 0;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(30, 58, 138, .07);
  padding: 42px 34px 40px;
}

.login-logo {
  display: block;
  width: 232px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 6px;
  -webkit-user-drag: none;
  user-select: none;
}

/* 错误提示占位在 logo 与输入框之间，高度固定：不占按钮前的间距，出错也不推动按钮 */
.login-msg {
  min-height: 20px;
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 20px;
  color: var(--danger);
  text-align: center;
  visibility: hidden;
}
.login-msg.show { visibility: visible; }

.login-card input[type="text"],
.login-card input[type="password"] {
  height: 46px;
  padding: 0 18px;
  margin-bottom: 24px;
  border: 1px solid #d9e0ea;
  border-radius: 10px;
  font-size: 15.5px;
  color: #1f2937;
  background: #fff;
}
/* 密码框到按钮的间距（设计稿里按钮贴近密码框） */
.login-card input[type="password"] { margin-bottom: 18px; }
.login-card input::placeholder { color: #9aa3b2; }
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: #1a5df0;
  box-shadow: 0 0 0 3px rgba(26, 93, 240, .12);
}

.login-submit {
  width: 100%;
  height: 50px;
  margin: 0;
  border: none;
  border-radius: 11px;
  background: #1a5df0;
  color: #fff;
  font-size: 16.5px;
  font-weight: 500;
  letter-spacing: .38em;
  text-indent: .38em;
}
.login-submit:hover:not(:disabled) { background: #1550d8; }
.login-submit:active:not(:disabled) { background: #1246c0; }

/* ================= 表单控件 ================= */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

input:disabled, select:disabled {
  background: #f1f5f9;
  color: var(--ink-3);
  cursor: not-allowed;
}

textarea { resize: vertical; min-height: 60px; }

/* ================= 按钮 ================= */
button {
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 15px;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

button:disabled { cursor: not-allowed; opacity: .55; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }

/* 用 <a> 当按钮时补齐 button 才有的边框与布局（.btn-ghost 只给了 border-color） */
a.btn-ghost, a.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-2);
  text-decoration: none;
}
a.btn-ghost:hover, a.btn-primary:hover { text-decoration: none; }

.btn-block { width: 100%; padding: 10px; font-size: 15px; }

/* ================= 控制台布局 ================= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  padding: 18px 18px 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.sidebar .brand small {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 2px;
  letter-spacing: .3px;
}

.nav { padding: 10px 8px; flex: 1; overflow: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}
.nav-item:hover { background: #f1f5f9; text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-item .ico { width: 16px; text-align: center; opacity: .9; }

.sidebar .me {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.sidebar .me b { color: var(--ink); font-size: 13.5px; font-weight: 600; }
.sidebar .me .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.main { flex: 1; min-width: 0; padding: 20px 24px 32px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.page-head .desc { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

/* ================= 卡片 ================= */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card + .card { margin-top: 14px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .grow { flex: 1; }
.toolbar input[type="text"] { max-width: 260px; }
.toolbar select { max-width: 160px; }

/* ================= 统计卡 ================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .num { font-size: 24px; font-weight: 650; color: var(--ink); line-height: 1.2; }
.stat .lbl { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

/* ================= 表格 ================= */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: #fff;
}
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line-2);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table th {
  background: var(--brand-soft);
  color: #1e3a8a;
  font-weight: 600;
  font-size: 13px;
  border-top: 1px solid var(--line-2);
}
.data-table th:first-child, .data-table td:first-child { border-left: 1px solid var(--line-2); }
.data-table th:last-child, .data-table td:last-child { border-right: 1px solid var(--line-2); }
.data-table tbody tr:nth-child(even) { background: #f8fafc; }
.data-table tbody tr:hover td { background: #eef2f7; }
.data-table .col-op { text-align: right; }
.data-table .muted { color: var(--ink-3); }
.data-table .wrap { white-space: normal; word-break: break-word; }

.table-scroll { overflow: auto; border-radius: 8px; }

/* ================= 徽章 / 状态 ================= */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  background: #eef2f7;
  color: var(--ink-2);
  margin-right: 4px;
}
.badge.blue { background: #e0edff; color: #1e40af; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.gray { background: #f1f5f9; color: #64748b; }
.badge.red { background: #fee2e2; color: #b91c1c; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot.on { background: var(--ok); }
.dot.off { background: #cbd5e1; }

/* ================= 空态 / 加载 ================= */
.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
}
.empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: .5; }

.loading { padding: 40px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-mask[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
.modal-head {
  padding: 16px 20px 12px;
  font-size: 15.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot {
  padding: 12px 20px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
}
.modal .row { margin-bottom: 13px; }
.modal .row:last-child { margin-bottom: 0; }
.modal .row > label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
.modal .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* 科目 / 角色 多选芯片 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 角色配置已下线（角色固定为管理员 / 教师），原来的 .role-* / .perm-* 样式一并删除 */

/* ================= 服务卡 ================= */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.svc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: #fff;
}
.svc .t { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.svc .n { font-weight: 600; font-size: 14px; }
.svc .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; word-break: break-all; }
.svc .acts { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ================= 分页 ================= */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 2px 2px;
  font-size: 12.5px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.pager button {
  padding: 4px 10px;
  font-size: 12.5px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink-2);
  border-radius: 6px;
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager .cur { color: var(--brand); font-weight: 600; }

/* ================= 提示条 ================= */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, top .2s;
  max-width: 90vw;
}
.toast.show { opacity: 1; top: 24px; }
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ================= 窄屏 ================= */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar .brand { border-bottom: none; padding: 12px 14px; white-space: nowrap; }
  .sidebar .brand small { display: none; }
  .nav { display: flex; padding: 6px; overflow-x: auto; }
  .nav-item { white-space: nowrap; margin-bottom: 0; }
  .sidebar .me { border-top: none; padding: 8px 12px; white-space: nowrap; }
  .main { padding: 14px 12px 28px; }
}

/* ================= 积分（账号设置表格） ================= */
.credit-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 600;
  letter-spacing: .01em;
}
.credit-ok { color: #8a5a1a; }
.credit-low { color: #b45309; }
.credit-zero { color: #b91c1c; }
