:root {
  --primary: #0f766e;
  --primary-6: #0d6b63;
  --primary-50: #eaf5f3;
  --accent: #b45309;
  --text: #17211f;
  --text-2: #5b6b67;
  --text-3: #8a9793;
  --line: #e6ebe9;
  --bg: #f5f7f6;
  --card: #ffffff;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 54px;
  padding: 0 8px 0 6px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.tb-left, .tb-right { width: 72px; display: flex; align-items: center; }
.tb-right { justify-content: flex-end; gap: 4px; }
.tb-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-2);
  background: none;
  border: 0;
  cursor: pointer;
}
.iconbtn:active { background: var(--primary-50); }
.branddot {
  width: 10px; height: 10px; margin-left: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}
.ico { display: inline-block; vertical-align: middle; }

.main { padding: 14px 14px 24px; flex: 1 1 auto; }

.flash {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--primary-50);
  color: var(--primary-6);
  border: 1px solid #cfe7e3;
}
.flash-error { background: #fef3f2; color: var(--danger); border-color: #fecdca; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-pad { padding: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 0;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .more { font-size: 13px; color: var(--text-3); }
.card-body { padding: 12px 16px 16px; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 2px 10px;
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: .3px;
}
.section-title b { font-weight: 600; color: var(--text-2); font-size: 14px; letter-spacing: 0; }

/* ---------------- 学生 ---------------- */
.student-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.student-row:last-child { border-bottom: 0; }
.student-row:active { background: #fafbfb; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  flex: 0 0 auto;
  letter-spacing: 1px;
}
.stu-main { flex: 1; min-width: 0; }
.stu-name { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.stu-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stu-side { text-align: right; flex: 0 0 auto; }
.stu-avg { font-size: 20px; font-weight: 700; color: var(--primary); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stu-avg small { font-size: 11px; color: var(--text-3); font-weight: 400; display: block; }

.add-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px dashed #b9cfc9;
  border-radius: var(--radius);
  color: var(--primary);
  background: #fbfdfc;
  font-weight: 500;
}
.add-card:active { background: var(--primary-50); }

/* ---------------- 统计 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}
.stat .v { font-size: 21px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.stat .k { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.stat.teal .v { color: var(--primary); }
.stat.amber .v { color: var(--accent); }

/* ---------------- 考试 ---------------- */
.exam-row {
  display: block;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.exam-row:last-child { border-bottom: 0; }
.exam-row:active { background: #fafbfb; }
.exam-top { display: flex; align-items: baseline; gap: 8px; }
.exam-name { font-weight: 600; font-size: 15.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-date { font-size: 12px; color: var(--text-3); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.exam-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 5px; font-size: 12.5px; color: var(--text-2); }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 6px;
  background: #f1f4f3;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.7;
}
.pill.teal { background: var(--primary-50); color: var(--primary-6); }
.pill.amber { background: #fdf4e7; color: var(--accent); }
.pill.rose { background: #fef1f2; color: #b42318; }

.score-big { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------------- 科目与成绩行 ---------------- */
.subject-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.subject-line:last-child { border-bottom: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.sl-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-name small { display: block; font-weight: 400; color: var(--text-3); font-size: 11.5px; }
.sl-score { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.sl-rank { font-size: 12px; color: var(--text-3); text-align: right; min-width: 66px; font-variant-numeric: tabular-nums; }

.score-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.score-table th {
  font-size: 12px; font-weight: 500; color: var(--text-3); text-align: right;
  padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.score-table th:first-child { text-align: left; }
.score-table td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: right; font-size: 14px; }
.score-table td:first-child { text-align: left; font-weight: 500; }
.score-table tr:last-child td { border-bottom: 0; }
.score-table .muted { color: var(--text-3); }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.input, select.input, textarea.input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid #d9e1de;
  border-radius: 10px;
  background: #fff;
  outline: none;
  font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 11px 12px; line-height: 1.5; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.input::placeholder { color: #a7b3af; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: #f1f4f3;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-6); }
.btn-ghost { background: #fff; border-color: #d9e1de; color: var(--text-2); }
.btn-danger { background: #fff; border-color: #fecdca; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 18px;
  border: 1px solid #dfe6e3;
  background: #fff;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
}
.chip.on { background: var(--primary-50); border-color: #bfded8; color: var(--primary-6); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* 成绩录入行 */
.score-entry {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1.25fr;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.score-entry:last-child { border-bottom: 0; }
.score-entry .se-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 7px; min-width: 0; }
.score-entry .se-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.se-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rank-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mini {
  width: 100%; height: 38px; padding: 0 6px;
  border: 1px solid #dfe6e3; border-radius: 8px;
  font-size: 15px; text-align: center; background: #fff; outline: none;
  font-variant-numeric: tabular-nums;
}
.mini:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-50); }
.mini-ph { position: relative; }
.mini-ph .unit {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-3); pointer-events: none;
}
.entry-head {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1.25fr;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
  padding-bottom: 4px;
}
.entry-head div:nth-child(2), .entry-head div:nth-child(3) { text-align: center; }

/* ---------------- 会话辅助 ---------------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { display: block; font-weight: 500; }
.row .s { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.row .end { color: var(--text-3); flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty-ico { color: #b9cfc9; margin-bottom: 8px; }
.empty p { margin: 0 0 4px; color: var(--text-2); font-size: 15px; }
.empty span { font-size: 13px; }
.empty .btn { margin-top: 16px; }

.trend-wrap { padding: 4px 0 0; }
.trend { width: 100%; height: 132px; overflow: visible; }
.trend-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.hr { height: 1px; background: var(--line); margin: 14px 0; }

.note { font-size: 12.5px; color: var(--text-3); line-height: 1.6; }

.rank-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.rank-badge b { color: var(--text); font-weight: 600; }
.rank-badge.top { color: var(--accent); }
.rank-badge.top b { color: var(--accent); }

.tabbar {
  position: sticky;
  bottom: 0;
  display: flex;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 7px;
  font-size: 11px;
  color: var(--text-3);
}
.tab.on { color: var(--primary); font-weight: 600; }
.tab .ico { opacity: .85; }

.auth-wrap { padding: 28px 18px; }
.auth-logo { text-align: center; margin: 18px 0 26px; }
.auth-logo .mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--primary); color: #fff; font-size: 24px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(15, 118, 110, .22);
  letter-spacing: 1px;
}
.auth-logo h1 { font-size: 20px; margin: 12px 0 4px; letter-spacing: .5px; }
.auth-logo p { margin: 0; font-size: 13px; color: var(--text-3); }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-3); }
.auth-switch a { color: var(--primary); font-weight: 600; }

@media (min-width: 720px) {
  body { background: #eef1f0; }
  .app { box-shadow: 0 0 0 1px var(--line); }
  .main { padding: 18px 18px 30px; }
}
