:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #1c2420;
  --ink-2: #5b665f;
  --ink-3: #8d968f;
  --line: #e3e7e2;
  --line-2: #eef1ec;
  --primary: #0f6e56;
  --primary-2: #1d9e75;
  --primary-soft: #e6f5ef;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #a15c07;
  --warn-soft: #fdf3e2;
  --info: #185fa5;
  --info-soft: #e9f2fb;
  --ok: #3b6d11;
  --ok-soft: #eef5e4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin: 0; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.login-card p { color: var(--ink-2); font-size: 13px; margin-bottom: 22px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; }

/* ---------- 框架 ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand span { color: var(--primary); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.save-hint { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px 11px;
  font-size: 14px;
  color: var(--ink-2);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab:hover { color: var(--ink); }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 72px;
}

/* ---------- 通用 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--ink-3); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.metric .label { font-size: 12px; color: var(--ink-2); }
.metric .num { font-size: 26px; font-weight: 600; line-height: 1.35; letter-spacing: -.5px; }
.metric .foot { font-size: 12px; color: var(--ink-3); }
.metric.alert .num { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }
.grid-2 > * { min-width: 0; }
.stack { min-width: 0; }
.stack > * + * { margin-top: 14px; }

/* ---------- 行 ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  min-width: 0;
}
.row:last-child { border-bottom: none; }
.row:hover { background: #fafbf9; }
.row .name { font-weight: 500; width: 64px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .desc { flex: 1; min-width: 0; color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.row.static { cursor: default; }
.row.static:hover { background: none; }

.score {
  width: 40px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex: none;
}
.score.high { background: var(--danger-soft); color: var(--danger); }
.score.warn { background: var(--warn-soft); color: var(--warn); }
.score.watch { background: var(--info-soft); color: var(--info); }
.score.ok { background: var(--ok-soft); color: var(--ok); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.tag.high { background: var(--danger-soft); color: var(--danger); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.plain { background: var(--line-2); color: var(--ink-2); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: #cfd6cf; background: #fbfcfa; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #0c5c48; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); border-color: #f0d3d0; background: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
textarea { height: auto; min-height: 76px; padding: 9px 10px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(29, 158, 117, .12); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.chip.on { background: var(--primary-soft); border-color: var(--primary-2); color: var(--primary); font-weight: 500; }

/* ---------- 学员列表 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=text] { flex: 1; min-width: 160px; height: 36px; }
.toolbar select { width: auto; min-width: 110px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line-2); font-size: 13px; vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fafbf9; }

/* ---------- 详情 ---------- */
.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex: none;
}
.detail-name { font-size: 18px; font-weight: 600; }
.detail-sub { font-size: 13px; color: var(--ink-2); }
.spacer { flex: 1; }

.risk-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.risk-num { font-size: 34px; font-weight: 600; line-height: 1; letter-spacing: -1px; }
.risk-num.high { color: var(--danger); }
.risk-num.warn { color: var(--warn); }
.risk-num.watch { color: var(--info); }
.risk-num.ok { color: var(--ok); }

.reason { font-size: 13px; color: var(--ink-2); padding: 3px 0; }
.reason b { color: var(--ink); font-weight: 500; }
.reason .pts { color: var(--ink-3); font-size: 12px; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

.timeline { border-left: 2px solid var(--line); padding-left: 14px; margin-left: 4px; }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-2);
}
.tl-date { font-size: 12px; color: var(--ink-3); }
.tl-body { font-size: 13px; }

.spark { display: flex; align-items: flex-end; gap: 8px; height: 64px; padding-top: 6px; }
.spark .bar { flex: 1; max-width: 30px; background: var(--primary-soft); border-radius: 3px 3px 0 0; position: relative; min-height: 3px; }
.spark .bar i { position: absolute; inset: auto 0 0 0; background: var(--primary-2); border-radius: 3px 3px 0 0; }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 24, .38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 60;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(16, 24, 20, .18);
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.modal .sub { font-size: 13px; color: var(--ink-2); margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-foot .spacer { flex: 1; }

.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.step-dot { height: 3px; flex: 1; border-radius: 2px; background: var(--line); }
.step-dot.on { background: var(--primary-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1e2a24;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  z-index: 90;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.empty { padding: 28px 8px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  main { padding: 14px 14px 84px; }
  .top-inner { padding: 8px 14px; }
  .tabs { padding: 0 10px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .metric .num { font-size: 23px; }
  .table th, .table td { padding: 8px 6px; }
  .hide-sm { display: none; }
  .modal-mask { padding: 0; }
  .modal { max-width: none; min-height: 100vh; border-radius: 0; padding: 18px 16px 30px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--card); padding-top: 12px; border-top: 1px solid var(--line); }
  .row .name { width: 56px; }
}
