* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --green: #16a34a;
  --amber: #d97706;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ---------- 登录 ---------- */
.login-box {
  max-width: 400px; margin: 0 auto; padding: 48px 24px 32px; text-align: center;
}
.login-icon {
  width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--primary); color: white; font-size: 32px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(37,99,235,.25);
}
h1 { font-size: 24px; font-weight: 700; }
.subtitle { color: var(--muted); margin: 8px 0 28px; font-size: 14px; }
.input-wrap { margin-bottom: 14px; }
input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: white;
  outline: none; transition: border-color .2s;
}
input:focus { border-color: var(--primary); }
.btn {
  width: 100%; padding: 12px 16px; font-size: 16px; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer; transition: opacity .2s;
}
.btn:active { opacity: .8; }
.btn.primary { background: var(--primary); color: white; }
.btn.ghost { background: white; color: var(--primary); border: 1px solid var(--primary); }
.btn.wide { margin-top: 20px; }
.msg { min-height: 20px; margin-top: 8px; color: #dc2626; font-size: 13px; }
.divider {
  display: flex; align-items: center; gap: 12px; margin: 28px 0 16px;
  color: var(--muted); font-size: 12px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--primary); color: white;
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.topbar-title { display: flex; flex-direction: column; }
.hello { font-size: 17px; font-weight: 600; }
.stat { font-size: 12px; opacity: .85; }
.link-btn { background: none; border: none; color: white; font-size: 14px; opacity: .9; cursor: pointer; }
.notice {
  margin: 12px 14px; padding: 10px 12px; background: #eff6ff; color: #1e40af;
  border-radius: 8px; font-size: 12px; line-height: 1.5;
}

/* ---------- 打分对象列表 ---------- */
.target-list { padding: 0 14px 24px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.target-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 12px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: transform .1s, box-shadow .2s;
}
.target-item:active { transform: scale(.98); }
.target-item.done { border-color: #bbf7d0; background: #f0fdf4; }
.target-name { font-size: 15px; font-weight: 600; }
.target-status { font-size: 11px; color: var(--muted); }
.target-item.done .target-status { color: var(--green); font-weight: 600; }
.target-status .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--line); margin-right: 4px; }
.target-item.done .dot { background: var(--green); }
.target-item.locked { cursor: not-allowed; opacity: .75; }

/* ---------- 锁定提示 / 完成按钮 ---------- */
.lock-banner {
  margin: 12px 14px 0; padding: 12px; background: #fef3c7; color: #92400e;
  border: 1px solid #fde68a; border-radius: 8px; font-size: 13px; line-height: 1.5;
}
.finish-wrap { padding: 8px 14px 30px; text-align: center; }
.finish-wrap .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.unlock-btn {
  background: #fff7ed; color: #c2410c; border: 1px solid #fdba74;
  border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.log-time { font-size: 11px; color: var(--muted); }

/* ---------- 交叉表（打分矩阵）---------- */
.legend-row {
  margin: 12px 14px 0; padding: 10px 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; font-size: 12px;
  color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-sup { background: #dbeafe; border: 1px solid #93c5fd; }
.lg-peer { background: #dcfce7; border: 1px solid #86efac; }
.legend-note { margin-left: auto; }
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matrix-wrap table { min-width: max-content; font-size: 12px; }
.matrix-wrap th, .matrix-wrap td { padding: 7px 8px; white-space: nowrap; }
/* 前两列和总分列固定，横向滚动时始终可见 */
.matrix-wrap .col-rank, .matrix-wrap .col-name, .matrix-wrap .col-total {
  position: sticky; background: var(--card); z-index: 2;
}
.matrix-wrap .col-rank { left: 0; min-width: 46px; }
.matrix-wrap .col-name { left: 46px; min-width: 76px; text-align: left; border-right: 2px solid var(--line); }
.matrix-wrap th.col-rank, .matrix-wrap th.col-name { background: #f8fafc; z-index: 3; }
.matrix-wrap .col-total { right: 0; min-width: 66px; border-left: 2px solid var(--line); background: #eff6ff; }
.matrix-wrap th.col-total { background: #dbeafe; z-index: 3; }
.matrix-wrap th:not(.col-rank):not(.col-name):not(.col-total) { color: #374151; }
.score-cell { text-align: center; color: #374151; min-width: 40px; }
.cell-sup { background: #eff6ff; }
.cell-peer { background: #f0fdf4; }
.cell-empty { color: #d1d5db; }
.matrix-wrap tbody tr:hover td { filter: brightness(.97); }

/* ---------- 弹窗 ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 50; }
.modal.open { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh;
  background: var(--card); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp .2s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--muted); }
.close-btn { background: none; border: none; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.form-items { padding: 8px 18px; overflow-y: auto; flex: 1; }
.form-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.form-item:last-child { border-bottom: none; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.item-title { font-size: 14px; font-weight: 600; }
.score-input-wrap { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.score-input {
  width: 58px; padding: 8px 4px; text-align: center; font-size: 18px; font-weight: 700;
  border: 1px solid var(--primary); border-radius: 8px; color: var(--primary); background: #eff6ff;
}
.max-label { font-size: 13px; color: var(--muted); }
.tips { font-size: 11px; color: var(--muted); line-height: 1.7; }
.tips span { display: inline-block; margin-right: 10px; white-space: nowrap; }
.tips b { color: #374151; font-weight: 600; }
.score-total {
  padding: 12px 18px; background: #f8fafc; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted);
}
.score-total strong { font-size: 22px; color: var(--primary); }
.modal-foot { padding: 12px 18px 20px; }

/* ---------- 管理员 ---------- */
.admin-login { max-width: 360px; margin: 24px auto; padding: 0 20px; }
.admin-login input { margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 700; margin: 18px 16px 8px; }
.section-sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.stat-row {
  margin: 14px; padding: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; color: var(--muted); display: flex; gap: 20px; flex-wrap: wrap;
}
.stat-row b { color: var(--primary); font-size: 16px; }
.table-wrap { margin: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: none; }
td.name-cell { text-align: left; padding-left: 14px; font-weight: 600; }
.rank-1 { color: #dc2626; font-weight: 700; }
.rank-2 { color: var(--amber); font-weight: 700; }
.rank-3 { color: #0891b2; font-weight: 700; }
.total-cell { font-weight: 700; color: var(--primary); }
.pending-cell { color: var(--muted); font-size: 12px; }
.bar { display: inline-block; width: 60px; height: 6px; background: var(--line); border-radius: 3px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); }
#adminContent { padding-bottom: 30px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(20px);
  background: #1f2937; color: white; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  .target-list { grid-template-columns: repeat(4, 1fr); }
  .modal-panel { max-width: 520px; margin: 0 auto; bottom: 0; border-radius: 16px 16px 0 0; }
}
