/* 石潇远成绩记录分析系统 —— 移动优先样式
   设计取向：手机是第一现场，桌面上居中显示为窄栏。
   配色：涨=红（进步）、跌=绿（下降），与本项目既有口径一致。 */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6472;
  --ink-3: #8b95a4;
  --line: #e4e7ec;
  --up: #d93025;
  --down: #1d9e75;
  --flat: #8b95a4;
  --brand: #2b5fd9;
  --brand-soft: #eaf0fd;
  --warn-bg: #fdeeee;
  --warn-line: #f3c6c3;
  --info-bg: #eef4fd;
  --info-line: #c6daf8;
  --radius: 14px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px; line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #eef2f8 0%, #f7f8fa 60%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 18px;
  padding: 32px 24px 24px; box-shadow: 0 8px 32px rgba(31,36,48,.08);
}
.login-title { margin: 0; font-size: 22px; font-weight: 600; text-align: center; }
.login-sub { margin: 6px 0 24px; text-align: center; color: var(--ink-3); font-size: 13px; }
.login-input {
  width: 100%; height: 48px; padding: 0 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd;
  font-family: inherit;
}
.login-input:focus { outline: none; border-color: var(--brand); background: #fff; }
.login-err { min-height: 20px; margin-top: 8px; color: var(--up); font-size: 13px; }
.login-tip { margin: 16px 0 0; text-align: center; color: var(--ink-3); font-size: 12px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(12px + env(safe-area-inset-top)) 16px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left span { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-family: inherit;
}
.chip:active { background: #f2f4f7; }
.chip-view { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------------- 主体 ---------------- */
#main {
  max-width: 680px; margin: 0 auto;
  padding: 14px 14px calc(78px + env(safe-area-inset-bottom));
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(31,36,48,.05);
}
.card-hd {
  padding: 13px 16px 0; font-size: 14px; font-weight: 600; color: var(--ink);
}
.card-bd { padding: 12px 16px 16px; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: none; border-radius: 10px; padding: 11px 16px;
  font-size: 15px; font-family: inherit; font-weight: 500;
  cursor: pointer; background: #eef0f4; color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.mt12 { margin-top: 12px; }

/* ---------------- 表单 ---------------- */
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.select, .input {
  width: 100%; height: 44px; padding: 0 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; color: var(--ink);
}
.select:focus, .input:focus { outline: none; border-color: var(--brand); background: #fff; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.meta-line { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.note { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }

/* ---------------- 总分卡 ---------------- */
.total-hero { padding: 16px; }
.total-main { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.total-score { font-size: 34px; font-weight: 600; line-height: 1; }
.total-score small { font-size: 14px; font-weight: 400; color: var(--ink-3); }
.total-rank { font-size: 15px; color: var(--ink-2); }
.total-side { margin-left: auto; text-align: right; }
.total-side .big { font-size: 22px; font-weight: 600; }
.total-side .sub { font-size: 12px; color: var(--ink-3); }
.total-meta { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.delta { font-weight: 600; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--flat); }

/* ---------------- 提醒 ---------------- */
.reminder-block { margin-bottom: 12px; }
.insight {
  display: flex; gap: 10px; padding: 11px 13px; border-radius: 12px;
  margin-bottom: 8px; font-size: 13px; line-height: 1.5;
}
.insight.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.insight.info { background: var(--info-bg); border: 1px solid var(--info-line); }
.insight-ico { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
  font-size: 12px; line-height: 18px; text-align: center; color: #fff; }
.insight.warn .insight-ico { background: var(--up); }
.insight.info .insight-ico { background: var(--brand); }
.insight-t { font-weight: 600; }
.insight-d { color: var(--ink-2); margin-top: 2px; }
.insight-s { color: var(--ink-3); margin-top: 3px; font-size: 12px; }

/* ---------------- 考试列表 ---------------- */
.exam-list { display: flex; flex-direction: column; gap: 8px; }
.exam-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd;
}
.exam-item.current { border-color: var(--brand); background: var(--brand-soft); }
.exam-main { flex: 1; min-width: 0; }
.exam-name { font-weight: 500; }
.exam-sub { font-size: 12px; color: var(--ink-3); }
.exam-tag {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #eef0f4; color: var(--ink-2);
}
.exam-tag.done { background: #e3f5ec; color: var(--down); }
.exam-tag.part { background: #fdf0e2; color: #b06a12; }

/* ---------------- 科目表 ---------------- */
.subj-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center;
}
.subj-row:last-child { border-bottom: none; }
.subj-name { font-weight: 500; }
.subj-nums { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.subj-right { text-align: right; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; margin-left: 4px;
}
.pill.up { background: #fdeceb; color: var(--up); }
.pill.down { background: #e6f6f0; color: var(--down); }
.pill.flat { background: #f0f1f4; color: var(--flat); }
.miss { color: var(--ink-3); font-size: 13px; }

/* ---------------- 录入卡片 ---------------- */
.progress-wrap { margin-bottom: 12px; }
.progress-bar { height: 6px; background: #e8eaee; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s; }
.progress-txt { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.subj-input-card { margin-bottom: 12px; }
.subj-input-hd {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.subj-input-hd .n { font-weight: 600; }
.subj-input-hd .done { margin-left: auto; font-size: 12px; color: var(--down); }
.subj-input-hd .todo { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-label { font-size: 11px; color: var(--ink-3); margin-bottom: 4px; display: block; }
.fs-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 8px 10px; background: #f7f8fa; border-radius: 8px; font-size: 13px; }
.fs-line input { width: 90px; height: 36px; padding: 0 8px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; text-align: right; }
.save-state { font-size: 12px; color: var(--ink-3); margin-left: auto; }

/* 满分自动带出：一行显示，点「改」才展开编辑 */
.fs-line .fs-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fs-line .fs-tag { font-size: 11px; color: var(--ink-3); }
.fs-line.is-auto { background: #eef4fd; border: 1px solid #dbe7fb; }
.fs-line.is-auto .fs-tag { color: var(--brand); }
.fs-line.is-manual { background: #fdf6ec; border: 1px solid #f5e3c6; }
.fs-line.is-manual .fs-tag { color: #a2690b; }
.fs-edit {
  margin-left: auto; border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); border-radius: 7px; padding: 3px 10px;
  font-size: 12px; font-family: inherit; cursor: pointer;
}
.fs-edit:active { background: #f2f4f7; }
.fs-editor { display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 8px 10px; background: #f7f8fa; border-radius: 8px; flex-wrap: wrap; }
.fs-editor input { width: 90px; height: 36px; padding: 0 8px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; text-align: right; background: #fff; }

/* 录入页顶部的满分规则说明 */
.rule-note {
  margin-bottom: 12px; padding: 10px 13px; border-radius: 10px;
  background: #eef4fd; border: 1px solid #dbe7fb; color: #185fa5;
  font-size: 13px; line-height: 1.5;
}
.rule-preview {
  margin: 4px 0 10px; padding: 10px 12px; border-radius: 10px;
  background: #eef4fd; border: 1px solid #dbe7fb; color: #185fa5;
  font-size: 13px; line-height: 1.55;
}

/* ---------------- 丢分编辑 ---------------- */
.loss-subj { border-bottom: 1px solid var(--line); padding: 10px 0; }
.loss-subj:last-child { border-bottom: none; }
.loss-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.loss-row:last-child { border-bottom: none; }
.loss-tag-pill {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: #eef0f4; color: var(--ink-2); white-space: nowrap;
}
.loss-pts { font-size: 13px; color: var(--up); font-weight: 500; white-space: nowrap; }
.loss-detail { font-size: 12px; color: var(--ink-3); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-x {
  border: none; background: none; color: var(--ink-3); font-size: 16px;
  padding: 2px 6px; cursor: pointer;
}

/* ---------------- 对比表 ---------------- */
.cmp-row {
  display: grid; grid-template-columns: 56px 1fr 1fr 84px;
  gap: 5px; align-items: center; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.cmp-row:last-child { border-bottom: none; }
.cmp-row.hd { font-size: 12px; color: var(--ink-3); border-bottom: 1px solid var(--line); }
/* 🔴 科目名不许换行（"生物"换行成两行会把整行撑高） */
.cmp-subj {
  font-weight: 500; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0;
}
.cmp-old, .cmp-new {
  font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cmp-old { color: var(--ink-3); }
.cmp-delta { text-align: right; font-variant-numeric: tabular-nums; }
/* 🔴 涨跌标签不许竖排（"上升10名"被压成竖排很难看） */
.cmp-delta .pill {
  display: inline-block; white-space: nowrap; margin: 1px 0 0 4px;
  padding: 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 500;
}
/* 组合对照：组合名较长，给它更宽的第一列 */
.cmp-row-wide { grid-template-columns: 92px 1fr 1fr 92px; }
.cmp-row-wide .cmp-subj { white-space: normal; line-height: 1.35; }

/* ---------------- 图表 ---------------- */
.chart { width: 100%; height: 220px; }
.chart-tall { height: 260px; }

/* ---------------- 归因报告 ---------------- */
.tag-bar { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.tag-name { width: 96px; font-size: 13px; flex: 0 0 auto; }
.tag-track { flex: 1; height: 8px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.tag-fill { height: 100%; background: var(--up); border-radius: 999px; }
.tag-val { width: 58px; text-align: right; font-size: 12px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; }
.repeat-flag { font-size: 11px; color: var(--up); background: #fdeceb;
  padding: 1px 6px; border-radius: 999px; margin-left: 6px; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  border: none; background: none; padding: 8px 0 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--ink-3); font-family: inherit;
}
.tab.active { color: var(--brand); }
.tab-ico { width: 21px; height: 21px; display: block; position: relative; }
.ti-home::before {
  content: ''; position: absolute; left: 2px; top: 6px; width: 17px; height: 13px;
  border: 1.8px solid currentColor; border-top: none; border-radius: 0 0 3px 3px;
}
.ti-home::after {
  content: ''; position: absolute; left: 4px; top: 2px; width: 13px; height: 13px;
  border-left: 1.8px solid currentColor; border-top: 1.8px solid currentColor;
  transform: rotate(45deg); transform-origin: center;
}
.ti-cmp::before, .ti-cmp::after {
  content: ''; position: absolute; top: 3px; width: 4px; height: 15px;
  background: currentColor; border-radius: 1px;
}
.ti-cmp::before { left: 5px; }
.ti-cmp::after { right: 5px; height: 9px; top: 9px; }
.ti-in::before {
  content: ''; position: absolute; left: 4px; top: 2px; width: 13px; height: 13px;
  border: 1.8px solid currentColor; border-radius: 3px;
}
.ti-in::after {
  content: ''; position: absolute; left: 8px; top: 6px; width: 6px; height: 6px;
  background: currentColor; border-radius: 50%;
}
.ti-loss::before {
  content: ''; position: absolute; left: 3px; top: 8px; width: 15px; height: 8px;
  border: 1.8px solid currentColor; border-radius: 2px;
}
.ti-loss::after {
  content: ''; position: absolute; left: 6px; top: 4px; width: 9px; height: 9px;
  border-left: 1.8px solid currentColor; border-top: 1.8px solid currentColor;
  transform: rotate(-45deg);
}
.ti-set::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 15px; height: 15px;
  border: 1.8px solid currentColor; border-radius: 50%;
}
.ti-set::after {
  content: ''; position: absolute; left: 8px; top: 8px; width: 5px; height: 5px;
  background: currentColor; border-radius: 50%;
}

/* ---------------- 弹层 ---------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: flex-end; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(20,24,32,.42); }
.modal-body {
  position: relative; width: 100%; max-width: 680px; max-height: 88vh;
  background: #fff; border-radius: 18px 18px 0 0; overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp .2s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: .6 } to { transform: none; opacity: 1 } }
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-x { border: none; background: none; font-size: 18px; color: var(--ink-3); cursor: pointer; }
.modal-bd { padding: 16px; overflow-y: auto; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: rgba(31,36,48,.92); color: #fff; padding: 9px 16px;
  border-radius: 999px; font-size: 13px; z-index: 80; max-width: 84vw;
  text-align: center;
}

/* ---------------- 分段控件 ---------------- */
.seg { display: flex; background: #eef0f4; border-radius: 9px; padding: 3px; }
.seg-btn {
  flex: 1; border: none; background: none; padding: 7px 4px; border-radius: 7px;
  font-size: 13px; color: var(--ink-2); font-family: inherit; cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--ink); font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------------- 桌面端 ---------------- */
@media (min-width: 760px) {
  #main { padding: 20px 16px 90px; }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%);
    max-width: 680px; border-radius: 14px 14px 0 0; border: 1px solid var(--line);
    border-bottom: none; }
  .modal { align-items: center; }
  .modal-body { border-radius: 16px; max-height: 82vh; }
}
