/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #2f6fed;
  --primary-dark: #1e56c8;
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #1f2733;
  --text-sub: #6b7686;
  --line: #e5eaf2;
  --green: #22a06b;
  --green-bg: #e7f6ef;
  --red: #d64545;
  --red-bg: #fdecec;
  --orange: #e08a1e;
  --orange-bg: #fdf3e4;
  --gray-bg: #eef1f6;
  --radius: 12px;
}
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.container { max-width: 640px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

/* ============ 视图 ============ */
.view { padding: 16px 14px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
[hidden] { display: none !important; }

/* ============ 顶部栏 ============ */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, #2f6fed, #4c8dff);
  color: #fff; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(47,111,237,.25);
}
.top-title { font-size: 1.1rem; font-weight: 700; }
.top-sub { font-size: .8rem; opacity: .85; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; }

/* ============ 按钮 ============ */
.btn {
  border: none; border-radius: 10px; padding: 11px 18px; font-size: .95rem;
  cursor: pointer; background: var(--gray-bg); color: var(--text);
  transition: opacity .15s, transform .1s; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:active { background: var(--primary-dark); }
.btn.block { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.sm { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }
.btn.ghost { background: rgba(255,255,255,.16); color: #fff; }
.btn.ghost:active { background: rgba(255,255,255,.28); }
.btn.danger { background: var(--red-bg); color: var(--red); }

/* ============ 登录页 ============ */
#view-login { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card); border-radius: 18px; padding: 34px 26px; width: 100%;
  max-width: 380px; box-shadow: 0 10px 34px rgba(31,39,51,.1); text-align: center;
}
.logo { margin-bottom: 6px; }
.logo img { width: 84px; height: 84px; object-fit: contain; margin-bottom: 4px; }
.data-link {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 20px; padding: 13px 30px;
  background: #fff; border: 2px solid #cfe0fb; border-radius: 999px;
  color: var(--primary); font-size: 1.08rem; font-weight: 700;
  text-decoration: none; box-shadow: 0 6px 18px rgba(31,39,51,.12);
  transition: transform .1s, box-shadow .15s;
}
.data-link:active { transform: scale(.96); }
.data-link-icon { font-size: 1.45rem; }
.login-card h1 { font-size: 1.45rem; margin-bottom: 2px; }
.sub { color: var(--text-sub); font-size: .88rem; margin-bottom: 22px; }
.field { margin-bottom: 12px; }
.field input, .date-row input[type="date"], .date-row select, #import-text {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 1rem; background: #fff; color: var(--text); font-family: inherit; outline: none;
}
.field input:focus, .date-row input:focus, .date-row select:focus { border-color: var(--primary); }
.login-tip { margin-top: 18px; font-size: .78rem; color: var(--text-sub); line-height: 1.7; }
.msg { min-height: 20px; font-size: .85rem; margin-top: 8px; color: var(--text-sub); }
.msg.ok { color: var(--green); font-weight: 600; }
.msg.err { color: var(--red); font-weight: 600; }

/* ============ 日期卡片 ============ */
.date-card {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(31,39,51,.06);
}
.date-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.date-row + .date-row { margin-top: 10px; }
.date-row span { font-weight: 600; font-size: .92rem; white-space: nowrap; }
.date-row input[type="date"], .date-row select { width: auto; flex: 1; min-width: 0; padding: 9px 10px; }
.tag { display: none; margin-top: 10px; padding: 7px 10px; border-radius: 8px; font-size: .84rem; font-weight: 600; }
.tag.show { display: block; }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.warn { background: var(--orange-bg); color: var(--orange); }

/* ============ 快捷操作 ============ */
.quick-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* ============ 学生名单 ============ */
.student-list { display: flex; flex-direction: column; gap: 10px; }
.stu-card {
  background: var(--card); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 1px 4px rgba(31,39,51,.06);
}
.stu-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stu-idx {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: .75rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 600;
}
.stu-name { font-weight: 600; font-size: .98rem; flex: 1; }
.stu-leader-flag { font-size: .7rem; background: #eef4ff; color: var(--primary); padding: 2px 7px; border-radius: 20px; }
.stu-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stu-option {
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 2px;
  text-align: center; font-size: .78rem; cursor: pointer; user-select: none;
  background: #fff; color: var(--text-sub); transition: all .12s; line-height: 1.3;
}
.stu-option.active { border-color: var(--primary); background: #eef4ff; color: var(--primary); font-weight: 600; }
.stu-option:active { transform: scale(.95); }

/* 提交状态反馈 */
.stu-card .submitted-badge { display: none; }
.stu-card.done { border-left: 3px solid var(--green); }

/* ============ 提交栏 ============ */
.submit-bar { margin-top: 18px; position: sticky; bottom: 12px; z-index: 5; }
.safe-bottom { height: 34px; }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 6px; background: var(--card); padding: 6px; border-radius: 12px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(31,39,51,.06); overflow-x: auto; }
.tab {
  flex: 1; white-space: nowrap; border: none; background: transparent; padding: 9px 6px;
  border-radius: 9px; font-size: .88rem; color: var(--text-sub); cursor: pointer; font-family: inherit; font-weight: 500;
}
.tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.tab-panel { animation: fade .2s ease; }

/* ============ 卡片 ============ */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 14px; box-shadow: 0 1px 4px rgba(31,39,51,.06);
}
.card h3 { font-size: 1rem; margin-bottom: 8px; }
.hint { font-size: .82rem; color: var(--text-sub); margin-bottom: 8px; line-height: 1.7; }

/* ============ 总览卡片 ============ */
.overview { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.ov-card {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(31,39,51,.06); border-top: 3px solid var(--primary);
}
.ov-card .num { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.ov-card .lab { font-size: .8rem; color: var(--text-sub); }
.ov-card.green { border-top-color: var(--green); }
.ov-card.red { border-top-color: var(--red); }
.ov-card.orange { border-top-color: var(--orange); }
.ov-card .num.green { color: var(--green); }
.ov-card .num.red { color: var(--red); }
.ov-card .num.orange { color: var(--orange); }

/* 今日各组 */
.day-group-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 2px; border-bottom: 1px dashed var(--line); font-size: .88rem;
}
.day-group-row:last-child { border-bottom: none; }
.chips { display: flex; gap: 5px; }
.chip { font-size: .72rem; padding: 2px 7px; border-radius: 20px; }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.warn { background: var(--orange-bg); color: var(--orange); }
.chip.bad { background: var(--red-bg); color: var(--red); }

/* ============ 连续未完成 ============ */
.streak-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 2px; border-bottom: 1px dashed var(--line); font-size: .9rem;
}
.streak-item:last-child { border-bottom: none; }
.streak-badge { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.streak-badge.b1 { background: var(--orange-bg); color: var(--orange); }
.streak-badge.b2 { background: var(--red-bg); color: var(--red); }
.streak-date { font-size: .75rem; color: var(--text-sub); margin-left: 6px; }
.empty-tip { color: var(--text-sub); font-size: .86rem; padding: 14px 0; text-align: center; }

/* ============ 排名表 ============ */
.rank-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rank-table th {
  text-align: left; padding: 8px 4px; color: var(--text-sub); font-weight: 600;
  border-bottom: 2px solid var(--line); font-size: .8rem; white-space: nowrap;
}
.rank-table td { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.rank-table tr:last-child td { border-bottom: none; }
.rank-num { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--gray-bg); align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.rank-num.top1 { background: #ffe08a; color: #7a5b00; }
.rank-num.top2 { background: #e3e8f0; color: #4a5568; }
.rank-num.top3 { background: #f4c9a0; color: #7a4a12; }
.rate-bar { height: 6px; border-radius: 3px; background: var(--gray-bg); overflow: hidden; width: 60px; }
.rate-fill { height: 100%; background: var(--green); border-radius: 3px; }
.highlight { color: var(--red); font-weight: 700; }

/* ============ 账号列表 ============ */
.account-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 2px; border-bottom: 1px dashed var(--line); gap: 8px; flex-wrap: wrap;
}
.account-item:last-child { border-bottom: none; }
.account-item .ac-name { font-weight: 700; }
.account-item .ac-group { font-size: .78rem; color: var(--text-sub); margin-left: 6px; }
.account-item .ac-pwd { font-size: .8rem; color: var(--text-sub); font-family: ui-monospace, monospace; }

/* ============ 弹层 ============ */
.modal {
  position: fixed; inset: 0; background: rgba(20,26,38,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--card); border-radius: 16px; padding: 22px; width: 100%; max-width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2); animation: fade .2s ease;
}
.modal-box h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* ============ 统计工具栏 ============ */
.stats-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.stats-source { font-size: .78rem; color: var(--text-sub); }

/* ============ 其他 ============ */
#view-login[hidden] { display: none !important; }
